Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 00f480d

Browse filesBrowse files
committed
Add examples with node:timers/promises
1 parent 7e1728b commit 00f480d
Copy full SHA for 00f480d

File tree

Expand file treeCollapse file tree

1 file changed

+13
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+13
-0
lines changed

‎JavaScript/4-callback-timer.js

Copy file name to clipboardExpand all lines: JavaScript/4-callback-timer.js
+13Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.