Urara-Blog/node_modules/.pnpm-store/v3/files/6e/df5feb412d0ce6b4f108dc8a663d9d316437fbda6c16ca8069ff984629217b6e646b631ec28eae5d3d85d2adcb32a25d1befc74aa0337c9e36028338a6ec81
2022-08-14 01:14:53 +08:00

21 lines
714 B
Text

/**
* A faster alternative to `Function#apply`, this function invokes `func`
* with the `this` binding of `thisArg` and the arguments of `args`.
*
* @private
* @param {Function} func The function to invoke.
* @param {*} thisArg The `this` binding of `func`.
* @param {Array} args The arguments to invoke `func` with.
* @returns {*} Returns the result of `func`.
*/
function apply(func, thisArg, args) {
switch (args.length) {
case 0: return func.call(thisArg);
case 1: return func.call(thisArg, args[0]);
case 2: return func.call(thisArg, args[0], args[1]);
case 3: return func.call(thisArg, args[0], args[1], args[2]);
}
return func.apply(thisArg, args);
}
module.exports = apply;