timersPromises.scheduler.wait(delay[, options])
稳定性: 1 - 实验性
delay<number> 在解析 Promise 之前等待的毫秒数。options<Object>ref<boolean> 设置为false表示计划的Timeout不需要 Node.js 事件循环保持活动状态。 默认值:true。signal<AbortSignal> 可选的AbortSignal,可用于取消等待。
- 返回: <Promise>
由 调度 API 草案规范定义的实验性 API,正在作为标准网页平台 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