i-promise
v1.1.0
Published
Returns an available ES6 Promise implementation, browserify friendly.
Downloads
74
Maintainers
Readme
i-promise
When calling this module a Promise library will be returned if one is available.
This module will not declare any dependencies, you should install a fallback library downstream if needed.
Install
npm install --save i-promise
Use
var Promise = require('i-promise');
if (!Promise) throw new Error('No ES6 Promise Library Available.');
return Promise.resolve('success')
Notes
In a browser (via browserify), it will return either window.Promise
, window.Q.Promise
or window.Q.promise
in that order, you should have an es6-promise shim or the Q library loaded globally in the browser if you need promises in older browsers.
In node, attempts to use the following will be made.
- native
Promise
(newer versions of node.js) - es6-promise
- es6-promises
- bluebird
- q (
Promise
thenpromise
)
Preferring user implementation over native
Default behavior is to always favor native implementation if found. You can still favor the implementation of your choice without overriding global Promise
:
require('i-promise/config').use(MyPromiseImplementation);
You must run this code before any call to require('i-promise')
.