bluebird-decorator
v1.0.0
Published
An ES7 decorator for ensuring that every Promise returned by a function is a Bluebird instance.
Downloads
2
Maintainers
Readme
bluebird-decorator
An ES7 decorator for ensuring that every Promise returned by a function is a Bluebird instance.
Installation
Install the package with NPM:
$ npm install bluebird-decorator
Usage
Example:
import bluebird from "bluebird-decorator";
class Dog {
@bluebird
bark() { return Promise.resolve("Woof!") }
}
let dog = new Dog();
let promise = dog.bark(); // Return value is a Bluebird instance, not a Promise.
promise.then(noise => console.log(noise)); // Print "Woof!".
Also, functions that do not return a Promise instance are ignored.