kevinbeaty / any-promise

NOTE: You probably want native promises now
MIT License
179 stars 17 forks source link

Explicit registration or default to global.Promise #4

Closed kevinbeaty closed 8 years ago

kevinbeaty commented 8 years ago

Add registration of preference through require('any-promise/register')('when') (where `when is preferred implementation.

On `require('any-promise'), loads an implementation with following priority

  1. Use previous registration through require('any-promise/register')('bluebird')
  2. Implementation specified by PROMISE_IMPL
  3. global.Promise if node.js version >= 0.12
  4. Auto detected promise based on first successful require of known promise libraries. Note this is a last resort, as the loaded library is non-deterministic. node.js >= 0.12 will always use global.Promise over this priority list.
  5. Throws error

Add require('any-promise/implementation') to retrieve registered implementation. Update tests and documentation.