diff --git a/actor.ts b/actor.ts index e03eb07..a141839 100644 --- a/actor.ts +++ b/actor.ts @@ -110,15 +110,13 @@ export class Turn { } quit(): void { - const actor = this._ensureActor("quit"); - this.localActions.push(t => actor.terminateWith(t, { ok: true })); + this.localActions.push(t => this._ensureActor("quit").terminateWith(t, { ok: true })); } assert(location: Ref, assertion: Assertion): Handle { - this._ensureActor("assert"); const h = nextHandle++; this.enqueue(location.actor, t => { - this.actor!.outbound.set(h, [location, assertion]); + this._ensureActor("assert").outbound.set(h, [location, assertion]); location.target[assert]?.(t, assertion, h); }); return h; @@ -161,9 +159,7 @@ export class Turn { } complete(): void { - if (this.completed) { - throw new Error("Reuse of completed Turn!"); - } + if (this.completed) throw new Error("Reuse of completed Turn!"); this.completed = true; this.queues.forEach((queue, actor) => actor.execute(() => queue.forEach(f => Turn.for(actor, f))));