es-toolkit 1.29.0 → 1.30.0

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.
Files changed (134) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/_chunk/{rangeRight-w3WrXN.js → range-HnEIT7.js} +0 -17
  3. package/dist/_chunk/{zipWith-Bb2eZI.js → zipWith-nbzldx.js} +11 -10
  4. package/dist/array/index.d.mts +1 -0
  5. package/dist/array/index.d.ts +1 -0
  6. package/dist/array/index.js +12 -2
  7. package/dist/array/index.mjs +1 -0
  8. package/dist/array/pull.d.mts +19 -0
  9. package/dist/array/pull.d.ts +19 -0
  10. package/dist/array/pull.mjs +11 -0
  11. package/dist/browser.global.js +1 -1
  12. package/dist/browser.global.js.map +1 -1
  13. package/dist/compat/_internal/isIndex.mjs +2 -2
  14. package/dist/compat/_internal/isPrototype.mjs +1 -1
  15. package/dist/compat/array/differenceWith.d.mts +91 -0
  16. package/dist/compat/array/differenceWith.d.ts +91 -0
  17. package/dist/compat/array/differenceWith.mjs +19 -0
  18. package/dist/compat/array/map.d.mts +182 -0
  19. package/dist/compat/array/map.d.ts +182 -0
  20. package/dist/compat/array/map.mjs +21 -0
  21. package/dist/compat/array/nth.d.mts +14 -0
  22. package/dist/compat/array/nth.d.ts +14 -0
  23. package/dist/compat/array/nth.mjs +15 -0
  24. package/dist/compat/array/pull.d.mts +19 -0
  25. package/dist/compat/array/pull.d.ts +19 -0
  26. package/dist/compat/array/pull.mjs +8 -0
  27. package/dist/compat/array/takeRightWhile.d.mts +84 -0
  28. package/dist/compat/array/takeRightWhile.d.ts +84 -0
  29. package/dist/compat/array/takeRightWhile.mjs +15 -0
  30. package/dist/compat/function/after.d.mts +31 -0
  31. package/dist/compat/function/after.d.ts +31 -0
  32. package/dist/compat/function/after.mjs +15 -0
  33. package/dist/compat/function/delay.d.mts +29 -0
  34. package/dist/compat/function/delay.d.ts +29 -0
  35. package/dist/compat/function/delay.mjs +10 -0
  36. package/dist/compat/function/nthArg.d.mts +22 -0
  37. package/dist/compat/function/nthArg.d.ts +22 -0
  38. package/dist/compat/function/nthArg.mjs +9 -0
  39. package/dist/compat/index.d.mts +30 -13
  40. package/dist/compat/index.d.ts +30 -13
  41. package/dist/compat/index.js +369 -56
  42. package/dist/compat/index.mjs +31 -13
  43. package/dist/compat/math/range.d.mts +47 -0
  44. package/dist/compat/math/range.d.ts +47 -0
  45. package/dist/compat/math/range.mjs +26 -0
  46. package/dist/compat/math/rangeRight.d.mts +47 -0
  47. package/dist/compat/math/rangeRight.d.ts +47 -0
  48. package/dist/compat/math/rangeRight.mjs +26 -0
  49. package/dist/compat/math/sumBy.d.mts +2 -2
  50. package/dist/compat/math/sumBy.d.ts +2 -2
  51. package/dist/compat/object/findKey.d.mts +58 -0
  52. package/dist/compat/object/findKey.d.ts +58 -0
  53. package/dist/compat/object/findKey.mjs +30 -0
  54. package/dist/compat/object/keys.d.mts +22 -0
  55. package/dist/compat/object/keys.d.ts +22 -0
  56. package/dist/compat/object/keys.mjs +32 -0
  57. package/dist/compat/object/propertyOf.d.mts +22 -0
  58. package/dist/compat/object/propertyOf.d.ts +22 -0
  59. package/dist/compat/object/propertyOf.mjs +9 -0
  60. package/dist/compat/predicate/isArrayLike.d.mts +1 -1
  61. package/dist/compat/predicate/isArrayLike.d.ts +1 -1
  62. package/dist/compat/predicate/isArrayLikeObject.d.mts +1 -1
  63. package/dist/compat/predicate/isArrayLikeObject.d.ts +1 -1
  64. package/dist/compat/predicate/isElement.d.mts +1 -1
  65. package/dist/compat/predicate/isElement.d.ts +1 -1
  66. package/dist/compat/predicate/isFinite.d.mts +1 -1
  67. package/dist/compat/predicate/isFinite.d.ts +1 -1
  68. package/dist/compat/predicate/isNaN.d.mts +1 -1
  69. package/dist/compat/predicate/isNaN.d.ts +1 -1
  70. package/dist/compat/predicate/isObject.d.mts +1 -1
  71. package/dist/compat/predicate/isObject.d.ts +1 -1
  72. package/dist/compat/predicate/isObjectLike.d.mts +1 -1
  73. package/dist/compat/predicate/isObjectLike.d.ts +1 -1
  74. package/dist/compat/string/deburr.d.mts +22 -0
  75. package/dist/compat/string/deburr.d.ts +22 -0
  76. package/dist/compat/string/deburr.mjs +8 -0
  77. package/dist/compat/string/escapeRegExp.d.mts +14 -0
  78. package/dist/compat/string/escapeRegExp.d.ts +14 -0
  79. package/dist/compat/string/escapeRegExp.mjs +8 -0
  80. package/dist/compat/string/lowerFirst.d.mts +14 -0
  81. package/dist/compat/string/lowerFirst.d.ts +14 -0
  82. package/dist/compat/string/lowerFirst.mjs +8 -0
  83. package/dist/compat/string/toLower.d.mts +20 -0
  84. package/dist/compat/string/toLower.d.ts +20 -0
  85. package/dist/compat/string/toLower.mjs +7 -0
  86. package/dist/compat/string/unescape.d.mts +16 -0
  87. package/dist/compat/string/unescape.d.ts +16 -0
  88. package/dist/compat/string/unescape.mjs +8 -0
  89. package/dist/compat/string/upperFirst.d.mts +14 -0
  90. package/dist/compat/string/upperFirst.d.ts +14 -0
  91. package/dist/compat/string/upperFirst.mjs +8 -0
  92. package/dist/compat/util/invoke.d.mts +23 -0
  93. package/dist/compat/util/invoke.d.ts +23 -0
  94. package/dist/compat/util/invoke.mjs +48 -0
  95. package/dist/compat/util/lt.d.mts +15 -0
  96. package/dist/compat/util/lt.d.ts +15 -0
  97. package/dist/compat/util/lt.mjs +10 -0
  98. package/dist/compat/util/lte.d.mts +15 -0
  99. package/dist/compat/util/lte.d.ts +15 -0
  100. package/dist/compat/util/lte.mjs +10 -0
  101. package/dist/compat/util/method.d.mts +22 -0
  102. package/dist/compat/util/method.d.ts +22 -0
  103. package/dist/compat/util/method.mjs +9 -0
  104. package/dist/compat/util/now.d.mts +18 -0
  105. package/dist/compat/util/now.d.ts +18 -0
  106. package/dist/compat/util/now.mjs +5 -0
  107. package/dist/compat/util/stubArray.d.mts +10 -0
  108. package/dist/compat/util/stubArray.d.ts +10 -0
  109. package/dist/compat/util/stubArray.mjs +5 -0
  110. package/dist/compat/util/stubFalse.d.mts +10 -0
  111. package/dist/compat/util/stubFalse.d.ts +10 -0
  112. package/dist/compat/util/stubFalse.mjs +5 -0
  113. package/dist/compat/util/stubObject.d.mts +10 -0
  114. package/dist/compat/util/stubObject.d.ts +10 -0
  115. package/dist/compat/util/stubObject.mjs +5 -0
  116. package/dist/compat/util/stubString.d.mts +10 -0
  117. package/dist/compat/util/stubString.d.ts +10 -0
  118. package/dist/compat/util/stubString.mjs +5 -0
  119. package/dist/compat/util/stubTrue.d.mts +10 -0
  120. package/dist/compat/util/stubTrue.d.ts +10 -0
  121. package/dist/compat/util/stubTrue.mjs +5 -0
  122. package/dist/compat/util/toArray.mjs +0 -3
  123. package/dist/compat/util/toPlainObject.d.mts +16 -0
  124. package/dist/compat/util/toPlainObject.d.ts +16 -0
  125. package/dist/compat/util/toPlainObject.mjs +24 -0
  126. package/dist/index.d.mts +1 -0
  127. package/dist/index.d.ts +1 -0
  128. package/dist/index.js +13 -12
  129. package/dist/index.mjs +1 -0
  130. package/dist/math/index.js +26 -10
  131. package/package.json +1 -1
  132. package/dist/compat/util/uniqueId.d.mts +0 -25
  133. package/dist/compat/util/uniqueId.d.ts +0 -25
  134. package/dist/compat/util/uniqueId.mjs +0 -7
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Checks if value is less than or equal to other.
3
+ *
4
+ * @param {unknown} value The value to compare.
5
+ * @param {unknown} other The other value to compare.
6
+ * @returns {boolean} Returns `true` if value is less than or equal to other, else `false`.
7
+ *
8
+ * @example
9
+ * lte(1, 3); // => true
10
+ * lte(3, 3); // => true
11
+ * lte(3, 1); // => false
12
+ */
13
+ declare function lte(value: unknown, other: unknown): boolean;
14
+
15
+ export { lte };
@@ -0,0 +1,10 @@
1
+ import { toNumber } from './toNumber.mjs';
2
+
3
+ function lte(value, other) {
4
+ if (typeof value === 'string' && typeof other === 'string') {
5
+ return value <= other;
6
+ }
7
+ return toNumber(value) <= toNumber(other);
8
+ }
9
+
10
+ export { lte };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Creates a function that invokes the method at `path` of a given object with the provided arguments.
3
+ *
4
+ * @param {PropertyKey | PropertyKey[]} path - The path of the method to invoke.
5
+ * @param {...any} args - The arguments to invoke the method with.
6
+ * @returns {(object?: unknown) => any} - Returns a new function that takes an object and invokes the method at `path` with `args`.
7
+ *
8
+ * @example
9
+ * const object = {
10
+ * a: {
11
+ * b: function (x, y) {
12
+ * return x + y;
13
+ * }
14
+ * }
15
+ * };
16
+ *
17
+ * const add = method('a.b', 1, 2);
18
+ * console.log(add(object)); // => 3
19
+ */
20
+ declare function method(path: PropertyKey | PropertyKey[], ...args: any[]): (object?: unknown) => any;
21
+
22
+ export { method };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Creates a function that invokes the method at `path` of a given object with the provided arguments.
3
+ *
4
+ * @param {PropertyKey | PropertyKey[]} path - The path of the method to invoke.
5
+ * @param {...any} args - The arguments to invoke the method with.
6
+ * @returns {(object?: unknown) => any} - Returns a new function that takes an object and invokes the method at `path` with `args`.
7
+ *
8
+ * @example
9
+ * const object = {
10
+ * a: {
11
+ * b: function (x, y) {
12
+ * return x + y;
13
+ * }
14
+ * }
15
+ * };
16
+ *
17
+ * const add = method('a.b', 1, 2);
18
+ * console.log(add(object)); // => 3
19
+ */
20
+ declare function method(path: PropertyKey | PropertyKey[], ...args: any[]): (object?: unknown) => any;
21
+
22
+ export { method };
@@ -0,0 +1,9 @@
1
+ import { invoke } from './invoke.mjs';
2
+
3
+ function method(path, ...args) {
4
+ return function (object) {
5
+ return invoke(object, path, args);
6
+ };
7
+ }
8
+
9
+ export { method };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Returns the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC.
3
+ *
4
+ * @returns {number} The current time in milliseconds.
5
+ *
6
+ * @example
7
+ * const currentTime = now();
8
+ * console.log(currentTime); // Outputs the current time in milliseconds
9
+ *
10
+ * @example
11
+ * const startTime = now();
12
+ * // Some time-consuming operation
13
+ * const endTime = now();
14
+ * console.log(`Operation took ${endTime - startTime} milliseconds`);
15
+ */
16
+ declare function now(): number;
17
+
18
+ export { now };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Returns the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC.
3
+ *
4
+ * @returns {number} The current time in milliseconds.
5
+ *
6
+ * @example
7
+ * const currentTime = now();
8
+ * console.log(currentTime); // Outputs the current time in milliseconds
9
+ *
10
+ * @example
11
+ * const startTime = now();
12
+ * // Some time-consuming operation
13
+ * const endTime = now();
14
+ * console.log(`Operation took ${endTime - startTime} milliseconds`);
15
+ */
16
+ declare function now(): number;
17
+
18
+ export { now };
@@ -0,0 +1,5 @@
1
+ function now() {
2
+ return Date.now();
3
+ }
4
+
5
+ export { now };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Returns a new empty array.
3
+ *
4
+ * @returns {Array} A new empty array.
5
+ * @example
6
+ * stubArray() // Returns []
7
+ */
8
+ declare function stubArray(): [];
9
+
10
+ export { stubArray };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Returns a new empty array.
3
+ *
4
+ * @returns {Array} A new empty array.
5
+ * @example
6
+ * stubArray() // Returns []
7
+ */
8
+ declare function stubArray(): [];
9
+
10
+ export { stubArray };
@@ -0,0 +1,5 @@
1
+ function stubArray() {
2
+ return [];
3
+ }
4
+
5
+ export { stubArray };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Returns false.
3
+ *
4
+ * @returns {boolean} false.
5
+ * @example
6
+ * stubFalse() // Returns false
7
+ */
8
+ declare function stubFalse(): boolean;
9
+
10
+ export { stubFalse };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Returns false.
3
+ *
4
+ * @returns {boolean} false.
5
+ * @example
6
+ * stubFalse() // Returns false
7
+ */
8
+ declare function stubFalse(): boolean;
9
+
10
+ export { stubFalse };
@@ -0,0 +1,5 @@
1
+ function stubFalse() {
2
+ return false;
3
+ }
4
+
5
+ export { stubFalse };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Returns an empty object.
3
+ *
4
+ * @returns {Object} An empty object.
5
+ * @example
6
+ * stubObject() // Returns {}
7
+ */
8
+ declare function stubObject(): {};
9
+
10
+ export { stubObject };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Returns an empty object.
3
+ *
4
+ * @returns {Object} An empty object.
5
+ * @example
6
+ * stubObject() // Returns {}
7
+ */
8
+ declare function stubObject(): {};
9
+
10
+ export { stubObject };
@@ -0,0 +1,5 @@
1
+ function stubObject() {
2
+ return {};
3
+ }
4
+
5
+ export { stubObject };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Returns an empty string.
3
+ *
4
+ * @returns {string} An empty string.
5
+ * @example
6
+ * stubString() // Returns ''
7
+ */
8
+ declare function stubString(): '';
9
+
10
+ export { stubString };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Returns an empty string.
3
+ *
4
+ * @returns {string} An empty string.
5
+ * @example
6
+ * stubString() // Returns ''
7
+ */
8
+ declare function stubString(): '';
9
+
10
+ export { stubString };
@@ -0,0 +1,5 @@
1
+ function stubString() {
2
+ return '';
3
+ }
4
+
5
+ export { stubString };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Returns true.
3
+ *
4
+ * @returns {boolean} true.
5
+ * @example
6
+ * stubTrue() // Returns true
7
+ */
8
+ declare function stubTrue(): boolean;
9
+
10
+ export { stubTrue };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Returns true.
3
+ *
4
+ * @returns {boolean} true.
5
+ * @example
6
+ * stubTrue() // Returns true
7
+ */
8
+ declare function stubTrue(): boolean;
9
+
10
+ export { stubTrue };
@@ -0,0 +1,5 @@
1
+ function stubTrue() {
2
+ return true;
3
+ }
4
+
5
+ export { stubTrue };
@@ -8,9 +8,6 @@ function toArray(value) {
8
8
  if (isArrayLike(value) || isMap(value)) {
9
9
  return Array.from(value);
10
10
  }
11
- if (typeof value === 'string') {
12
- return value.split('');
13
- }
14
11
  if (typeof value === 'object') {
15
12
  return Object.values(value);
16
13
  }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Converts value to a plain object flattening inherited enumerable string keyed properties of value to own properties of the plain object.
3
+ *
4
+ * @param {any} value The value to convert.
5
+ * @returns {Record<string, any>} Returns the converted plain object.
6
+ *
7
+ * @example
8
+ * function Foo() {
9
+ * this.b = 2;
10
+ * }
11
+ * Foo.prototype.c = 3;
12
+ * toPlainObject(new Foo()); // { b: 2, c: 3 }
13
+ */
14
+ declare function toPlainObject(value: any): Record<string, any>;
15
+
16
+ export { toPlainObject };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Converts value to a plain object flattening inherited enumerable string keyed properties of value to own properties of the plain object.
3
+ *
4
+ * @param {any} value The value to convert.
5
+ * @returns {Record<string, any>} Returns the converted plain object.
6
+ *
7
+ * @example
8
+ * function Foo() {
9
+ * this.b = 2;
10
+ * }
11
+ * Foo.prototype.c = 3;
12
+ * toPlainObject(new Foo()); // { b: 2, c: 3 }
13
+ */
14
+ declare function toPlainObject(value: any): Record<string, any>;
15
+
16
+ export { toPlainObject };
@@ -0,0 +1,24 @@
1
+ import { keysIn } from '../object/keysIn.mjs';
2
+
3
+ function toPlainObject(value) {
4
+ const plainObject = {};
5
+ const valueKeys = keysIn(value);
6
+ for (let i = 0; i < valueKeys.length; i++) {
7
+ const key = valueKeys[i];
8
+ const objValue = value[key];
9
+ if (key === '__proto__') {
10
+ Object.defineProperty(plainObject, key, {
11
+ configurable: true,
12
+ enumerable: true,
13
+ value: objValue,
14
+ writable: true,
15
+ });
16
+ }
17
+ else {
18
+ plainObject[key] = objValue;
19
+ }
20
+ }
21
+ return plainObject;
22
+ }
23
+
24
+ export { toPlainObject };
package/dist/index.d.mts CHANGED
@@ -29,6 +29,7 @@ export { maxBy } from './array/maxBy.mjs';
29
29
  export { minBy } from './array/minBy.mjs';
30
30
  export { orderBy } from './array/orderBy.mjs';
31
31
  export { partition } from './array/partition.mjs';
32
+ export { pull } from './array/pull.mjs';
32
33
  export { pullAt } from './array/pullAt.mjs';
33
34
  export { sample } from './array/sample.mjs';
34
35
  export { sampleSize } from './array/sampleSize.mjs';
package/dist/index.d.ts CHANGED
@@ -29,6 +29,7 @@ export { maxBy } from './array/maxBy.js';
29
29
  export { minBy } from './array/minBy.js';
30
30
  export { orderBy } from './array/orderBy.js';
31
31
  export { partition } from './array/partition.js';
32
+ export { pull } from './array/pull.js';
32
33
  export { pullAt } from './array/pullAt.js';
33
34
  export { sample } from './array/sample.js';
34
35
  export { sampleSize } from './array/sampleSize.js';
package/dist/index.js CHANGED
@@ -2,13 +2,13 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const zipWith = require('./_chunk/zipWith-Bb2eZI.js');
5
+ const zipWith = require('./_chunk/zipWith-nbzldx.js');
6
6
  const array_index = require('./array/index.js');
7
7
  const promise_index = require('./_chunk/index-BGZDR9.js');
8
8
  const unary = require('./_chunk/unary-CcTNuC.js');
9
9
  const function_index = require('./function/index.js');
10
10
  const noop = require('./_chunk/noop-2IwLUk.js');
11
- const rangeRight = require('./_chunk/rangeRight-w3WrXN.js');
11
+ const range = require('./_chunk/range-HnEIT7.js');
12
12
  const randomInt = require('./_chunk/randomInt-CF7bZK.js');
13
13
  const math_index = require('./math/index.js');
14
14
  const toMerged = require('./_chunk/toMerged-DGFrN7.js');
@@ -52,6 +52,7 @@ exports.last = zipWith.last;
52
52
  exports.maxBy = zipWith.maxBy;
53
53
  exports.minBy = zipWith.minBy;
54
54
  exports.partition = zipWith.partition;
55
+ exports.pull = zipWith.pull;
55
56
  exports.pullAt = zipWith.pullAt;
56
57
  exports.sample = zipWith.sample;
57
58
  exports.sampleSize = zipWith.sampleSize;
@@ -59,7 +60,6 @@ exports.shuffle = zipWith.shuffle;
59
60
  exports.tail = zipWith.tail;
60
61
  exports.take = zipWith.take;
61
62
  exports.takeRight = zipWith.takeRight;
62
- exports.takeRightWhile = zipWith.takeRightWhile;
63
63
  exports.takeWhile = zipWith.takeWhile;
64
64
  exports.toFilled = zipWith.toFilled;
65
65
  exports.union = zipWith.union;
@@ -79,6 +79,7 @@ exports.zipObject = zipWith.zipObject;
79
79
  exports.zipWith = zipWith.zipWith;
80
80
  exports.orderBy = array_index.orderBy;
81
81
  exports.sortBy = array_index.sortBy;
82
+ exports.takeRightWhile = array_index.takeRightWhile;
82
83
  exports.AbortError = promise_index.AbortError;
83
84
  exports.TimeoutError = promise_index.TimeoutError;
84
85
  exports.delay = promise_index.delay;
@@ -103,17 +104,17 @@ exports.curryRight = function_index.curryRight;
103
104
  exports.spread = function_index.spread;
104
105
  exports.throttle = function_index.throttle;
105
106
  exports.noop = noop.noop;
106
- exports.clamp = rangeRight.clamp;
107
- exports.inRange = rangeRight.inRange;
108
- exports.mean = rangeRight.mean;
109
- exports.meanBy = rangeRight.meanBy;
110
- exports.median = rangeRight.median;
111
- exports.medianBy = rangeRight.medianBy;
112
- exports.range = rangeRight.range;
113
- exports.rangeRight = rangeRight.rangeRight;
114
- exports.sum = rangeRight.sum;
107
+ exports.clamp = range.clamp;
108
+ exports.inRange = range.inRange;
109
+ exports.mean = range.mean;
110
+ exports.meanBy = range.meanBy;
111
+ exports.median = range.median;
112
+ exports.medianBy = range.medianBy;
113
+ exports.range = range.range;
114
+ exports.sum = range.sum;
115
115
  exports.random = randomInt.random;
116
116
  exports.randomInt = randomInt.randomInt;
117
+ exports.rangeRight = math_index.rangeRight;
117
118
  exports.round = math_index.round;
118
119
  exports.sumBy = math_index.sumBy;
119
120
  exports.clone = toMerged.clone;
package/dist/index.mjs CHANGED
@@ -29,6 +29,7 @@ export { maxBy } from './array/maxBy.mjs';
29
29
  export { minBy } from './array/minBy.mjs';
30
30
  export { orderBy } from './array/orderBy.mjs';
31
31
  export { partition } from './array/partition.mjs';
32
+ export { pull } from './array/pull.mjs';
32
33
  export { pullAt } from './array/pullAt.mjs';
33
34
  export { sample } from './array/sample.mjs';
34
35
  export { sampleSize } from './array/sampleSize.mjs';
@@ -2,9 +2,25 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const rangeRight = require('../_chunk/rangeRight-w3WrXN.js');
5
+ const range = require('../_chunk/range-HnEIT7.js');
6
6
  const randomInt = require('../_chunk/randomInt-CF7bZK.js');
7
7
 
8
+ function rangeRight(start, end, step = 1) {
9
+ if (end == null) {
10
+ end = start;
11
+ start = 0;
12
+ }
13
+ if (!Number.isInteger(step) || step === 0) {
14
+ throw new Error(`The step value must be a non-zero integer.`);
15
+ }
16
+ const length = Math.max(Math.ceil((end - start) / step), 0);
17
+ const result = new Array(length);
18
+ for (let i = 0; i < length; i++) {
19
+ result[i] = start + (length - i - 1) * step;
20
+ }
21
+ return result;
22
+ }
23
+
8
24
  function round(value, precision = 0) {
9
25
  if (!Number.isInteger(precision)) {
10
26
  throw new Error('Precision must be an integer.');
@@ -21,16 +37,16 @@ function sumBy(items, getValue) {
21
37
  return result;
22
38
  }
23
39
 
24
- exports.clamp = rangeRight.clamp;
25
- exports.inRange = rangeRight.inRange;
26
- exports.mean = rangeRight.mean;
27
- exports.meanBy = rangeRight.meanBy;
28
- exports.median = rangeRight.median;
29
- exports.medianBy = rangeRight.medianBy;
30
- exports.range = rangeRight.range;
31
- exports.rangeRight = rangeRight.rangeRight;
32
- exports.sum = rangeRight.sum;
40
+ exports.clamp = range.clamp;
41
+ exports.inRange = range.inRange;
42
+ exports.mean = range.mean;
43
+ exports.meanBy = range.meanBy;
44
+ exports.median = range.median;
45
+ exports.medianBy = range.medianBy;
46
+ exports.range = range.range;
47
+ exports.sum = range.sum;
33
48
  exports.random = randomInt.random;
34
49
  exports.randomInt = randomInt.randomInt;
50
+ exports.rangeRight = rangeRight;
35
51
  exports.round = round;
36
52
  exports.sumBy = sumBy;
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.29.0",
4
+ "version": "1.30.0",
5
5
  "homepage": "https://es-toolkit.slash.page",
6
6
  "bugs": "https://github.com/toss/es-toolkit/issues",
7
7
  "repository": {
@@ -1,25 +0,0 @@
1
- /**
2
- * Generates a unique identifier, optionally prefixed with a given string.
3
- *
4
- * @param {string} [prefix] - An optional string to prefix the unique identifier.
5
- * If not provided or not a string, only the unique
6
- * numeric identifier is returned.
7
- * @returns {string} A string containing the unique identifier, with the optional
8
- * prefix if provided.
9
- *
10
- * @example
11
- * // Generate a unique ID with a prefix
12
- * uniqueId('user_'); // => 'user_1'
13
- *
14
- * @example
15
- * // Generate a unique ID without a prefix
16
- * uniqueId(); // => '2'
17
- *
18
- * @example
19
- * // Subsequent calls increment the internal counter
20
- * uniqueId('item_'); // => 'item_3'
21
- * uniqueId(); // => '4'
22
- */
23
- declare function uniqueId(prefix?: string): string;
24
-
25
- export { uniqueId };
@@ -1,25 +0,0 @@
1
- /**
2
- * Generates a unique identifier, optionally prefixed with a given string.
3
- *
4
- * @param {string} [prefix] - An optional string to prefix the unique identifier.
5
- * If not provided or not a string, only the unique
6
- * numeric identifier is returned.
7
- * @returns {string} A string containing the unique identifier, with the optional
8
- * prefix if provided.
9
- *
10
- * @example
11
- * // Generate a unique ID with a prefix
12
- * uniqueId('user_'); // => 'user_1'
13
- *
14
- * @example
15
- * // Generate a unique ID without a prefix
16
- * uniqueId(); // => '2'
17
- *
18
- * @example
19
- * // Subsequent calls increment the internal counter
20
- * uniqueId('item_'); // => 'item_3'
21
- * uniqueId(); // => '4'
22
- */
23
- declare function uniqueId(prefix?: string): string;
24
-
25
- export { uniqueId };
@@ -1,7 +0,0 @@
1
- let idCounter = 0;
2
- function uniqueId(prefix = '') {
3
- const id = ++idCounter;
4
- return `${prefix}${id}`;
5
- }
6
-
7
- export { uniqueId };