From 62adc63934d8be52b90512ad0e8165d9dd36eafc Mon Sep 17 00:00:00 2001 From: Marcos Casagrande Date: Sun, 7 Jun 2020 15:23:52 +0200 Subject: [PATCH] refactor(std/signal): Replace setTimeout with IIFE (#6153) --- std/signal/mod.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/std/signal/mod.ts b/std/signal/mod.ts index c15d1b3269..f09f768824 100644 --- a/std/signal/mod.ts +++ b/std/signal/mod.ts @@ -61,12 +61,12 @@ export function signal( export function onSignal(signo: number, callback: () => void): Disposable { const sig = signal(signo); - //setTimeout allows `sig` to be returned before blocking on the await - setTimeout(async () => { + // allows `sig` to be returned before blocking on the await + (async (): Promise => { for await (const _ of sig) { callback(); } - }, 0); + })(); return sig; }