web-ui-pack
Version:
Web package with UI elements
15 lines (14 loc) • 787 B
TypeScript
/**
* Produce Promise during for "no less than pointed time".
* If Promise takes more than pointed time: no additional waiting
* If Promise resolves or rejects in less than pointed time: waiting for rest time
* @param promise Promise that we must wait for pointed time
* @param ms min time that Promise must take
* @param [smartOrCallback=true] Allow not to wait if pointed promise is resolved immediately default-`true`
* @example
* let isPending = false
* promiseWait(Promise.resolve(), 300, (isWait) => (isPending=isWait))
* // OR
* isPending = true;
* promiseWait(Promise.resolve(), 300, true).finally(() => (isPending=false)) */
export default function promiseWait<T>(promise: Promise<T>, ms: number, smartOrCallback?: boolean | ((isWait: boolean) => any)): Promise<T>;