10 examples of 'nodejs await sleep' in JavaScript

Every line of 'nodejs await sleep' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
1297function sleep(ms) {
1298 return new Promise(resolve => setTimeout(resolve, ms));
1299}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

72function sleep(ms) {
73 return new Promise(resolve => setTimeout(resolve, ms));
74}
9function sleep(seconds) {
10 return new Promise(resolve => setTimeout(resolve, seconds * 1000));
11}
24function sleep(seconds) {
25 return new Promise((resolve) => setTimeout(resolve, 1000 * seconds));
26}
6export function sleep (time) {
7 return new Promise(resolve => setTimeout(resolve, time))
8}
57function sleep(n: number) {
58 return new Promise(resolve => setTimeout(resolve, n));
59}
94function sleep(i: number) {
95 return new Promise(res => setTimeout(res, i))
96}
15function sleep(seconds) {
16 let resolve;
17 const p = new Promise(r => resolve=r);
18 setTimeout(resolve, seconds*1000);
19 return p;
20}
9function sleep(delay) {
10 return new Promise(function (resolve, reject) {
11 if (delay >= 1) {
12 setTimeout(function () {
13 resolve();
14 }, delay);
15 } else {
16 resolve();
17 }
18 });
19}
65sleep: function sleep(ms) {
66 var start = Date.now(),
67 i = 0;
68
69 while (Date.now() < start + ms) {
70 i = i.toString();
71 }
72},

Related snippets