Call.js 623 B

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