@launchdarkly/js-server-sdk-common
Version:
LaunchDarkly Server SDK for JavaScript - common code
35 lines • 1.96 kB
TypeScript
/**
* Iterate a collection any apply the specified operation. The first operation which
* returns a value will be returned and iteration will stop.
*
* @param collection The collection to enumerate.
* @param operator The operation to apply to each item.
* @returns The result of the first successful operation.
*/
export declare function firstResult<T, U>(collection: T[] | undefined, operator: (val: T, index: number) => U | undefined): U | undefined;
/**
* Iterate a collection in series awaiting each check operation.
* @param collection The collection to iterate.
* @param check The check to perform for each item in the container.
* @param cb Called with true if all items pass the check.
*/
export declare function allSeriesAsync<T>(collection: T[] | undefined, check: (val: T, index: number, cb: (res: boolean) => void) => void, cb: (res: boolean) => void): void;
/**
* Iterate a collection in series awaiting each check operation.
* @param collection The collection to iterate.
* @param check The check to perform for each item in the container.
* @param cb called with true on the first item that passes the check. False
* means no items passed the check.
*/
export declare function firstSeriesAsync<T>(collection: T[] | undefined, check: (val: T, index: number, cb: (res: boolean) => void) => void, cb: (res: boolean) => void): void;
/**
* Iterate a collection and execute the the given check operation
* for all items concurrently.
* @param collection The collection to iterate.
* @param check The check to run for each item.
* @param cb Callback executed when all items have been checked. The callback
* will be called with true if each item resulted in true, otherwise it will
* be called with false.
*/
export declare function allAsync<T>(collection: T[] | undefined, check: (val: T, cb: (res: boolean) => void) => void, cb: (res: boolean | null | undefined) => void): void;
//# sourceMappingURL=collection.d.ts.map