Package Exports
- create-thenable
- create-thenable/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (create-thenable) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
create-thenable
Create a thenable for a given Promise
Install
$ npm install --save create-thenableUsage
var thenable = require('create-thenable')(require('bluebird'))
return thenable.catch(errHandlers).then(handler)The returned thenable has a then method that creates a new promise. It also proxies methods from the prototype and guarantees the presence of catch and finally. When these proxied methods are called, they call then to create the promise and then call the method on the result. That way you can do this:
var thenable = createThenable(require('bluebird'), function () {
resolve('foo')
})
thenable.tap(function () {
console.log('succeeded')
})
.then(function (value) {
assert(value, 'foo')
})thenable isn't a true Bluebird Promise but you can still trigger its methods as if it were.
API
createThenable(Promise, resolver) -> thenable
Promise
Required
Type: function
A Promise constructor
resolver
Required
Type: function
The resolver function to pass to the Promise constructor
License
MIT © Ben Drucker