UNPKG

@solid/community-server

Version:

Community Solid Server: an open and modular implementation of the Solid specifications

27 lines (26 loc) 1.07 kB
export type PromiseOrValue<T> = T | Promise<T>; /** * Verifies if the given value is a Promise or not. * * @param object - Object to check. */ export declare function isPromise<T>(object: PromiseOrValue<T>): object is Promise<T>; /** * Calls `callback` with the resolved value of `object`. * In case `object` is a Promise, the result will also be a Promise, * otherwise the result will be sync. */ export declare function resolvePromiseOrValue<TIn, TOut>(object: PromiseOrValue<TIn>, callback: (val: TIn) => TOut): PromiseOrValue<TOut>; /** * A function that simulates the Array.some behaviour but on an array of Promises. * Returns true if at least one promise returns true. * Returns false if all promises return false or error. * * @remarks * * Predicates provided as input must be implemented considering * the following points: * 1. if they throw an error, it won't be propagated; * 2. throwing an error should be logically equivalent to returning false. */ export declare function promiseSome(predicates: Promise<boolean>[]): Promise<boolean>;