Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

require-from-url

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

require-from-url - npm Package Compare versions

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)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc