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

module-invalidate

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

module-invalidate - npm Package Compare versions

Comparing version 0.9.2 to 0.9.3

tests/test9_child.js

51

index.js

@@ -9,5 +9,5 @@ 'use strict';

for ( var id in Module._cache )
if ( 'invalidate' in Module._cache[id] )
Module._cache[id].invalidate();
for ( var filename in Module._cache )
if ( 'invalidate' in Module._cache[filename] )
Module._cache[filename].invalidate();
}

@@ -17,5 +17,5 @@

for ( var id in Module._cache )
if ( Module._cache[id].exports === exports )
Module._cache[id].invalidate();
for ( var filename in Module._cache )
if ( Module._cache[filename].exports === exports )
Module._cache[filename].invalidate();
}

@@ -34,3 +34,3 @@

if ( '_invalidateCallbacks' in this ) {
this._invalidateCallbacks.forEach(callback => callback(this._exports));

@@ -179,20 +179,20 @@ this._invalidateCallbacks.clear();

Module.prototype.unload = function() {
/* test
Module.prototype._unload = function() {
var exports = this._exports;
this.invalidate();
this._exports = exports;
this.invalidable = false;
delete Module._cache[this.filename];
this.exports = null;
// remove this module from all module children
for ( var path in this.cache ) {
for ( var filename in Module._cache ) {
var children = this.cache[path].children;
var children = Module._cache[filename].children;
var pos = children.indexOf(this);
if ( pos != -1 )
if ( pos !== -1 )
children.splice(pos);
}
// remove module from Module._cache
delete this.constructor._cache[this.filename];
this.parent = null;

@@ -203,8 +203,19 @@

// remove module from Module._pathCache
var pathCache = this.constructor._pathCache;
var pathCache = Module._pathCache;
var keys = Object.keys(pathCache);
for ( var i = 0; i < keys.length; ++i )
if ( pathCache[keys[i]] == this.filename )
if ( pathCache[keys[i]] === this.filename )
delete pathCache[keys[i]];
}
*/
Module.prototype.unloadByPath = function(path) {
Module._cache[Module._resolveFilename(path, this, this.parent === null)].unload();
}
Module.unloadByExports = function(exports) {
for ( var filename in Module._cache )
if ( Module._cache[filename].exports === exports )
Module._cache[filename].unload();
}
{
"name": "module-invalidate",
"version": "0.9.2",
"version": "0.9.3",
"description": "invalidate required modules",

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

@@ -126,3 +126,3 @@ # module-invalidate

##### require('module-invalidate')
#### require('module-invalidate')
Enable the module-invalidate mechanism.

@@ -132,3 +132,3 @@ Any nodejs-non-internal module loaded after this call can be handled by this library.

##### module.invalidable
#### module.invalidable
This property controls whether the module can be invalidated. By default, modules are not invalidable. This property must be set before exporting.

@@ -145,4 +145,4 @@

##### module.invalidateByPath(path)
Invalidates the specified module (same syntax and context than `require()`). The module should have been flagged as invalidable using `module.invaluable`.
#### module.invalidateByPath(path)
Invalidates the specified module by its path (same syntax and context than `require()`). The module should have been flagged as invalidable using `module.invaluable`.

@@ -157,3 +157,3 @@ ###### Example:

##### Module.invalidateByExports(exports)
#### Module.invalidateByExports(exports)
Invalidates the module by giving its exported object. The module should have been flagged as invalidable using `module.invaluable`.

@@ -204,3 +204,3 @@

##### Module.invalidate()
#### Module.invalidate()
Invalidates all nodejs-non-internal modules. Only process modules that have been flagged as invalidable using `module.invaluable`.

@@ -215,3 +215,3 @@

##### module.invalidate()
#### module.invalidate()
Invalidates the module `module`. The module should have been flagged as invalidable using `module.invaluable`.

@@ -224,8 +224,22 @@

##### module.onInvalidate(callback)
#### module.unload()
Definitely unloads the module `module`.
#### module.unloadByPath(path)
Definitely unloads the module by its path (same syntax and context than `require()`).
#### Module.unloadByExports(exports)
Definitely unloads the module by giving its exported object.
#### module.onInvalidate(callback)
callback: `function(immutable_exports)`
Register a callback that will be called when the module is invalidated. The `immutable_exports` is a permanent reference to the current module.exports .
Register a callback that will be called when the module is invalidated. The `immutable_exports` is a permanent reference to the current module.exports .
`onInvalidate` returns a function that unregisters the callback.
## How it works

@@ -232,0 +246,0 @@

require('../index.js');
module.on('invalidated', function() {
})
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