|
@@ -101,6 +101,29 @@ var core = new (function () { |
|
|
return false;
|
|
|
};
|
|
|
|
|
|
+ /*
|
|
|
+ binds a function to an object
|
|
|
+ */
|
|
|
+ this.bind = function(self, fn)
|
|
|
+ {
|
|
|
+ var curryArgs = arguments.length > 2 ? Array.prototype.slice.call(arguments, 2) : [];
|
|
|
+ if (typeof fn === 'function' && !(fn instanceof RegExp)) {
|
|
|
+ return curryArgs.length
|
|
|
+ ? function () {
|
|
|
+ return arguments.length
|
|
|
+ ? fn.apply(self, curryArgs.concat(slice.call(arguments, 0)))
|
|
|
+ : fn.apply(self, curryArgs);
|
|
|
+ }
|
|
|
+ : function () {
|
|
|
+ return arguments.length
|
|
|
+ ? fn.apply(self, arguments)
|
|
|
+ : fn.call(self);
|
|
|
+ };
|
|
|
+ } else {
|
|
|
+ // in IE, native methods are not functions so they cannot be bound (note: they don't need to be)
|
|
|
+ return fn;
|
|
|
+ }
|
|
|
+ }
|
|
|
})();
|
|
|
|
|
|
module.exports = core;
|
0 comments on commit
9132d13