2022-08-11 12:38:08 +00:00
|
|
|
//@ts-check
|
|
|
|
import wait from "./wait.mjs";
|
2023-05-09 02:00:53 +00:00
|
|
|
import { awaitedIdentity } from "./identity.mjs";
|
|
|
|
import isLocalHost from "./isLocalHost.mjs";
|
2022-08-11 12:38:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Waits the specified amount of time before returning the value
|
|
|
|
* @param {number} _durationMs Duration, in milliseconds. Defaults to 1 second
|
|
|
|
* @returns
|
|
|
|
*/
|
2023-05-09 02:00:53 +00:00
|
|
|
const fakeWait = (_durationMs = 1000) => awaitedIdentity;
|
2022-08-11 12:38:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* useful to check for transitions while developing styles, if the loading screen
|
|
|
|
* disappears too fast for example.
|
|
|
|
* @template T
|
|
|
|
* @param {number} durationMs Duration, in milliseconds. Defaults to 1 second
|
|
|
|
* @returns {(value?: T | undefined) => Promise<T>}
|
|
|
|
*/
|
|
|
|
export const waitIfLocalHost = isLocalHost ? wait : fakeWait;
|
|
|
|
|
|
|
|
export default waitIfLocalHost;
|