require-from-url
Advanced tools
Comparing version 2.0.2 to 3.0.0
30
index.js
var parse = require("url").parse; | ||
var listen = require("./addLoadListener.js"); | ||
var Steps = require("promise-tiny/Steps"); | ||
module.exports = function() { | ||
var _url = Array.from(arguments), | ||
_len = _url.length, | ||
module.exports = function(_url, cb) { | ||
var _len = _url.length, | ||
values = Array(_len); | ||
return new Steps().on('Begin', function(next) { | ||
_url.forEach(function(url, index) { | ||
listen(parse(url), function(value) { | ||
values[index] = value; | ||
if(!--_len) { | ||
for(var i=0; i<values.length; i++) | ||
if(values[i] instanceof Error) { | ||
next('Rejected', values[i]); | ||
return; | ||
} | ||
next('Resolved', values); | ||
} | ||
}); | ||
_url.forEach(function(url, index) { | ||
listen(parse(url), function(value) { | ||
values[index] = value; | ||
if(!--_len) { | ||
for(var i=0; i<values.length; i++) | ||
if(values[i] instanceof Error) { | ||
cb(values[i]); | ||
return; | ||
} | ||
cb.apply(undefined, [].concat(null, values)); | ||
} | ||
}); | ||
}); | ||
}; |
{ | ||
"name": "require-from-url", | ||
"version": "2.0.2", | ||
"version": "3.0.0", | ||
"description": "Require module from URL", | ||
@@ -9,5 +9,3 @@ "main": "./index.js", | ||
}, | ||
"dependencies": { | ||
"promise-tiny": "*" | ||
}, | ||
"dependencies": {}, | ||
"keywords": [ | ||
@@ -14,0 +12,0 @@ "nodejs", |
@@ -11,3 +11,2 @@ # require-from-url | ||
## Usage | ||
@@ -18,17 +17,11 @@ | ||
requireFromUrl("https://yishizhencang.com:8080/HelloWorld.js") | ||
.on('Resolved', function(next, HelloWorld) { | ||
var api = new HelloWorld.default; | ||
api.welcome(function(greeting) { | ||
console.log(greeting); | ||
}); | ||
}) | ||
.on('Rejected', function(next, e) { | ||
console.log(e); | ||
}); | ||
requireFromUrl(["https://nodeway.org/HelloWorld.js"], function(err, HelloWorld) { | ||
if(err) return; | ||
var api = new HelloWorld.default; | ||
api.hello('world', (err, greeting) => console.log(greeting)); | ||
}); | ||
``` | ||
## License | ||
MIT © [May xiaoya zhang](gzhangzy@gmail.com) |
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 1 instance in 1 package
0
0
3180
73
26
- Removedpromise-tiny@*
- Removedpromise-tiny@0.2.0(transitive)