Attaches to an external promise library and provides additional methods built solely on the basic promise operations:
- construct a new promise with a callback function
- resolve a promise with some result data
- reject a promise with a reason
usage
For any third-party promise library:
const promise = require('bluebird');
const spex = require('spex')(promise);
For ES6 promises:
const spex = require('spex')(Promise);
Parameters:
Name | Type | Description |
---|---|---|
promiseLib |
Object | function | Instance of a promise library to be used by this module. Some implementations use Alternatively, an object of type PromiseAdapter can be passed in, which provides compatibility with any promise library outside of the standard. Passing in a promise library that cannot be recognized will throw
|
Returns:
Namespace with all supported methods.
- Type
- Object