Skip to content

Commit 00f480d

Browse files
committed
Add examples with node:timers/promises
1 parent 7e1728b commit 00f480d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

JavaScript/4-callback-timer.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,16 @@ const fn = () => {
77
const timeout = (interval, fn) => setTimeout(fn, interval);
88

99
timeout(5000, fn);
10+
11+
// Node timers promises
12+
13+
(async () => {
14+
const { setTimeout } = require('node:timers/promises');
15+
16+
setTimeout(1000, 'Hello').then((data) => {
17+
console.log(data);
18+
});
19+
20+
await setTimeout(1000);
21+
console.log('Done');
22+
})();

0 commit comments

Comments
 (0)