Skip to main content
setInterval - node__timers--promises.d.ts - Node documentation
function setInterval

Usage in Deno

```typescript import { setInterval } from "node:node__timers--promises.d.ts"; ```
setInterval<T = void>(
delay?: number,
value?: T,
options?: TimerOptions,
): AsyncIterable<T>
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()); ```

Type Parameters

T = void

Parameters

optional
delay: number
optional
value: T
optional
options: TimerOptions

Return Type

AsyncIterable<T>