101
Version:
common javascript utils that can be required selectively that assume es5+
18 lines (16 loc) • 459 B
JavaScript
/**
* @module 101/apply
*/
/**
* Functional version of function.apply
* @function module:101/apply
* @param {*} thisArg - Context applied to fn
* @param {array} args - Arguments applied to fn
* @return {function} function which accepts a function, fn, and applies thisArg, and args to it. Returns fn.apply(thisArg, args).
*/
module.exports = apply;
function apply (thisArg, args) {
return function (fn) {
return fn.apply(thisArg, args);
};
}