1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-24 15:19:26 -05:00

Use object destructing (#130)

This commit is contained in:
Weijia Wang 2018-06-05 16:43:00 +08:00 committed by Ryan Dahl
parent 78124cd45f
commit 58eb14031d
2 changed files with 11 additions and 10 deletions

12
main.ts
View file

@ -34,11 +34,13 @@ let startCalled = false;
startCalled = true; startCalled = true;
const msg = pb.Msg.decode(payload); const msg = pb.Msg.decode(payload);
const cwd = msg.startCwd; const {
const argv = msg.startArgv; startCwd: cwd,
const debugFlag = msg.startDebugFlag; startArgv: argv,
const mainJs = msg.startMainJs; startDebugFlag: debugFlag,
const mainMap = msg.startMainMap; startMainJs: mainJs,
startMainMap: mainMap
} = msg;
debug = debugFlag; debug = debugFlag;
util.log("start", { cwd, argv, debugFlag }); util.log("start", { cwd, argv, debugFlag });

View file

@ -27,15 +27,14 @@ export function initTimers() {
function onMessage(payload: Uint8Array) { function onMessage(payload: Uint8Array) {
const msg = pb.Msg.decode(payload); const msg = pb.Msg.decode(payload);
assert(msg.command === pb.Msg.Command.TIMER_READY); assert(msg.command === pb.Msg.Command.TIMER_READY);
const id = msg.timerReadyId; const { timerReadyId, timerReadyDone } = msg;
const done = msg.timerReadyDone; const timer = timers.get(timerReadyId);
const timer = timers.get(id);
if (!timer) { if (!timer) {
return; return;
} }
timer.cb(...timer.args); timer.cb(...timer.args);
if (done) { if (timerReadyDone) {
timers.delete(id); timers.delete(timerReadyId);
} }
} }