Skip to content

Instantly share code, notes, and snippets.

@shigeki
Created April 20, 2012 08:59
Show Gist options
  • Save shigeki/2427216 to your computer and use it in GitHub Desktop.
Save shigeki/2427216 to your computer and use it in GitHub Desktop.
patch for d.run(fn, argument, ...), d.apply(fn, this, arguments) , d.call(fn, this, argument, ... )
--- a/lib/domain.js
+++ b/lib/domain.js
@@ -136,7 +136,15 @@ Domain.prototype.remove = function(ee) {
};
Domain.prototype.run = function(fn) {
- this.bind(fn)();
+ this.bind(fn).apply(null, Array.prototype.slice.call(arguments,1));
+};
+
+Domain.prototype.apply = function(fn, thisobj) {
+ this.bind(fn).apply(thisobj, arguments[2]);
+};
+
+Domain.prototype.call = function(fn, thisobj) {
+ this.bind(fn).apply(thisobj, Array.prototype.slice.call(arguments,1));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment