timers: introduce timers/promises
Move the promisified timers implementations into a new sub-module
to avoid the need to promisify. The promisified versions now return
the timers/promises versions.
Also adds `ref` option to the promisified versions
```js
const {
setTimeout,
setImmediate
} = require('timers/promises');
setTimeout(10, null, { ref: false })
.then(console.log);
setImmediate(null, { ref: false })
.then(console.log);
```
Signed-off-by:
James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/33950
Reviewed-By:
Denys Otrishko <shishugi@gmail.com>
Reviewed-By:
Benjamin Gruenbaum <benjamingr@gmail.com>
parent
bfc0e3f0
Please register or sign in to comment