promise-wrap

0.1.0 • Public • Published

promise-wrap

License NPM Version Tag Version Build Status

Have you ever wished that something were just wrapped in a promise?

somethingThatRequiresACallback(function(err, data) {
  if (err) {
    //handle error
  }
  //do useful stuff
}

Now it is:

var pw = require('promise-wrap');

pw(somethingThatRequiresACallback).then(function(data) {
  //do useful stuff
}).error(function(err) {
  //handle error
});

Context

By default promise-wrap will .apply the first argument with a null context and use the rest as parameters. If you want to specify a context simply pw.withContextAndArguments(call, context, args...)

Chaining

Very soon there will be support for setting up methods for chaining so that you can

var pw = require('promise-wrap');

somePromise()
.then(pw.chain(somethingThatRequiresACallback))
.then(function(data) {
  //do useful stuff
}).error(function(err) {
  //handle error
});

Package Sidebar

Install

npm i promise-wrap

Weekly Downloads

2

Version

0.1.0

License

ISC

Last publish

Collaborators

  • terribleplan