engine-v8-version.js 850 B

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