1.0.3 • Published 12 months ago

until-done v1.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
12 months ago

until-done

License

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.

1.0.3

12 months ago

1.0.2

12 months ago

1.0.1

1 year ago

1.0.0

1 year ago