blob: 4b238c69160548fc0e9a8a29efcaec44a914fa61 [file] [log] [blame]
Leo Repp58b9f112021-11-22 11:57:47 +01001'use strict';
2
3var GetIntrinsic = require('get-intrinsic');
4var callBound = require('call-bind/callBound');
5
6var $TypeError = GetIntrinsic('%TypeError%');
7
8var IsArray = require('./IsArray');
9
10var $apply = GetIntrinsic('%Reflect.apply%', true) || callBound('%Function.prototype.apply%');
11
12// https://ecma-international.org/ecma-262/6.0/#sec-call
13
14module.exports = function Call(F, V) {
15 var argumentsList = arguments.length > 2 ? arguments[2] : [];
16 if (!IsArray(argumentsList)) {
17 throw new $TypeError('Assertion failed: optional `argumentsList`, if provided, must be a List');
18 }
19 return $apply(F, V, argumentsList);
20};