Socket
Socket
Sign inDemoInstall

fuxor

Package Overview
Dependencies
0
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0 to 2.1.0

4

index.js

@@ -20,5 +20,7 @@ const Module = require('module');

module.exports = {
add: function (mapping) {
add: function (mapping, result) {
if (Array.isArray(mapping)) {
mapping.forEach(map => mappings.set(map.name, map.result));
} else if (typeof mapping === 'string') {
mappings.set(mapping, result);
} else {

@@ -25,0 +27,0 @@ mappings.set(mapping.name, mapping.result);

{
"name": "fuxor",
"version": "2.0.0",
"version": "2.1.0",
"description": "Simple dependency injection by overriding require",

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

@@ -6,5 +6,5 @@ [![Build Status](https://travis-ci.org/Kevnz/fuxor.png?branch=master)](https://travis-ci.org/Kevnz/fuxor)

```
```:javascript
const fuxor = require('fuxor');
fuxor.add({ name: 'fs', result: {
fuxor.add('fs', {
readFileSync: function () {

@@ -18,8 +18,13 @@ return 'Not really a file';

```
### API
#### Add
```
```:javascript
const fuxor = require('fuxor');
// Add one entry to be overridden
fuxor.add('fs', {
readFileSync: function () {
return 'Not really a file';
}
});
// Add one entry to be overridden
fuxor.add({ name: 'fs', result: {

@@ -29,3 +34,3 @@ readFileSync: function () {

}
});
}});
// Add multiple entries at once

@@ -45,3 +50,3 @@ fuxor.add([{ name: 'fs', result: {

#### Clear
```
```:javascript
const fuxor = require('fuxor');

@@ -53,3 +58,3 @@ // After items have been added

#### remove
```
```:javascript
const fuxor = require('fuxor');

@@ -61,3 +66,3 @@ // After items have been added

#### reset
```
```:javascript
const fuxor = require('fuxor');

@@ -64,0 +69,0 @@ // After items have been added

@@ -125,2 +125,17 @@ const test = require('tap').test;

test('Adding by string (key) and result', function (t) {
fuxor.clear();
const fs = require('fs');
fuxor.add('fs', {
test: function (result) {
t.ok(result, 'this should be called' );
t.end();
}
});
const fs2 = require('fs');
t.notEqual(fs , fs2, 'should not be the same');
fs2.test(true);
});
test('Adding multiple overrides in one add', function (t) {

@@ -127,0 +142,0 @@ fuxor.clear();

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc