1 | var slice = require('../array/slice');
|
2 |
|
3 | /**
|
4 | * Return a function that will execute in the given context, optionally adding any additional supplied parameters to the beginning of the arguments collection.
|
5 | * @param {Function} fn Function.
|
6 | * @param {object} context Execution context.
|
7 | * @param {rest} args Arguments (0...n arguments).
|
8 | * @return {Function} Wrapped Function.
|
9 | */
|
10 | function bind(fn, context, args){
|
11 | var argsArr = slice(arguments, 2); //curried args
|
12 | return function(){
|
13 | return fn.apply(context, argsArr.concat(slice(arguments)));
|
14 | };
|
15 | }
|
16 |
|
17 | module.exports = bind;
|
18 |
|
19 |
|