10 examples of 'node js sleep' in JavaScript

Every line of 'node js 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
57function sleep(n: number) {
58 return new Promise(resolve => setTimeout(resolve, n));
59}
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

4function sleep()
5{
6 arguments = arguments[0] instanceof Array ? arguments[0] : Array.from(arguments)
7
8 execFileSync(__dirname+'/../bin/sleep.js', arguments)
9}
6export function sleep (time) {
7 return new Promise(resolve => setTimeout(resolve, time))
8}
94function sleep(i: number) {
95 return new Promise(res => setTimeout(res, i))
96}
6sleep: function sleep(ms) {
7 return new Promise(resolve => setTimeout(resolve, ms));
8},
4static sleep(interval) {
5 return new Promise(resolve => {
6 setTimeout(() => {
7 resolve();
8 }, interval);
9 });
10}
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},
17function sleep() {
18 return new Promise(requestAnimationFrame);
19}
16function sleep(ms = 0) {
17 return new Promise(r => setTimeout(r, ms));
18}
10function sleep(time, result) {
11 return new Promise((resolve) => setTimeout(() => resolve(result), time));
12}

Related snippets