diff --git a/package.json b/package.json index 3c8c650..fc3c916 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ztimson/utils", - "version": "0.16.1", + "version": "0.16.2", "description": "Utility library", "author": "Zak Timson", "license": "MIT", diff --git a/src/time.ts b/src/time.ts index 8b99f47..16d8cd9 100644 --- a/src/time.ts +++ b/src/time.ts @@ -39,12 +39,12 @@ export function sleep(ms: number): Promise { * await sleepUntil(() => loading); // Won't continue until loading flag is false * ``` * - * @param {() => boolean} fn Return true to continue + * @param {() => boolean | Promise} fn Return true to continue * @param {number} checkInterval Run function ever x milliseconds * @return {Promise} Callback when sleep is over */ -export async function sleepUntil(fn : () => boolean, checkInterval=100): Promise { - while(fn()) await sleep(checkInterval); +export async function sleepUntil(fn : () => boolean | Promise, checkInterval = 100): Promise { + while(await fn()) await sleep(checkInterval); } /**