until-done
v1.0.3
Published
waits until condition is met then proceeds
Downloads
16
Readme
until-done
A lightweight utility for waiting until a condition is met.
Installation
npm install until-done
Usage/Examples
import untilDone from "until-done";
async function fetchData() {
let apiResponse = null;
// Simulating an asynchronous API call
setTimeout(() => {
apiResponse = { data: "Sample response" };
});
await untilDone(() => apiResponse !== null);
//check for the apiResponse Every 1s (by default)
// API response is available, proceed with code execution
console.log("API response:", apiResponse);
}
fetchData();
import untilDone from "until-done";
async function fetchData() {
let apiResponse = null;
// Simulating an asynchronous API call
setTimeout(() => {
apiResponse = { data: "Sample response" };
}, 3000);
await untilDone(() => apiResponse !== null, 500);
//check for the apiResponse Every 500ms
// API response is available, proceed with code execution
console.log("API response:", apiResponse);
}
fetchData();
License
This project is licensed under the Apache License 2.0. See the LICENSE file for details.