Functional utility library for working with Deferred objects
Main documentation is right here!
Deferreds.js is a utility library centered around working with Deferred objects. The main goal is to do for Deferred objects what async.js does for Node-style asynchronous functions—that is, provide many common higher-order functions (map, reduce, filter, etc.) accepting potentially-asynchronous Deferred objects as arguments.
Just like async.js, deferreds.js provides several flow control functions. To give you an idea of what these look like, here's perhaps the most useful function, pipe (called "waterfall" in async.js):
pipevar deferred = ;setTimeoutdeferredresolve'one' 'two';10;return deferredpromise;console.logarg1; //> 'one'console.logarg2; //> 'two'var deferred = ;setTimeoutdeferredresolvearg1: arg1arg2: arg2arg3: 'three';10;return deferredpromise;console.logresultarg1; //> 'one'console.logresultarg2; //> 'two'console.logresultarg3; //> 'three'var deferred = ;setTimeoutdeferredresolve'four';10;return deferredpromise;thenconsole.logresult; //> ['four'];