import { PlainObject } from "../models.mjs"; //#region src/array/single.d.ts /** * Get the _only_ item matching the given value * * Throws an error if multiple items match the 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 Only item that matches the value, or `undefined` if no match is found * * @example * ```typescript * single( * [{id: 1}, {id: 2}, {id: 3}], * item => item.id, * 2 * ); // => {id: 2} * ``` */ declare function single unknown>(array: Item[], callback: Callback, value: ReturnType): Item | undefined; /** * Get the _only_ item matching the given value by key * * Throws an error if multiple items match the value * * @param array Array to search in * @param key Key to get an item's value for matching * @param value Value to match against * @returns Only item that matches the value, or `undefined` if no match is found * * @example * ```typescript * single( * [{id: 1}, {id: 2}, {id: 3}], * 'id', * 2 * ); // => {id: 2} * ``` */ declare function single(array: Item[], key: ItemKey, value: Item[ItemKey]): Item | undefined; /** * Get the _only_ item matching the filter * * Throws an error if multiple items match the filter * * @param array Array to search in * @param filter Filter callback to match items * @returns Only item that matches the filter, or `undefined` if no match is found * * @example * ```typescript * single( * [{id: 1}, {id: 2}, {id: 3}], * item => item.id === 2 * ); // => {id: 2} * ``` */ declare function single(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): Item | undefined; //#endregion export { single };