es-toolkit 1.11.0-dev.261 → 1.11.0-dev.264

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,7 +1,4 @@
1
1
  import "../chunk-DDH7K4QM.mjs";
2
- import {
3
- without
4
- } from "../chunk-PYEYV7BY.mjs";
5
2
  import {
6
3
  xor
7
4
  } from "../chunk-L7FQX5MN.mjs";
@@ -20,18 +17,12 @@ import {
20
17
  import {
21
18
  zipWith
22
19
  } from "../chunk-4KYXHZ4R.mjs";
23
- import {
24
- union
25
- } from "../chunk-R6QA7PLZ.mjs";
26
20
  import {
27
21
  unionBy
28
22
  } from "../chunk-NFS7RWWE.mjs";
29
23
  import {
30
24
  unionWith
31
25
  } from "../chunk-2ZCITDMK.mjs";
32
- import {
33
- uniq
34
- } from "../chunk-DVK2N4KC.mjs";
35
26
  import {
36
27
  uniqBy
37
28
  } from "../chunk-B4COTK4K.mjs";
@@ -45,10 +36,8 @@ import {
45
36
  unzipWith
46
37
  } from "../chunk-IFNXROZR.mjs";
47
38
  import {
48
- sampleSize
49
- } from "../chunk-EHSKB6DF.mjs";
50
- import "../chunk-GIWAOOFY.mjs";
51
- import "../chunk-SYWMYQYJ.mjs";
39
+ without
40
+ } from "../chunk-PYEYV7BY.mjs";
52
41
  import {
53
42
  shuffle
54
43
  } from "../chunk-G7UQ5PUR.mjs";
@@ -71,8 +60,11 @@ import {
71
60
  toFilled
72
61
  } from "../chunk-OP4OAKQJ.mjs";
73
62
  import {
74
- intersectionWith
75
- } from "../chunk-XI7KRD2C.mjs";
63
+ union
64
+ } from "../chunk-R6QA7PLZ.mjs";
65
+ import {
66
+ uniq
67
+ } from "../chunk-DVK2N4KC.mjs";
76
68
  import {
77
69
  keyBy
78
70
  } from "../chunk-AJKZMN2V.mjs";
@@ -95,8 +87,10 @@ import {
95
87
  sample
96
88
  } from "../chunk-2KNLZB7V.mjs";
97
89
  import {
98
- flattenDeep
99
- } from "../chunk-ML727RRJ.mjs";
90
+ sampleSize
91
+ } from "../chunk-EHSKB6DF.mjs";
92
+ import "../chunk-GIWAOOFY.mjs";
93
+ import "../chunk-SYWMYQYJ.mjs";
100
94
  import {
101
95
  forEachRight
102
96
  } from "../chunk-IEA53J7P.mjs";
@@ -116,8 +110,8 @@ import {
116
110
  intersectionBy
117
111
  } from "../chunk-O6UXZR3U.mjs";
118
112
  import {
119
- differenceWith
120
- } from "../chunk-6NVQAHXP.mjs";
113
+ intersectionWith
114
+ } from "../chunk-XI7KRD2C.mjs";
121
115
  import {
122
116
  drop
123
117
  } from "../chunk-3EZAFZG3.mjs";
@@ -136,6 +130,9 @@ import {
136
130
  import {
137
131
  flatMap
138
132
  } from "../chunk-UY76KTPE.mjs";
133
+ import {
134
+ flattenDeep
135
+ } from "../chunk-ML727RRJ.mjs";
139
136
  import {
140
137
  flatten
141
138
  } from "../chunk-33MSBDC6.mjs";
@@ -154,6 +151,9 @@ import {
154
151
  import {
155
152
  differenceBy
156
153
  } from "../chunk-LVWX5B43.mjs";
154
+ import {
155
+ differenceWith
156
+ } from "../chunk-6NVQAHXP.mjs";
157
157
  import "../chunk-424M7IR7.mjs";
158
158
  export {
159
159
  chunk,
@@ -465,4 +465,36 @@ declare const startsWith: (str: string, target: string, position?: number) => bo
465
465
  */
466
466
  declare const endsWith: (str: string, target: string, position?: number) => boolean;
467
467
 
468
- export { chunk, endsWith, get, set, startsWith, zipObjectDeep };
468
+ /**
469
+ * Finds the element in an array that has the maximum value.
470
+ *
471
+ * @template T - The type of elements in the array.
472
+ * @param {T[]} items The array of elements to search.
473
+ * @returns {T} The element with the maximum value.
474
+ * @example
475
+ * // Returns 9
476
+ * max([3, 1, 4, 1, 5, 9])
477
+ *
478
+ * @example
479
+ * // Returns 8
480
+ * max([0, -3, 2, 8, 7])
481
+ */
482
+ declare function max<T>(items?: readonly T[]): T;
483
+
484
+ /**
485
+ * Finds the element in an array that has the minimum value.
486
+ *
487
+ * @template T - The type of elements in the array.
488
+ * @param {T[]} items The array of elements to search.
489
+ * @returns {T} The element with the minimum value.
490
+ * @example
491
+ * // Returns 1
492
+ * min([3, 1, 4, 1, 5, 9])
493
+ *
494
+ * @example
495
+ * // Returns -3
496
+ * min([0, -3, 2, 8, 7])
497
+ */
498
+ declare function min<T>(items?: readonly T[]): T;
499
+
500
+ export { chunk, endsWith, get, max, min, set, startsWith, zipObjectDeep };
@@ -465,4 +465,36 @@ declare const startsWith: (str: string, target: string, position?: number) => bo
465
465
  */
466
466
  declare const endsWith: (str: string, target: string, position?: number) => boolean;
467
467
 
468
- export { chunk, endsWith, get, set, startsWith, zipObjectDeep };
468
+ /**
469
+ * Finds the element in an array that has the maximum value.
470
+ *
471
+ * @template T - The type of elements in the array.
472
+ * @param {T[]} items The array of elements to search.
473
+ * @returns {T} The element with the maximum value.
474
+ * @example
475
+ * // Returns 9
476
+ * max([3, 1, 4, 1, 5, 9])
477
+ *
478
+ * @example
479
+ * // Returns 8
480
+ * max([0, -3, 2, 8, 7])
481
+ */
482
+ declare function max<T>(items?: readonly T[]): T;
483
+
484
+ /**
485
+ * Finds the element in an array that has the minimum value.
486
+ *
487
+ * @template T - The type of elements in the array.
488
+ * @param {T[]} items The array of elements to search.
489
+ * @returns {T} The element with the minimum value.
490
+ * @example
491
+ * // Returns 1
492
+ * min([3, 1, 4, 1, 5, 9])
493
+ *
494
+ * @example
495
+ * // Returns -3
496
+ * min([0, -3, 2, 8, 7])
497
+ */
498
+ declare function min<T>(items?: readonly T[]): T;
499
+
500
+ export { chunk, endsWith, get, max, min, set, startsWith, zipObjectDeep };
@@ -96,9 +96,11 @@ __export(compat_exports, {
96
96
  keyBy: () => keyBy,
97
97
  last: () => last,
98
98
  lowerCase: () => lowerCase,
99
+ max: () => max,
99
100
  maxBy: () => maxBy,
100
101
  mean: () => mean,
101
102
  meanBy: () => meanBy,
103
+ min: () => min,
102
104
  minBy: () => minBy,
103
105
  negate: () => negate,
104
106
  noop: () => noop,
@@ -338,11 +340,11 @@ function keyBy(arr, getKeyFromItem) {
338
340
  // src/array/maxBy.ts
339
341
  function maxBy(items, getValue) {
340
342
  let maxElement = items[0];
341
- let max = -Infinity;
343
+ let max2 = -Infinity;
342
344
  for (const element of items) {
343
345
  const value = getValue(element);
344
- if (value > max) {
345
- max = value;
346
+ if (value > max2) {
347
+ max2 = value;
346
348
  maxElement = element;
347
349
  }
348
350
  }
@@ -352,11 +354,11 @@ function maxBy(items, getValue) {
352
354
  // src/array/minBy.ts
353
355
  function minBy(items, getValue) {
354
356
  let minElement = items[0];
355
- let min = Infinity;
357
+ let min2 = Infinity;
356
358
  for (const element of items) {
357
359
  const value = getValue(element);
358
- if (value < min) {
359
- min = value;
360
+ if (value < min2) {
361
+ min2 = value;
360
362
  minElement = element;
361
363
  }
362
364
  }
@@ -1204,6 +1206,32 @@ var startsWith = (str, target, position = 0) => {
1204
1206
  var endsWith = (str, target, position = str.length) => {
1205
1207
  return str.endsWith(target, position);
1206
1208
  };
1209
+
1210
+ // src/compat/math/max.ts
1211
+ function max(items = []) {
1212
+ let maxElement = items[0];
1213
+ let max2 = void 0;
1214
+ for (const element of items) {
1215
+ if (max2 == null || element > max2) {
1216
+ max2 = element;
1217
+ maxElement = element;
1218
+ }
1219
+ }
1220
+ return maxElement;
1221
+ }
1222
+
1223
+ // src/compat/math/min.ts
1224
+ function min(items = []) {
1225
+ let minElement = items[0];
1226
+ let min2 = void 0;
1227
+ for (const element of items) {
1228
+ if (min2 == null || element < min2) {
1229
+ min2 = element;
1230
+ minElement = element;
1231
+ }
1232
+ }
1233
+ return minElement;
1234
+ }
1207
1235
  // Annotate the CommonJS export names for ESM import in node:
1208
1236
  0 && (module.exports = {
1209
1237
  AbortError,
@@ -1248,9 +1276,11 @@ var endsWith = (str, target, position = str.length) => {
1248
1276
  keyBy,
1249
1277
  last,
1250
1278
  lowerCase,
1279
+ max,
1251
1280
  maxBy,
1252
1281
  mean,
1253
1282
  meanBy,
1283
+ min,
1254
1284
  minBy,
1255
1285
  negate,
1256
1286
  noop,