custom-require
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -6,3 +6,3 @@ /// <reference types="node" /> | ||
__parentModules: CustomNodeModule[]; | ||
__removeCustomRequire: (customRequire: CustomRequire) => void; | ||
__removeCustomRequire: (customRequire: CustomRequire) => CustomNodeModule[]; | ||
__addCustomRequire: (customRequire: CustomRequire) => void; | ||
@@ -18,3 +18,3 @@ __invalidateCache: () => void; | ||
require(id: string, callerModule?: CustomNodeModule): any; | ||
unrequire(id: string, callerModule?: CustomNodeModule, invalidateCache?: boolean): void; | ||
unrequire(id: string, callerModule?: CustomNodeModule, invalidateCache?: boolean): CustomNodeModule[]; | ||
getCachedModule(id: string, mod: NodeModule): CustomNodeModule; | ||
@@ -21,0 +21,0 @@ getCallerModule(filterlist?: string[]): CustomNodeModule; |
@@ -27,6 +27,7 @@ "use strict"; | ||
var cachedModule = this.getCachedModule(id, callerModule); | ||
cachedModule.__removeCustomRequire(this); | ||
var list = cachedModule.__removeCustomRequire(this); | ||
if (invalidateCache) { | ||
cachedModule.__invalidateCache(); | ||
} | ||
return list; | ||
}; | ||
@@ -61,2 +62,3 @@ CustomRequire.prototype.getCachedModule = function (id, mod) { | ||
Module.prototype.__cleanCalled = function (customRequire, mod) { | ||
var list = []; | ||
var whoRequired = this.__whoRequired(); | ||
@@ -80,13 +82,17 @@ var clean = true; | ||
customRequire.called.splice(customRequire.called.indexOf(this), 1); | ||
list.push(this); | ||
} | ||
for (var _c = 0, _d = this.__childModules; _c < _d.length; _c++) { | ||
var childModule = _d[_c]; | ||
childModule.__cleanCalled(customRequire, mod); | ||
list = list.concat(childModule.__cleanCalled(customRequire, mod)); | ||
} | ||
return list; | ||
}; | ||
Module.prototype.__removeCustomRequire = function (customRequire) { | ||
var list = []; | ||
if (this.__customRequires.indexOf(customRequire) > -1) { | ||
this.__customRequires.splice(this.__customRequires.indexOf(customRequire), 1); | ||
this.__cleanCalled(customRequire, this); | ||
list = this.__cleanCalled(customRequire, this); | ||
} | ||
return list; | ||
}; | ||
@@ -93,0 +99,0 @@ Module.prototype.__addCustomRequire = function (customRequire) { |
@@ -34,3 +34,3 @@ { | ||
}, | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"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
19798
203