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 Promise constructor to create a new promise, while others use the module's function for it. Both types are supported the same.

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 Invalid promise library specified.

Author:
  • Vitaly Tomilov
Source:
See:
Returns:

Namespace with all supported methods.

Type
Object