require-in-the-middle
Advanced tools
Comparing version 4.0.1 to 5.0.0
14
index.js
@@ -31,3 +31,3 @@ 'use strict' | ||
this.cache = {} | ||
this.cache = new Map() | ||
this._unhooked = false | ||
@@ -59,5 +59,5 @@ this._origRequire = Module.prototype.require | ||
// return known patched modules immediately | ||
if (Object.prototype.hasOwnProperty.call(self.cache, filename) === true) { | ||
if (self.cache.has(filename) === true) { | ||
debug('returning already patched cached module: %s', filename) | ||
return self.cache[filename] | ||
return self.cache.get(filename) | ||
} | ||
@@ -136,12 +136,12 @@ | ||
// only call onrequire the first time a module is loaded | ||
if (Object.prototype.hasOwnProperty.call(self.cache, filename) === false) { | ||
if (self.cache.has(filename) === false) { | ||
// ensure that the cache entry is assigned a value before calling | ||
// onrequire, in case calling onrequire requires the same module. | ||
self.cache[filename] = exports | ||
self.cache.set(filename, exports) | ||
debug('calling require hook: %s', moduleName) | ||
self.cache[filename] = onrequire(exports, moduleName, basedir) | ||
self.cache.set(filename, onrequire(exports, moduleName, basedir)) | ||
} | ||
debug('returning module: %s', moduleName) | ||
return self.cache[filename] | ||
return self.cache.get(filename) | ||
} | ||
@@ -148,0 +148,0 @@ } |
{ | ||
"name": "require-in-the-middle", | ||
"version": "4.0.1", | ||
"version": "5.0.0", | ||
"description": "Module to hook into the Node.js require function", | ||
@@ -44,5 +44,5 @@ "main": "index.js", | ||
"coordinates": [ | ||
55.6819147, | ||
12.5720135 | ||
55.778265, | ||
12.593155 | ||
] | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10885