From 31a88a4dbff9456cef4500a2e9e100e0d87a060f Mon Sep 17 00:00:00 2001 From: Phil Crosby Date: Mon, 30 Apr 2012 00:00:08 -0700 Subject: Add Function.proxy. --- lib/utils.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/utils.js b/lib/utils.js index ca7ce2bc..3a355d7b 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -156,10 +156,13 @@ var utils = { return utils.createFullUrl(str); else return utils.createSearchUrl(str); - }, - + } }; +/* Execute a function with the given value for "this". Equivalent to jQuery.proxy(). */ +Function.prototype.proxy = function(fn, self) { return function() { fn.apply(self, arguments); }; }; + + /* * Simple JavaScript Inheritance, by John Resig. * This provides a short syntax for organizing code into classes. -- cgit v1.2.3