diginext-utils
Version:
README.md
23 lines • 801 B
TypeScript
/**
* Removes the first item from an array where the specified property matches the given value.
* Returns a new array without modifying the original.
*
* @template T - The type of elements in the array
* @param array - The array to remove from
* @param key - The property key to match
* @param value - The value to match
* @returns A new array with the matching item removed
*
* @example
* ```ts
* const users = [
* { id: 1, name: 'Alice' },
* { id: 2, name: 'Bob' },
* { id: 3, name: 'Charlie' }
* ];
* removeItemByKey(users, 'id', 2);
* // [{ id: 1, name: 'Alice' }, { id: 3, name: 'Charlie' }]
* ```
*/
export declare function removeItemByKey<T extends Record<string, unknown>>(array: T[], key: keyof T, value: unknown): T[];
//# sourceMappingURL=removeItemByKey.d.ts.map