Skip to content

Commit dce896f

Browse files
committed
Improve complex example
1 parent fc3e222 commit dce896f

File tree

4 files changed

+8
-11
lines changed

4 files changed

+8
-11
lines changed

JavaScript/complex/application.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
'use strict';
22

3-
// global.api = {};
43
const api = {};
54
api.fs = require('fs');
65
api.vm = require('vm');
76
api.timers = require('timers');
87

9-
// global.application = {};
108
const application = {};
119
application.unit1 = require('./lib/unit1');
1210
application.unit2 = require('./lib/unit2');
1311
require('./lib/unit3')(api, application);
1412

15-
application.reloadUnit = name => {
13+
application.reloadUnit = (name) => {
1614
const moduleKey = require.resolve('./lib/' + name);
1715
delete require.cache[moduleKey];
1816
require('./lib/' + name)(api, application);

JavaScript/complex/lib/module.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
'use strict';
22

3-
module.exports = (api, metasync) => {
4-
3+
module.exports = (api, application) => {
54
const FILE_SCOPE_CONSTANT = 100;
6-
metasync.MODULE_SCOPE_CONSTANT = 200;
5+
application.APPLICATION_SCOPE_CONSTANT = 200;
76
api.metasync.EXPORTED_CONSTANT = 300;
87

98
const fileScopeFunction = () => {};
10-
metasync.moduleScopeFunction = () => {};
9+
application.applicationScopeFunction = () => {};
1110
api.metasync.exportedFunction = () => {};
1211

12+
console.log({
13+
FILE_SCOPE_CONSTANT,
14+
fileScopeFunction,
15+
});
1316
};

JavaScript/complex/lib/unit1.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict';
22

33
module.exports = {
4-
54
showPaths() {
65
console.dir({
76
__dirname,
@@ -13,5 +12,4 @@ module.exports = {
1312
doSomething() {
1413
console.log('Somenting done');
1514
}
16-
1715
};

JavaScript/complex/lib/unit3.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const LOCAL_CONSTANT = 'local value';
55
const EXPORTED_CONSTANT = 'exported value';
66

77
module.exports = (api, application) => {
8-
98
application.unit3 = unit3;
109
unit3.EXPORTED_CONSTANT = EXPORTED_CONSTANT;
1110

@@ -20,5 +19,4 @@ module.exports = (api, application) => {
2019

2120
unit3.doSomethingSpecial = () => {
2221
};
23-
2422
};

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy