From 58912e5e52fefa12d973bcad14796af79f725ea6 Mon Sep 17 00:00:00 2001 From: Antoliny0919 Date: Mon, 29 Jun 2026 01:03:40 +0900 Subject: [PATCH 1/2] fix(compat/find): align implementation param names with overload signatures --- src/compat/array/find.ts | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/compat/array/find.ts b/src/compat/array/find.ts index 7c57bd68b..780ba4ef2 100644 --- a/src/compat/array/find.ts +++ b/src/compat/array/find.ts @@ -103,30 +103,26 @@ export function find( * console.log(result); // { id: 1, name: 'Alice' } */ export function find( - source: ArrayLike | Record | null | undefined, - _doesMatch: - | ((item: T, index: number, arr: any) => unknown) - | Partial - | [keyof T, unknown] - | PropertyKey = identity, + collection: ArrayLike | Record | null | undefined, + predicate: ((item: T, index: number, arr: any) => unknown) | Partial | [keyof T, unknown] | PropertyKey = identity, fromIndex = 0 ): T | undefined { - if (!source) { + if (!collection) { return undefined; } if (fromIndex < 0) { - fromIndex = Math.max(source.length + fromIndex, 0); + fromIndex = Math.max(collection.length + fromIndex, 0); } - const doesMatch = iteratee(_doesMatch); - if (!Array.isArray(source)) { - const keys = Object.keys(source) as Array; + const doesMatch = iteratee(predicate); + if (!Array.isArray(collection)) { + const keys = Object.keys(collection) as Array; for (let i = fromIndex; i < keys.length; i++) { const key = keys[i]; - const value = source[key] as T; + const value = collection[key] as T; - if (doesMatch(value, key as number, source)) { + if (doesMatch(value, key as number, collection)) { return value; } } @@ -134,5 +130,5 @@ export function find( return undefined; } - return source.slice(fromIndex).find(doesMatch); + return collection.slice(fromIndex).find(doesMatch); } From 1d2610b3521ecdba1578f51be270abe3897670cc Mon Sep 17 00:00:00 2001 From: Antoliny0919 Date: Mon, 6 Jul 2026 16:54:38 +0900 Subject: [PATCH 2/2] revert predicate to doesMatch --- src/compat/array/find.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/compat/array/find.ts b/src/compat/array/find.ts index 780ba4ef2..0b66dc70c 100644 --- a/src/compat/array/find.ts +++ b/src/compat/array/find.ts @@ -91,7 +91,7 @@ export function find( * Finds the first item in an object that has a specific property, where the property name is provided as a PropertyKey. * * @template T - * @param source - The source array or object to search through. + * @param collection - The source array or object to search through. * @param [doesMatch=identity] - The criteria to match. It can be a function, a partial object, a key-value pair, or a property name. * @param [fromIndex=0] - The index to start the search from, defaults to 0. * @returns The first property value that has the specified property, or `undefined` if no match is found. @@ -104,7 +104,11 @@ export function find( */ export function find( collection: ArrayLike | Record | null | undefined, - predicate: ((item: T, index: number, arr: any) => unknown) | Partial | [keyof T, unknown] | PropertyKey = identity, + _doesMatch: + | ((item: T, index: number, arr: any) => unknown) + | Partial + | [keyof T, unknown] + | PropertyKey = identity, fromIndex = 0 ): T | undefined { if (!collection) { @@ -114,7 +118,7 @@ export function find( fromIndex = Math.max(collection.length + fromIndex, 0); } - const doesMatch = iteratee(predicate); + const doesMatch = iteratee(_doesMatch); if (!Array.isArray(collection)) { const keys = Object.keys(collection) as Array;