import { Result } from "../result/models.mjs"; import { PromiseOptions, PromisesItems, PromisesOptions, PromisesResult, PromisesUnwrapped, PromisesValue, PromisesValues } from "./models.mjs"; //#region src/promise/index.d.ts /** * Wrap a _Promise_ with safety handlers, with optional abort capabilities and timeout * * @param promise _Promise_ to wrap * @param options Options for the _Promise_ * @returns Wrapped _Promise_ */ declare function attemptPromise(promise: Promise, options?: PromiseOptions | AbortSignal | number): Promise; /** * Wrap a _Promise_-returning callback with safety handlers, with optional abort capabilities and timeout * * @param callback Callback to wrap * @param options Options for the _Promise_ * @returns _Promise_-wrapped callback */ declare function attemptPromise(callback: () => Promise, options?: PromiseOptions | AbortSignal | number): Promise; /** * Wrap a callback with a _Promise_ and safety handlers, with optional abort capabilities and timeout * * @param callback Callback to wrap * @param options Options for the _Promise_ * @returns _Promise_-wrapped callback */ declare function attemptPromise(callback: () => Value, options?: PromiseOptions | AbortSignal | number): Promise; /** * Handle a list of _Promises_, returning their results in an ordered array * * Depending on the strategy, the function will either reject on the first error encountered or return an array of rejected and resolved results * * @param items List of _Promises_ * @param options Options for handling the _Promises_ * @returns List of results */ declare function promises(items: [...Items], options?: Options): Promise : PromisesValues>>; /** * Handle a list of _Promises_, returning their results in an ordered array * * Depending on the strategy, the function will either reject on the first error encountered or return an array of rejected and resolved results * * @param items List of _Promises_ * @param options Options for handling the _Promises_ * @returns List of results */ declare function promises(items: Promise[], options?: Options): Promise[]>; /** * Handle a list of _Promises_, returning their results in an ordered array * * If any _Promise_ in the list is rejected, the whole function will reject * * @param items List of _Promises_ * @param strategy Strategy for handling the _Promises_; rejects on the first error encountered * @returns List of results */ declare function promises(items: [...Items], strategy: 'first'): Promise>; /** * Handle a list of _Promises_, returning their results in an ordered array * * If any _Promise_ in the list is rejected, the whole function will reject * * @param items List of _Promises_ * @param strategy Strategy for handling the _Promises_; rejects on the first error encountered * @returns List of results */ declare function promises(items: Promise[], strategy: 'first'): Promise; /** * Handle a list of _Promises_, returning their results in an ordered array of rejected and resolved results * * @param items List of _Promises_ * @param signal AbortSignal for aborting the operation _(when aborted, the _Promise_ will reject with the reason of the signal)_ * @returns List of results */ declare function promises(items: [...Items], signal?: AbortSignal): Promise>>; /** * Handle a list of _Promises_, returning their results in an ordered array of rejected and resolved results * * @param items List of _Promises_ * @param signal AbortSignal for aborting the operation _(when aborted, the _Promise_ will reject with the reason of the signal)_ * @returns List of results */ declare function promises(items: Array | (() => Promise)>, signal?: AbortSignal): Promise[]>; declare namespace promises { var result: typeof resultPromises; } /** * Handle a list of _Promises_, returning their results in an ordered array of results _({@link Result})_ * * Depending on the strategy, the function will either reject on the first error encountered or return an array of rejected and resolved results * * _Available as `resultPromises` and `promises.result`_ * * @param items List of _Promises_ * @param signal AbortSignal for aborting the operation _(when aborted, the _Promise_ will reject with the reason of the signal)_ * @returns List of results */ declare function resultPromises(items: [...Items], signal?: AbortSignal): Promise>>; /** * Handle a list of _Promises_, returning their results in an ordered array of results _({@link Result})_ * * Depending on the strategy, the function will either reject on the first error encountered or return an array of rejected and resolved results * * _Available as `resultPromises` and `promises.result`_ * * @param items List of _Promises_ * @param signal AbortSignal for aborting the operation _(when aborted, the _Promise_ will reject with the reason of the signal)_ * @returns List of results */ declare function resultPromises(items: Promise[], signal?: AbortSignal): Promise>[]>; //#endregion export { attemptPromise, promises, resultPromises };