es-toolkit 1.49.0-dev.1912 → 1.49.0-dev.1914

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.
@@ -9,7 +9,7 @@ import { ListIteratorTypeGuard } from "../_internal/ListIteratorTypeGuard.mjs";
9
9
  * Filters characters in a string based on the predicate function.
10
10
  *
11
11
  * @param collection - The string to filter
12
- * @param predicate - The function to test each character
12
+ * @param [predicate] - The function to test each character
13
13
  * @returns An array of characters that pass the predicate test
14
14
  *
15
15
  * @example
@@ -35,7 +35,7 @@ declare function filter<T, U extends T>(collection: ArrayLike<T> | null | undefi
35
35
  *
36
36
  * @template T
37
37
  * @param collection - The array-like object to filter
38
- * @param predicate - The function or shorthand to test each element
38
+ * @param [predicate] - The function or shorthand to test each element
39
39
  * @returns An array of elements that pass the predicate test
40
40
  *
41
41
  * @example
@@ -64,7 +64,7 @@ declare function filter<T extends object, U extends T[keyof T]>(collection: T |
64
64
  *
65
65
  * @template T
66
66
  * @param collection - The object to filter
67
- * @param predicate - The function or shorthand to test each value
67
+ * @param [predicate] - The function or shorthand to test each value
68
68
  * @returns An array of values that pass the predicate test
69
69
  *
70
70
  * @example
@@ -9,7 +9,7 @@ import { ListIteratorTypeGuard } from "../_internal/ListIteratorTypeGuard.js";
9
9
  * Filters characters in a string based on the predicate function.
10
10
  *
11
11
  * @param collection - The string to filter
12
- * @param predicate - The function to test each character
12
+ * @param [predicate] - The function to test each character
13
13
  * @returns An array of characters that pass the predicate test
14
14
  *
15
15
  * @example
@@ -35,7 +35,7 @@ declare function filter<T, U extends T>(collection: ArrayLike<T> | null | undefi
35
35
  *
36
36
  * @template T
37
37
  * @param collection - The array-like object to filter
38
- * @param predicate - The function or shorthand to test each element
38
+ * @param [predicate] - The function or shorthand to test each element
39
39
  * @returns An array of elements that pass the predicate test
40
40
  *
41
41
  * @example
@@ -64,7 +64,7 @@ declare function filter<T extends object, U extends T[keyof T]>(collection: T |
64
64
  *
65
65
  * @template T
66
66
  * @param collection - The object to filter
67
- * @param predicate - The function or shorthand to test each value
67
+ * @param [predicate] - The function or shorthand to test each value
68
68
  * @returns An array of values that pass the predicate test
69
69
  *
70
70
  * @example
@@ -7,7 +7,7 @@ const require_iteratee = require("../util/iteratee.js");
7
7
  * If a function is provided, it is invoked for each element in the collection.
8
8
  *
9
9
  * @template T
10
- * @param source - The array or object to iterate over.
10
+ * @param collection - The array or object to iterate over.
11
11
  * @param [predicate=identity] - The function invoked per iteration.
12
12
  * @returns Returns a new array of filtered elements that satisfy the predicate.
13
13
  *
@@ -24,25 +24,25 @@ const require_iteratee = require("../util/iteratee.js");
24
24
  * filter([{ a: 1 }, { a: 2 }, { a: 3 }], ['a', 2]);
25
25
  * // => [{ a: 2 }]
26
26
  */
27
- function filter(source, predicate = require_identity.identity) {
28
- if (!source) return [];
27
+ function filter(collection, predicate = require_identity.identity) {
28
+ if (!collection) return [];
29
29
  predicate = require_iteratee.iteratee(predicate);
30
- if (!Array.isArray(source)) {
30
+ if (!Array.isArray(collection)) {
31
31
  const result = [];
32
- const keys = Object.keys(source);
33
- const length = require_isArrayLike.isArrayLike(source) ? source.length : keys.length;
32
+ const keys = Object.keys(collection);
33
+ const length = require_isArrayLike.isArrayLike(collection) ? collection.length : keys.length;
34
34
  for (let i = 0; i < length; i++) {
35
35
  const key = keys[i];
36
- const value = source[key];
37
- if (predicate(value, key, source)) result.push(value);
36
+ const value = collection[key];
37
+ if (predicate(value, key, collection)) result.push(value);
38
38
  }
39
39
  return result;
40
40
  }
41
41
  const result = [];
42
- const length = source.length;
42
+ const length = collection.length;
43
43
  for (let i = 0; i < length; i++) {
44
- const value = source[i];
45
- if (predicate(value, i, source)) result.push(value);
44
+ const value = collection[i];
45
+ if (predicate(value, i, collection)) result.push(value);
46
46
  }
47
47
  return result;
48
48
  }
@@ -7,7 +7,7 @@ import { iteratee } from "../util/iteratee.mjs";
7
7
  * If a function is provided, it is invoked for each element in the collection.
8
8
  *
9
9
  * @template T
10
- * @param source - The array or object to iterate over.
10
+ * @param collection - The array or object to iterate over.
11
11
  * @param [predicate=identity] - The function invoked per iteration.
12
12
  * @returns Returns a new array of filtered elements that satisfy the predicate.
13
13
  *
@@ -24,25 +24,25 @@ import { iteratee } from "../util/iteratee.mjs";
24
24
  * filter([{ a: 1 }, { a: 2 }, { a: 3 }], ['a', 2]);
25
25
  * // => [{ a: 2 }]
26
26
  */
27
- function filter(source, predicate = identity) {
28
- if (!source) return [];
27
+ function filter(collection, predicate = identity) {
28
+ if (!collection) return [];
29
29
  predicate = iteratee(predicate);
30
- if (!Array.isArray(source)) {
30
+ if (!Array.isArray(collection)) {
31
31
  const result = [];
32
- const keys = Object.keys(source);
33
- const length = isArrayLike(source) ? source.length : keys.length;
32
+ const keys = Object.keys(collection);
33
+ const length = isArrayLike(collection) ? collection.length : keys.length;
34
34
  for (let i = 0; i < length; i++) {
35
35
  const key = keys[i];
36
- const value = source[key];
37
- if (predicate(value, key, source)) result.push(value);
36
+ const value = collection[key];
37
+ if (predicate(value, key, collection)) result.push(value);
38
38
  }
39
39
  return result;
40
40
  }
41
41
  const result = [];
42
- const length = source.length;
42
+ const length = collection.length;
43
43
  for (let i = 0; i < length; i++) {
44
- const value = source[i];
45
- if (predicate(value, i, source)) result.push(value);
44
+ const value = collection[i];
45
+ if (predicate(value, i, collection)) result.push(value);
46
46
  }
47
47
  return result;
48
48
  }
@@ -10,7 +10,7 @@ import { ListIteratorTypeGuard } from "../_internal/ListIteratorTypeGuard.mjs";
10
10
  * @template T, U
11
11
  * @param collection - The array-like object to search
12
12
  * @param predicate - The type guard function to test each element
13
- * @param fromIndex - The index to start searching from
13
+ * @param [fromIndex] - The index to start searching from
14
14
  * @returns The first element that matches the type guard, or undefined if none found
15
15
  *
16
16
  * @example
@@ -23,8 +23,8 @@ declare function find<T, U extends T>(collection: ArrayLike<T> | null | undefine
23
23
  *
24
24
  * @template T
25
25
  * @param collection - The array-like object to search
26
- * @param predicate - The function or shorthand to test each element
27
- * @param fromIndex - The index to start searching from
26
+ * @param [predicate] - The function or shorthand to test each element
27
+ * @param [fromIndex] - The index to start searching from
28
28
  * @returns The first matching element, or undefined if none found
29
29
  *
30
30
  * @example
@@ -41,7 +41,7 @@ declare function find<T>(collection: ArrayLike<T> | null | undefined, predicate?
41
41
  * @template T, U
42
42
  * @param collection - The object to search
43
43
  * @param predicate - The type guard function to test each value
44
- * @param fromIndex - The index to start searching from
44
+ * @param [fromIndex] - The index to start searching from
45
45
  * @returns The first value that matches the type guard, or undefined if none found
46
46
  *
47
47
  * @example
@@ -54,8 +54,8 @@ declare function find<T extends object, U extends T[keyof T]>(collection: T | nu
54
54
  *
55
55
  * @template T
56
56
  * @param collection - The object to search
57
- * @param predicate - The function or shorthand to test each value
58
- * @param fromIndex - The index to start searching from
57
+ * @param [predicate] - The function or shorthand to test each value
58
+ * @param [fromIndex] - The index to start searching from
59
59
  * @returns The first matching value, or undefined if none found
60
60
  *
61
61
  * @example
@@ -10,7 +10,7 @@ import { ListIteratorTypeGuard } from "../_internal/ListIteratorTypeGuard.js";
10
10
  * @template T, U
11
11
  * @param collection - The array-like object to search
12
12
  * @param predicate - The type guard function to test each element
13
- * @param fromIndex - The index to start searching from
13
+ * @param [fromIndex] - The index to start searching from
14
14
  * @returns The first element that matches the type guard, or undefined if none found
15
15
  *
16
16
  * @example
@@ -23,8 +23,8 @@ declare function find<T, U extends T>(collection: ArrayLike<T> | null | undefine
23
23
  *
24
24
  * @template T
25
25
  * @param collection - The array-like object to search
26
- * @param predicate - The function or shorthand to test each element
27
- * @param fromIndex - The index to start searching from
26
+ * @param [predicate] - The function or shorthand to test each element
27
+ * @param [fromIndex] - The index to start searching from
28
28
  * @returns The first matching element, or undefined if none found
29
29
  *
30
30
  * @example
@@ -41,7 +41,7 @@ declare function find<T>(collection: ArrayLike<T> | null | undefined, predicate?
41
41
  * @template T, U
42
42
  * @param collection - The object to search
43
43
  * @param predicate - The type guard function to test each value
44
- * @param fromIndex - The index to start searching from
44
+ * @param [fromIndex] - The index to start searching from
45
45
  * @returns The first value that matches the type guard, or undefined if none found
46
46
  *
47
47
  * @example
@@ -54,8 +54,8 @@ declare function find<T extends object, U extends T[keyof T]>(collection: T | nu
54
54
  *
55
55
  * @template T
56
56
  * @param collection - The object to search
57
- * @param predicate - The function or shorthand to test each value
58
- * @param fromIndex - The index to start searching from
57
+ * @param [predicate] - The function or shorthand to test each value
58
+ * @param [fromIndex] - The index to start searching from
59
59
  * @returns The first matching value, or undefined if none found
60
60
  *
61
61
  * @example
@@ -6,7 +6,7 @@ const require_iteratee = require("../util/iteratee.js");
6
6
  *
7
7
  * @template T
8
8
  * @param source - The source array or object to search through.
9
- * @param doesMatch - The criteria to match. It can be a function, a partial object, a key-value pair, or a property name.
9
+ * @param [doesMatch=identity] - The criteria to match. It can be a function, a partial object, a key-value pair, or a property name.
10
10
  * @param [fromIndex=0] - The index to start the search from, defaults to 0.
11
11
  * @returns The first property value that has the specified property, or `undefined` if no match is found.
12
12
  *
@@ -6,7 +6,7 @@ import { iteratee } from "../util/iteratee.mjs";
6
6
  *
7
7
  * @template T
8
8
  * @param source - The source array or object to search through.
9
- * @param doesMatch - The criteria to match. It can be a function, a partial object, a key-value pair, or a property name.
9
+ * @param [doesMatch=identity] - The criteria to match. It can be a function, a partial object, a key-value pair, or a property name.
10
10
  * @param [fromIndex=0] - The index to start the search from, defaults to 0.
11
11
  * @returns The first property value that has the specified property, or `undefined` if no match is found.
12
12
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "es-toolkit",
3
- "version": "1.49.0-dev.1912+3552afed",
3
+ "version": "1.49.0-dev.1914+9bb1d03e",
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",