diff options
Diffstat (limited to 'doc/api/timers.md')
-rw-r--r-- | doc/api/timers.md | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/doc/api/timers.md b/doc/api/timers.md index 4cddecd24f..d054ad7d41 100644 --- a/doc/api/timers.md +++ b/doc/api/timers.md @@ -8,7 +8,7 @@ The `timer` module exposes a global API for scheduling functions to be called at some future period of time. Because the timer functions are -globals, there is no need to call `require('timers')` to use the API. +globals, there is no need to call `require('node:timers')` to use the API. The timer functions within Node.js implement a similar API as the timers API provided by Web Browsers but use a different internal implementation that is @@ -269,7 +269,7 @@ returned Promises will be rejected with an `'AbortError'`. For `setImmediate()`: ```js -const { setImmediate: setImmediatePromise } = require('timers/promises'); +const { setImmediate: setImmediatePromise } = require('node:timers/promises'); const ac = new AbortController(); const signal = ac.signal; @@ -287,7 +287,7 @@ ac.abort(); For `setTimeout()`: ```js -const { setTimeout: setTimeoutPromise } = require('timers/promises'); +const { setTimeout: setTimeoutPromise } = require('node:timers/promises'); const ac = new AbortController(); const signal = ac.signal; @@ -347,7 +347,7 @@ changes: The `timers/promises` API provides an alternative set of timer functions that return `Promise` objects. The API is accessible via -`require('timers/promises')`. +`require('node:timers/promises')`. ```mjs import { @@ -362,7 +362,7 @@ const { setTimeout, setImmediate, setInterval, -} = require('timers/promises'); +} = require('node:timers/promises'); ``` ### `timersPromises.setTimeout([delay[, value[, options]]])` @@ -394,7 +394,7 @@ console.log(res); // Prints 'result' ```cjs const { setTimeout, -} = require('timers/promises'); +} = require('node:timers/promises'); setTimeout(100, 'result').then((res) => { console.log(res); // Prints 'result' @@ -428,7 +428,7 @@ console.log(res); // Prints 'result' ```cjs const { setImmediate, -} = require('timers/promises'); +} = require('node:timers/promises'); setImmediate('result').then((res) => { console.log(res); // Prints 'result' @@ -472,7 +472,7 @@ console.log(Date.now()); ```cjs const { setInterval, -} = require('timers/promises'); +} = require('node:timers/promises'); const interval = 100; (async function() { @@ -511,7 +511,7 @@ to calling `timersPromises.setTimeout(delay, undefined, options)` except that the `ref` option is not supported. ```mjs -import { scheduler } from 'timers/promises'; +import { scheduler } from 'node:timers/promises'; await scheduler.wait(1000); // Wait one second before continuing ``` |