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

fuxor

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fuxor - npm Package Compare versions

Comparing version 2.1.0 to 3.0.0

test/app/nested/example.js

14

index.js

@@ -5,2 +5,4 @@ const Module = require('module');

const mappings = new Map();
const namespaceMappings = new Map();
const path = require('path');

@@ -14,2 +16,11 @@ Module._load = function(moduleName, module) {

}
if (moduleName.indexOf('::') > -1) {
console.log('from the _load cwd', process.cwd());
console.log('from the _load __dirname', __dirname);
const [ namespace, moduleToLoad ] = moduleName.split('::');
console.log('namespace', namespace);
const modulePath = path.join(process.cwd(), namespaceMappings.get(namespace), moduleToLoad);
console.log('modulePath', modulePath);
return defaultLoad(modulePath);
}
if (mappings.has(moduleName)) {

@@ -39,3 +50,6 @@ return mappings.get(moduleName);

Module._load = defaultLoad;
},
namespace: function(name, pathStart) {
namespaceMappings.set(name, pathStart);
}
}

5

package.json
{
"name": "fuxor",
"version": "2.1.0",
"version": "3.0.0",
"description": "Simple dependency injection by overriding require",

@@ -9,2 +9,5 @@ "main": "index.js",

"dependency inject",
"dependency injection",
"namespacing",
"namespace",
"ioc",

@@ -11,0 +14,0 @@ "test",

@@ -158,1 +158,14 @@ const test = require('tap').test;

});
test('Add folder to namespace', function (t) {
fuxor.clear();
fuxor.namespace('app', './test/app');
const app = require('app::sample');
const nested = require('app::nested');
const example = require('app::nested/example');
t.ok(app() === true, 'method should return');
t.ok(nested() === false, 'module should be the correct one');
t.ok(example() === 'example', 'method should return');
t.end();
});
.travis.yml

Sorry, the diff of this file is not supported yet

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