diff options
Diffstat (limited to 'src/node_modules/es-abstract/helpers/callBind.js')
-rw-r--r-- | src/node_modules/es-abstract/helpers/callBind.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/node_modules/es-abstract/helpers/callBind.js b/src/node_modules/es-abstract/helpers/callBind.js new file mode 100644 index 0000000..3c1a327 --- /dev/null +++ b/src/node_modules/es-abstract/helpers/callBind.js @@ -0,0 +1,34 @@ +'use strict'; + +var bind = require('function-bind'); + +var GetIntrinsic = require('../GetIntrinsic'); + +var $apply = GetIntrinsic('%Function.prototype.apply%'); +var $call = GetIntrinsic('%Function.prototype.call%'); +var $reflectApply = GetIntrinsic('%Reflect.apply%', true) || bind.call($call, $apply); + +var $defineProperty = GetIntrinsic('%Object.defineProperty%', true); + +if ($defineProperty) { + try { + $defineProperty({}, 'a', { value: 1 }); + } catch (e) { + // IE 8 has a broken defineProperty + $defineProperty = null; + } +} + +module.exports = function callBind() { + return $reflectApply(bind, $call, arguments); +}; + +var applyBind = function applyBind() { + return $reflectApply(bind, $apply, arguments); +}; + +if ($defineProperty) { + $defineProperty(module.exports, 'apply', { value: applyBind }); +} else { + module.exports.apply = applyBind; +} |