Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitef5f0eb

Browse files
committed
Small refactorings
1 parentac3af23 commitef5f0eb

File tree

1 file changed

+12
-21
lines changed

1 file changed

+12
-21
lines changed

‎lib/rewire.js

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,19 @@ var Module = require("module"),
77
detectStrictMode=require("./detectStrictMode.js"),
88
moduleEnv=require("./moduleEnv.js");
99

10-
var__get__Src=__get__.toString(),
11-
__set__Src=__set__.toString(),
12-
__with__Src=__with__.toString();
10+
varsrcs={
11+
"__get__":__get__.toString(),
12+
"__set__":__set__.toString(),
13+
"__with__":__with__.toString()
14+
};
1315

1416
/**
1517
* Does actual rewiring the module. For further documentation @see index.js
1618
*/
1719
functioninternalRewire(parentModulePath,targetPath){
1820
vartargetModule,
1921
prelude,
20-
appendix,
21-
srcs;
22-
23-
srcs={
24-
"__get__":__get__Src,
25-
"__set__":__set__Src,
26-
"__with__":__with__Src
27-
};
22+
appendix;
2823

2924
// Checking params
3025
if(typeoftargetPath!=="string"){
@@ -48,19 +43,15 @@ function internalRewire(parentModulePath, targetPath) {
4843
// We prepend a list of all globals declared with var so they can be overridden (without changing original globals)
4944
prelude=getImportGlobalsSrc();
5045

51-
5246
// We append our special setter and getter.
5347
appendix="\n";
5448

55-
Object.keys(srcs).forEach(function(key){
56-
varstr=[
57-
"Object.defineProperty(module.exports, '",
58-
key,
59-
"', {enumerable: false, value: ",
60-
srcs[key],
61-
"}); "
62-
].join("");
63-
appendix+=str;
49+
Object.keys(srcs).forEach(functionforEachSrc(key){
50+
appendix+="Object.defineProperty(module.exports, '"+
51+
key+
52+
"', {enumerable: false, value: "+
53+
srcs[key]+
54+
"}); ";
6455
});
6556

6657
// Check if the module uses the strict mode.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp