Ultralight promise extension compatible with Bluebird
npm install nativebirdUltralight promise extension compatible with Bluebird
!logo
As a pioneer in JavaScript async ecosystem, Bluebird is a great userland promise library with handy utility methods included. However the way it works leads to larger bundle size and more verbose stack trace.
NativeBird is compatible with a core Bluebird subset by extending native promise, and all of its extended APIs (implemented within ~200 lines) are fully tested with the corresponding test cases in Bluebird.
NativeBird can be used in several scenarios:
- To reuse promise utility methods like Promise.map and Promise.each without copying snippets from a gist.
- To perform migration in existing Bluebird projects.
- To simply learn JavaScript async operation skills 🐶.
``sh`
npm install nativebird
`js`
import Promise from "nativebird";
It's also fine to copy promise.mjs and its type definition directly into your project directory.
- Static methods:
- Promise.delay
- Promise.try
- Promise.each
- Promise.mapSeries
- Promise.map
- Promise.reduce
- Promise.defer (deprecated)promise.delay
- Instance methods:
- promise.map
- promise.reduce
- promise.mapSeries
- promise.each
- promise.timeout
- promise.tap
- promise.all
- promise.spread
- promise.asCallback
-
Since NativeBird inherits from native promise, all promise APIs defined in ECMAScript standard (say Promise.allSettled and Promise.any) are naturally supported.
- Promise.cancel is not supported.Promise.isFulfilled
- Synchronous inspection (e.g. ) is not supported.
To implement a new API in Bluebird, please also port the corresponding test cases under test/mocha in Bluebird repo and test it with npm test`.
MIT