Exports
[<Class>]
type Exports =
static member scheduler: Scheduler
static member setImmediate<'T> (?value: 'T, ?options: TimerOptions) : Promise<'T>
static member setInterval<'T> (?delay: float, ?value: 'T, ?options: TimerOptions) : AsyncIterator<'T,obj,obj>
static member setTimeout<'T> (?delay: float, ?value: 'T, ?options: TimerOptions) : Promise<'T>| Assembly | Xantham.Fable.Node |
| Attributes | [<Erase>] |
The package's value exports, each bound to its import.
Properties
Methods
static member setImmediate<'T> (?value: 'T, ?options: TimerOptions) : Promise<'T>
static member setImmediate<'T> (?value: 'T, ?options: TimerOptions) : Promise<'T>import {
setImmediate,
} from 'node:timers/promises';
const res = await setImmediate('result');
console.log(res); // Prints 'result'
@since v15.0.0
| Parameter | |
|---|---|
value | A value with which the promise is fulfilled. |
static member setInterval<'T> (?delay: float, ?value: 'T, ?options: TimerOptions) : AsyncIterator<'T,obj,obj>
static member setInterval<'T> (?delay: float, ?value: 'T, ?options: TimerOptions) : AsyncIterator<'T,obj,obj>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.
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());
@since v15.9.0
| Parameter | |
|---|---|
delay | The number of milliseconds to wait between iterations. Default:1. |
value | A value with which the iterator returns. |
static member setTimeout<'T> (?delay: float, ?value: 'T, ?options: TimerOptions) : Promise<'T>
static member setTimeout<'T> (?delay: float, ?value: 'T, ?options: TimerOptions) : Promise<'T>import {
setTimeout,
} from 'node:timers/promises';
const res = await setTimeout(100, 'result');
console.log(res); // Prints 'result'
@since v15.0.0
| Parameter | |
|---|---|
delay | The number of milliseconds to wait before fulfilling the promise. Default:1. |
value | A value with which the promise is fulfilled. |