proback.js - dependency-free very minimal helper for APIs with Promise/callback dual design


========
proback.js is an extremely tiny helper library to help the creation of APIs where functions are aimed to enable Promise-based and callback-based usage as well.
Usage
Rules
Usage
Command line:
npm install proback.js --save
In JS code:
var Proback = require('proback.js');
...
function yourService( data, callback ){
new Promise( function (resolve, reject) {
object.fnCallWithCallback( data, Proback.handler( null, resolve, reject ) )
}).then( function (res) {
expect(res).to.equal('Done.')
done()
})
}
var Proback = require('proback.js');
...
function yourService( data, callback ){
return new Promise( function (resolve, reject) {
object.fnCallWithCallback( data, function (err, res) {
if (err) return Proback.rejecter(err, null, reject)
return Proback.resolver(res, null, resolve)
} )
}).then( function (res) {
expect(res).to.equal('Done.')
done()
})
}