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,17 @@
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
+ export declare function once<F extends () => any>(func: F): F;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,26 @@
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
+ export declare function throttle(func: () => void, throttleMs: number): () => void;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ export * from './array';
2
+ export * from './function';
3
+ export * from './math';
4
+ export * from './object';
5
+ export * from './predicate';
6
+ export * from './promise';