import { Result } from "./results.js"; //#region src/utils/promises.d.ts type ReactPromise = Promise & ({ status: "rejected"; reason: unknown; } | { status: "fulfilled"; value: T; } | { status: "pending"; }); type Resolve = (value: T) => void; type Reject = (reason: unknown) => void; declare function createPromise(callback: (resolve: Resolve, reject: Reject) => void): ReactPromise; /** * Like Promise.resolve(...), but also adds the status and value properties for use with React's `use` hook, and caches * the value so that invoking `resolved` twice returns the same promise. */ declare function resolved(value: T): ReactPromise; /** * Like Promise.reject(...), but also adds the status and value properties for use with React's `use` hook, and caches * the value so that invoking `rejected` twice returns the same promise. */ declare function rejected(reason: unknown): ReactPromise; declare function neverResolve(): ReactPromise; declare function pending(promise: Promise, options?: { disableErrorWrapping?: boolean; }): ReactPromise; /** * Should be used to wrap Promises that are not immediately awaited, so they don't throw an unhandled promise rejection * error. * * Vercel kills serverless functions on unhandled promise rejection errors, so this is important. */ declare function ignoreUnhandledRejection>(promise: T): void; /** * See concatStacktraces for more information. */ declare function concatStacktracesIfRejected(promise: Promise): void; declare function wait(ms: number): Promise; declare function waitUntil(date: Date): Promise; declare function runAsynchronouslyWithAlert(...args: Parameters): void; declare function runAsynchronously(promiseOrFunc: void | Promise | (() => void | Promise) | undefined, options?: { noErrorLogging?: boolean; onError?: (error: Error) => void; }): void; declare class TimeoutError extends Error { readonly ms: number; constructor(ms: number); } declare function timeout(promiseOrFunc: Promise | (() => Promise), ms: number): Promise>; declare function timeoutThrow(promise: Promise, ms: number): Promise; type RateLimitOptions = { /** * The number of requests to process in parallel. Currently only 1 is supported. */ concurrency: 1; /** * If true, multiple requests waiting at the same time will be reduced to just one. Default is false. */ batchCalls?: boolean; /** * Waits for throttleMs since the start of last request before starting the next request. Default is 0. */ throttleMs?: number; /** * Waits for gapMs since the end of last request before starting the next request. Default is 0. */ gapMs?: number; /** * Waits until there have been no new requests for debounceMs before starting a new request. Default is 0. */ debounceMs?: number; }; declare function rateLimited(func: () => Promise, options: RateLimitOptions): () => Promise; declare function throttled(func: (...args: A) => Promise, delayMs: number): (...args: A) => Promise; //#endregion export { RateLimitOptions, ReactPromise, concatStacktracesIfRejected, createPromise, ignoreUnhandledRejection, neverResolve, pending, rateLimited, rejected, resolved, runAsynchronously, runAsynchronouslyWithAlert, throttled, timeout, timeoutThrow, wait, waitUntil }; //# sourceMappingURL=promises.d.ts.map