es-toolkit 1.26.1-dev.838 → 1.26.1-dev.839

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.
@@ -1,8 +1,82 @@
1
1
  type Iteratee<T> = PropertyKey | Partial<T> | ((value: T) => unknown);
2
+ /**
3
+ * Computes the difference between an array and another array using an iteratee function.
4
+ *
5
+ * @template T1, T2
6
+ * @param {ArrayLike<T1> | null | undefined} array - The primary array from which to derive the difference.
7
+ * @param {ArrayLike<T2>} values - The array containing elements to be excluded from the primary array.
8
+ * @param {Iteratee<T1 | T2>} iteratee - The iteratee invoked per element.
9
+ * @returns {T1[]} A new array containing the elements that are present in the primary array but not in the values array.
10
+ *
11
+ * @example
12
+ * const result = differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
13
+ * // result will be [1.2]
14
+ *
15
+ * @example
16
+ * const result = differenceBy([{ x: 2 }, { x: 1 }], [{ x: 1 }], 'x');
17
+ * // result will be [{ x: 2 }]
18
+ */
2
19
  declare function differenceBy<T1, T2>(array: ArrayLike<T1> | null | undefined, values: ArrayLike<T2>, iteratee: Iteratee<T1 | T2>): T1[];
20
+ /**
21
+ * Computes the difference between an array and two other arrays using an iteratee function.
22
+ *
23
+ * @template T1, T2, T3
24
+ * @param {ArrayLike<T1> | null | undefined} array - The primary array from which to derive the difference.
25
+ * @param {ArrayLike<T2>} values1 - The first array containing elements to be excluded from the primary array.
26
+ * @param {ArrayLike<T3>} values2 - The second array containing elements to be excluded from the primary array.
27
+ * @param {Iteratee<T1 | T2 | T3>} iteratee - The iteratee invoked per element.
28
+ * @returns {T1[]} A new array containing the elements that are present in the primary array but not in the values arrays.
29
+ *
30
+ * @example
31
+ * const result = differenceBy([2.1, 1.2], [2.3, 3.4], [1.2], Math.floor);
32
+ * // result will be []
33
+ */
3
34
  declare function differenceBy<T1, T2, T3>(array: ArrayLike<T1> | null | undefined, values1: ArrayLike<T2>, values2: ArrayLike<T3>, iteratee: Iteratee<T1 | T2 | T3>): T1[];
35
+ /**
36
+ * Computes the difference between an array and three other arrays using an iteratee function.
37
+ *
38
+ * @template T1, T2, T3, T4
39
+ * @param {ArrayLike<T1> | null | undefined} array - The primary array from which to derive the difference.
40
+ * @param {ArrayLike<T2>} values1 - The first array containing elements to be excluded from the primary array.
41
+ * @param {ArrayLike<T3>} values2 - The second array containing elements to be excluded from the primary array.
42
+ * @param {ArrayLike<T4>} values3 - The third array containing elements to be excluded from the primary array.
43
+ * @param {Iteratee<T1 | T2 | T3 | T4>} iteratee - The iteratee invoked per element.
44
+ * @returns {T1[]} A new array containing the elements that are present in the primary array but not in the values arrays.
45
+ *
46
+ * @example
47
+ * const result = differenceBy([2.1, 1.2], [2.3, 3.4], [1.2], [2.1], Math.floor);
48
+ * // result will be []
49
+ */
4
50
  declare function differenceBy<T1, T2, T3, T4>(array: ArrayLike<T1> | null | undefined, values1: ArrayLike<T2>, values2: ArrayLike<T3>, values3: ArrayLike<T4>, iteratee: Iteratee<T1 | T2 | T3 | T4>): T1[];
51
+ /**
52
+ * Computes the difference between an array and four other arrays using an iteratee function.
53
+ *
54
+ * @template T1, T2, T3, T4, T5
55
+ * @param {ArrayLike<T1> | null | undefined} array - The primary array from which to derive the difference.
56
+ * @param {ArrayLike<T2>} values1 - The first array containing elements to be excluded from the primary array.
57
+ * @param {ArrayLike<T3>} values2 - The second array containing elements to be excluded from the primary array.
58
+ * @param {ArrayLike<T4>} values3 - The third array containing elements to be excluded from the primary array.
59
+ * @param {ArrayLike<T5>} values4 - The fourth array containing elements to be excluded from the primary array.
60
+ * @param {Iteratee<T1 | T2 | T3 | T4 | T5>} iteratee - The iteratee invoked per element.
61
+ * @returns {T1[]} A new array containing the elements that are present in the primary array but not in the values arrays.
62
+ *
63
+ * @example
64
+ * const result = differenceBy([2.1, 1.2], [2.3, 3.4], [1.2], [2.1], [3.4], Math.floor);
65
+ * // result will be []
66
+ */
5
67
  declare function differenceBy<T1, T2, T3, T4, T5>(array: ArrayLike<T1> | null | undefined, values1: ArrayLike<T2>, values2: ArrayLike<T3>, values3: ArrayLike<T4>, values4: ArrayLike<T5>, iteratee: Iteratee<T1 | T2 | T3 | T4 | T5>): T1[];
68
+ /**
69
+ * Computes the difference between an array and multiple arrays using an iteratee function.
70
+ *
71
+ * @template T
72
+ * @param {ArrayLike<T> | null | undefined} array - The primary array from which to derive the difference.
73
+ * @param {...Array<ArrayLike<T>>} values - Multiple arrays containing elements to be excluded from the primary array.
74
+ * @returns {T[]} A new array containing the elements that are present in the primary array but not in the values arrays.
75
+ *
76
+ * @example
77
+ * const result = differenceBy([2.1, 1.2], [2.3, 3.4], [1.2], [2.1], [3.4], Math.floor);
78
+ * // result will be []
79
+ */
6
80
  declare function differenceBy<T>(array: ArrayLike<T> | null | undefined, ...values: Array<ArrayLike<T>>): T[];
7
81
 
8
82
  export { differenceBy };
@@ -1,8 +1,82 @@
1
1
  type Iteratee<T> = PropertyKey | Partial<T> | ((value: T) => unknown);
2
+ /**
3
+ * Computes the difference between an array and another array using an iteratee function.
4
+ *
5
+ * @template T1, T2
6
+ * @param {ArrayLike<T1> | null | undefined} array - The primary array from which to derive the difference.
7
+ * @param {ArrayLike<T2>} values - The array containing elements to be excluded from the primary array.
8
+ * @param {Iteratee<T1 | T2>} iteratee - The iteratee invoked per element.
9
+ * @returns {T1[]} A new array containing the elements that are present in the primary array but not in the values array.
10
+ *
11
+ * @example
12
+ * const result = differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
13
+ * // result will be [1.2]
14
+ *
15
+ * @example
16
+ * const result = differenceBy([{ x: 2 }, { x: 1 }], [{ x: 1 }], 'x');
17
+ * // result will be [{ x: 2 }]
18
+ */
2
19
  declare function differenceBy<T1, T2>(array: ArrayLike<T1> | null | undefined, values: ArrayLike<T2>, iteratee: Iteratee<T1 | T2>): T1[];
20
+ /**
21
+ * Computes the difference between an array and two other arrays using an iteratee function.
22
+ *
23
+ * @template T1, T2, T3
24
+ * @param {ArrayLike<T1> | null | undefined} array - The primary array from which to derive the difference.
25
+ * @param {ArrayLike<T2>} values1 - The first array containing elements to be excluded from the primary array.
26
+ * @param {ArrayLike<T3>} values2 - The second array containing elements to be excluded from the primary array.
27
+ * @param {Iteratee<T1 | T2 | T3>} iteratee - The iteratee invoked per element.
28
+ * @returns {T1[]} A new array containing the elements that are present in the primary array but not in the values arrays.
29
+ *
30
+ * @example
31
+ * const result = differenceBy([2.1, 1.2], [2.3, 3.4], [1.2], Math.floor);
32
+ * // result will be []
33
+ */
3
34
  declare function differenceBy<T1, T2, T3>(array: ArrayLike<T1> | null | undefined, values1: ArrayLike<T2>, values2: ArrayLike<T3>, iteratee: Iteratee<T1 | T2 | T3>): T1[];
35
+ /**
36
+ * Computes the difference between an array and three other arrays using an iteratee function.
37
+ *
38
+ * @template T1, T2, T3, T4
39
+ * @param {ArrayLike<T1> | null | undefined} array - The primary array from which to derive the difference.
40
+ * @param {ArrayLike<T2>} values1 - The first array containing elements to be excluded from the primary array.
41
+ * @param {ArrayLike<T3>} values2 - The second array containing elements to be excluded from the primary array.
42
+ * @param {ArrayLike<T4>} values3 - The third array containing elements to be excluded from the primary array.
43
+ * @param {Iteratee<T1 | T2 | T3 | T4>} iteratee - The iteratee invoked per element.
44
+ * @returns {T1[]} A new array containing the elements that are present in the primary array but not in the values arrays.
45
+ *
46
+ * @example
47
+ * const result = differenceBy([2.1, 1.2], [2.3, 3.4], [1.2], [2.1], Math.floor);
48
+ * // result will be []
49
+ */
4
50
  declare function differenceBy<T1, T2, T3, T4>(array: ArrayLike<T1> | null | undefined, values1: ArrayLike<T2>, values2: ArrayLike<T3>, values3: ArrayLike<T4>, iteratee: Iteratee<T1 | T2 | T3 | T4>): T1[];
51
+ /**
52
+ * Computes the difference between an array and four other arrays using an iteratee function.
53
+ *
54
+ * @template T1, T2, T3, T4, T5
55
+ * @param {ArrayLike<T1> | null | undefined} array - The primary array from which to derive the difference.
56
+ * @param {ArrayLike<T2>} values1 - The first array containing elements to be excluded from the primary array.
57
+ * @param {ArrayLike<T3>} values2 - The second array containing elements to be excluded from the primary array.
58
+ * @param {ArrayLike<T4>} values3 - The third array containing elements to be excluded from the primary array.
59
+ * @param {ArrayLike<T5>} values4 - The fourth array containing elements to be excluded from the primary array.
60
+ * @param {Iteratee<T1 | T2 | T3 | T4 | T5>} iteratee - The iteratee invoked per element.
61
+ * @returns {T1[]} A new array containing the elements that are present in the primary array but not in the values arrays.
62
+ *
63
+ * @example
64
+ * const result = differenceBy([2.1, 1.2], [2.3, 3.4], [1.2], [2.1], [3.4], Math.floor);
65
+ * // result will be []
66
+ */
5
67
  declare function differenceBy<T1, T2, T3, T4, T5>(array: ArrayLike<T1> | null | undefined, values1: ArrayLike<T2>, values2: ArrayLike<T3>, values3: ArrayLike<T4>, values4: ArrayLike<T5>, iteratee: Iteratee<T1 | T2 | T3 | T4 | T5>): T1[];
68
+ /**
69
+ * Computes the difference between an array and multiple arrays using an iteratee function.
70
+ *
71
+ * @template T
72
+ * @param {ArrayLike<T> | null | undefined} array - The primary array from which to derive the difference.
73
+ * @param {...Array<ArrayLike<T>>} values - Multiple arrays containing elements to be excluded from the primary array.
74
+ * @returns {T[]} A new array containing the elements that are present in the primary array but not in the values arrays.
75
+ *
76
+ * @example
77
+ * const result = differenceBy([2.1, 1.2], [2.3, 3.4], [1.2], [2.1], [3.4], Math.floor);
78
+ * // result will be []
79
+ */
6
80
  declare function differenceBy<T>(array: ArrayLike<T> | null | undefined, ...values: Array<ArrayLike<T>>): T[];
7
81
 
8
82
  export { differenceBy };
@@ -441,10 +441,17 @@ function iteratee(value) {
441
441
  return value;
442
442
  }
443
443
  case 'object': {
444
- return Array.isArray(value) ? matchesProperty(value[0], value[1]) : matches(value);
444
+ if (Array.isArray(value) && value.length === 2) {
445
+ return matchesProperty(value[0], value[1]);
446
+ }
447
+ return matches(value);
448
+ }
449
+ case 'string':
450
+ case 'symbol':
451
+ case 'number': {
452
+ return property(value);
445
453
  }
446
454
  }
447
- return property(value);
448
455
  }
449
456
 
450
457
  function differenceBy(arr, ...values) {
@@ -12,10 +12,17 @@ function iteratee(value) {
12
12
  return value;
13
13
  }
14
14
  case 'object': {
15
- return Array.isArray(value) ? matchesProperty(value[0], value[1]) : matches(value);
15
+ if (Array.isArray(value) && value.length === 2) {
16
+ return matchesProperty(value[0], value[1]);
17
+ }
18
+ return matches(value);
19
+ }
20
+ case 'string':
21
+ case 'symbol':
22
+ case 'number': {
23
+ return property(value);
16
24
  }
17
25
  }
18
- return property(value);
19
26
  }
20
27
 
21
28
  export { iteratee };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "es-toolkit",
3
3
  "description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
4
- "version": "1.26.1-dev.838+c5fa2654",
4
+ "version": "1.26.1-dev.839+9936d106",
5
5
  "homepage": "https://es-toolkit.slash.page",
6
6
  "bugs": "https://github.com/toss/es-toolkit/issues",
7
7
  "repository": {