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>- 
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),只是不支持 ref 选项。
¥Calling timersPromises.scheduler.wait(delay, options) is roughly equivalent
to calling timersPromises.setTimeout(delay, undefined, options) except that
the ref option is not supported.
import { scheduler } from 'node:timers/promises';
await scheduler.wait(1000); // Wait one second before continuing