UNPKG

864 BJavaScriptView Raw
1'use strict';
2var global = require('../internals/global');
3var userAgent = require('../internals/engine-user-agent');
4
5var process = global.process;
6var Deno = global.Deno;
7var versions = process && process.versions || Deno && Deno.version;
8var v8 = versions && versions.v8;
9var match, version;
10
11if (v8) {
12 match = v8.split('.');
13 // in old Chrome, versions of V8 isn't V8 = Chrome / 10
14 // but their correct versions are not interesting for us
15 version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]);
16}
17
18// BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0`
19// so check `userAgent` even if `.v8` exists, but 0
20if (!version && userAgent) {
21 match = userAgent.match(/Edge\/(\d+)/);
22 if (!match || match[1] >= 74) {
23 match = userAgent.match(/Chrome\/(\d+)/);
24 if (match) version = +match[1];
25 }
26}
27
28module.exports = version;