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 3.1.0 to 3.1.1

6

addLoadListener.js

@@ -0,6 +1,8 @@

var parse = require("url").parse;
var loader = require("./requireFromUrl.js");
var resolves = {}, listeners = {};
function addLoadListener(url, listener) {
var href = url.href;
function addLoadListener(urlString, listener) {
var url = parse(urlString),
href = url.href;
if(href in resolves) listener(resolves[href]);

@@ -7,0 +9,0 @@ else if(listeners[href]) listeners[href].push(listener);

@@ -1,11 +0,10 @@

var parse = require("url").parse;
var listen = require("./addLoadListener.js");
module.exports = function(_url, cb) {
var _len = _url.length,
values = Array(_len);
_url.forEach(function(url, index) {
listen(parse(url), function(value) {
module.exports = function(urls, cb) {
var len = urls.length,
values = Array(len);
urls.forEach(function(url, index) {
listen(url, function(value) {
values[index] = value;
if(!--_len) {
if(!--len) {
for(var i=0; i<values.length; i++)

@@ -12,0 +11,0 @@ if(values[i] instanceof Error) {

{
"name": "require-from-url",
"version": "3.1.0",
"version": "3.1.1",
"description": "Require module from URL",

@@ -5,0 +5,0 @@ "main": "./index.js",

'use strict';
var parse = require("url").parse;
var resolves = {};
var spawnSync = require('child_process').spawnSync;

@@ -10,9 +12,14 @@ var options = {

function sync(url) {
var returns = spawnSync('node', ['fetch.js', url], options);
var [err, str, filename] = JSON.parse(returns.stdout.toString());
if(err) throw new Error(err);
return requireFromString(str, filename);
function sync(urlString) {
var url = parse(urlString),
href = url.href;
if(!resolves[href]) {
var returns = spawnSync('node', ['fetch.js', href], options);
var [err, str, filename] = JSON.parse(returns.stdout.toString());
if(err) throw new Error(err);
resolves[href] = requireFromString(str, filename);
}
return resolves[href];
}
module.exports = sync;
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