2020-08-25 23:57:08 +00:00
|
|
|
'use strict';
|
|
|
|
|
2021-02-26 03:58:33 +00:00
|
|
|
var GetIntrinsic = require('get-intrinsic');
|
|
|
|
var callBound = require('call-bind/callBound');
|
2020-08-25 23:57:08 +00:00
|
|
|
|
2022-11-10 10:43:16 +00:00
|
|
|
var $TypeError = GetIntrinsic('%TypeError%');
|
|
|
|
|
|
|
|
var IsArray = require('./IsArray');
|
|
|
|
|
2020-08-25 23:57:08 +00:00
|
|
|
var $apply = GetIntrinsic('%Reflect.apply%', true) || callBound('%Function.prototype.apply%');
|
|
|
|
|
2021-02-26 03:58:33 +00:00
|
|
|
// https://ecma-international.org/ecma-262/6.0/#sec-call
|
2020-08-25 23:57:08 +00:00
|
|
|
|
|
|
|
module.exports = function Call(F, V) {
|
2022-11-10 10:43:16 +00:00
|
|
|
var argumentsList = arguments.length > 2 ? arguments[2] : [];
|
|
|
|
if (!IsArray(argumentsList)) {
|
|
|
|
throw new $TypeError('Assertion failed: optional `argumentsList`, if provided, must be a List');
|
|
|
|
}
|
|
|
|
return $apply(F, V, argumentsList);
|
2020-08-25 23:57:08 +00:00
|
|
|
};
|