diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/utils.js | 11 | 
1 files changed, 11 insertions, 0 deletions
| diff --git a/lib/utils.js b/lib/utils.js index a5887e89..ab44e43f 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -166,6 +166,17 @@ Function.prototype.proxy = function(self) {  };  /* + * This creates a new function out of an existing function, where the new function takes fewer arguments. + * This allows us to pass around functions instead of functions + a partial list of arguments. + */ +Function.prototype.curry = function(fixedArguments) { +  var fn = this; +  return function() { return fn.apply(this, fixedArguments.concat(Array.copy(arguments))); }; +}; + +Array.copy = function(array) { return Array.prototype.slice.call(array, 0); }; + +/*   * Simple JavaScript Inheritance, by John Resig.   * This provides a short syntax for organizing code into classes.   * Taken from http://ejohn.org/blog/simple-javascript-inheritance/. | 
