Useful for developing asynchronous express middleware
Turn this:
foo( 'someValue' )
.then(function bar() {
// we finished
});
into this:
// bar expects a callback where the last argument is a `done` or `next` callback
bar( 'someValue', function( someValue, next ) {
foo( someValue, next );
});
npm i --save nexthenify
Basic usage
const nexthenify = require( 'nexthenify' );
function foo( value ) {
return new Promise(( resolve, reject ) => {
if ( value === 1 ) resolve( 'is 1' );
else reject( 'not 1' );
});
}
bar( 'someValue', nexthenify( foo ));
Optionally pass a context to use:
bar( 'someValue', nexthenify( foo, this ));
Requires gulp: npm i -g gulp
npm test