timersPromises.scheduler.wait(delay[, options])
\Stability: 1 - Experimental
-
delay<number> 解决 promise 前等待的毫秒数。\
delay<number> The number of milliseconds to wait before resolving the promise. -
options<Object>-
ref<boolean> 设置为false以指示调度的Timeout不应要求 Node.js 事件循环保持活动状态。默认值:true。\
ref<boolean> Set tofalseto indicate that the scheduledTimeoutshould not require the Node.js event loop to remain active. Default:true. -
signal<AbortSignal> 可用于取消等待的可选AbortSignal。\
signal<AbortSignal> An optionalAbortSignalthat can be used to cancel waiting.
-
-
返回:<Promise>
\Returns: <Promise>
由 调度 API 规范草案定义的实验性 API 正在开发为标准 Web 平台 API。
\An experimental API defined by the Scheduling APIs draft specification being developed as a standard Web Platform API.
调用 timersPromises.scheduler.wait(delay, options) 相当于调用 timersPromises.setTimeout(delay, undefined, options)。
\Calling timersPromises.scheduler.wait(delay, options) is equivalent
to calling timersPromises.setTimeout(delay, undefined, options).
import { scheduler } from 'node:timers/promises';
await scheduler.wait(1000); // Wait one second before continuing