From 6e9c025900e2e2bbb16bf717590007925e860fcf Mon Sep 17 00:00:00 2001 From: John Carr Date: Sun, 21 Mar 2010 20:02:55 +0000 Subject: [PATCH] Make addBoth API more like the one in twisted --- defer.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/defer.js b/defer.js index f5dce00..400d156 100644 --- a/defer.js +++ b/defer.js @@ -37,15 +37,21 @@ Deferred.prototype = { this._processCallbacks (); }, - addCallback: function (callable, args) { + addCallback: function (callable) { + var args = Array.prototype.slice.call(arguments); + args.shift (); this.addCallbacks (callable, args); }, - addErrback: function (callable, args) { + addErrback: function (callable) { + var args = Array.prototype.slice.call(arguments); + args.shift (); this.addCallbacks (null, null, callable, args); }, - addBoth: function (callable, args) { + addBoth: function (callable) { + var args = Array.prototype.slice.call(arguments); + args.shift (); // Add the same callable as a callback and an errback this.addCallbacks(callable, args, callable, args); }, @@ -118,7 +124,7 @@ function async (fn) { try { while (1) { if (result instanceof Deferred) { - result.addBoth (process, [g, deferred]); + result.addBoth (process, g, deferred); return deferred; } else if (result instanceof Failure) { g.throw (result);