diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-05-27 17:36:13 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-05-27 17:36:13 +0200 |
commit | 5f466137ad6ac596600e3ff53c9b786815398445 (patch) | |
tree | f914c221874f0b16bf3def7ac01d59d1a99a3b0b /node_modules/core-js/modules/es6.reflect.construct.js | |
parent | c9f5ac8e763eda19aa0564179300cfff76785435 (diff) |
node_modules, clean up package.json
Diffstat (limited to 'node_modules/core-js/modules/es6.reflect.construct.js')
-rw-r--r-- | node_modules/core-js/modules/es6.reflect.construct.js | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/node_modules/core-js/modules/es6.reflect.construct.js b/node_modules/core-js/modules/es6.reflect.construct.js index c3928cd92..96483d708 100644 --- a/node_modules/core-js/modules/es6.reflect.construct.js +++ b/node_modules/core-js/modules/es6.reflect.construct.js @@ -1,21 +1,29 @@ // 26.1.2 Reflect.construct(target, argumentsList [, newTarget]) -var $ = require('./$') - , $export = require('./$.export') - , aFunction = require('./$.a-function') - , anObject = require('./$.an-object') - , isObject = require('./$.is-object') - , bind = Function.bind || require('./$.core').Function.prototype.bind; +var $export = require('./_export') + , create = require('./_object-create') + , aFunction = require('./_a-function') + , anObject = require('./_an-object') + , isObject = require('./_is-object') + , fails = require('./_fails') + , bind = require('./_bind') + , rConstruct = (require('./_global').Reflect || {}).construct; -// MS Edge supports only 2 arguments +// MS Edge supports only 2 arguments and argumentsList argument is optional // FF Nightly sets third argument as `new.target`, but does not create `this` from it -$export($export.S + $export.F * require('./$.fails')(function(){ +var NEW_TARGET_BUG = fails(function(){ function F(){} - return !(Reflect.construct(function(){}, [], F) instanceof F); -}), 'Reflect', { + return !(rConstruct(function(){}, [], F) instanceof F); +}); +var ARGS_BUG = !fails(function(){ + rConstruct(function(){}); +}); + +$export($export.S + $export.F * (NEW_TARGET_BUG || ARGS_BUG), 'Reflect', { construct: function construct(Target, args /*, newTarget*/){ aFunction(Target); anObject(args); var newTarget = arguments.length < 3 ? Target : aFunction(arguments[2]); + if(ARGS_BUG && !NEW_TARGET_BUG)return rConstruct(Target, args, newTarget); if(Target == newTarget){ // w/o altered newTarget, optimization for 0-4 arguments switch(args.length){ @@ -32,7 +40,7 @@ $export($export.S + $export.F * require('./$.fails')(function(){ } // with altered newTarget, not support built-in constructors var proto = newTarget.prototype - , instance = $.create(isObject(proto) ? proto : Object.prototype) + , instance = create(isObject(proto) ? proto : Object.prototype) , result = Function.apply.call(Target, instance, args); return isObject(result) ? result : instance; } |