Usage in Deno
```typescript import * as mod from "node:node__timers--promises.d.ts"; ```The `timers/promises` API provides an alternative set of timer functions
that return `Promise` objects. The API is accessible via `import timersPromises from 'node:timers/promises'`.
```js
import {
setTimeout,
setImmediate,
setInterval,
} from 'node:timers/promises';
```
f
setImmediate
```js
import {
setImmediate,
} from 'node:timers/promises';
const res = await setImmediate('result');
console.log(res); // Prints 'result'
```
f
setInterval
Returns an async iterator that generates values in an interval of `delay` ms.
If `ref` is `true`, you need to call `next()` of async iterator explicitly
or implicitly to keep the event loop alive.
```js
import {
setInterval,
} from 'node:timers/promises';
const interval = 100;
for await (const startTime of setInterval(interval, Date.now())) {
const now = Date.now();
console.log(now);
if ((now - startTime) > 1000)
break;
}
console.log(Date.now());
```
f
setTimeout
```js
import {
setTimeout,
} from 'node:timers/promises';
const res = await setTimeout(100, 'result');
console.log(res); // Prints 'result'
```
v
scheduler
No documentation available