timersPromises.scheduler.wait(delay[, options])


稳定性: 1 - 实验性

调度 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),只是 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