Gathering detailed insights and metrics for delay
Gathering detailed insights and metrics for delay
Gathering detailed insights and metrics for delay
Gathering detailed insights and metrics for delay
exponential-backoff
A utility that allows retrying a function with an exponential delay between attempts.
debounce
Delay function calls until a set time elapses after the last invocation
tailwindcss-animation-delay
Tailwind CSS plugin, add animation-delay CSS property.
thunky
delay the evaluation of a paramless async function and cache the result
npm install delay
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
609 Stars
68 Commits
36 Forks
17 Watching
1 Branches
16 Contributors
Updated on 15 Nov 2024
JavaScript (85.82%)
TypeScript (14.18%)
Cumulative downloads
Total Downloads
Last day
1.6%
827,356
Compared to previous day
Last week
5.1%
4,307,485
Compared to previous week
Last month
11.9%
17,498,072
Compared to previous month
Last year
12%
174,088,738
Compared to previous year
Delay a promise a specified amount of time
If you target Node.js only, you can use import {setTimeout} from 'node:timers/promises'; await setTimeout(1000);
instead. This package can still be useful if you need browser support or the extra features.
1npm install delay
1import delay from 'delay'; 2 3bar(); 4 5await delay(100); 6 7// Executed 100 milliseconds later 8baz();
Create a promise which resolves after the specified milliseconds
.
Create a promise which resolves after a random amount of milliseconds between minimum
and maximum
has passed.
Useful for tests and web scraping since they can have unpredictable performance. For example, if you have a test that asserts a method should not take longer than a certain amount of time, and then run it on a CI, it could take longer. So with this method, you could give it a threshold instead.
Type: number
Milliseconds to delay the promise.
Type: object
Type: unknown
A value to resolve in the returned promise.
1import delay from 'delay'; 2 3const result = await delay(100, {value: '🦄'}); 4 5// Executed after 100 milliseconds 6console.log(result); 7//=> '🦄'
Type: AbortSignal
The returned promise will be rejected with an AbortError
if the signal is aborted.
1import delay from 'delay'; 2 3const abortController = new AbortController(); 4 5setTimeout(() => { 6 abortController.abort(); 7}, 500); 8 9try { 10 await delay(1000, {signal: abortController.signal}); 11} catch (error) { 12 // 500 milliseconds later 13 console.log(error.name) 14 //=> 'AbortError' 15}
Clears the delay and settles the promise.
If you pass in a promise that is already cleared or a promise coming from somewhere else, it does nothing.
1import delay, {clearDelay} from 'delay'; 2 3const delayedPromise = delay(1000, {value: 'Done'}); 4 5setTimeout(() => { 6 clearDelay(delayedPromise); 7}, 500); 8 9// 500 milliseconds later 10console.log(await delayedPromise); 11//=> 'Done'
Creates a new delay
instance using the provided functions for clearing and setting timeouts. Useful if you're about to stub timers globally, but you still want to use delay
to manage your tests.
1import {createDelay} from 'delay'; 2 3const customDelay = createDelay({clearTimeout, setTimeout}); 4 5const result = await customDelay(100, {value: '🦄'}); 6 7// Executed after 100 milliseconds 8console.log(result); 9//=> '🦄'
setImmediate()
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
security policy file detected
Details
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 9/30 approved changesets -- score normalized to 3
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More