mirror of
https://github.com/denoland/deno.git
synced 2024-12-23 15:49:44 -05:00
refactor(std/signal): Replace setTimeout with IIFE (#6153)
This commit is contained in:
parent
7b597c82fc
commit
62adc63934
1 changed files with 3 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue