register.js
function loadImplementation(implementation){
  var impl = null

  if(shouldPreferGlobalPromise(implementation)){
    // if no implementation or env specified use global.Promise
    impl = {
      Promise: global.Promise,
      implementation: 'global.Promise'
    }
  } else if(implementation){
    // if implementation specified, require it
    var lib = require(implementation)
    impl = {
      Promise: lib.Promise || lib,
      implementation: implementation
    }
  } else {
    // try to auto detect implementation. This is non-deterministic
    // and should prefer other branches, but this is our last chance
    // to load something without throwing error
    impl = tryAutoDetect()
  }

  if(impl === null){
    throw new Error('Cannot find any-promise implementation nor'+
      ' global.Promise. You must install polyfill or call'+
      ' require("any-promise/register") with your preferred'+
      ' implementation, e.g. require("any-promise/register/bluebird")'+
      ' on application load prior to any require("any-promise").')
  }

  return impl
}
function loadImplementation(implementation){
  var impl = null

  if(shouldPreferGlobalPromise(implementation)){
    // if no implementation or env specified use global.Promise
    impl = {
      Promise: global.Promise,
      implementation: 'global.Promise'
    }
  } else if(implementation){
    // if implementation specified, require it
    var lib = require(implementation)
    impl = {
      Promise: lib.Promise || lib,
      implementation: implementation
    }
  } else {
    // try to auto detect implementation. This is non-deterministic
    // and should prefer other branches, but this is our last chance
    // to load something without throwing error
    impl = tryAutoDetect()
  }

  if(impl === null){
    throw new Error('Cannot find any-promise implementation nor'+
      ' global.Promise. You must install polyfill or call'+
      ' require("any-promise/register") with your preferred'+
      ' implementation, e.g. require("any-promise/register/bluebird")'+
      ' on application load prior to any require("any-promise").')
  }

  return impl
}
function loadImplementation ( implementation ) { var impl = null if ( shouldPreferGlobalPromise ( implementation ) ) { // if no implementation or env specified use global.Promise impl = { Promise : global . Promise , implementation : 'global.Promise' } } else if ( implementation ) { // if implementation specified, require it var lib = require ( implementation ) impl = { Promise : lib . Promise || lib , implementation : implementation } } else { // try to auto detect implementation. This is non-deterministic // and should prefer other branches, but this is our last chance // to load something without throwing error impl = tryAutoDetect ( ) } if ( impl === null ) { throw new Error ( 'Cannot find any-promise implementation nor' + ' global.Promise. You must install polyfill or call' + ' require("any-promise/register") with your preferred' + ' implementation, e.g. require("any-promise/register/bluebird")' + ' on application load prior to any require("any-promise").' ) } return impl }
Node.js version of loadImplementation.

Requires the given implementation and returns the registration
containing {Promise, implementation}

If implementation is undefined or global.Promise, loads it
Otherwise uses require
Node . js version of loadImplementation .