th.en - make it painless to adapt between callbacks and promises
make it painless to adapt between callbacks and promises
then is like a magic portal to warp between Promised land and the firey depths of Callback hell.
var then = require'th'var fs = require'fs'fsreadFile'./tmp' thenthenconsole.log'file'console.log'errors!' err// although you may want to be using streaming file methods, anyhow
When we invoke
then() the first time, it creates a callback to give to
fs.readFile. When we call it the next time, it's like a Promises/A+
Importantly, there are times when we want to go back from a chain of promises to a callback:
if err return nextCberrvar promise = myPromisethensomeStepthenoneMoreThingthencallbackpromise nextCb
See usage note above for behavior.
callback as a handler for promise
$ npm install th
From package root:
$ npm install $ npm test
- jden email@example.com
MIT. (c) MMXIII AgileMD http://agilemd.com