Initial commit
This commit is contained in:
15
node_modules/stealthy-require/LICENSE
generated
vendored
Normal file
15
node_modules/stealthy-require/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
ISC License
|
||||
|
||||
Copyright (c) 2017, Nicolai Kamenzky and contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
81
node_modules/stealthy-require/lib/index.js
generated
vendored
Normal file
81
node_modules/stealthy-require/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
'use strict';
|
||||
|
||||
var isNative = /\.node$/;
|
||||
|
||||
function forEach(obj, callback) {
|
||||
for ( var key in obj ) {
|
||||
if (!Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
continue;
|
||||
}
|
||||
callback(key);
|
||||
}
|
||||
}
|
||||
|
||||
function assign(target, source) {
|
||||
forEach(source, function (key) {
|
||||
target[key] = source[key];
|
||||
});
|
||||
return target;
|
||||
}
|
||||
|
||||
function clearCache(requireCache) {
|
||||
forEach(requireCache, function (resolvedPath) {
|
||||
if (!isNative.test(resolvedPath)) {
|
||||
delete requireCache[resolvedPath];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = function (requireCache, callback, callbackForModulesToKeep, module) {
|
||||
|
||||
var originalCache = assign({}, requireCache);
|
||||
clearCache(requireCache);
|
||||
|
||||
if (callbackForModulesToKeep) {
|
||||
|
||||
var originalModuleChildren = module.children ? module.children.slice() : false; // Creates a shallow copy of module.children
|
||||
|
||||
callbackForModulesToKeep();
|
||||
|
||||
// Lists the cache entries made by callbackForModulesToKeep()
|
||||
var modulesToKeep = [];
|
||||
forEach(requireCache, function (key) {
|
||||
modulesToKeep.push(key);
|
||||
});
|
||||
|
||||
// Discards the modules required in callbackForModulesToKeep()
|
||||
clearCache(requireCache);
|
||||
|
||||
if (module.children) { // Only true for node.js
|
||||
module.children = originalModuleChildren; // Removes last references to modules required in callbackForModulesToKeep() -> No memory leak
|
||||
}
|
||||
|
||||
// Takes the cache entries of the original cache in case the modules where required before
|
||||
for ( var i = 0; i < modulesToKeep.length; i+=1 ) {
|
||||
if (originalCache[modulesToKeep[i]]) {
|
||||
requireCache[modulesToKeep[i]] = originalCache[modulesToKeep[i]];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var freshModule = callback();
|
||||
|
||||
var stealthCache = callbackForModulesToKeep ? assign({}, requireCache) : false;
|
||||
|
||||
clearCache(requireCache);
|
||||
|
||||
if (callbackForModulesToKeep) {
|
||||
// In case modules to keep were required inside the stealthy require for the first time, copy them to the restored cache
|
||||
for ( var k = 0; k < modulesToKeep.length; k+=1 ) {
|
||||
if (stealthCache[modulesToKeep[k]]) {
|
||||
requireCache[modulesToKeep[k]] = stealthCache[modulesToKeep[k]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assign(requireCache, originalCache);
|
||||
|
||||
return freshModule;
|
||||
|
||||
};
|
||||
33
node_modules/stealthy-require/package.json
generated
vendored
Normal file
33
node_modules/stealthy-require/package.json
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "stealthy-require",
|
||||
"version": "1.1.1",
|
||||
"description": "The closest you can get to require something with bypassing the require cache",
|
||||
"main": "./lib/index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/analog-nico/stealthy-require.git"
|
||||
},
|
||||
"author": "Nicolai Kamenzky (https://github.com/analog-nico)",
|
||||
"license": "ISC",
|
||||
"homepage": "https://github.com/analog-nico/stealthy-require#readme",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"bcrypt": "~1.0.2",
|
||||
"browserify": "~14.3.0",
|
||||
"chai": "~3.5.0",
|
||||
"chalk": "~1.1.3",
|
||||
"gulp": "~3.9.1",
|
||||
"gulp-coveralls": "~0.1.4",
|
||||
"gulp-eslint": "~2.1.0",
|
||||
"gulp-istanbul": "~1.1.1",
|
||||
"gulp-mocha": "~3.0.1",
|
||||
"mkdirp": "~0.5.1",
|
||||
"publish-please": "~2.3.1",
|
||||
"rimraf": "~2.6.1",
|
||||
"run-sequence": "~1.2.2",
|
||||
"webpack": "~1.15.0"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user