custom-require
Advanced tools
Comparing version 0.1.17 to 0.1.18
@@ -10,2 +10,3 @@ /// <reference types="node" /> | ||
__invalidateCache: () => void; | ||
__invalidate: () => NodeModule[]; | ||
__checkInvalid: () => boolean; | ||
@@ -23,3 +24,3 @@ __whoRequired: () => NodeModule[]; | ||
require(id: string, callerModule?: NodeModule): any; | ||
unrequire(id: string | NodeModule, callerModule?: NodeModule, invalidateCache?: boolean): NodeModule[]; | ||
unrequire(id: string | NodeModule, callerModule?: NodeModule): NodeModule[]; | ||
getCachedModule(id: string, mod: NodeModule): NodeModule; | ||
@@ -26,0 +27,0 @@ getCallerModule(filterlist?: string[]): NodeModule; |
@@ -20,3 +20,3 @@ "use strict"; | ||
if (cachedModule && cachedModule.__checkInvalid()) { | ||
this.unrequire(cachedModule, null, true); | ||
cachedModule.__invalidate(); | ||
} | ||
@@ -28,3 +28,3 @@ var res = callerModule.require(id); | ||
}; | ||
CustomRequire.prototype.unrequire = function (id, callerModule, invalidateCache) { | ||
CustomRequire.prototype.unrequire = function (id, callerModule) { | ||
if (typeof id == "string") { | ||
@@ -38,5 +38,2 @@ if (!callerModule) { | ||
var list = id.__removeCustomRequire(this); | ||
if (invalidateCache) { | ||
id.__invalidateCache(); | ||
} | ||
if (this.unrequirecallback) { | ||
@@ -78,2 +75,19 @@ this.unrequirecallback(list); | ||
} | ||
Module.prototype.__invalidate = function (list) { | ||
if (this.__invalid) { | ||
return; | ||
} | ||
if (!list) { | ||
list = []; | ||
} | ||
list.push(this); | ||
this.__invalid = true; | ||
if (this.__customRequires.length == 0) { | ||
for (var _i = 0, _a = this.__parentModules; _i < _a.length; _i++) { | ||
var parentModule = _a[_i]; | ||
parentModule.__invalidate(list); | ||
} | ||
} | ||
return list; | ||
}; | ||
Module.prototype.__cleanCalled = function (customRequire, mod, cyclicCheck) { | ||
@@ -80,0 +94,0 @@ if (!cyclicCheck) { |
@@ -34,3 +34,3 @@ { | ||
}, | ||
"version": "0.1.17", | ||
"version": "0.1.18", | ||
"dependencies": { | ||
@@ -37,0 +37,0 @@ "callsite": "^1.0.0" |
Sorry, the diff of this file is not supported yet
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
27875
328