any-promise
Advanced tools
Comparing version 0.0.2 to 0.1.0
"use strict"; | ||
var PROMISE_EXISTS = typeof Promise !== 'undefined', | ||
PROMISE_IMPL = process.env.PROMISE_IMPL, | ||
var PROMISE_IMPL = process.env.PROMISE_IMPL, | ||
undef; | ||
if(PROMISE_EXISTS){ | ||
module.exports = Promise; | ||
} else { | ||
module.exports = (function(){ | ||
var libs; | ||
if(PROMISE_IMPL !== undef){ | ||
libs = [process.env.PROMISE_IMPL]; | ||
} else { | ||
libs = [ | ||
"es6-promise", | ||
"promise", | ||
"native-promise-only", | ||
"bluebird", | ||
"rsvp", | ||
"when", | ||
"q"]; | ||
} | ||
var i = 0, len = libs.length, lib; | ||
for(; i < len; i++){ | ||
try { | ||
lib = require(libs[i]); | ||
if(lib.Promise !== undef){ | ||
return lib.Promise; | ||
} | ||
return lib; | ||
} catch(e){} | ||
} | ||
throw new Error('Must install one of: '+libs.join()); | ||
})(); | ||
} | ||
module.exports = (function(){ | ||
var libs; | ||
if(PROMISE_IMPL !== undef){ | ||
libs = [process.env.PROMISE_IMPL]; | ||
} else { | ||
libs = [ | ||
"es6-promise", | ||
"promise", | ||
"native-promise-only", | ||
"bluebird", | ||
"rsvp", | ||
"when", | ||
"q"]; | ||
} | ||
var i = 0, len = libs.length, lib; | ||
for(; i < len; i++){ | ||
try { | ||
lib = require(libs[i]); | ||
if(lib.Promise !== undef){ | ||
return lib.Promise; | ||
} | ||
return lib; | ||
} catch(e){} | ||
} | ||
if(typeof Promise !== 'undefined'){ | ||
return Promise; | ||
} | ||
throw new Error('Must install one of: '+libs.join()); | ||
})(); |
{ | ||
"name": "any-promise", | ||
"version": "0.0.2", | ||
"version": "0.1.0", | ||
"description": "Resolve any installed ES6 compatible promise", | ||
@@ -27,11 +27,11 @@ "main": "any-promise.js", | ||
"promise": "~6.0.1", | ||
"es6-promise": "~2.0.0", | ||
"rsvp": "~3.0.14", | ||
"bluebird": "~2.3.10", | ||
"when": "~3.5.2", | ||
"q": "~1.0.1", | ||
"es6-promise": "~2.0.1", | ||
"rsvp": "~3.0.16", | ||
"bluebird": "~2.5.3", | ||
"when": "~3.6.4", | ||
"q": "~1.1.2", | ||
"native-promise-only": "~0.7.6-a", | ||
"promises-aplus-tests": "~2.1.0", | ||
"mocha": "~2.0.1" | ||
"mocha": "~2.1.0" | ||
} | ||
} |
@@ -7,3 +7,3 @@ ## Any Promise | ||
Prefers a global `Promise` object (native or polyfill). If one is not detected, attempts to load libraries in the following order. The first successful `require` will be exported. | ||
Attempts to load libraries in the following order. The first successful `require` will be exported. | ||
@@ -18,2 +18,4 @@ - [es6-promise](https://github.com/jakearchibald/es6-promise) | ||
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. | ||
@@ -20,0 +22,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4098
38
33