UNPKG

wait-utils

Version:

A modern, zero-dependency wait / timing utility toolkit for JavaScript and TypeScript.

1 lines 22.2 kB
{"version":3,"sources":["../../src/index.ts","../../src/errors/abortError.ts","../../src/errors/timeoutError.ts","../../src/setIntervalAsync.ts","../../src/setTimeoutAsync.ts","../../src/utils/throwIfAborted.ts","../../src/wait.ts","../../src/timeout.ts","../../src/utils/hasOwnProperty.ts","../../src/utils/or.ts","../../src/poll.ts","../../src/waitUntil.ts"],"sourcesContent":["export { AbortError } from \"./errors/abortError\";\n\nexport { TimeoutError } from \"./errors/timeoutError\";\n\nexport {\n type AfterPollCallback,\n poll,\n type PollCallback,\n type PollContext,\n type PollOptions,\n} from \"./poll\";\n\nexport { type IntervalContext, setIntervalAsync } from \"./setIntervalAsync\";\n\nexport { setTimeoutAsync } from \"./setTimeoutAsync\";\n\nexport { timeout } from \"./timeout\";\n\nexport { wait } from \"./wait\";\n\nexport { waitUntil } from \"./waitUntil\";\n","/**\n * Error thrown when an operation is aborted via an `AbortSignal`.\n *\n * This error is used in asynchronous operations\n * to indicate that the caller explicitly cancelled\n * the request by invoking `AbortController.abort()`.\n */\nexport class AbortError extends DOMException {\n constructor(message = \"This operation was aborted\") {\n super(message, \"AbortError\");\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * Error thrown when an operation exceeds its allowed time limit.\n *\n * This error is used in asynchronous operations to indicate\n * that the operation took too long to complete and was\n * terminated based on a timeout setting.\n */\nexport class TimeoutError extends DOMException {\n constructor(message = \"This operation was timed out\") {\n super(message, \"TimeoutError\");\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * Context object provided to the {@link setIntervalAsync} callback.\n */\nexport interface IntervalContext {\n /**\n * The delay in milliseconds before the next tick.\n * Defaults to the initial delay provided to {@link setIntervalAsync}.\n * The callback can modify this property to change intervals dynamically.\n */\n delay?: number;\n\n /**\n * When set to `true`, the inverval is stopped.\n */\n stop?: boolean;\n\n /**\n * The tick counter, starting at `1` and incremented automatically.\n * @readonly\n * @remarks This property cannot be modified by the callback.\n */\n readonly tickCount: number;\n}\n\n/**\n * Asynchronously calls a callback repeatedly at a given interval.\n *\n * Internally uses `setTimeout`, so interval drift may occur.\n *\n * @param callback - Invoked on each tick. Receives a mutable {@link IntervalContext} object,\n * allowing the callback to change delay dynamically or stop the interval.\n * @param delay - The delay in milliseconds between invocations.\n * Can be changed dynamically via `context.delay`.\n * @param signal - An `AbortSignal` which can cancel the interval.\n *\n * @returns A promise that:\n * - resolves when `context.stop` is set to `true` inside the callback (graceful termination),\n * - rejects with `signal.reason` if the signal aborts,\n * - rejects if the callback throws or rejects.\n *\n * @example\n * ```ts\n * let count = 0;\n * setIntervalAsync(ctx => {\n * console.log(\"tick\", ++count);\n * ctx.stop = count >= 5;\n * }, 1000).then(() => {\n * console.log(\"Completed after 5 ticks\");\n * });\n * ```\n */\nexport function setIntervalAsync(\n callback: (context: IntervalContext) => unknown | Promise<unknown>,\n delay?: number,\n signal?: AbortSignal,\n): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n if (signal?.aborted) {\n reject(signal.reason);\n return;\n }\n\n let isRunning = true;\n let tickCount = 0;\n const context: IntervalContext = { tickCount: 0, delay };\n Object.defineProperty(context, \"tickCount\", {\n configurable: false,\n enumerable: true,\n get: () => tickCount,\n });\n\n const onAbort = () => {\n if (isRunning) {\n isRunning = false;\n clearTimeout(timeoutId);\n reject(signal?.reason);\n }\n };\n\n const onError = (error: unknown) => {\n if (isRunning) {\n isRunning = false;\n signal?.removeEventListener(\"abort\", onAbort);\n reject(error);\n }\n };\n\n const onResolve = () => {\n if (isRunning) {\n isRunning = false;\n signal?.removeEventListener(\"abort\", onAbort);\n resolve();\n }\n };\n\n const onTimeout = async () => {\n if (isRunning) {\n try {\n ++tickCount;\n await callback(context);\n if (context.stop === true) {\n onResolve();\n } else if (isRunning) {\n timeoutId = setTimeout(onTimeout, context.delay);\n }\n } catch (error) {\n onError(error);\n }\n }\n };\n\n let timeoutId = setTimeout(onTimeout, context.delay);\n signal?.addEventListener(\"abort\", onAbort, { once: true });\n });\n}\n","/**\n * Asynchronously delays execution for the specified duration.\n *\n * @param delay - The number of milliseconds to wait.\n * @param signal - An `AbortSignal` that can cancel the wait early.\n *\n * @returns A promise that resolves after the delay, or rejects with\n * the `signal.reason` if `signal` is aborted before timeout.\n *\n * @example\n * ```ts\n * // Basic usage\n * await setTimeoutAsync(1000);\n *\n * // Abortable usage\n * const controller = new AbortController();\n * setTimeoutAsync(2000, controller.signal)\n * .catch(reason => console.log('Aborted due to', reason));\n * controller.abort('Timeout canceled');\n * ```\n */\nexport function setTimeoutAsync(\n delay?: number,\n signal?: AbortSignal,\n): Promise<void> {\n if (signal == null) {\n return new Promise((resolve) => setTimeout(resolve, delay));\n }\n return new Promise<void>((resolve, reject) => {\n if (signal.aborted) {\n reject(signal.reason);\n return;\n }\n\n const onAbort = () => {\n clearTimeout(timeoutId);\n reject(signal.reason);\n };\n\n const onResolve = () => {\n signal.removeEventListener(\"abort\", onAbort);\n resolve();\n };\n\n const timeoutId = setTimeout(onResolve, delay);\n signal.addEventListener(\"abort\", onAbort, { once: true });\n });\n}\n","// Node 17.3 (Release date: 2021-12-17)\nexport const HAS_THROW_IF_ABORTED = \"throwIfAborted\" in AbortSignal.prototype;\n\n/**\n * Throws `AbortSignal.reason` if the signal\n * has been aborted; otherwise it does nothing.\n */\nexport const throwIfAborted = HAS_THROW_IF_ABORTED ? nativeFn : polyfillFn;\n\nexport function nativeFn(signal?: AbortSignal): void {\n signal?.throwIfAborted();\n}\n\nexport function polyfillFn(signal?: AbortSignal): void {\n if (signal?.aborted) {\n throw signal.reason;\n }\n}\n","import { setTimeoutAsync } from \"./setTimeoutAsync\";\nimport { throwIfAborted } from \"./utils/throwIfAborted\";\n\n/**\n * Waits for the specified number of milliseconds.\n *\n * Supports cancellation via an `AbortSignal`.\n *\n * @param delay - The number of milliseconds to wait.\n * @param signal - Optional `AbortSignal` to cancel the wait early.\n *\n * @returns A promise that:\n * - resolves after the delay\n * - rejects with the `AbortSignal.reason` if cancelled before the delay\n */\nexport async function wait(\n delay?: number | null,\n signal?: AbortSignal,\n): Promise<void> {\n throwIfAborted(signal);\n\n if (delay == null) {\n return;\n }\n\n delay = Number(delay);\n if (!Number.isNaN(delay) && delay > 0) {\n return setTimeoutAsync(delay, signal);\n }\n}\n","import { TimeoutError } from \"./errors/timeoutError\";\nimport { wait } from \"./wait\";\n\n/**\n * Rejects with a `TimeoutError` after the specified delay,\n * unless cancelled by an `AbortSignal`.\n *\n * @param delay - The number of milliseconds to wait before timing out.\n * @param signal - Optional `AbortSignal` to cancel the timeout.\n *\n * @returns A promise that:\n * - resolves if the signal is aborted before the delay\n * - rejects with a `TimeoutError` if the delay completes\n * - rethrows an error if an unexpected rejection occurs\n */\nexport function timeout(\n delay?: number | null,\n signal?: AbortSignal,\n): Promise<void> {\n return wait(delay, signal).then(\n () => {\n throw new TimeoutError();\n },\n (error) => {\n if (signal?.reason !== error) {\n throw error;\n }\n },\n );\n}\n","/**\n * Determines whether an object has a property with the specified name.\n *\n * @param obj\n * @param key\n *\n * @returns `true` if the object has the property, otherwise `false`.\n */\nexport function hasOwnProperty<T>(obj: T, key: keyof T): boolean {\n return Object.prototype.hasOwnProperty.call(obj, key);\n}\n","// Node 20.3 (Release date: 2023-06-08)\nexport const HAS_ANY = \"any\" in AbortSignal;\n\n/**\n * Takes up to two abort signals and returns an {@link AbortSignal}.\n *\n * @param signal1\n * @param signal2\n *\n * @returns\n * - If two signals given, then an {@link AbortSignal} that combines them.\n * - If one signal given, then the given signal.\n * - If no signals given, then `undefined`.\n */\nexport const or = HAS_ANY ? nativeFn : polyfillFn;\n\nexport function nativeFn(\n signal1: AbortSignal,\n signal2?: AbortSignal,\n): AbortSignal;\nexport function nativeFn(\n signal1: AbortSignal | undefined,\n signal2: AbortSignal,\n): AbortSignal;\nexport function nativeFn(\n signal1?: AbortSignal,\n signal2?: AbortSignal,\n): AbortSignal | undefined;\nexport function nativeFn(\n signal1?: AbortSignal,\n signal2?: AbortSignal,\n): AbortSignal | undefined {\n if (signal2 == null) {\n return signal1;\n }\n if (signal1 == null) {\n return signal2;\n }\n return AbortSignal.any([signal1, signal2]);\n}\n\nexport function polyfillFn(\n signal1: AbortSignal,\n signal2?: AbortSignal,\n): AbortSignal;\nexport function polyfillFn(\n signal1: AbortSignal | undefined,\n signal2: AbortSignal,\n): AbortSignal;\nexport function polyfillFn(\n signal1?: AbortSignal,\n signal2?: AbortSignal,\n): AbortSignal | undefined;\nexport function polyfillFn(\n signal1?: AbortSignal,\n signal2?: AbortSignal,\n): AbortSignal | undefined {\n if (signal2 == null) {\n return signal1;\n }\n\n if (signal1 == null) {\n return signal2;\n }\n\n const controller = new AbortController();\n\n const onAbort1 = () => {\n if (!controller.signal.aborted) {\n controller.abort(signal1.reason);\n signal2.removeEventListener(\"abort\", onAbort2);\n }\n };\n\n const onAbort2 = () => {\n if (!controller.signal.aborted) {\n controller.abort(signal2.reason);\n signal1.removeEventListener(\"abort\", onAbort1);\n }\n };\n\n if (signal1.aborted) {\n controller.abort(signal1.reason);\n } else if (signal2.aborted) {\n controller.abort(signal2.reason);\n } else {\n signal1.addEventListener(\"abort\", onAbort1, { once: true });\n signal2.addEventListener(\"abort\", onAbort2, { once: true });\n }\n\n return controller.signal;\n}\n","import { IntervalContext, setIntervalAsync } from \"./setIntervalAsync\";\nimport { timeout } from \"./timeout\";\nimport { hasOwnProperty } from \"./utils/hasOwnProperty\";\nimport { or } from \"./utils/or\";\nimport { throwIfAborted } from \"./utils/throwIfAborted\";\n\n/**\n * A hook invoked after each successful callback execution in {@link poll}.\n *\n * Can be used for logging, adjusting the next delay, or stopping the wait loop.\n *\n * This is skipped if the callback stops the wait or throws.\n *\n * @param context - The current {@link PollContext}.\n */\nexport type AfterPollCallback<T = unknown> = (\n context: PollContext<T>,\n) => unknown | Promise<unknown>;\n\n/**\n * The main function invoked at each iteration in {@link poll}.\n *\n * This function performs the primary asynchronous operation.\n * To stop further attempts, set `context.stop = true`.\n *\n * @param context - The current {@link PollContext}.\n *\n * @returns A result value, or a Promise that resolves to one.\n */\nexport type PollCallback<T = unknown, R = unknown> = (\n context: PollContext<T>,\n) => R | Promise<R>;\n\n/**\n * Context object in {@link poll}.\n */\nexport interface PollContext<T = unknown> {\n /**\n * The current attempt number, starting from `1` and incremented automatically.\n * @readonly\n */\n readonly attempt: number;\n\n /**\n * The delay (in milliseconds) before the next attempt.\n *\n * Can be updated dynamically to implement backoff, jitter, etc.\n */\n delay?: number | null;\n\n /**\n * Set to `true` to stop further attempts.\n */\n stop?: boolean;\n\n /**\n * User-provided data.\n *\n * Useful for sharing state or configuration across attempts.\n */\n userData?: T;\n}\n\n/**\n * Configuration options for {@link poll}.\n */\nexport interface PollOptions<T = unknown> {\n /**\n * A function to run after each poll attempt.\n *\n * Can be used to log results, inspect attempt state, or modify future behavior.\n */\n afterPoll?: AfterPollCallback<T>;\n\n /**\n * The delay (in milliseconds) between subsequent attempts.\n *\n * Can be changed dynamically via {@link PollContext.delay | context.delay}.\n */\n delay?: number | null;\n\n /**\n * The delay (in milliseconds) before the first attempt.\n * If not specified, falls back to {@link delay}.\n */\n initialDelay?: number | null;\n\n /**\n * An {@link AbortSignal} to cancel the wait loop.\n *\n * If triggered, the function throws an `AbortError`.\n */\n signal?: AbortSignal;\n\n /**\n * The maximum total duration (in milliseconds) to wait before timing out.\n *\n * If exceeded, the function throws a `TimeoutError`.\n */\n timeout?: number;\n\n /**\n * User-provided data.\n *\n * Useful for sharing state or configuration across attempts.\n */\n userData?: T;\n}\n\n/**\n * Repeatedly invokes a callback function until it succeeds, is stopped, aborted, or times out.\n *\n * After each successful callback execution, an optional {@link PollOptions.afterPoll}\n * hook is invoked. You can control retry timing by updating `context.delay` or exit\n * early by setting `context.stop = true`.\n *\n * @typeParam T - The shape of the user data passed through the context.\n * @typeParam R - The return type of the callback function.\n *\n * @param callback - The function to invoke on each attempt.\n * @param options - Optional configuration to control timing, retries, and cancellation.\n *\n * @returns The last value returned by the callback.\n *\n * @throws `AbortError` if the operation is cancelled using `signal`.\n * @throws `TimeoutError` if the total wait duration exceeds `timeout`.\n */\nexport async function poll<T, R>(\n callback: PollCallback<T, R>,\n options: PollOptions<T> = {},\n): Promise<R> {\n throwIfAborted(options.signal);\n const { delay, afterPoll, userData } = options;\n\n let attempt = 0;\n const context: PollContext<T> = { attempt: 0, delay, userData };\n Object.defineProperty(context, \"attempt\", {\n configurable: false,\n enumerable: true,\n get: () => attempt,\n });\n\n let signal = options.signal;\n let response!: R;\n const main = async (ctx: IntervalContext) => {\n ++attempt;\n response = await callback(context);\n if (signal?.aborted) {\n return;\n }\n ctx.stop = context.stop;\n if (ctx.stop === true) {\n return;\n }\n await afterPoll?.(context);\n ctx.delay = context.delay ?? 0;\n ctx.stop = context.stop;\n };\n\n const initialDelay = hasOwnProperty(options, \"initialDelay\")\n ? options.initialDelay\n : delay;\n\n if (options.timeout == null) {\n await setIntervalAsync(main, initialDelay ?? 0, signal);\n return response;\n }\n\n const timeoutController = new AbortController();\n signal = or(options.signal, timeoutController.signal);\n\n try {\n await Promise.race([\n timeout(options.timeout, signal),\n setIntervalAsync(main, initialDelay ?? 0, signal),\n ]);\n return response;\n } finally {\n timeoutController.abort();\n }\n}\n","import { setTimeoutAsync } from \"./setTimeoutAsync\";\nimport { throwIfAborted } from \"./utils/throwIfAborted\";\n\n/**\n * Waits until the specified time is reached.\n *\n * @param timestamp - Target time:\n * - If a {@link Date}, relative to {@link Date.now}.\n * - If a `number`, relative to {@link performance.now}.\n *\n * @param signal - Optional `AbortSignal` to cancel the wait early.\n *\n * @returns A promise that:\n * - resolves when the current time is at or past the target time\n * - rejects with the signal’s reason if cancelled before the target\n */\nexport async function waitUntil(\n timestamp?: Date | number | null,\n signal?: AbortSignal,\n): Promise<void> {\n throwIfAborted(signal);\n\n if (timestamp == null) {\n return;\n }\n\n const delay =\n timestamp instanceof Date\n ? timestamp.getTime() - Date.now()\n : Number(timestamp) - performance.now();\n\n if (!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,EAC7B,CAAAC,GAAQ,UAGZG,EAAI,KAAOJ,EAAQ,KACfI,EAAI,OAAS,KAGjB,MAAMP,IAAYG,CAAO,EACzBI,EAAI,MAAQJ,EAAQ,OAAS,EAC7BI,EAAI,KAAOJ,EAAQ,MACrB,EAEMK,EAAeC,EAAeZ,EAAS,cAAc,EACvDA,EAAQ,aACRE,EAEJ,GAAIF,EAAQ,SAAW,KACrB,aAAMa,EAAiBJ,EAAME,GAAgB,EAAGJ,CAAM,EAC/CC,EAGT,IAAMM,EAAoB,IAAI,gBAC9BP,EAASQ,EAAGf,EAAQ,OAAQc,EAAkB,MAAM,EAEpD,GAAI,CACF,aAAM,QAAQ,KAAK,CACjBE,EAAQhB,EAAQ,QAASO,CAAM,EAC/BM,EAAiBJ,EAAME,GAAgB,EAAGJ,CAAM,CAClD,CAAC,EACMC,CACT,QAAE,CACAM,EAAkB,MAAM,CAC1B,CACF,CCpKA,eAAsBG,EACpBC,EACAC,EACe,CAGf,GAFAC,EAAeD,CAAM,EAEjBD,GAAa,KACf,OAGF,IAAMG,EACJH,aAAqB,KACjBA,EAAU,QAAQ,EAAI,KAAK,IAAI,EAC/B,OAAOA,CAAS,EAAI,YAAY,IAAI,EAEtC,CAAC,OAAO,MAAMG,CAAK,GAAKA,EAAQ,GAClC,MAAMC,EAAgBD,EAAOF,CAAM,CAEvC","names":["index_exports","__export","AbortError","TimeoutError","poll","setIntervalAsync","setTimeoutAsync","timeout","wait","waitUntil","__toCommonJS","AbortError","message","TimeoutError","message","setIntervalAsync","callback","delay","signal","resolve","reject","isRunning","tickCount","context","onAbort","timeoutId","onError","error","onResolve","onTimeout","setTimeoutAsync","delay","signal","resolve","reject","onAbort","timeoutId","HAS_THROW_IF_ABORTED","throwIfAborted","nativeFn","polyfillFn","signal","wait","delay","signal","throwIfAborted","setTimeoutAsync","timeout","delay","signal","wait","TimeoutError","error","hasOwnProperty","obj","key","HAS_ANY","or","nativeFn","polyfillFn","signal1","signal2","controller","onAbort1","onAbort2","poll","callback","options","throwIfAborted","delay","afterPoll","userData","attempt","context","signal","response","main","ctx","initialDelay","hasOwnProperty","setIntervalAsync","timeoutController","or","timeout","waitUntil","timestamp","signal","throwIfAborted","delay","setTimeoutAsync"]}