1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-24 08:09:08 -05:00

refactor(std/signal): Replace setTimeout with IIFE (#6153)

This commit is contained in:
Marcos Casagrande 2020-06-07 15:23:52 +02:00 committed by GitHub
parent 7b597c82fc
commit 62adc63934
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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<void> => {
for await (const _ of sig) {
callback();
}
}, 0);
})();
return sig;
}