devsite/node_modules/promise-each/node_modules/any-promise/README.md
2024-07-07 18:49:38 -07:00

1.4 KiB

Any Promise

Build Status

Let your library support any ES6 compatible Promise library or polyfill and leave the choice to the end user. The end user can install a polyfill or npm install their preference before using this library and the installed library will be automatically detected.

Attempts to load libraries in the following order. The first successful require will be exported.

If no library is installed, attempts to export the global Promise (native or polyfill). The browserify version will always export the the global Promise, so polyfill as necessary.

If you have multiple libraries installed (e.g. for testing), and would like to specify one you can use the PROMISE_IMPL env variable.

var Promise = require('any-promise');

return Promise
  .all([xf, f, init, coll])
  .then(fn);


return new Promise(function(resolve, reject){
  try {
    resolve(item);
  } catch(e){
    reject(e);
  }
});