require-from-url
Advanced tools
Comparing version 1.0.2 to 2.0.0
var parse = require("url").parse; | ||
var listen = require("./addLoadListener.js"); | ||
var Promise= require("promise-tiny"); | ||
var Steps = require("promise-tiny/Steps"); | ||
@@ -9,3 +9,3 @@ module.exports = function() { | ||
values = Array(_len); | ||
return new Promise(function(resolve, reject) { | ||
return new Steps().on('Begin', function(next) { | ||
_url.forEach(function(url, index) { | ||
@@ -17,7 +17,7 @@ listen(parse(url), function(value) { | ||
if(values[i] instanceof Error) { | ||
reject(values[i]); | ||
next('Rejected', values[i]); | ||
return; | ||
} | ||
} | ||
resolve(values); | ||
next('Resolved', values); | ||
} | ||
@@ -24,0 +24,0 @@ }); |
{ | ||
"name": "require-from-url", | ||
"version": "1.0.2", | ||
"version": "2.0.0", | ||
"description": "Require module from URL", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
@@ -17,12 +17,12 @@ # require-from-url | ||
requireFromUrl(["http://yishizhencang.com:8080/HelloWorld.js"]) | ||
.then(function(HelloWorld) { | ||
var api = new HelloWorld.default; | ||
api.welcome(function(greeting) { | ||
console.log(greeting); | ||
requireFromUrl("http://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); | ||
}); | ||
}) | ||
.catch(function(e) { | ||
console.log(e); | ||
}); | ||
``` | ||
@@ -29,0 +29,0 @@ |
3382