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