From 469e0c7befe9875c4c61e738a278f1fb6e98ccd2 Mon Sep 17 00:00:00 2001 From: foxxyz Date: Sat, 26 Jun 2021 16:03:02 -0700 Subject: [PATCH 1/3] doc: replace outdated `util.promisify` timer examples with references --- doc/api/timers.md | 44 ++++++++++---------------------------------- 1 file changed, 10 insertions(+), 34 deletions(-) diff --git a/doc/api/timers.md b/doc/api/timers.md index 89f9ad312e33c4..15abbba16c2f9b 100644 --- a/doc/api/timers.md +++ b/doc/api/timers.md @@ -170,25 +170,7 @@ next event loop iteration. If `callback` is not a function, a [`TypeError`][] will be thrown. This method has a custom variant for promises that is available using -[`util.promisify()`][]: - -```js -const util = require('util'); -const setImmediatePromise = util.promisify(setImmediate); - -setImmediatePromise('foobar').then((value) => { - // value === 'foobar' (passing values is optional) - // This is executed after all I/O callbacks. -}); - -// Or with async function -async function timerExample() { - console.log('Before I/O callbacks'); - await setImmediatePromise(); - console.log('After I/O callbacks'); -} -timerExample(); -``` +[`timersPromises.setImmediate()`][]. ### `setInterval(callback[, delay[, ...args]])`