es-toolkit 1.6.1-dev.143 → 1.6.1-dev.145

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,16 +1,16 @@
1
1
  import "../chunk-N6EM6ETS.mjs";
2
- import {
3
- once
4
- } from "../chunk-CMBC4MXG.mjs";
5
- import {
6
- throttle
7
- } from "../chunk-QOJGMVVR.mjs";
8
2
  import {
9
3
  debounce
10
4
  } from "../chunk-3IP4JVLL.mjs";
11
5
  import {
12
6
  noop
13
7
  } from "../chunk-LKXCOLNY.mjs";
8
+ import {
9
+ once
10
+ } from "../chunk-CMBC4MXG.mjs";
11
+ import {
12
+ throttle
13
+ } from "../chunk-QOJGMVVR.mjs";
14
14
  import "../chunk-2MM5EJJX.mjs";
15
15
  export {
16
16
  debounce,
package/dist/index.d.mts CHANGED
@@ -9,6 +9,7 @@ export { dropRight } from './array/dropRight.mjs';
9
9
  export { dropRightWhile } from './array/dropRightWhile.mjs';
10
10
  export { dropWhile } from './array/dropWhile.mjs';
11
11
  export { fill } from './array/fill.mjs';
12
+ export { forEachRight } from './array/forEachRight.mjs';
12
13
  export { groupBy } from './array/groupBy.mjs';
13
14
  export { intersection } from './array/intersection.mjs';
14
15
  export { intersectionBy } from './array/intersectionBy.mjs';
package/dist/index.d.ts CHANGED
@@ -9,6 +9,7 @@ export { dropRight } from './array/dropRight.js';
9
9
  export { dropRightWhile } from './array/dropRightWhile.js';
10
10
  export { dropWhile } from './array/dropWhile.js';
11
11
  export { fill } from './array/fill.js';
12
+ export { forEachRight } from './array/forEachRight.js';
12
13
  export { groupBy } from './array/groupBy.js';
13
14
  export { intersection } from './array/intersection.js';
14
15
  export { intersectionBy } from './array/intersectionBy.js';
package/dist/index.js CHANGED
@@ -49,6 +49,7 @@ __export(src_exports, {
49
49
  dropRightWhile: () => dropRightWhile,
50
50
  dropWhile: () => dropWhile,
51
51
  fill: () => fill,
52
+ forEachRight: () => forEachRight,
52
53
  groupBy: () => groupBy,
53
54
  intersection: () => intersection,
54
55
  intersectionBy: () => intersectionBy,
@@ -195,6 +196,14 @@ function fill(arr, value, start = 0, end = arr.length) {
195
196
  return arr;
196
197
  }
197
198
 
199
+ // src/array/forEachRight.ts
200
+ function forEachRight(arr, callback) {
201
+ for (let i = arr.length - 1; i >= 0; i--) {
202
+ const element = arr[i];
203
+ callback(element, i, arr);
204
+ }
205
+ }
206
+
198
207
  // src/array/groupBy.ts
199
208
  function groupBy(arr, getKeyFromItem) {
200
209
  const result = {};
@@ -289,34 +298,6 @@ function sample(arr) {
289
298
  return arr[randomIndex];
290
299
  }
291
300
 
292
- // src/math/clamp.ts
293
- function clamp(value, bound1, bound2) {
294
- if (bound2 == null) {
295
- return Math.min(value, bound1);
296
- }
297
- return Math.min(Math.max(value, bound1), bound2);
298
- }
299
-
300
- // src/math/sum.ts
301
- function sum(nums) {
302
- let result = 0;
303
- for (const num of nums) {
304
- result += num;
305
- }
306
- return result;
307
- }
308
-
309
- // src/math/mean.ts
310
- function mean(nums) {
311
- return sum(nums) / nums.length;
312
- }
313
-
314
- // src/math/meanBy.ts
315
- function meanBy(items, getValue) {
316
- const nums = items.map((x) => getValue(x));
317
- return mean(nums);
318
- }
319
-
320
301
  // src/math/random.ts
321
302
  function random(minimum, maximum) {
322
303
  if (maximum == null) {
@@ -334,35 +315,6 @@ function randomInt(minimum, maximum) {
334
315
  return Math.floor(random(minimum, maximum));
335
316
  }
336
317
 
337
- // src/math/round.ts
338
- function round(value, precision = 0) {
339
- if (!Number.isInteger(precision)) {
340
- throw new Error("Precision must be an integer.");
341
- }
342
- const multiplier = Math.pow(10, precision);
343
- return Math.round(value * multiplier) / multiplier;
344
- }
345
-
346
- // src/math/range.ts
347
- function range(start, end, step) {
348
- if (end == null) {
349
- end = start;
350
- start = 0;
351
- }
352
- if (step == null) {
353
- step = 1;
354
- }
355
- if (!Number.isInteger(step) || step === 0) {
356
- throw new Error(`The step value must be a non-zero integer.`);
357
- }
358
- const length = Math.max(Math.ceil((end - start) / step), 0);
359
- const result = new Array(length);
360
- for (let i = 0; i < length; i++) {
361
- result[i] = start + i * step;
362
- }
363
- return result;
364
- }
365
-
366
318
  // src/array/sampleSize.ts
367
319
  function sampleSize(array, size) {
368
320
  if (size > array.length) {
@@ -620,6 +572,63 @@ function throttle(func, throttleMs) {
620
572
  return throttledFunction;
621
573
  }
622
574
 
575
+ // src/math/clamp.ts
576
+ function clamp(value, bound1, bound2) {
577
+ if (bound2 == null) {
578
+ return Math.min(value, bound1);
579
+ }
580
+ return Math.min(Math.max(value, bound1), bound2);
581
+ }
582
+
583
+ // src/math/sum.ts
584
+ function sum(nums) {
585
+ let result = 0;
586
+ for (const num of nums) {
587
+ result += num;
588
+ }
589
+ return result;
590
+ }
591
+
592
+ // src/math/mean.ts
593
+ function mean(nums) {
594
+ return sum(nums) / nums.length;
595
+ }
596
+
597
+ // src/math/meanBy.ts
598
+ function meanBy(items, getValue) {
599
+ const nums = items.map((x) => getValue(x));
600
+ return mean(nums);
601
+ }
602
+
603
+ // src/math/round.ts
604
+ function round(value, precision = 0) {
605
+ if (!Number.isInteger(precision)) {
606
+ throw new Error("Precision must be an integer.");
607
+ }
608
+ const multiplier = Math.pow(10, precision);
609
+ return Math.round(value * multiplier) / multiplier;
610
+ }
611
+
612
+ // src/math/range.ts
613
+ function range(start, end, step) {
614
+ if (end == null) {
615
+ end = start;
616
+ start = 0;
617
+ }
618
+ if (step == null) {
619
+ step = 1;
620
+ }
621
+ if (!Number.isInteger(step) || step === 0) {
622
+ throw new Error(`The step value must be a non-zero integer.`);
623
+ }
624
+ const length = Math.max(Math.ceil((end - start) / step), 0);
625
+ const result = new Array(length);
626
+ for (let i = 0; i < length; i++) {
627
+ result[i] = start + i * step;
628
+ }
629
+ return result;
630
+ }
631
+
623
632
  // src/object/omit.ts
624
633
  function omit(obj, keys) {
625
634
  const result = __spreadValues({}, obj);
@@ -716,6 +725,7 @@ function delay(ms, { signal } = {}) {
716
725
  dropRightWhile,
717
726
  dropWhile,
718
727
  fill,
728
+ forEachRight,
719
729
  groupBy,
720
730
  intersection,
721
731
  intersectionBy,