Skip to content

Commit

Permalink
Use object destructing (denoland#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
Weijia Wang authored and ry committed Jun 5, 2018
1 parent 78124cd commit 58eb140
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
12 changes: 7 additions & 5 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
9 changes: 4 additions & 5 deletions timers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 58eb140

Please sign in to comment.