import { IIdName } from '../models/id-name.mjs'; import { IId, IName } from '../models/interfaces.mjs'; import { ArrayOrSingle } from '../models/types.mjs'; export declare function arrayGetIds>, Tid = T['id']>(arr?: Readonly[], callback?: (item: T) => Tid): Tid[]; export declare function arrayGetIdNames, Tid = T['id'], Tname = T['name']>(arr?: Readonly[], callback?: (item: T) => IIdName): IIdName[]; export declare function arrayGetNames, Tname = T['name']>(arr?: Readonly[], callback?: (item: T) => Tname): Tname[]; /** * Return the object with the given id from the array. * @param arrItems The array to search for the ids. * @param id id to search for in the arrItems list. * @returns The object with the given name. If not found, undefined is returned. */ export declare function arrayFindById, Tid = T['id']>(arrItems?: T[], id?: Tid): T | undefined; /** * Return the object with the given id from the array. * @param arrItems The array to search for the ids. * @param id id to search for in the arrItems list. * @returns The name of the found item. If not found, undefined is returned. */ export declare function arrayFindNameById, Tid = T['id'], Tname = T['name']>(arrItems?: T[], id?: Tid): Tname | undefined; /** * Return the objects that contain the given ids. * @param arrItems The array to search for the ids. * @param ids The array of ids to find in arrItems. * @returns The object with the given name. If not found, an empty Array is returned. */ export declare function arrayFindByIds>, Tid = T['id']>(arrItems?: T[], ids?: Tid[]): T[]; /** * Return the objects that do NOT match any of the given ids. * @param arrItems The array to search for the ids. * @param ids The array of ids to NOT find in arrItems. * @returns The object with the given name. If not found, and exception is thrown. */ export declare function arrayFindByNotIds>, Tid = T['id']>(arrItems?: T[], ids?: Tid[]): T[]; export declare function arrayMustFind, Tid = T['id']>(arrItems: T[] | undefined, id: Tid, functionSourceName?: string): T; /** * Return the object with the given name from the array. * @param arrItems The array of items to search for the name. Null checks are taken into account. * @param name Name to search for in the IName * @returns The object with the given name. If not found, and exception is thrown. */ export declare function arrayFindByName, Tname = T['name']>(arrItems?: T[], name?: Tname): T | undefined; export declare function arrayFilter(arrItems: T[] | undefined, filterFunc: (item: T) => boolean): T[]; export declare function arrayFind(arrItems: T[] | undefined, findFunc: (item: T) => boolean): T | undefined; export declare function arrayMustFindFunc(arrItems: T[], findFunc: (item: T) => boolean, functionSourceName?: string, exceptionSuffix?: () => string): NonNullable; export declare function arrayMustFindByName, Tname = T['name']>(arrItems: T[], name: Tname, functionSourceName?: string): NonNullable; export declare function arrayOfIds, Tid = T['id']>(arr?: Readonly[]): NonNullable[]; export declare function arrayOfNames, Tname = T['name']>(arr?: Readonly[]): Tname[]; export declare function arrayElementNonEmpty(arr?: T[], index?: number, functionSourceName?: string, customMessage?: string): NonNullable; /** * Gets the first item from an array, or a default value if the array is empty. Undefined is returned if no default value provided. * Good for quick tests of objects to see if it is an array, and getting the first value. * @param tArray The array to get the first value from, if it is an array. * @param defaultIfNone An optional default value if the array is empty. * @returns The first item in the array, or undefined or defaultIfNone if the array has no values. */ export declare function arrayFirst(tArray?: T[], defaultIfNone?: T): T | undefined; export declare function arrayFirstNonEmpty(arr?: T[], functionSourceName?: string, customMessage?: string): NonNullable; /** * Gets the last item from an array, or a default value if the array is empty. Null is returned if no default value provided. * Good for quick tests of objects to see if it is an array, and getting the first value. * @param tArray The array to get the last value from, if it is an array. * @param defaultIfNone An optional default value if the array is empty. * @returns The last item in the array, or null or defaultIfNone if the array has no values. */ export declare function arrayLast(tArray?: T[], defaultIfNone?: T): T | undefined; export declare function arrayLastNonEmpty(arr?: T[], functionSourceName?: string, customMessage?: string): NonNullable; export declare function arrayForEachReturns(arr: T[] | undefined, funcArrayResults: (item: T) => void): void; export declare function ToSafeArray(arrOrT?: Readonly>): T[]; /** * Helper function to reduce an array of objects or arrays. * Takes care of handling undefined, objects and/or arrays and returns a guaranteed flattened array of type TreturnType. * Keep in mind, this is only for when you want to return an array of IId type derived objects. * @param arr The array or single item to iterate over. ToSafeArray is called. * @param funcArrayResults Callback that returns undefined or an object or array of TreturnType. * @returns The reduced array of all objects and arrays returned funcArrayResults. Will be [] if all returns were undefined or the calling array is undefined. */ export declare function arrayReduceArrayReturns(arr: Readonly> | undefined, funcArrayResults: (item: T, index: number) => ArrayOrSingle | undefined): TreturnType[]; export declare function arraySwapItemsById, Tid = T['id']>(arrItems: T[], sourceId: Tid, destId: Tid): T[]; export declare function arraySwapItems(arrItems: T[], sourceIndex: number, destIndex: number): T[]; //# sourceMappingURL=array-helper.d.mts.map