From b7d445c74b188077898779103c4fa951fab17b66 Mon Sep 17 00:00:00 2001 From: Phil Crosby Date: Sat, 5 May 2012 16:28:28 -0700 Subject: Make createActionOpenUrl be a simple function. --- lib/utils.js | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'lib') diff --git a/lib/utils.js b/lib/utils.js index a5887e89..ab44e43f 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -165,6 +165,17 @@ Function.prototype.proxy = function(self) { return function() { return fn.apply(self, arguments); }; }; +/* + * 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. -- cgit v1.2.3