epiphany/node_modules/any-promise
2023-12-09 22:19:03 -08:00
..
.jshintrc install 11ty 2023-12-09 22:19:03 -08:00
.npmignore install 11ty 2023-12-09 22:19:03 -08:00
any-promise-shim.js install 11ty 2023-12-09 22:19:03 -08:00
any-promise.js install 11ty 2023-12-09 22:19:03 -08:00
LICENSE install 11ty 2023-12-09 22:19:03 -08:00
package.json install 11ty 2023-12-09 22:19:03 -08:00
README.md install 11ty 2023-12-09 22:19:03 -08:00

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);
  }
});