mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 06:56:03 +01:00
fix(waitFor): type corrections
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
---Yields the current thread until a non-nil value is returned by the function.
|
---Yields the current thread until a non-nil value is returned by the function.
|
||||||
---@generic T
|
---@generic T
|
||||||
---@param cb fun(): T?
|
---@param cb fun(): T
|
||||||
---@param errMessage string?
|
---@param errMessage string?
|
||||||
---@param timeout number? Error out after `~x` ms. Defaults to 1000, unless set to `false`.
|
---@param timeout? number | false Error out after `~x` ms. Defaults to 1000, unless set to `false`.
|
||||||
---@return T?
|
---@return T
|
||||||
---@async
|
---@async
|
||||||
function lib.waitFor(cb, errMessage, timeout)
|
function lib.waitFor(cb, errMessage, timeout)
|
||||||
local value = cb()
|
local value = cb()
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export function sleep(ms: number) {
|
|||||||
* Creates a promise that will be resolved once any value is returned by the function (including null).
|
* Creates a promise that will be resolved once any value is returned by the function (including null).
|
||||||
* @param {number?} timeout Error out after `~x` ms. Defaults to 1000, unless set to `false`.
|
* @param {number?} timeout Error out after `~x` ms. Defaults to 1000, unless set to `false`.
|
||||||
*/
|
*/
|
||||||
export async function waitFor<T>(cb: () => T, errMessage?: string, timeout?: number): Promise<T> {
|
export async function waitFor<T>(cb: () => T, errMessage?: string, timeout?: number | false): Promise<T> {
|
||||||
let value = await cb();
|
let value = await cb();
|
||||||
|
|
||||||
if (value !== undefined) return value;
|
if (value !== undefined) return value;
|
||||||
|
|||||||
Reference in New Issue
Block a user