any-promise
Advanced tools
Comparing version 0.0.1 to 0.0.2
"use strict"; | ||
/* global Symbol */ | ||
var PROMISE_EXISTS = typeof Promise !== 'undefined', | ||
PROMISE_IMPL, | ||
PROMISE_IMPL = process.env.PROMISE_IMPL, | ||
undef; | ||
@@ -11,33 +10,26 @@ | ||
module.exports = (function(){ | ||
function load(){ | ||
var libs; | ||
if(PROMISE_IMPL === undef && typeof process !== 'undefined' && process.env){ | ||
PROMISE_IMPL = process.env.PROMISE_IMPL; | ||
} | ||
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()); | ||
var libs; | ||
if(PROMISE_IMPL !== undef){ | ||
libs = [process.env.PROMISE_IMPL]; | ||
} else { | ||
libs = [ | ||
"es6-promise", | ||
"promise", | ||
"native-promise-only", | ||
"bluebird", | ||
"rsvp", | ||
"when", | ||
"q"]; | ||
} | ||
return load(); | ||
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()); | ||
})(); | ||
@@ -44,0 +36,0 @@ } |
{ | ||
"name": "any-promise", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Resolve any installed ES6 compatible promise", | ||
"main": "any-promise.js", | ||
"browser": "any-promise-shim.js", | ||
"scripts": { | ||
@@ -7,0 +8,0 @@ "test": "make test" |
@@ -18,1 +18,19 @@ ## Any Promise | ||
If you have multiple libraries installed (e.g. for testing), and would like to specify one you can use the `PROMISE_IMPL` env variable. | ||
```javascript | ||
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); | ||
} | ||
}); | ||
``` |
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
4096
7
36
3
35