2024-01-01 14:58:21 -05:00
|
|
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2023-07-02 14:19:30 -04:00
|
|
|
import { promisify } from "node:util";
|
|
|
|
import timers from "node:timers";
|
2023-02-14 11:38:45 -05:00
|
|
|
|
|
|
|
export const setTimeout = promisify(timers.setTimeout),
|
|
|
|
setImmediate = promisify(timers.setImmediate),
|
|
|
|
setInterval = promisify(timers.setInterval);
|
|
|
|
|
2024-07-31 06:00:01 -04:00
|
|
|
export const scheduler = {
|
|
|
|
async wait(delay: number, options?: { signal?: AbortSignal }): Promise<void> {
|
|
|
|
return await setTimeout(delay, undefined, options);
|
|
|
|
},
|
|
|
|
yield: setImmediate,
|
|
|
|
};
|
|
|
|
|
2023-02-14 11:38:45 -05:00
|
|
|
export default {
|
|
|
|
setTimeout,
|
|
|
|
setImmediate,
|
|
|
|
setInterval,
|
|
|
|
};
|