Skip to content

Commit

Permalink
extract v8 version detection
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Oct 12, 2019
1 parent 1418f5f commit fe7f519
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
16 changes: 16 additions & 0 deletions packages/core-js/internals/v8-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
var global = require('../internals/global');
var userAgent = require('../internals/user-agent');

var versions = global.process && process.versions;
var v8 = versions && versions.v8;
var match, version;

if (v8) {
match = v8.split('.');
version = match[0] + match[1];
} else if (userAgent) {
match = userAgent.match(/Chrome\/(\d+)/);
if (match) version = match[1];
}

module.exports = version && +version;
7 changes: 2 additions & 5 deletions packages/core-js/modules/es.promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ var promiseResolve = require('../internals/promise-resolve');
var hostReportErrors = require('../internals/host-report-errors');
var newPromiseCapabilityModule = require('../internals/new-promise-capability');
var perform = require('../internals/perform');
var userAgent = require('../internals/user-agent');
var InternalStateModule = require('../internals/internal-state');
var isForced = require('../internals/is-forced');
var wellKnownSymbol = require('../internals/well-known-symbol');
var V8_VERSION = require('../internals/v8-version');

var SPECIES = wellKnownSymbol('species');
var PROMISE = 'Promise';
Expand All @@ -36,8 +36,6 @@ var TypeError = global.TypeError;
var document = global.document;
var process = global.process;
var $fetch = getBuiltIn('fetch');
var versions = process && process.versions;
var v8 = versions && versions.v8 || '';
var newPromiseCapability = newPromiseCapabilityModule.f;
var newGenericPromiseCapability = newPromiseCapability;
var IS_NODE = classof(process) == 'process';
Expand Down Expand Up @@ -65,8 +63,7 @@ var FORCED = isForced(PROMISE, function () {
// v8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
// https://bugs.chromium.org/p/chromium/issues/detail?id=830565
// we can't detect it synchronously, so just check versions
&& v8.indexOf('6.6') !== 0
&& userAgent.indexOf('Chrome/66') === -1);
&& V8_VERSION !== 66);
});

var INCORRECT_ITERATION = FORCED || !checkCorrectnessOfIteration(function (iterable) {
Expand Down

0 comments on commit fe7f519

Please sign in to comment.