diff --git a/packages/core-js-pure/override/internals/entry-unbind.js b/packages/core-js-pure/override/internals/entry-unbind.js index c19eb84c29bd..191c5c363660 100644 --- a/packages/core-js-pure/override/internals/entry-unbind.js +++ b/packages/core-js-pure/override/internals/entry-unbind.js @@ -1,4 +1,4 @@ 'use strict'; -var getBuiltIn = require('../internals/get-built-in'); +var getBuiltInStaticMethod = require('../internals/get-built-in-static-method'); -module.exports = getBuiltIn; +module.exports = getBuiltInStaticMethod; diff --git a/packages/core-js-pure/override/internals/get-built-in-static-method.js b/packages/core-js-pure/override/internals/get-built-in-static-method.js new file mode 100644 index 000000000000..5ef450ef6d92 --- /dev/null +++ b/packages/core-js-pure/override/internals/get-built-in-static-method.js @@ -0,0 +1,11 @@ +'use strict'; +var path = require('../internals/path'); +var global = require('../internals/global'); + +var getMethod = function (C, METHOD) { + return C && C[METHOD]; +}; + +module.exports = function (NAMESPACE, METHOD) { + return getMethod(path[NAMESPACE], METHOD) || getMethod(global[NAMESPACE], METHOD); +}; diff --git a/packages/core-js-pure/override/internals/get-built-in.js b/packages/core-js-pure/override/internals/get-built-in.js index f861be92f0f5..878b97a257d6 100644 --- a/packages/core-js-pure/override/internals/get-built-in.js +++ b/packages/core-js-pure/override/internals/get-built-in.js @@ -3,11 +3,10 @@ var path = require('../internals/path'); var global = require('../internals/global'); var isCallable = require('../internals/is-callable'); -var aFunction = function (variable) { - return isCallable(variable) ? variable : undefined; +var aFunction = function (argument) { + return isCallable(argument) ? argument : undefined; }; -module.exports = function (namespace, method) { - return arguments.length < 2 ? aFunction(path[namespace]) || aFunction(global[namespace]) - : path[namespace] && path[namespace][method] || global[namespace] && global[namespace][method]; +module.exports = function (NAMESPACE) { + return aFunction(path[NAMESPACE]) || aFunction(global[NAMESPACE]); }; diff --git a/packages/core-js/es/object/create.js b/packages/core-js/es/object/create.js index db9822160d03..8c1373523cc2 100644 --- a/packages/core-js/es/object/create.js +++ b/packages/core-js/es/object/create.js @@ -1,6 +1,6 @@ 'use strict'; -var getBuiltIn = require('../../internals/get-built-in'); +var getBuiltInStaticMethod = require('../../internals/get-built-in-static-method'); module.exports = function create(P, D) { - return getBuiltIn('Object', 'create')(P, D); + return getBuiltInStaticMethod('Object', 'create')(P, D); }; diff --git a/packages/core-js/internals/get-built-in-static-method.js b/packages/core-js/internals/get-built-in-static-method.js new file mode 100644 index 000000000000..0c507088f62f --- /dev/null +++ b/packages/core-js/internals/get-built-in-static-method.js @@ -0,0 +1,7 @@ +'use strict'; +var global = require('../internals/global'); + +module.exports = function (NAMESPACE, METHOD) { + var C = global[NAMESPACE]; + return C && C[METHOD]; +}; diff --git a/packages/core-js/internals/get-built-in.js b/packages/core-js/internals/get-built-in.js index f6a98b750364..fc321092a20d 100644 --- a/packages/core-js/internals/get-built-in.js +++ b/packages/core-js/internals/get-built-in.js @@ -2,10 +2,7 @@ var global = require('../internals/global'); var isCallable = require('../internals/is-callable'); -var aFunction = function (argument) { - return isCallable(argument) ? argument : undefined; -}; - -module.exports = function (namespace, method) { - return arguments.length < 2 ? aFunction(global[namespace]) : global[namespace] && global[namespace][method]; +module.exports = function (CONSTRUCTOR) { + var C = global[CONSTRUCTOR]; + return isCallable(C) ? C : undefined; }; diff --git a/packages/core-js/internals/html.js b/packages/core-js/internals/html.js index b8da90e67104..2cf7c57f0597 100644 --- a/packages/core-js/internals/html.js +++ b/packages/core-js/internals/html.js @@ -1,4 +1,4 @@ 'use strict'; -var getBuiltIn = require('../internals/get-built-in'); +var getBuiltInStaticMethod = require('../internals/get-built-in-static-method'); -module.exports = getBuiltIn('document', 'documentElement'); +module.exports = getBuiltInStaticMethod('document', 'documentElement'); diff --git a/packages/core-js/internals/is-constructor.js b/packages/core-js/internals/is-constructor.js index 4db2d72a4b46..53dd46109829 100644 --- a/packages/core-js/internals/is-constructor.js +++ b/packages/core-js/internals/is-constructor.js @@ -3,12 +3,12 @@ var uncurryThis = require('../internals/function-uncurry-this'); var fails = require('../internals/fails'); var isCallable = require('../internals/is-callable'); var classof = require('../internals/classof'); -var getBuiltIn = require('../internals/get-built-in'); +var getBuiltInStaticMethod = require('../internals/get-built-in-static-method'); var inspectSource = require('../internals/inspect-source'); var noop = function () { /* empty */ }; var empty = []; -var construct = getBuiltIn('Reflect', 'construct'); +var construct = getBuiltInStaticMethod('Reflect', 'construct'); var constructorRegExp = /^\s*(?:class|function)\b/; var exec = uncurryThis(constructorRegExp.exec); var INCORRECT_TO_STRING = !constructorRegExp.test(noop); diff --git a/packages/core-js/internals/own-keys.js b/packages/core-js/internals/own-keys.js index bf4864da89c2..f552116d803e 100644 --- a/packages/core-js/internals/own-keys.js +++ b/packages/core-js/internals/own-keys.js @@ -1,5 +1,5 @@ 'use strict'; -var getBuiltIn = require('../internals/get-built-in'); +var getBuiltInStaticMethod = require('../internals/get-built-in-static-method'); var uncurryThis = require('../internals/function-uncurry-this'); var getOwnPropertyNamesModule = require('../internals/object-get-own-property-names'); var getOwnPropertySymbolsModule = require('../internals/object-get-own-property-symbols'); @@ -8,7 +8,7 @@ var anObject = require('../internals/an-object'); var concat = uncurryThis([].concat); // all object keys, includes non-enumerable and symbols -module.exports = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) { +module.exports = getBuiltInStaticMethod('Reflect', 'ownKeys') || function ownKeys(it) { var keys = getOwnPropertyNamesModule.f(anObject(it)); var getOwnPropertySymbols = getOwnPropertySymbolsModule.f; return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys; diff --git a/packages/core-js/internals/string-parse.js b/packages/core-js/internals/string-parse.js index e7196f4de368..de2f71fa0a42 100644 --- a/packages/core-js/internals/string-parse.js +++ b/packages/core-js/internals/string-parse.js @@ -1,10 +1,10 @@ 'use strict'; // adapted from https://github.com/jridgewell/string-dedent -var getBuiltIn = require('../internals/get-built-in'); +var getBuiltInStaticMethod = require('../internals/get-built-in-static-method'); var uncurryThis = require('../internals/function-uncurry-this'); var fromCharCode = String.fromCharCode; -var fromCodePoint = getBuiltIn('String', 'fromCodePoint'); +var fromCodePoint = getBuiltInStaticMethod('String', 'fromCodePoint'); var charAt = uncurryThis(''.charAt); var charCodeAt = uncurryThis(''.charCodeAt); var stringIndexOf = uncurryThis(''.indexOf); diff --git a/packages/core-js/internals/wrap-error-constructor-with-cause.js b/packages/core-js/internals/wrap-error-constructor-with-cause.js index 4fb16a9f90a4..01645e907f89 100644 --- a/packages/core-js/internals/wrap-error-constructor-with-cause.js +++ b/packages/core-js/internals/wrap-error-constructor-with-cause.js @@ -1,5 +1,6 @@ 'use strict'; var getBuiltIn = require('../internals/get-built-in'); +var getBuiltInStaticMethod = require('../internals/get-built-in-static-method'); var hasOwn = require('../internals/has-own-property'); var createNonEnumerableProperty = require('../internals/create-non-enumerable-property'); var isPrototypeOf = require('../internals/object-is-prototype-of'); @@ -17,7 +18,7 @@ module.exports = function (FULL_NAME, wrapper, FORCED, IS_AGGREGATE_ERROR) { var OPTIONS_POSITION = IS_AGGREGATE_ERROR ? 2 : 1; var path = FULL_NAME.split('.'); var ERROR_NAME = path[path.length - 1]; - var OriginalError = getBuiltIn.apply(null, path); + var OriginalError = path.length > 1 ? getBuiltInStaticMethod(path[0], path[1]) : getBuiltIn(path[0]); if (!OriginalError) return; diff --git a/packages/core-js/modules/es.json.stringify.js b/packages/core-js/modules/es.json.stringify.js index 61e14ac17e8a..4a4f69ba415f 100644 --- a/packages/core-js/modules/es.json.stringify.js +++ b/packages/core-js/modules/es.json.stringify.js @@ -1,6 +1,7 @@ 'use strict'; var $ = require('../internals/export'); var getBuiltIn = require('../internals/get-built-in'); +var getBuiltInStaticMethod = require('../internals/get-built-in-static-method'); var apply = require('../internals/function-apply'); var call = require('../internals/function-call'); var uncurryThis = require('../internals/function-uncurry-this'); @@ -12,7 +13,7 @@ var getReplacerFunction = require('../internals/get-json-replacer-function'); var NATIVE_SYMBOL = require('../internals/symbol-constructor-detection'); var $String = String; -var $stringify = getBuiltIn('JSON', 'stringify'); +var $stringify = getBuiltInStaticMethod('JSON', 'stringify'); var exec = uncurryThis(/./.exec); var charAt = uncurryThis(''.charAt); var charCodeAt = uncurryThis(''.charCodeAt); diff --git a/packages/core-js/modules/es.reflect.construct.js b/packages/core-js/modules/es.reflect.construct.js index 4e99ab0ed121..3754171de0c2 100644 --- a/packages/core-js/modules/es.reflect.construct.js +++ b/packages/core-js/modules/es.reflect.construct.js @@ -1,6 +1,6 @@ 'use strict'; var $ = require('../internals/export'); -var getBuiltIn = require('../internals/get-built-in'); +var getBuiltInStaticMethod = require('../internals/get-built-in-static-method'); var apply = require('../internals/function-apply'); var aConstructor = require('../internals/a-constructor'); var anObject = require('../internals/an-object'); @@ -9,7 +9,7 @@ var fails = require('../internals/fails'); var ObjectPrototype = Object.prototype; var create = Object.create; -var nativeConstruct = getBuiltIn('Reflect', 'construct'); +var nativeConstruct = getBuiltInStaticMethod('Reflect', 'construct'); var bind = create.bind; var push = [].push; diff --git a/packages/core-js/modules/es.reflect.prevent-extensions.js b/packages/core-js/modules/es.reflect.prevent-extensions.js index 8b9e6f858ecb..b300f3d08b99 100644 --- a/packages/core-js/modules/es.reflect.prevent-extensions.js +++ b/packages/core-js/modules/es.reflect.prevent-extensions.js @@ -1,6 +1,6 @@ 'use strict'; var $ = require('../internals/export'); -var getBuiltIn = require('../internals/get-built-in'); +var getBuiltInStaticMethod = require('../internals/get-built-in-static-method'); var anObject = require('../internals/an-object'); // `Reflect.preventExtensions` method @@ -9,7 +9,7 @@ $({ target: 'Reflect', stat: true }, { preventExtensions: function preventExtensions(target) { anObject(target); try { - var objectPreventExtensions = getBuiltIn('Object', 'preventExtensions'); + var objectPreventExtensions = getBuiltInStaticMethod('Object', 'preventExtensions'); if (objectPreventExtensions) objectPreventExtensions(target); return true; } catch (error) { diff --git a/packages/core-js/modules/esnext.json.raw-json.js b/packages/core-js/modules/esnext.json.raw-json.js index 777b6669a142..de6134b172fa 100644 --- a/packages/core-js/modules/esnext.json.raw-json.js +++ b/packages/core-js/modules/esnext.json.raw-json.js @@ -1,7 +1,7 @@ 'use strict'; var $ = require('../internals/export'); var NATIVE_RAW_JSON = require('../internals/native-raw-json'); -var getBuiltIn = require('../internals/get-built-in'); +var getBuiltInStaticMethod = require('../internals/get-built-in-static-method'); var call = require('../internals/function-call'); var uncurryThis = require('../internals/function-uncurry-this'); var isCallable = require('../internals/is-callable'); @@ -15,8 +15,8 @@ var setInternalState = require('../internals/internal-state').set; var $String = String; var $SyntaxError = SyntaxError; -var parse = getBuiltIn('JSON', 'parse'); -var $stringify = getBuiltIn('JSON', 'stringify'); +var parse = getBuiltInStaticMethod('JSON', 'parse'); +var $stringify = getBuiltInStaticMethod('JSON', 'stringify'); var create = Object.create; var freeze = Object.freeze; var at = uncurryThis(''.charAt); diff --git a/packages/core-js/modules/esnext.number.from-string.js b/packages/core-js/modules/esnext.number.from-string.js index c4bf32984e6f..2019d1e49ed2 100644 --- a/packages/core-js/modules/esnext.number.from-string.js +++ b/packages/core-js/modules/esnext.number.from-string.js @@ -1,6 +1,6 @@ 'use strict'; var $ = require('../internals/export'); -var getBuiltIn = require('../internals/get-built-in'); +var getBuiltInStaticMethod = require('../internals/get-built-in-static-method'); var uncurryThis = require('../internals/function-uncurry-this'); var toIntegerOrInfinity = require('../internals/to-integer-or-infinity'); @@ -9,7 +9,7 @@ var INVALID_RADIX = 'Invalid radix'; var $RangeError = RangeError; var $SyntaxError = SyntaxError; var $TypeError = TypeError; -var parseInt = getBuiltIn('Number', 'parseInt'); +var parseInt = getBuiltInStaticMethod('Number', 'parseInt'); var valid = /^[\da-z]+$/; var charAt = uncurryThis(''.charAt); var exec = uncurryThis(valid.exec); diff --git a/packages/core-js/modules/esnext.symbol.is-well-known-symbol.js b/packages/core-js/modules/esnext.symbol.is-well-known-symbol.js index 27ef336388f5..c2524a62410f 100644 --- a/packages/core-js/modules/esnext.symbol.is-well-known-symbol.js +++ b/packages/core-js/modules/esnext.symbol.is-well-known-symbol.js @@ -3,13 +3,14 @@ var $ = require('../internals/export'); var shared = require('../internals/shared'); var getBuiltIn = require('../internals/get-built-in'); +var getBuiltInStaticMethod = require('../internals/get-built-in-static-method'); var uncurryThis = require('../internals/function-uncurry-this'); var isSymbol = require('../internals/is-symbol'); var wellKnownSymbol = require('../internals/well-known-symbol'); var Symbol = getBuiltIn('Symbol'); var $isWellKnownSymbol = Symbol.isWellKnownSymbol; -var getOwnPropertyNames = getBuiltIn('Object', 'getOwnPropertyNames'); +var getOwnPropertyNames = getBuiltInStaticMethod('Object', 'getOwnPropertyNames'); var thisSymbolValue = uncurryThis(Symbol.prototype.valueOf); var WellKnownSymbolsStore = shared('wks'); diff --git a/packages/core-js/modules/web.url.constructor.js b/packages/core-js/modules/web.url.constructor.js index 6b954f69b48b..129d08d8e075 100644 --- a/packages/core-js/modules/web.url.constructor.js +++ b/packages/core-js/modules/web.url.constructor.js @@ -2,7 +2,7 @@ var $ = require('../internals/export'); var USE_NATIVE_URL = require('../internals/url-constructor-detection'); var global = require('../internals/global'); -var getBuiltIn = require('../internals/get-built-in'); +var getBuiltInStaticMethod = require('../internals/get-built-in-static-method'); var bind = require('../internals/function-bind-context'); var uncurryThis = require('../internals/function-uncurry-this'); var defineBuiltIn = require('../internals/define-built-in'); @@ -26,8 +26,8 @@ var getInternalSearchParamsState = URLSearchParamsModule.getState; var NativeURL = global.URL; var TypeError = global.TypeError; var parseInt = global.parseInt; -var assign = getBuiltIn('Object', 'assign'); -var arrayFrom = getBuiltIn('Array', 'from'); +var assign = getBuiltInStaticMethod('Object', 'assign'); +var arrayFrom = getBuiltInStaticMethod('Array', 'from'); var floor = Math.floor; var pow = Math.pow; var charAt = uncurryThis(''.charAt);