0.0.2 • Published 6 years ago

wait-for-es7 v0.0.2

Weekly downloads
26
License
ISC
Repository
github
Last release
6 years ago

wait-for-es7

WaitFor - util function which is waiting for some condition (checkFn) during timeout, checks it every interval. Rejects if condition not fulfilled.

NPM version Build Status Dependency Status Coverage percentage experimental

Install

npm install wait-for-es7 --save

or

yarn add wait-for-es7

Usage

import waitFor from "wait-for-es6";

const startTime = new Date().getTime();

await waitFor( () => startTime < new Date().getTime() - 4000, { timeout: 5000, interval: 500 } );
// Not rejected, because 4000ms < 5000ms

await waitFor( () => false, { timeout: 5000, interval: 500 } );
// Will reject, because checkFn always return false

API

async function waitFor(checkFn: () => boolean | Promise<boolean>, options: IWaitForOptions = {});

interface IWaitForOptions {
    timeout?: number;
    interval?: number;
}

Test

npm install
npm test
0.0.2

6 years ago

0.0.1

6 years ago