Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/rewire.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJohannes Ewald <johannes.ewald@peerigon.com>2014-10-28 03:48:51 +0300
committerJohannes Ewald <johannes.ewald@peerigon.com>2014-10-28 03:48:51 +0300
commitef5f0eb632a465ba274dd942b2f0f32156effb1f (patch)
treef7c9c2115e2cfb8799d4a130721e730fa29aabd6 /lib
parentac3af235cd955a7de672eddda3e60baaf240cbad (diff)
Small refactorings
Diffstat (limited to 'lib')
-rw-r--r--lib/rewire.js33
1 files changed, 12 insertions, 21 deletions
diff --git a/lib/rewire.js b/lib/rewire.js
index 29ad93f..e0b56f1 100644
--- a/lib/rewire.js
+++ b/lib/rewire.js
@@ -7,9 +7,11 @@ var Module = require("module"),
detectStrictMode = require("./detectStrictMode.js"),
moduleEnv = require("./moduleEnv.js");
-var __get__Src = __get__.toString(),
- __set__Src = __set__.toString(),
- __with__Src = __with__.toString();
+var srcs = {
+ "__get__": __get__.toString(),
+ "__set__": __set__.toString(),
+ "__with__": __with__.toString()
+};
/**
* Does actual rewiring the module. For further documentation @see index.js
@@ -17,14 +19,7 @@ var __get__Src = __get__.toString(),
function internalRewire(parentModulePath, targetPath) {
var targetModule,
prelude,
- appendix,
- srcs;
-
- srcs = {
- "__get__": __get__Src,
- "__set__": __set__Src,
- "__with__": __with__Src
- };
+ appendix;
// Checking params
if (typeof targetPath !== "string") {
@@ -48,19 +43,15 @@ function internalRewire(parentModulePath, targetPath) {
// We prepend a list of all globals declared with var so they can be overridden (without changing original globals)
prelude = getImportGlobalsSrc();
-
// We append our special setter and getter.
appendix = "\n";
- Object.keys(srcs).forEach( function (key) {
- var str = [
- "Object.defineProperty(module.exports, '",
- key,
- "', {enumerable: false, value: ",
- srcs[key],
- "}); "
- ].join("");
- appendix += str;
+ Object.keys(srcs).forEach(function forEachSrc(key) {
+ appendix += "Object.defineProperty(module.exports, '" +
+ key +
+ "', {enumerable: false, value: " +
+ srcs[key] +
+ "}); ";
});
// Check if the module uses the strict mode.