10 examples of 'javascript delay execution' in JavaScript

Every line of 'javascript delay execution' 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
5function invokeDelayed(aTimeout, aTarget) {
6 if (arguments.length < 2)
7 throw "invokeDelayed needs 2 arguments - timeout, callback.";
8 space.schedule(aTarget, aTimeout);
9}
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

151function delayCallback() {
152 var args = 0 < arguments.length ? [].slice.call(arguments, 0) : []
153 var fn = args.shift()
154 if (!isFunc(fn)) {
155 return
156 }
157 var that = this
158 setTimeout(function () {
159 fn.apply(that, args)
160 }, 0)
161}
30function delay(fn) {
31 setTimeout(fn, current)
32 current += delta
33}
157recovery.timers.setTimeout('timeout', function timeout() {
158 var err = new Error('Failed to reconnect in a timely manner');
159 opts.duration = (+new Date()) - opts.start;
160
161 recovery.emit('reconnect timeout', err, opts);
162 connect(err);
163}, opts['reconnect timeout']);
368function delay(ms, callback) {
369 var now = +new Date();
370 var tick = now;
371
372 while (tick - now < ms) {
373 tick = +new Date();
374 }
375 callback();
376}
21export function delay(timeout) {
22 return new Promise(resolve => {
23 setTimeout(() => {
24 resolve();
25 }, timeout);
26 });
27}
84function delay(timeout: number) {
85 return new Promise((resolve) => {
86 setTimeout(resolve, timeout);
87 });
88}
7function delay(timeout) {
8 return new Promise(resolve => setTimeout(resolve, timeout));
9}
53delay(func, params, delay) {
54 let time = new Date().getTime();
55 let t = {func:func, params:params, delay:delay, time:time};
56 this._delayTasks.push(t);
57}
26function delay(time = 0, fn) {
27 return setTimeout(fn, time);
28}

Related snippets