Created
June 25, 2021 16:35
-
-
Save seonglae/e14a8e013e5a10522f1caa10eaf89a05 to your computer and use it in GitHub Desktop.
Wait Until Verifiyer Function return true Interval Promise Function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| async function waitUntil<T>( | |
| flag: (...args: any[]) => boolean, | |
| callback: (...args: any[]) => T, | |
| args: any[] = [], | |
| time: number = 50 | |
| ): Promise<T> { | |
| return new Promise(async resolve => | |
| flag() ? resolve(await callback(...args)) : setTimeout(() => this.waitUntil(flag, callback, args, time), time) | |
| ) | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Javascript Version