es-toolkit 0.0.1-dev.20

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 (163) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +31 -0
  3. package/dist/array/chunk.d.ts +24 -0
  4. package/dist/array/chunk.spec.d.ts +1 -0
  5. package/dist/array/difference.d.ts +23 -0
  6. package/dist/array/difference.spec.d.ts +1 -0
  7. package/dist/array/differenceBy.d.ts +26 -0
  8. package/dist/array/differenceBy.spec.d.ts +1 -0
  9. package/dist/array/differenceWith.d.ts +22 -0
  10. package/dist/array/differenceWith.spec.d.ts +1 -0
  11. package/dist/array/drop.d.ts +16 -0
  12. package/dist/array/drop.spec.d.ts +1 -0
  13. package/dist/array/dropRight.d.ts +16 -0
  14. package/dist/array/dropRight.spec.d.ts +1 -0
  15. package/dist/array/dropRightWhile.d.ts +18 -0
  16. package/dist/array/dropRightWhile.spec.d.ts +1 -0
  17. package/dist/array/dropWhile.d.ts +18 -0
  18. package/dist/array/dropWhile.spec.d.ts +1 -0
  19. package/dist/array/groupBy.d.ts +31 -0
  20. package/dist/array/groupBy.spec.d.ts +1 -0
  21. package/dist/array/index.d.ts +30 -0
  22. package/dist/array/index.js +991 -0
  23. package/dist/array/intersection.d.ts +18 -0
  24. package/dist/array/intersection.spec.d.ts +1 -0
  25. package/dist/array/intersectionBy.d.ts +21 -0
  26. package/dist/array/intersectionBy.spec.d.ts +1 -0
  27. package/dist/array/intersectionWith.d.ts +22 -0
  28. package/dist/array/intersectionWith.spec.d.ts +1 -0
  29. package/dist/array/partition.d.ts +22 -0
  30. package/dist/array/partition.spec.d.ts +1 -0
  31. package/dist/array/sample.d.ts +14 -0
  32. package/dist/array/sample.spec.d.ts +1 -0
  33. package/dist/array/shuffle.d.ts +14 -0
  34. package/dist/array/shuffle.spec.d.ts +1 -0
  35. package/dist/array/take.d.ts +23 -0
  36. package/dist/array/take.spec.d.ts +1 -0
  37. package/dist/array/takeRight.d.ts +21 -0
  38. package/dist/array/takeRight.spec.d.ts +1 -0
  39. package/dist/array/takeRightWhile.d.ts +18 -0
  40. package/dist/array/takeRightWhile.spec.d.ts +1 -0
  41. package/dist/array/takeWhile.d.ts +19 -0
  42. package/dist/array/takeWhile.spec.d.ts +1 -0
  43. package/dist/array/union.d.ts +17 -0
  44. package/dist/array/union.spec.d.ts +1 -0
  45. package/dist/array/unionBy.d.ts +21 -0
  46. package/dist/array/unionBy.spec.d.ts +1 -0
  47. package/dist/array/unionWith.d.ts +20 -0
  48. package/dist/array/unionWith.spec.d.ts +1 -0
  49. package/dist/array/uniq.d.ts +15 -0
  50. package/dist/array/uniq.spec.d.ts +1 -0
  51. package/dist/array/uniqBy.d.ts +12 -0
  52. package/dist/array/uniqBy.spec.d.ts +1 -0
  53. package/dist/array/uniqWith.d.ts +12 -0
  54. package/dist/array/uniqWith.spec.d.ts +1 -0
  55. package/dist/array/xor.d.ts +17 -0
  56. package/dist/array/xor.spec.d.ts +1 -0
  57. package/dist/array/xorBy.d.ts +20 -0
  58. package/dist/array/xorBy.spec.d.ts +1 -0
  59. package/dist/array/xorWith.d.ts +19 -0
  60. package/dist/array/xorWith.spec.d.ts +1 -0
  61. package/dist/array/zip.d.ts +25 -0
  62. package/dist/array/zip.spec.d.ts +1 -0
  63. package/dist/array/zipWith.d.ts +32 -0
  64. package/dist/array/zipWith.spec.d.ts +1 -0
  65. package/dist/function/debounce.d.ts +24 -0
  66. package/dist/function/debounce.spec.d.ts +1 -0
  67. package/dist/function/index.d.ts +3 -0
  68. package/dist/function/index.js +112 -0
  69. package/dist/function/once.d.ts +17 -0
  70. package/dist/function/once.spec.d.ts +1 -0
  71. package/dist/function/throttle.d.ts +26 -0
  72. package/dist/function/throttle.spec.d.ts +1 -0
  73. package/dist/index.d.ts +6 -0
  74. package/dist/index.js +1514 -0
  75. package/dist/math/clamp.d.ts +19 -0
  76. package/dist/math/clamp.spec.d.ts +1 -0
  77. package/dist/math/index.d.ts +3 -0
  78. package/dist/math/index.js +148 -0
  79. package/dist/math/round.d.ts +16 -0
  80. package/dist/math/round.spec.d.ts +1 -0
  81. package/dist/math/sum.d.ts +14 -0
  82. package/dist/math/sum.spec.d.ts +1 -0
  83. package/dist/object/index.d.ts +4 -0
  84. package/dist/object/index.js +286 -0
  85. package/dist/object/omit.d.ts +16 -0
  86. package/dist/object/omit.spec.d.ts +1 -0
  87. package/dist/object/omitBy.d.ts +19 -0
  88. package/dist/object/omitBy.spec.d.ts +1 -0
  89. package/dist/object/pick.d.ts +16 -0
  90. package/dist/object/pick.spec.d.ts +1 -0
  91. package/dist/object/pickBy.d.ts +19 -0
  92. package/dist/object/pickBy.spec.d.ts +1 -0
  93. package/dist/predicate/index.d.ts +4 -0
  94. package/dist/predicate/index.js +98 -0
  95. package/dist/predicate/isNil.d.ts +20 -0
  96. package/dist/predicate/isNil.spec.d.ts +1 -0
  97. package/dist/predicate/isNotNil.d.ts +16 -0
  98. package/dist/predicate/isNotNil.spec.d.ts +1 -0
  99. package/dist/predicate/isNull.d.ts +21 -0
  100. package/dist/predicate/isNull.spec.d.ts +1 -0
  101. package/dist/predicate/isUndefined.d.ts +21 -0
  102. package/dist/predicate/isUndefined.spec.d.ts +1 -0
  103. package/dist/promise/delay.d.ts +19 -0
  104. package/dist/promise/delay.spec.d.ts +1 -0
  105. package/dist/promise/index.d.ts +1 -0
  106. package/dist/promise/index.js +29 -0
  107. package/esm/_virtual/_rollupPluginBabelHelpers.mjs +163 -0
  108. package/esm/array/_virtual/_rollupPluginBabelHelpers.mjs +78 -0
  109. package/esm/array/chunk.mjs +38 -0
  110. package/esm/array/difference.mjs +29 -0
  111. package/esm/array/differenceBy.mjs +35 -0
  112. package/esm/array/differenceWith.mjs +30 -0
  113. package/esm/array/drop.mjs +20 -0
  114. package/esm/array/dropRight.mjs +20 -0
  115. package/esm/array/dropRightWhile.mjs +26 -0
  116. package/esm/array/dropWhile.mjs +25 -0
  117. package/esm/array/groupBy.mjs +54 -0
  118. package/esm/array/index.mjs +30 -0
  119. package/esm/array/intersection.mjs +24 -0
  120. package/esm/array/intersectionBy.mjs +30 -0
  121. package/esm/array/intersectionWith.mjs +30 -0
  122. package/esm/array/partition.mjs +46 -0
  123. package/esm/array/sample.mjs +19 -0
  124. package/esm/array/shuffle.mjs +27 -0
  125. package/esm/array/take.mjs +27 -0
  126. package/esm/array/takeRight.mjs +28 -0
  127. package/esm/array/takeRightWhile.mjs +27 -0
  128. package/esm/array/takeWhile.mjs +41 -0
  129. package/esm/array/union.mjs +23 -0
  130. package/esm/array/unionBy.mjs +35 -0
  131. package/esm/array/unionWith.mjs +26 -0
  132. package/esm/array/uniq.mjs +37 -0
  133. package/esm/array/uniqBy.mjs +20 -0
  134. package/esm/array/uniqWith.mjs +39 -0
  135. package/esm/array/xor.mjs +25 -0
  136. package/esm/array/xorBy.mjs +30 -0
  137. package/esm/array/xorWith.mjs +29 -0
  138. package/esm/array/zip.mjs +52 -0
  139. package/esm/array/zipWith.mjs +54 -0
  140. package/esm/function/debounce.mjs +39 -0
  141. package/esm/function/index.mjs +3 -0
  142. package/esm/function/once.mjs +31 -0
  143. package/esm/function/throttle.mjs +38 -0
  144. package/esm/index.mjs +45 -0
  145. package/esm/math/_virtual/_rollupPluginBabelHelpers.mjs +66 -0
  146. package/esm/math/clamp.mjs +26 -0
  147. package/esm/math/index.mjs +3 -0
  148. package/esm/math/round.mjs +22 -0
  149. package/esm/math/sum.mjs +33 -0
  150. package/esm/object/_virtual/_rollupPluginBabelHelpers.mjs +151 -0
  151. package/esm/object/index.mjs +4 -0
  152. package/esm/object/omit.mjs +35 -0
  153. package/esm/object/omitBy.mjs +35 -0
  154. package/esm/object/pick.mjs +35 -0
  155. package/esm/object/pickBy.mjs +35 -0
  156. package/esm/predicate/index.mjs +4 -0
  157. package/esm/predicate/isNil.mjs +24 -0
  158. package/esm/predicate/isNotNil.mjs +20 -0
  159. package/esm/predicate/isNull.mjs +25 -0
  160. package/esm/predicate/isUndefined.mjs +25 -0
  161. package/esm/promise/delay.mjs +25 -0
  162. package/esm/promise/index.mjs +1 -0
  163. package/package.json +108 -0
@@ -0,0 +1,30 @@
1
+ import { differenceBy } from './differenceBy.mjs';
2
+ import { intersectionBy } from './intersectionBy.mjs';
3
+ import { unionBy } from './unionBy.mjs';
4
+
5
+ /**
6
+ * Computes the symmetric difference between two arrays using a custom mapping function.
7
+ * The symmetric difference is the set of elements which are in either of the arrays,
8
+ * but not in their intersection, determined by the result of the mapping function.
9
+ *
10
+ * @template T - Type of elements in the input arrays.
11
+ * @template U - Type of the values returned by the mapping function.
12
+ *
13
+ * @param {T[]} arr1 - The first array.
14
+ * @param {T[]} arr2 - The second array.
15
+ * @param {function(item: T): U} mapper - The function to map array elements to comparison values.
16
+ * @returns {T[]} An array containing the elements that are present in either `arr1` or `arr2` but not in both, based on the values returned by the mapping function.
17
+ *
18
+ * @example
19
+ * // Custom mapping function for objects with an 'id' property
20
+ * const idMapper = obj => obj.id;
21
+ * xorBy([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], idMapper);
22
+ * // Returns [{ id: 1 }, { id: 3 }]
23
+ */
24
+ function xorBy(arr1, arr2, mapper) {
25
+ var union = unionBy(arr1, arr2, mapper);
26
+ var intersection = intersectionBy(arr1, arr2, mapper);
27
+ return differenceBy(union, intersection, mapper);
28
+ }
29
+
30
+ export { xorBy };
@@ -0,0 +1,29 @@
1
+ import { differenceWith } from './differenceWith.mjs';
2
+ import { intersectionWith } from './intersectionWith.mjs';
3
+ import { unionWith } from './unionWith.mjs';
4
+
5
+ /**
6
+ * Computes the symmetric difference between two arrays using a custom equality function.
7
+ * The symmetric difference is the set of elements which are in either of the arrays,
8
+ * but not in their intersection.
9
+ *
10
+ * @template T - Type of elements in the input arrays.
11
+ *
12
+ * @param {T[]} arr1 - The first array.
13
+ * @param {T[]} arr2 - The second array.
14
+ * @param {(item1: T, item2: T) => boolean} areElementsEqual - The custom equality function to compare elements.
15
+ * @returns {T[]} An array containing the elements that are present in either `arr1` or `arr2` but not in both, based on the custom equality function.
16
+ *
17
+ * @example
18
+ * // Custom equality function for objects with an 'id' property
19
+ * const areObjectsEqual = (a, b) => a.id === b.id;
20
+ * xorWith([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], areObjectsEqual);
21
+ * // Returns [{ id: 1 }, { id: 3 }]
22
+ */
23
+ function xorWith(arr1, arr2, areElementsEqual) {
24
+ var union = unionWith(arr1, arr2, areElementsEqual);
25
+ var intersection = intersectionWith(arr1, arr2, areElementsEqual);
26
+ return differenceWith(union, intersection, areElementsEqual);
27
+ }
28
+
29
+ export { xorWith };
@@ -0,0 +1,52 @@
1
+ import { toConsumableArray as _toConsumableArray, createForOfIteratorHelper as _createForOfIteratorHelper } from './_virtual/_rollupPluginBabelHelpers.mjs';
2
+
3
+ /**
4
+ * Combines multiple arrays into a single array of tuples.
5
+ *
6
+ * This function takes multiple arrays and returns a new array where each element is a tuple
7
+ * containing the corresponding elements from the input arrays. If the input arrays are of
8
+ * different lengths, the resulting array will have the length of the longest input array,
9
+ * with undefined values for missing elements.
10
+ *
11
+ * @param {...T[][]} arrs - The arrays to zip together.
12
+ * @returns {T[][]} A new array of tuples containing the corresponding elements from the input arrays.
13
+ *
14
+ * @example
15
+ * const arr1 = [1, 2, 3];
16
+ * const arr2 = ['a', 'b', 'c'];
17
+ * const result = zip(arr1, arr2);
18
+ * // result will be [[1, 'a'], [2, 'b'], [3, 'c']]
19
+ *
20
+ * const arr3 = [true, false];
21
+ * const result2 = zip(arr1, arr2, arr3);
22
+ * // result2 will be [[1, 'a', true], [2, 'b', false], [3, 'c', undefined]]
23
+ */
24
+
25
+ function zip() {
26
+ var result = [];
27
+ for (var _len = arguments.length, arrs = new Array(_len), _key = 0; _key < _len; _key++) {
28
+ arrs[_key] = arguments[_key];
29
+ }
30
+ var maxIndex = Math.max.apply(Math, _toConsumableArray(arrs.map(function (x) {
31
+ return x.length;
32
+ })));
33
+ for (var i = 0; i < maxIndex; i++) {
34
+ var element = [];
35
+ var _iterator = _createForOfIteratorHelper(arrs),
36
+ _step;
37
+ try {
38
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
39
+ var arr = _step.value;
40
+ element.push(arr[i]);
41
+ }
42
+ } catch (err) {
43
+ _iterator.e(err);
44
+ } finally {
45
+ _iterator.f();
46
+ }
47
+ result.push(element);
48
+ }
49
+ return result;
50
+ }
51
+
52
+ export { zip };
@@ -0,0 +1,54 @@
1
+ import { toConsumableArray as _toConsumableArray } from './_virtual/_rollupPluginBabelHelpers.mjs';
2
+
3
+ /**
4
+ * Combines multiple arrays into a single array using a custom combiner function.
5
+ *
6
+ * This function takes multiple arrays and a combiner function, and returns a new array where each element
7
+ * is the result of applying the combiner function to the corresponding elements of the input arrays.
8
+ *
9
+ * @param {T[]} arr1 - The first array to zip.
10
+ * @param {U[]} [arr2] - The second array to zip (optional).
11
+ * @param {V[]} [arr3] - The third array to zip (optional).
12
+ * @param {W[]} [arr4] - The fourth array to zip (optional).
13
+ * @param {function} combine - The combiner function that takes corresponding elements from each array and returns a single value.
14
+ * @returns {R[]} A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays.
15
+ *
16
+ * @example
17
+ * // Example usage with two arrays:
18
+ * const arr1 = [1, 2, 3];
19
+ * const arr2 = [4, 5, 6];
20
+ * const result = zipWith(arr1, arr2, (a, b) => a + b);
21
+ * // result will be [5, 7, 9]
22
+ *
23
+ * @example
24
+ * // Example usage with three arrays:
25
+ * const arr1 = [1, 2];
26
+ * const arr2 = [3, 4];
27
+ * const arr3 = [5, 6];
28
+ * const result = zipWith(arr1, arr2, arr3, (a, b, c) => `${a}${b}${c}`);
29
+ * // result will be [`135`, `246`]
30
+ */
31
+
32
+ function zipWith(arr1) {
33
+ for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
34
+ rest[_key - 1] = arguments[_key];
35
+ }
36
+ var arrs = [arr1].concat(_toConsumableArray(rest.slice(0, -1)));
37
+ var combine = rest[rest.length - 1];
38
+ var result = [];
39
+ var maxIndex = Math.max.apply(Math, _toConsumableArray(arrs.map(function (arr) {
40
+ return arr.length;
41
+ })));
42
+ var _loop = function _loop(i) {
43
+ var elements = arrs.map(function (arr) {
44
+ return arr[i];
45
+ });
46
+ result.push(combine.apply(void 0, _toConsumableArray(elements)));
47
+ };
48
+ for (var i = 0; i < maxIndex; i++) {
49
+ _loop(i);
50
+ }
51
+ return result;
52
+ }
53
+
54
+ export { zipWith };
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Creates a debounced function that delays invoking the provided function until after `debounceMs` milliseconds
3
+ * have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel`
4
+ * method to cancel any pending execution.
5
+ *
6
+ * @param {() => void} func - The function to debounce.
7
+ * @param {number} debounceMs - The number of milliseconds to delay.
8
+ * @returns {{ (): void; cancel: () => void }} A new debounced function with a `cancel` method.
9
+ *
10
+ * @example
11
+ * const debouncedFunction = debounce(() => {
12
+ * console.log('Function executed');
13
+ * }, 1000);
14
+ *
15
+ * // Will log 'Function executed' after 1 second if not called again in that time
16
+ * debouncedFunction();
17
+ *
18
+ * // Will not log anything as the previous call is canceled
19
+ * debouncedFunction.cancel();
20
+ */
21
+ function debounce(func, debounceMs) {
22
+ var timeoutId = null;
23
+ var debounced = function debounced() {
24
+ if (timeoutId != null) {
25
+ clearTimeout(timeoutId);
26
+ }
27
+ timeoutId = setTimeout(function () {
28
+ func();
29
+ }, debounceMs);
30
+ };
31
+ debounced.cancel = function () {
32
+ if (timeoutId != null) {
33
+ clearTimeout(timeoutId);
34
+ }
35
+ };
36
+ return debounced;
37
+ }
38
+
39
+ export { debounce };
@@ -0,0 +1,3 @@
1
+ export { debounce } from './debounce.mjs';
2
+ export { once } from './once.mjs';
3
+ export { throttle } from './throttle.mjs';
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Creates a function that is restricted to invoking the provided function `func` once.
3
+ * Repeated calls to the function will return the value from the first invocation.
4
+ *
5
+ * @param {F} func - The function to restrict.
6
+ * @returns {F} A new function that invokes `func` once and caches the result.
7
+ *
8
+ * @example
9
+ * const initialize = once(() => {
10
+ * console.log('Initialized!');
11
+ * return true;
12
+ * });
13
+ *
14
+ * initialize(); // Logs: 'Initialized!' and returns true
15
+ * initialize(); // Returns true without logging
16
+ */
17
+ function once(func) {
18
+ var called = false;
19
+ var cache;
20
+ return function () {
21
+ if (called) {
22
+ return cache;
23
+ }
24
+ var result = func();
25
+ called = true;
26
+ cache = result;
27
+ return result;
28
+ };
29
+ }
30
+
31
+ export { once };
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Creates a throttled function that only invokes the provided function at most once
3
+ * per every `throttleMs` milliseconds. Subsequent calls to the throttled function
4
+ * within the wait time will not trigger the execution of the original function.
5
+ *
6
+ * @param {() => void} func - The function to throttle.
7
+ * @param {number} throttleMs - The number of milliseconds to throttle executions to.
8
+ * @returns {() => void} A new throttled function.
9
+ *
10
+ * @example
11
+ * const throttledFunction = throttle(() => {
12
+ * console.log('Function executed');
13
+ * }, 1000);
14
+ *
15
+ * // Will log 'Function executed' immediately
16
+ * throttledFunction();
17
+ *
18
+ * // Will not log anything as it is within the throttle time
19
+ * throttledFunction();
20
+ *
21
+ * // After 1 second
22
+ * setTimeout(() => {
23
+ * throttledFunction(); // Will log 'Function executed'
24
+ * }, 1000);
25
+ */
26
+ function throttle(func, throttleMs) {
27
+ var lastCallTime;
28
+ var throttledFunction = function throttledFunction() {
29
+ var now = Date.now();
30
+ if (lastCallTime == null || now - lastCallTime >= throttleMs) {
31
+ lastCallTime = now;
32
+ func();
33
+ }
34
+ };
35
+ return throttledFunction;
36
+ }
37
+
38
+ export { throttle };
package/esm/index.mjs ADDED
@@ -0,0 +1,45 @@
1
+ export { chunk } from './array/chunk.mjs';
2
+ export { difference } from './array/difference.mjs';
3
+ export { differenceBy } from './array/differenceBy.mjs';
4
+ export { differenceWith } from './array/differenceWith.mjs';
5
+ export { drop } from './array/drop.mjs';
6
+ export { dropRight } from './array/dropRight.mjs';
7
+ export { dropRightWhile } from './array/dropRightWhile.mjs';
8
+ export { dropWhile } from './array/dropWhile.mjs';
9
+ export { groupBy } from './array/groupBy.mjs';
10
+ export { intersection } from './array/intersection.mjs';
11
+ export { intersectionBy } from './array/intersectionBy.mjs';
12
+ export { intersectionWith } from './array/intersectionWith.mjs';
13
+ export { partition } from './array/partition.mjs';
14
+ export { sample } from './array/sample.mjs';
15
+ export { shuffle } from './array/shuffle.mjs';
16
+ export { take } from './array/take.mjs';
17
+ export { takeRight } from './array/takeRight.mjs';
18
+ export { takeRightWhile } from './array/takeRightWhile.mjs';
19
+ export { takeWhile } from './array/takeWhile.mjs';
20
+ export { union } from './array/union.mjs';
21
+ export { unionBy } from './array/unionBy.mjs';
22
+ export { unionWith } from './array/unionWith.mjs';
23
+ export { uniq } from './array/uniq.mjs';
24
+ export { uniqBy } from './array/uniqBy.mjs';
25
+ export { uniqWith } from './array/uniqWith.mjs';
26
+ export { xor } from './array/xor.mjs';
27
+ export { xorBy } from './array/xorBy.mjs';
28
+ export { xorWith } from './array/xorWith.mjs';
29
+ export { zip } from './array/zip.mjs';
30
+ export { zipWith } from './array/zipWith.mjs';
31
+ export { debounce } from './function/debounce.mjs';
32
+ export { once } from './function/once.mjs';
33
+ export { throttle } from './function/throttle.mjs';
34
+ export { clamp } from './math/clamp.mjs';
35
+ export { round } from './math/round.mjs';
36
+ export { sum } from './math/sum.mjs';
37
+ export { omit } from './object/omit.mjs';
38
+ export { omitBy } from './object/omitBy.mjs';
39
+ export { pick } from './object/pick.mjs';
40
+ export { pickBy } from './object/pickBy.mjs';
41
+ export { isNil } from './predicate/isNil.mjs';
42
+ export { isNotNil } from './predicate/isNotNil.mjs';
43
+ export { isNull } from './predicate/isNull.mjs';
44
+ export { isUndefined } from './predicate/isUndefined.mjs';
45
+ export { delay } from './promise/delay.mjs';
@@ -0,0 +1,66 @@
1
+ function _unsupportedIterableToArray(o, minLen) {
2
+ if (!o) return;
3
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
4
+ var n = Object.prototype.toString.call(o).slice(8, -1);
5
+ if (n === "Object" && o.constructor) n = o.constructor.name;
6
+ if (n === "Map" || n === "Set") return Array.from(o);
7
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
8
+ }
9
+ function _arrayLikeToArray(arr, len) {
10
+ if (len == null || len > arr.length) len = arr.length;
11
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
12
+ return arr2;
13
+ }
14
+ function _createForOfIteratorHelper(o, allowArrayLike) {
15
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
16
+ if (!it) {
17
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
18
+ if (it) o = it;
19
+ var i = 0;
20
+ var F = function () {};
21
+ return {
22
+ s: F,
23
+ n: function () {
24
+ if (i >= o.length) return {
25
+ done: true
26
+ };
27
+ return {
28
+ done: false,
29
+ value: o[i++]
30
+ };
31
+ },
32
+ e: function (e) {
33
+ throw e;
34
+ },
35
+ f: F
36
+ };
37
+ }
38
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
39
+ }
40
+ var normalCompletion = true,
41
+ didErr = false,
42
+ err;
43
+ return {
44
+ s: function () {
45
+ it = it.call(o);
46
+ },
47
+ n: function () {
48
+ var step = it.next();
49
+ normalCompletion = step.done;
50
+ return step;
51
+ },
52
+ e: function (e) {
53
+ didErr = true;
54
+ err = e;
55
+ },
56
+ f: function () {
57
+ try {
58
+ if (!normalCompletion && it.return != null) it.return();
59
+ } finally {
60
+ if (didErr) throw err;
61
+ }
62
+ }
63
+ };
64
+ }
65
+
66
+ export { _arrayLikeToArray as arrayLikeToArray, _createForOfIteratorHelper as createForOfIteratorHelper, _unsupportedIterableToArray as unsupportedIterableToArray };
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Clamps a number within the inclusive lower and upper bounds.
3
+ *
4
+ * This function takes a number and two bounds, and returns the number clamped within the specified bounds.
5
+ * If only one bound is provided, it returns the minimum of the value and the bound.
6
+ *
7
+ * @param {number} value - The number to clamp.
8
+ * @param {number} minimum - The minimum bound to clamp the number.
9
+ * @param {number} maximum - The maximum bound to clamp the number.
10
+ * @returns {number} The clamped number within the specified bounds.
11
+ *
12
+ * @example
13
+ * * const result1 = clamp(10, 5); // result1 will be 5, as 10 is clamped to the bound 5
14
+ * const result2 = clamp(10, 5, 15); // result2 will be 10, as it is within the bounds 5 and 15
15
+ * const result3 = clamp(2, 5, 15); // result3 will be 5, as 2 is clamped to the lower bound 5
16
+ * const result4 = clamp(20, 5, 15); // result4 will be 15, as 20 is clamped to the upper bound 15
17
+ */
18
+
19
+ function clamp(value, bound1, bound2) {
20
+ if (bound2 == null) {
21
+ return Math.min(value, bound1);
22
+ }
23
+ return Math.min(Math.max(value, bound1), bound2);
24
+ }
25
+
26
+ export { clamp };
@@ -0,0 +1,3 @@
1
+ export { clamp } from './clamp.mjs';
2
+ export { round } from './round.mjs';
3
+ export { sum } from './sum.mjs';
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Rounds a number to a specified precision.
3
+ *
4
+ * This function takes a number and an optional precision value, and returns the number rounded
5
+ * to the specified number of decimal places.
6
+ *
7
+ * @param {number} value - The number to round.
8
+ * @param {number} [precision=0] - The number of decimal places to round to. Defaults to 0.
9
+ * @returns {number} The rounded number.
10
+ *
11
+ * @example
12
+ * * const result1 = round(1.2345); // result1 will be 1
13
+ * const result2 = round(1.2345, 2); // result2 will be 1.23
14
+ * const result3 = round(1.2345, 3); // result3 will be 1.235
15
+ */
16
+ function round(value) {
17
+ var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
18
+ var multiplier = Math.pow(10, precision);
19
+ return Math.round(value * multiplier) / multiplier;
20
+ }
21
+
22
+ export { round };
@@ -0,0 +1,33 @@
1
+ import { createForOfIteratorHelper as _createForOfIteratorHelper } from './_virtual/_rollupPluginBabelHelpers.mjs';
2
+
3
+ /**
4
+ * Calculates the sum of an array of numbers.
5
+ *
6
+ * This function takes an array of numbers and returns the sum of all the elements in the array.
7
+ *
8
+ * @param {number[]} nums - An array of numbers to be summed.
9
+ * @returns {number} The sum of all the numbers in the array.
10
+ *
11
+ * @example
12
+ * * const numbers = [1, 2, 3, 4, 5];
13
+ * const result = sum(numbers);
14
+ * // result will be 15
15
+ */
16
+ function sum(nums) {
17
+ var result = 0;
18
+ var _iterator = _createForOfIteratorHelper(nums),
19
+ _step;
20
+ try {
21
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
22
+ var num = _step.value;
23
+ result += num;
24
+ }
25
+ } catch (err) {
26
+ _iterator.e(err);
27
+ } finally {
28
+ _iterator.f();
29
+ }
30
+ return result;
31
+ }
32
+
33
+ export { sum };
@@ -0,0 +1,151 @@
1
+ function _iterableToArrayLimit(r, l) {
2
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
3
+ if (null != t) {
4
+ var e,
5
+ n,
6
+ i,
7
+ u,
8
+ a = [],
9
+ f = !0,
10
+ o = !1;
11
+ try {
12
+ if (i = (t = t.call(r)).next, 0 === l) {
13
+ if (Object(t) !== t) return;
14
+ f = !1;
15
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
16
+ } catch (r) {
17
+ o = !0, n = r;
18
+ } finally {
19
+ try {
20
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
21
+ } finally {
22
+ if (o) throw n;
23
+ }
24
+ }
25
+ return a;
26
+ }
27
+ }
28
+ function ownKeys(e, r) {
29
+ var t = Object.keys(e);
30
+ if (Object.getOwnPropertySymbols) {
31
+ var o = Object.getOwnPropertySymbols(e);
32
+ r && (o = o.filter(function (r) {
33
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
34
+ })), t.push.apply(t, o);
35
+ }
36
+ return t;
37
+ }
38
+ function _objectSpread2(e) {
39
+ for (var r = 1; r < arguments.length; r++) {
40
+ var t = null != arguments[r] ? arguments[r] : {};
41
+ r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
42
+ _defineProperty(e, r, t[r]);
43
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
44
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
45
+ });
46
+ }
47
+ return e;
48
+ }
49
+ function _toPrimitive(t, r) {
50
+ if ("object" != typeof t || !t) return t;
51
+ var e = t[Symbol.toPrimitive];
52
+ if (void 0 !== e) {
53
+ var i = e.call(t, r || "default");
54
+ if ("object" != typeof i) return i;
55
+ throw new TypeError("@@toPrimitive must return a primitive value.");
56
+ }
57
+ return ("string" === r ? String : Number)(t);
58
+ }
59
+ function _toPropertyKey(t) {
60
+ var i = _toPrimitive(t, "string");
61
+ return "symbol" == typeof i ? i : i + "";
62
+ }
63
+ function _defineProperty(obj, key, value) {
64
+ key = _toPropertyKey(key);
65
+ if (key in obj) {
66
+ Object.defineProperty(obj, key, {
67
+ value: value,
68
+ enumerable: true,
69
+ configurable: true,
70
+ writable: true
71
+ });
72
+ } else {
73
+ obj[key] = value;
74
+ }
75
+ return obj;
76
+ }
77
+ function _slicedToArray(arr, i) {
78
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
79
+ }
80
+ function _arrayWithHoles(arr) {
81
+ if (Array.isArray(arr)) return arr;
82
+ }
83
+ function _unsupportedIterableToArray(o, minLen) {
84
+ if (!o) return;
85
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
86
+ var n = Object.prototype.toString.call(o).slice(8, -1);
87
+ if (n === "Object" && o.constructor) n = o.constructor.name;
88
+ if (n === "Map" || n === "Set") return Array.from(o);
89
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
90
+ }
91
+ function _arrayLikeToArray(arr, len) {
92
+ if (len == null || len > arr.length) len = arr.length;
93
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
94
+ return arr2;
95
+ }
96
+ function _nonIterableRest() {
97
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
98
+ }
99
+ function _createForOfIteratorHelper(o, allowArrayLike) {
100
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
101
+ if (!it) {
102
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
103
+ if (it) o = it;
104
+ var i = 0;
105
+ var F = function () {};
106
+ return {
107
+ s: F,
108
+ n: function () {
109
+ if (i >= o.length) return {
110
+ done: true
111
+ };
112
+ return {
113
+ done: false,
114
+ value: o[i++]
115
+ };
116
+ },
117
+ e: function (e) {
118
+ throw e;
119
+ },
120
+ f: F
121
+ };
122
+ }
123
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
124
+ }
125
+ var normalCompletion = true,
126
+ didErr = false,
127
+ err;
128
+ return {
129
+ s: function () {
130
+ it = it.call(o);
131
+ },
132
+ n: function () {
133
+ var step = it.next();
134
+ normalCompletion = step.done;
135
+ return step;
136
+ },
137
+ e: function (e) {
138
+ didErr = true;
139
+ err = e;
140
+ },
141
+ f: function () {
142
+ try {
143
+ if (!normalCompletion && it.return != null) it.return();
144
+ } finally {
145
+ if (didErr) throw err;
146
+ }
147
+ }
148
+ };
149
+ }
150
+
151
+ export { _arrayLikeToArray as arrayLikeToArray, _arrayWithHoles as arrayWithHoles, _createForOfIteratorHelper as createForOfIteratorHelper, _defineProperty as defineProperty, _iterableToArrayLimit as iterableToArrayLimit, _nonIterableRest as nonIterableRest, _objectSpread2 as objectSpread2, _slicedToArray as slicedToArray, _toPrimitive as toPrimitive, _toPropertyKey as toPropertyKey, _unsupportedIterableToArray as unsupportedIterableToArray };
@@ -0,0 +1,4 @@
1
+ export { omit } from './omit.mjs';
2
+ export { omitBy } from './omitBy.mjs';
3
+ export { pick } from './pick.mjs';
4
+ export { pickBy } from './pickBy.mjs';
@@ -0,0 +1,35 @@
1
+ import { objectSpread2 as _objectSpread2, createForOfIteratorHelper as _createForOfIteratorHelper } from './_virtual/_rollupPluginBabelHelpers.mjs';
2
+
3
+ /**
4
+ * Creates a new object with specified keys omitted.
5
+ *
6
+ * This function takes an object and an array of keys, and returns a new object that
7
+ * excludes the properties corresponding to the specified keys.
8
+ *
9
+ * @param {T} obj - The object to omit keys from.
10
+ * @param {K[]} keys - An array of keys to be omitted from the object.
11
+ * @returns {Omit<T, K>} A new object with the specified keys omitted.
12
+ *
13
+ * @example
14
+ * * const obj = { a: 1, b: 2, c: 3 };
15
+ * const result = omit(obj, ['b', 'c']);
16
+ * // result will be { a: 1 }
17
+ */
18
+ function omit(obj, keys) {
19
+ var result = _objectSpread2({}, obj);
20
+ var _iterator = _createForOfIteratorHelper(keys),
21
+ _step;
22
+ try {
23
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
24
+ var key = _step.value;
25
+ delete result[key];
26
+ }
27
+ } catch (err) {
28
+ _iterator.e(err);
29
+ } finally {
30
+ _iterator.f();
31
+ }
32
+ return result;
33
+ }
34
+
35
+ export { omit };