Skip to content

Commit 3f8a3a6

Browse files
committed
Remove unneeded if statement
1 parent 8973797 commit 3f8a3a6

File tree

1 file changed

+24
-26
lines changed

1 file changed

+24
-26
lines changed

JavaScript/2-multiprocess/worker.js

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,32 +21,30 @@ class ActorSystem {
2121
ActorSystem.actor = null;
2222
ActorSystem.instance = null;
2323

24-
if (process.channel) {
25-
process.on('message', message => {
26-
const { command } = message;
27-
if (command === 'start') {
28-
const { name } = message;
29-
require(`./actors/${name.toLowerCase()}.js`);
30-
const ActorClass = ActorSystem.actor;
31-
ActorSystem.instance = new ActorClass();
32-
return;
33-
}
34-
if (command === 'stop') {
35-
const { instance } = ActorSystem;
36-
if (instance) instance.exit();
37-
return;
38-
}
39-
if (command === 'message') {
40-
const { instance } = ActorSystem;
41-
if (instance) {
42-
const { data } = message;
43-
const { name } = ActorSystem.actor;
44-
instance.message(data).then(() => {
45-
process.send({ command: 'ready', name, pid: process.pid });
46-
});
47-
}
24+
process.on('message', message => {
25+
const { command } = message;
26+
if (command === 'start') {
27+
const { name } = message;
28+
require(`./actors/${name.toLowerCase()}.js`);
29+
const ActorClass = ActorSystem.actor;
30+
ActorSystem.instance = new ActorClass();
31+
return;
32+
}
33+
if (command === 'stop') {
34+
const { instance } = ActorSystem;
35+
if (instance) instance.exit();
36+
return;
37+
}
38+
if (command === 'message') {
39+
const { instance } = ActorSystem;
40+
if (instance) {
41+
const { data } = message;
42+
const { name } = ActorSystem.actor;
43+
instance.message(data).then(() => {
44+
process.send({ command: 'ready', name, pid: process.pid });
45+
});
4846
}
49-
});
50-
}
47+
}
48+
});
5149

5250
module.exports = ActorSystem;

0 commit comments

Comments
 (0)