blob: bae91c171d7811ac9bbac50e686c340d015ad733 [file] [log] [blame]
Leo Repp58b9f112021-11-22 11:57:47 +01001'use strict';
2
3var bind = require('function-bind');
4var GetIntrinsic = require('get-intrinsic');
5
6var $apply = GetIntrinsic('%Function.prototype.apply%');
7var $call = GetIntrinsic('%Function.prototype.call%');
8var $reflectApply = GetIntrinsic('%Reflect.apply%', true) || bind.call($call, $apply);
9
10var $defineProperty = GetIntrinsic('%Object.defineProperty%', true);
11
12if ($defineProperty) {
13 try {
14 $defineProperty({}, 'a', { value: 1 });
15 } catch (e) {
16 // IE 8 has a broken defineProperty
17 $defineProperty = null;
18 }
19}
20
21module.exports = function callBind() {
22 return $reflectApply(bind, $call, arguments);
23};
24
25var applyBind = function applyBind() {
26 return $reflectApply(bind, $apply, arguments);
27};
28
29if ($defineProperty) {
30 $defineProperty(module.exports, 'apply', { value: applyBind });
31} else {
32 module.exports.apply = applyBind;
33}