@bitty/insist
Version:
Insistently runs a callback and only resolves the promise when its result is truthy.
20 lines • 720 B
TypeScript
/**
* Function that returns `boolean` or a `Promise` that resolves to `boolean`.
*/
export type Condition = () => boolean | Promise<boolean>;
/**
* Insists on a condition until it is satisfied. When the condition is not
* satisfied there is a delay, defined in milliseconds, for it to be checked
* again.
* @example
* ```js
* insist(() => window.document.readyState === 'complete').then(() => {
* console.log('The DOM is ready!');
* });
* ```
* @param condition - The condition function.
* @param time - The delay time, in milliseconds, to execute condition again.
*/
declare function insist(condition: Condition, time?: number): Promise<void>;
export default insist;
//# sourceMappingURL=insist.d.ts.map