Gathering detailed insights and metrics for async-wait-until
Gathering detailed insights and metrics for async-wait-until
Gathering detailed insights and metrics for async-wait-until
Gathering detailed insights and metrics for async-wait-until
async-until
Wait until a given callback returns true
async-test-util
Util-functions that are be useful in async tests
wait-until-async
Simple library which builds on top of wait-promise, but provides utilities for conditions being async functions.
async-wait-for-promise
Wait for a condition or timeout to occur
Waits for an expectation to be truthy. A small library with a convenient API suitable for unit and integration testing
npm install async-wait-until
Typescript
Module System
Min. Node Version
Node Version
NPM Version
TypeScript (73.66%)
JavaScript (26.34%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
78 Stars
260 Commits
13 Forks
2 Watchers
19 Branches
3 Contributors
Updated on Jul 09, 2025
Latest Version
2.0.27
Package Id
async-wait-until@2.0.27
Unpacked Size
323.41 kB
Size
52.80 kB
File Count
37
NPM Version
10.8.2
Node Version
20.19.0
Published on
Apr 04, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
28
A lightweight, zero-dependency library for waiting asynchronously until a specific condition is met. Works in any JavaScript environment that supports Promises, including older Node.js versions and browsers (with polyfills if necessary).
For detailed documentation, visit https://devlato.github.io/async-wait-until/
Install using npm:
1npm install async-wait-until
The library includes UMD, CommonJS, and ESM bundles, so you can use it in any environment.
1import { waitUntil } from 'async-wait-until'; 2 3// Example: Wait for an element to appear 4await waitUntil(() => document.querySelector('#target') !== null);
1import { waitUntil } from 'async-wait-until'; 2 3const waitForElement = async () => { 4 // Wait for an element with the ID "target" to appear 5 const element = await waitUntil(() => document.querySelector('#target'), { timeout: 5000 }); 6 console.log('Element found:', element); 7}; 8 9waitForElement();
If the condition is not met within the timeout, a TimeoutError
is thrown.
1import { waitUntil, TimeoutError } from 'async-wait-until'; 2 3const waitForElement = async () => { 4 try { 5 const element = await waitUntil(() => document.querySelector('#target'), { timeout: 5000 }); 6 console.log('Element found:', element); 7 } catch (error) { 8 if (error instanceof TimeoutError) { 9 console.error('Timeout: Element not found'); 10 } else { 11 console.error('Unexpected error:', error); 12 } 13 } 14}; 15 16waitForElement();
waitUntil(predicate, options)
Waits for the predicate
function to return a truthy value and resolves with that value.
Parameters:
Name | Type | Required | Default | Description |
---|---|---|---|---|
predicate | Function | ✅ Yes | - | A function that returns a truthy value (or a Promise for one). |
options.timeout | number | 🚫 No | 5000 ms | Maximum wait time before throwing TimeoutError . Use WAIT_FOREVER for no timeout. |
options.intervalBetweenAttempts | number | 🚫 No | 50 ms | Interval between predicate evaluations. |
Use WAIT_FOREVER
to wait without a timeout:
1import { waitUntil, WAIT_FOREVER } from 'async-wait-until'; 2 3await waitUntil(() => someCondition, { timeout: WAIT_FOREVER });
Change how often the predicate is evaluated:
1await waitUntil(() => someCondition, { intervalBetweenAttempts: 1000 }); // Check every 1 second
Contributions are welcome! To contribute:
npm install
.npm test
npm run lint
npm run format
npm run build
npm run docs
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
SAST tool is run on all commits
Details
Reason
1 existing vulnerabilities detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 6
Details
Reason
branch protection is not maximal on development and all release branches
Details
Reason
Found 0/19 approved changesets -- score normalized to 0
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
detected GitHub workflow tokens with excessive permissions
Details
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Score
Last Scanned on 2025-07-07
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