summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWeijia Wang <wjwang13@fudan.edu.cn>2018-06-05 16:43:00 +0800
committerRyan Dahl <ry@tinyclouds.org>2018-06-05 10:43:00 +0200
commit58eb14031dce828565b51da303cde0128fced872 (patch)
treea5de656ad33e47143aa72638732f0dd422324b9a
parent78124cd45f5b5efe1f06e82554ff09273b75b050 (diff)
Use object destructing (#130)
-rw-r--r--main.ts12
-rw-r--r--timers.ts9
2 files changed, 11 insertions, 10 deletions
diff --git a/main.ts b/main.ts
index a2a97c90a..e8eb37856 100644
--- a/main.ts
+++ b/main.ts
@@ -34,11 +34,13 @@ let startCalled = false;
startCalled = true;
const msg = pb.Msg.decode(payload);
- const cwd = msg.startCwd;
- const argv = msg.startArgv;
- const debugFlag = msg.startDebugFlag;
- const mainJs = msg.startMainJs;
- const mainMap = msg.startMainMap;
+ const {
+ startCwd: cwd,
+ startArgv: argv,
+ startDebugFlag: debugFlag,
+ startMainJs: mainJs,
+ startMainMap: mainMap
+ } = msg;
debug = debugFlag;
util.log("start", { cwd, argv, debugFlag });
diff --git a/timers.ts b/timers.ts
index 136ae745c..cddb859d9 100644
--- a/timers.ts
+++ b/timers.ts
@@ -27,15 +27,14 @@ export function initTimers() {
function onMessage(payload: Uint8Array) {
const msg = pb.Msg.decode(payload);
assert(msg.command === pb.Msg.Command.TIMER_READY);
- const id = msg.timerReadyId;
- const done = msg.timerReadyDone;
- const timer = timers.get(id);
+ const { timerReadyId, timerReadyDone } = msg;
+ const timer = timers.get(timerReadyId);
if (!timer) {
return;
}
timer.cb(...timer.args);
- if (done) {
- timers.delete(id);
+ if (timerReadyDone) {
+ timers.delete(timerReadyId);
}
}