Skip to content

Commit 96b3c09

Browse files
committed
Improve code style
1 parent 27b3529 commit 96b3c09

File tree

13 files changed

+48
-26
lines changed

13 files changed

+48
-26
lines changed

JavaScript/6-ws/static/client.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const api = scaffold({
3030
update: ['id', 'record'],
3131
delete: ['id'],
3232
find: ['mask'],
33-
}
33+
},
3434
});
3535

3636
socket.addEventListener('open', async () => {

JavaScript/7-fs/main.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const staticServer = require('./static.js');
88
const apiPath = path.join(process.cwd(), './api');
99
const routing = {};
1010

11-
(async () => {
11+
const main = async () => {
1212
const files = await fsp.readdir(apiPath);
1313
for (const fileName of files) {
1414
if (!fileName.endsWith('.js')) continue;
@@ -19,4 +19,6 @@ const routing = {};
1919

2020
staticServer('./static', 8000);
2121
server(routing, 8001);
22-
})();
22+
};
23+
24+
main();

JavaScript/7-fs/static/client.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const api = scaffold({
3030
update: ['id', 'record'],
3131
delete: ['id'],
3232
find: ['mask'],
33-
}
33+
},
3434
});
3535

3636
socket.addEventListener('open', async () => {

JavaScript/8-vm/main.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const sandbox = { console, db: Object.freeze(db), common: { hash } };
1212
const apiPath = path.join(process.cwd(), './api');
1313
const routing = {};
1414

15-
(async () => {
15+
const main = async () => {
1616
const files = await fsp.readdir(apiPath);
1717
for (const fileName of files) {
1818
if (!fileName.endsWith('.js')) continue;
@@ -23,4 +23,6 @@ const routing = {};
2323

2424
staticServer('./static', 8000);
2525
server(routing, 8001);
26-
})();
26+
};
27+
28+
main();

JavaScript/9-logger/main.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const sandbox = {
1717
const apiPath = path.join(process.cwd(), './api');
1818
const routing = {};
1919

20-
(async () => {
20+
const main = async () => {
2121
const files = await fsp.readdir(apiPath);
2222
for (const fileName of files) {
2323
if (!fileName.endsWith('.js')) continue;
@@ -28,4 +28,6 @@ const routing = {};
2828

2929
staticServer('./static', 8000);
3030
server(routing, 8001);
31-
})();
31+
};
32+
33+
main();

JavaScript/a-config/main.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const sandbox = {
1818
const apiPath = path.join(process.cwd(), './api');
1919
const routing = {};
2020

21-
(async () => {
21+
const main = async () => {
2222
const files = await fsp.readdir(apiPath);
2323
for (const fileName of files) {
2424
if (!fileName.endsWith('.js')) continue;
@@ -29,4 +29,6 @@ const routing = {};
2929

3030
staticServer('./static', config.static.port);
3131
server(routing, config.api.port);
32-
})();
32+
};
33+
34+
main();

JavaScript/b-transport/main.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const sandbox = {
1818
const apiPath = path.join(process.cwd(), './api');
1919
const routing = {};
2020

21-
(async () => {
21+
const main = async () => {
2222
const files = await fsp.readdir(apiPath);
2323
for (const fileName of files) {
2424
if (!fileName.endsWith('.js')) continue;
@@ -29,4 +29,6 @@ const routing = {};
2929

3030
staticServer('./static', config.static.port, logger);
3131
transport(routing, config.api.port, logger);
32-
})();
32+
};
33+
34+
main();

JavaScript/b-transport/static/client.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const scaffold = (url) => {
5454
return transport[protocol](url);
5555
};
5656

57-
(async () => {
57+
const main = async () => {
5858
const api = await scaffold('http://localhost:8001')({
5959
user: {
6060
create: ['record'],
@@ -70,8 +70,10 @@ const scaffold = (url) => {
7070
},
7171
talks: {
7272
say: ['message'],
73-
}
73+
},
7474
});
7575
const data = await api.talks.say('hello');
7676
console.dir({ data });
77-
})();
77+
};
78+
79+
main();

JavaScript/c-commonjs/main.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const transport = require(`./transport/${config.api.transport}.js`);
1111
const apiPath = path.join(process.cwd(), './api');
1212
const routing = {};
1313

14-
(async () => {
14+
const main = async () => {
1515
const files = await fsp.readdir(apiPath);
1616
for (const fileName of files) {
1717
if (!fileName.endsWith('.js')) continue;
@@ -22,4 +22,6 @@ const routing = {};
2222

2323
staticServer('./static', config.static.port, logger);
2424
transport(routing, config.api.port, logger);
25-
})();
25+
};
26+
27+
main();

JavaScript/c-commonjs/static/client.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const scaffold = (url) => {
5454
return transport[protocol](url);
5555
};
5656

57-
(async () => {
57+
const main = async () => {
5858
const api = await scaffold('http://localhost:8001')({
5959
user: {
6060
create: ['record'],
@@ -70,8 +70,10 @@ const scaffold = (url) => {
7070
},
7171
talks: {
7272
say: ['message'],
73-
}
73+
},
7474
});
7575
const data = await api.talks.say('hello');
7676
console.dir({ data });
77-
})();
77+
};
78+
79+
main();

JavaScript/d-messenger/main.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const sandbox = {
1919
const apiPath = path.join(process.cwd(), './api');
2020
const routing = {};
2121

22-
(async () => {
22+
const main = async () => {
2323
const files = await fsp.readdir(apiPath);
2424
for (const fileName of files) {
2525
if (!fileName.endsWith('.js')) continue;
@@ -30,4 +30,6 @@ const routing = {};
3030

3131
staticServer('./static', config.static.port, logger);
3232
transport(routing, config.api.port, logger);
33-
})();
33+
};
34+
35+
main();

JavaScript/d-messenger/setup.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const executeFile = async (client, name) => {
3030
}
3131
};
3232

33-
(async () => {
33+
const main = async () => {
3434
await metasql.create(SCHEMAS, DB);
3535
const databaseFile = path.join(DB, 'database.sql');
3636
const structureFile = path.join(DB, 'structure.sql');
@@ -49,6 +49,8 @@ const executeFile = async (client, name) => {
4949
await executeFile(db, 'data.sql');
5050
await db.end();
5151
console.log('Environment is ready');
52-
})().catch((err) => {
52+
};
53+
54+
main().catch((err) => {
5355
console.error(err);
5456
});

JavaScript/d-messenger/static/client.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const scaffold = (url) => {
5656
return transport[protocol](url);
5757
};
5858

59-
(async () => {
59+
const main = async () => {
6060
const api = await scaffold('http://localhost:8001')({
6161
auth: {
6262
signin: ['login', 'password'],
@@ -69,4 +69,6 @@ const scaffold = (url) => {
6969
});
7070
const data = await api.auth.signin('marcus', 'marcus');
7171
console.dir({ data });
72-
})();
72+
};
73+
74+
main();

0 commit comments

Comments
 (0)