New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

r42

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

r42 - npm Package Compare versions

Comparing version 0.0.14 to 0.0.15

102

lib/moduleContext.js

@@ -43,2 +43,7 @@ 'use strict';

}
this.$modules[resolvedName].loading = false;
_.each(this.$modules[resolvedName].callbacks, function (callback) {
callback(null, this.$modules[resolvedName].content);
});
this.$modules[resolvedName].callbacks = [];
callback(null, this.$modules[resolvedName].content);

@@ -49,57 +54,70 @@ }.bind(this));

name = this.$mm.resolve(name);
if (name in this.$modules) {
this.$modules[name].dependent.push(callee);
if (this.$modules[name].loading) {
this.$modules[name].callbacks.push(callback);
return;
}
return callback(null, this.$modules[name].content);
}
var modulePath = path.join(this.$baseDir, name + '.js');
var exists = fs.existsSync(modulePath);
if (!exists) {
return fs.exists(path.join(this.$baseDir, name, 'index.js'), function (exists) {
if (!exists) {
try {
return callback(null, require(name));
}
catch(e) {
console.error('Cannot load module ' + name + ' (required by module' + callee + ')');
return callback(e);
}
}
this.getModule(callee, path.join(name, 'index'), callback);
}.bind(this));
}
this.$modules[name] = {
dependent: [],
dependent: [callee],
content: {},
loading: true,
callbacks: [],
};
var modulePath = path.join(this.$baseDir, name + '.js');
if (fs.exists(modulePath, function (exists) {
if (!exists) {
return fs.exists(path.join(this.$baseDir, name, 'index.js'), function (exists) {
if (!exists) {
return callback(null, require(name));
}
this.getModule(callee, path.join(name, 'index'), callback);
}.bind(this));
}
var defineCalled = false;
var defineCalled = false;
var define = _.createCallback(
_.partial(
_.partialRight(
this.$define, function (err) {
this.$modules[name].dependent.push(callee);
callback(err, this.$modules[name].content);
}.bind(this)
),
name
var define = _.createCallback(
_.partial(
_.partialRight(
this.$define, function (err) {
this.$modules[name].dependent.push(callee);
callback(err, this.$modules[name].content);
}.bind(this)
),
null,
2
);
name
),
null,
2
);
run.runFile(modulePath, {
define: function () {
if (defineCalled === true) {
throw new Error('[r42] ModuleContext: define must be called only once ' +
'per module but was called twice in ' + name);
}
defineCalled = true;
define.apply(null, arguments);
}.bind(this)
}, function (err) {
if (err) {
throw err;
run.runFile(modulePath, {
define: function () {
if (defineCalled === true) {
throw new Error('[r42] ModuleContext: define must be called only once ' +
'per module but was called twice in ' + name);
}
if (!defineCalled) {
throw new Error('[r42] ModuleContext: define not called by module ' + name);
}
});
}.bind(this)));
defineCalled = true;
define.apply(null, arguments);
}.bind(this)
}, function (err) {
if (err) {
throw err;
}
if (!defineCalled) {
throw new Error('[r42] ModuleContext: define not called by module ' + name);
}
});
};

@@ -106,0 +124,0 @@ ModuleContext.prototype.removeModule = function (resolvedName) {

{
"name": "r42",
"version": "0.0.14",
"version": "0.0.15",
"description": "Dependency injection done right.",

@@ -5,0 +5,0 @@ "author": "Quentin Raynaud <npm@qraynaud.eu>",

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