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

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.
@@ -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
  }
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.1913+2cf42742",
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",