10 examples of 'angular sleep' in JavaScript

Every line of 'angular 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
10function sleep(ms) {
11 var start = new Date().getTime();
12 while(new Date().getTime() < start + ms);
13}
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

180function sleep(miliseconds) {
181 var currentTime = new Date().getTime();
182 while (currentTime + miliseconds >= new Date().getTime()) {
183 }
184}
194function sleep(milliseconds) {
195 var start = new Date().getTime();
196 for (var i = 0; i < 1e7; i++) {
197 if ((new Date().getTime() - start) > milliseconds){
198 break;
199 }
200 }
201}
1465export function sleep(ms) {
1466 const dt = new Date();
1467 dt.setTime(dt.getTime() + ms);
1468 while (new Date().getTime() < dt.getTime()) { }
1469}
15function sleep(seconds) {
16 let resolve;
17 const p = new Promise(r => resolve=r);
18 setTimeout(resolve, seconds*1000);
19 return p;
20}
109function safeSleep(t) {
110 if (t == undefined) {
111 t = 200;
112 }
113
114 var start = Date.now();
115 while(rbm.running) {
116 sleep(200);
117 if (Date.now() - start >= t) {
118 break;
119 }
120 }
121}
24function sleep(seconds) {
25 return new Promise((resolve) => setTimeout(resolve, 1000 * seconds));
26}
9function sleep(seconds) {
10 return new Promise(resolve => setTimeout(resolve, seconds * 1000));
11}
1297function sleep(ms) {
1298 return new Promise(resolve => setTimeout(resolve, ms));
1299}
5async function sleep(ms) {
6 return new Promise(resolve => setTimeout(resolve, ms))
7}

Related snippets