import { PlainObject } from "../models.mjs"; //#region src/array/find.d.ts /** * Get the first item matching the given value * * @param array Array to search in * @param callback Callback to get an item's value for matching * @param value Value to match against * @returns First item that matches the value, or `undefined` if no match is found * * @example * ```typescript * find( * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}], * item => item.value, * 10, * ); // => {id: 1, value: 10} * ``` */ declare function find unknown>(array: Item[], callback: Callback, value: ReturnType): Item | undefined; /** * Get the first item matching the given value by key * * @param array Array to search in * @param key Key to get an item's value for matching * @param value Value to match against * @returns First item that matches the value, or `undefined` if no match is found * * @example * ```typescript * find( * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}], * 'value', * 10, * ); // => {id: 1, value: 10} * ``` */ declare function find(array: Item[], key: ItemKey, value: Item[ItemKey]): Item | undefined; /** * Get the first item matching the filter * * @param array Array to search in * @param filter Filter callback to match items * @returns First item that matches the filter, or `undefined` if no match is found * * @example * ```typescript * find( * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}], * item => item.value === 10, * ); // => {id: 1, value: 10} * ``` */ declare function find(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): Item | undefined; /** * Get the first item matching the given value * * @param array Array to search in * @param value Value to match against * @returns First item that matches the value, or `undefined` if no match is found * * @example * ```typescript * find([1, 2, 3, 2, 1], 1); // => 1 * ``` */ declare function find(array: Item[], value: Item): Item | undefined; declare namespace find { var last: typeof findLast; } /** * Get the last item matching the given value * * _Available as `findLast` and `find.last`_ * * @param array Array to search in * @param callback Callback to get an item's value for matching * @param value Value to match against * @returns Last item that matches the value, or `undefined` if no match is found * * @example * ```typescript * findLast( * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}], * item => item.value, * 10, * ); // => {id: 3, value: 10} * ``` */ declare function findLast unknown>(array: Item[], callback: Callback, value: ReturnType): Item | undefined; /** * Get the last item matching the given value by key * * _Available as `findLast` and `find.last`_ * * @param array Array to search in * @param key Key to get an item's value for matching * @param value Value to match against * @returns Last item that matches the value, or `undefined` if no match is found * * @example * ```typescript * findLast( * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}], * 'value', * 10, * ); // => {id: 3, value: 10} * ``` */ declare function findLast(array: Item[], key: ItemKey, value: Item[ItemKey]): Item | undefined; /** * Get the last item matching the filter * * _Available as `findLast` and `find.last`_ * * @param array Array to search in * @param filter Filter callback to match items * @returns Last item that matches the filter, or `undefined` if no match is found * * @example * ```typescript * findLast( * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}], * item => item.value === 10, * ); // => {id: 3, value: 10} * ``` */ declare function findLast(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): Item | undefined; /** * Get the last item matching the given value * * _Available as `findLast` and `find.last`_ * * @param array Array to search in * @param value Value to match against * @returns Last item that matches the value, or `undefined` if no match is found * * @example * ```typescript * findLast([1, 2, 3, 2, 1], 1); // => 1 * ``` */ declare function findLast(array: Item[], value: Item): Item | undefined; //#endregion export { find, findLast };