Launch Week Day 3: Introducing Organization Notifications in Socket.Learn More
Socket
Book a DemoSign in
Socket

decache

Package Overview
Dependencies
Maintainers
2
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

decache - npm Package Compare versions

Comparing version
4.0.0
to
4.1.0
+23
lib/mymodule/index.js
var hello = require('../othermodule.js'); // require a second ("child") mondule
// micro-module to test functionality
(function() {
'use strict';
var runcount = false;
console.log("Hello module says: " + hello()); // super useful module ;-)
var get = function () {
return runcount;
}
var set = function () {
runcount = runcount + 1;
return runcount;
}
module.exports = {
get: get,
set: set
};
}()); // benalman.com/news/2010/11/immediately-invoked-function-expression
require('./decache');
+9
-1
var path = require('path'); // if module is locally defined we path.resolve it
var callsite = require('callsite');
require.find = function (moduleName) {
if (moduleName[0] === '.') {
moduleName = path.resolve(path.dirname(module.parent.filename), moduleName);
var stack = callsite();
for (var i in stack) {
var filename = stack[i].getFileName();
if (filename !== module.filename) {
moduleName = path.resolve(path.dirname(filename), moduleName);
break;
}
}
}

@@ -7,0 +15,0 @@ try {

+5
-2
{
"name": "decache",
"version": "4.0.0",
"version": "4.1.0",
"description": "decache (Delete Cache) lets you delete modules from node.js require() cache; useful when testing your modules/projects.",

@@ -40,3 +40,6 @@ "main": "decache.js",

"coverage"
]
],
"dependencies": {
"callsite": "^1.0.0"
}
}
// awesome tests here!
var test = require('tape'); // the reliable testing framework
var setup = require('../setup'); // ensure decache is pre-loaded
var decache = require('../decache.js');

@@ -4,0 +5,0 @@ var mymodule = require('../lib/mymodule');

var hello = require('./othermodule.js'); // require a second ("child") mondule
// micro-module to test functionality
(function() {
'use strict';
var runcount = false;
console.log("Hello module says: " + hello()); // super useful module ;-)
var get = function () {
return runcount;
}
var set = function () {
runcount = runcount + 1;
return runcount;
}
module.exports = {
get: get,
set: set
};
}()); // benalman.com/news/2010/11/immediately-invoked-function-expression