es-toolkit 1.50.0-dev.2037 → 1.50.0-dev.2039

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,7 +6,7 @@ const require_toInteger = require("../util/toInteger.js");
6
6
  * Finds the first item in an object that has a specific property, where the property name is provided as a PropertyKey.
7
7
  *
8
8
  * @template T
9
- * @param source - The source array or object to search through.
9
+ * @param collection - The source array or object to search through.
10
10
  * @param [doesMatch=identity] - The criteria to match. It can be a function, a partial object, a key-value pair, or a property name.
11
11
  * @param [fromIndex=0] - The index to start the search from, defaults to 0.
12
12
  * @returns The first property value that has the specified property, or `undefined` if no match is found.
@@ -17,21 +17,21 @@ const require_toInteger = require("../util/toInteger.js");
17
17
  * const result = find(obj, 'name');
18
18
  * console.log(result); // { id: 1, name: 'Alice' }
19
19
  */
20
- function find(source, _doesMatch = require_identity.identity, fromIndex = 0) {
21
- if (!source) return;
20
+ function find(collection, _doesMatch = require_identity.identity, fromIndex = 0) {
21
+ if (!collection) return;
22
22
  fromIndex = require_toInteger.toInteger(fromIndex);
23
- if (fromIndex < 0) fromIndex = Math.max(source.length + fromIndex, 0);
23
+ if (fromIndex < 0) fromIndex = Math.max(collection.length + fromIndex, 0);
24
24
  const doesMatch = require_iteratee.iteratee(_doesMatch);
25
- if (!Array.isArray(source)) {
26
- const keys = Object.keys(source);
25
+ if (!Array.isArray(collection)) {
26
+ const keys = Object.keys(collection);
27
27
  for (let i = fromIndex; i < keys.length; i++) {
28
28
  const key = keys[i];
29
- const value = source[key];
30
- if (doesMatch(value, key, source)) return value;
29
+ const value = collection[key];
30
+ if (doesMatch(value, key, collection)) return value;
31
31
  }
32
32
  return;
33
33
  }
34
- return source.slice(fromIndex).find(doesMatch);
34
+ return collection.slice(fromIndex).find(doesMatch);
35
35
  }
36
36
  //#endregion
37
37
  exports.find = find;
@@ -6,7 +6,7 @@ import { toInteger } from "../util/toInteger.mjs";
6
6
  * Finds the first item in an object that has a specific property, where the property name is provided as a PropertyKey.
7
7
  *
8
8
  * @template T
9
- * @param source - The source array or object to search through.
9
+ * @param collection - The source array or object to search through.
10
10
  * @param [doesMatch=identity] - The criteria to match. It can be a function, a partial object, a key-value pair, or a property name.
11
11
  * @param [fromIndex=0] - The index to start the search from, defaults to 0.
12
12
  * @returns The first property value that has the specified property, or `undefined` if no match is found.
@@ -17,21 +17,21 @@ import { toInteger } from "../util/toInteger.mjs";
17
17
  * const result = find(obj, 'name');
18
18
  * console.log(result); // { id: 1, name: 'Alice' }
19
19
  */
20
- function find(source, _doesMatch = identity, fromIndex = 0) {
21
- if (!source) return;
20
+ function find(collection, _doesMatch = identity, fromIndex = 0) {
21
+ if (!collection) return;
22
22
  fromIndex = toInteger(fromIndex);
23
- if (fromIndex < 0) fromIndex = Math.max(source.length + fromIndex, 0);
23
+ if (fromIndex < 0) fromIndex = Math.max(collection.length + fromIndex, 0);
24
24
  const doesMatch = iteratee(_doesMatch);
25
- if (!Array.isArray(source)) {
26
- const keys = Object.keys(source);
25
+ if (!Array.isArray(collection)) {
26
+ const keys = Object.keys(collection);
27
27
  for (let i = fromIndex; i < keys.length; i++) {
28
28
  const key = keys[i];
29
- const value = source[key];
30
- if (doesMatch(value, key, source)) return value;
29
+ const value = collection[key];
30
+ if (doesMatch(value, key, collection)) return value;
31
31
  }
32
32
  return;
33
33
  }
34
- return source.slice(fromIndex).find(doesMatch);
34
+ return collection.slice(fromIndex).find(doesMatch);
35
35
  }
36
36
  //#endregion
37
37
  export { find };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "es-toolkit",
3
- "version": "1.50.0-dev.2037+827b92f7",
3
+ "version": "1.50.0-dev.2039+3fe4097c",
4
4
  "description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
5
5
  "homepage": "https://es-toolkit.dev",
6
6
  "bugs": "https://github.com/toss/es-toolkit/issues",