10 examples of 'javascript blocking wait' in JavaScript

Every line of 'javascript blocking wait' 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
106export async function wait(timeout: number): Promise<void> {
107 return new Promise<void>((resolve, reject) => setTimeout(resolve, timeout))
108}
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

598function wait (timeout) {
599 return new Promise((resolve) => setTimeout(resolve, timeout));
600}
66(function wait() { setTimeout(wait, 5000) })();
49function waitsFor(callback) {
50 if (skipRunsCounter === 0) {
51 jasmineApi.waitsFor.apply(this, arguments);
52 }
53}
84export function waitFor(timeout, done, onCallback, onTimeout) {
85 if (typeof onCallback !== 'function') {
86 onCallback = onCallback
87 ? function (r) { void expect(r).to.be.exist; }
88 : function (r) { expect.fail('unexpected callback: ' + r); };
89 }
90 if (typeof onTimeout !== 'function') {
91 onTimeout = onTimeout
92 ? function () {}
93 : function () { expect.fail('timeout'); };
94 }
95 let to = setTimeout(() => {
96 try {
97 to = null;
98 onTimeout();
99 } catch (e) {
100 return done(e);
101 }
102 return done();
103 }, timeout);
104 return function () {
105 if (to == null) return;
106 try {
107 clearTimeout(to);
108 to = null;
109 onCallback.apply(this, arguments);
110 } catch (e) {
111 return done(e);
112 }
113 return done();
114 };
115}
22async wait(n) {
23 await new Promise(resolve => this.waits.add([this.count + n, resolve]));
24}
168async function wait(time) {
169 return new Promise((resolve) => {
170 setTimeout(resolve, time)
171 })
172}
4public async wait(time: number) {
5 setTimeout(
6 () => new Promise((resolve) => {
7 resolve()
8 }), time)
9}
147export async function waitFor(milliseconds: number): Promise<void> {
148 /* istanbul ignore next */
149 return new Promise(resolve => setTimeout(() => resolve(), milliseconds));
150}
250function Wait(callback) {
251 if (!suite.isPlayback) {
252 setTimeout(function () {
253 //console.log('sleep for 30 seconds');
254 return callback(null);
255 }, 30000);
256 } else {
257 return callback(null);
258 }
259}

Related snippets