es-toolkit 1.9.0 → 1.10.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 (245) hide show
  1. package/CHANGELOG.md +22 -1
  2. package/README.md +1 -1
  3. package/dist/array/chunk.mjs +1 -1
  4. package/dist/array/compact.mjs +1 -1
  5. package/dist/array/countBy.mjs +1 -1
  6. package/dist/array/difference.mjs +1 -1
  7. package/dist/array/differenceBy.mjs +1 -1
  8. package/dist/array/differenceWith.mjs +1 -1
  9. package/dist/array/drop.mjs +1 -1
  10. package/dist/array/dropRight.mjs +1 -1
  11. package/dist/array/dropRightWhile.mjs +1 -1
  12. package/dist/array/dropWhile.mjs +1 -1
  13. package/dist/array/fill.mjs +1 -1
  14. package/dist/array/flatten.mjs +1 -1
  15. package/dist/array/flattenDeep.d.mts +25 -0
  16. package/dist/array/flattenDeep.d.ts +25 -0
  17. package/dist/array/flattenDeep.js +52 -0
  18. package/dist/array/flattenDeep.js.map +1 -0
  19. package/dist/array/flattenDeep.mjs +9 -0
  20. package/dist/array/forEachRight.mjs +1 -1
  21. package/dist/array/groupBy.mjs +1 -1
  22. package/dist/array/head.mjs +1 -1
  23. package/dist/array/index.d.mts +4 -0
  24. package/dist/array/index.d.ts +4 -0
  25. package/dist/array/index.js +38 -0
  26. package/dist/array/index.js.map +1 -1
  27. package/dist/array/index.mjs +58 -42
  28. package/dist/array/initial.d.mts +26 -0
  29. package/dist/array/initial.d.ts +26 -0
  30. package/dist/array/initial.js +36 -0
  31. package/dist/array/initial.js.map +1 -0
  32. package/dist/array/initial.mjs +8 -0
  33. package/dist/array/intersection.mjs +1 -1
  34. package/dist/array/intersectionBy.mjs +1 -1
  35. package/dist/array/intersectionWith.mjs +1 -1
  36. package/dist/array/keyBy.mjs +1 -1
  37. package/dist/array/last.d.mts +25 -0
  38. package/dist/array/last.d.ts +25 -0
  39. package/dist/array/last.js +33 -0
  40. package/dist/array/last.js.map +1 -0
  41. package/dist/array/last.mjs +8 -0
  42. package/dist/array/maxBy.mjs +1 -1
  43. package/dist/array/minBy.mjs +1 -1
  44. package/dist/array/orderBy.mjs +1 -1
  45. package/dist/array/partition.mjs +1 -1
  46. package/dist/array/sample.mjs +1 -1
  47. package/dist/array/sampleSize.mjs +1 -1
  48. package/dist/array/shuffle.mjs +1 -1
  49. package/dist/array/tail.mjs +1 -1
  50. package/dist/array/take.mjs +1 -1
  51. package/dist/array/takeRight.mjs +1 -1
  52. package/dist/array/takeRightWhile.mjs +1 -1
  53. package/dist/array/takeWhile.mjs +1 -1
  54. package/dist/array/toFilled.d.mts +33 -0
  55. package/dist/array/toFilled.d.ts +33 -0
  56. package/dist/array/toFilled.js +40 -0
  57. package/dist/array/toFilled.js.map +1 -0
  58. package/dist/array/toFilled.mjs +8 -0
  59. package/dist/array/union.mjs +1 -1
  60. package/dist/array/unionBy.mjs +1 -1
  61. package/dist/array/unionWith.mjs +1 -1
  62. package/dist/array/uniq.mjs +1 -1
  63. package/dist/array/uniqBy.mjs +1 -1
  64. package/dist/array/uniqWith.mjs +1 -1
  65. package/dist/array/unzip.mjs +1 -1
  66. package/dist/array/unzipWith.mjs +1 -1
  67. package/dist/array/without.mjs +1 -1
  68. package/dist/array/xor.mjs +1 -1
  69. package/dist/array/xorBy.mjs +1 -1
  70. package/dist/array/xorWith.mjs +1 -1
  71. package/dist/array/zip.mjs +1 -1
  72. package/dist/array/zipObject.mjs +1 -1
  73. package/dist/array/zipWith.mjs +1 -1
  74. package/dist/chunk-236H5JZJ.mjs +1 -0
  75. package/dist/chunk-2HIMLZE3.mjs +46 -0
  76. package/dist/chunk-2HIMLZE3.mjs.map +1 -0
  77. package/dist/chunk-2MRZANXZ.mjs +1 -0
  78. package/dist/chunk-2MRZANXZ.mjs.map +1 -0
  79. package/dist/chunk-2SLTL4KL.mjs +13 -0
  80. package/dist/{chunk-NOFHNJ5C.mjs.map → chunk-2SLTL4KL.mjs.map} +1 -1
  81. package/dist/{chunk-QZITBKWX.mjs → chunk-4E4D3BMI.mjs} +2 -2
  82. package/dist/chunk-5IKVJGHO.mjs +14 -0
  83. package/dist/chunk-5IKVJGHO.mjs.map +1 -0
  84. package/dist/chunk-ASJF5D6C.mjs +1 -0
  85. package/dist/chunk-ASJF5D6C.mjs.map +1 -0
  86. package/dist/chunk-BOOQBJN2.mjs +9 -0
  87. package/dist/chunk-BOOQBJN2.mjs.map +1 -0
  88. package/dist/chunk-EYYZQFOP.mjs +14 -0
  89. package/dist/chunk-EYYZQFOP.mjs.map +1 -0
  90. package/dist/chunk-F3WCQQET.mjs +14 -0
  91. package/dist/chunk-F3WCQQET.mjs.map +1 -0
  92. package/dist/{chunk-LT6E4Y4Z.mjs → chunk-GDC64SYJ.mjs} +2 -2
  93. package/dist/{chunk-SDIMTYZW.mjs → chunk-IZAD2S7R.mjs} +2 -2
  94. package/dist/chunk-JYSV56US.mjs +41 -0
  95. package/dist/chunk-JYSV56US.mjs.map +1 -0
  96. package/dist/chunk-KPBQ7OUY.mjs +9 -0
  97. package/dist/chunk-KPBQ7OUY.mjs.map +1 -0
  98. package/dist/chunk-ML727RRJ.mjs +13 -0
  99. package/dist/chunk-ML727RRJ.mjs.map +1 -0
  100. package/dist/chunk-OP4OAKQJ.mjs +16 -0
  101. package/dist/chunk-OP4OAKQJ.mjs.map +1 -0
  102. package/dist/chunk-OSOLEQLZ.mjs +1 -0
  103. package/dist/chunk-OSOLEQLZ.mjs.map +1 -0
  104. package/dist/chunk-QKYYOLJ6.mjs +1 -0
  105. package/dist/chunk-QKYYOLJ6.mjs.map +1 -0
  106. package/dist/chunk-U4JGKZ56.mjs +41 -0
  107. package/dist/chunk-U4JGKZ56.mjs.map +1 -0
  108. package/dist/chunk-U56ZOM7L.mjs +9 -0
  109. package/dist/chunk-U56ZOM7L.mjs.map +1 -0
  110. package/dist/chunk-WMM7TZLG.mjs +9 -0
  111. package/dist/{chunk-OHQAR5AU.mjs.map → chunk-WMM7TZLG.mjs.map} +1 -1
  112. package/dist/chunk-WVQ7YVRK.mjs +11 -0
  113. package/dist/chunk-WVQ7YVRK.mjs.map +1 -0
  114. package/dist/chunk-XGCYC4YA.mjs +5516 -0
  115. package/dist/chunk-XGCYC4YA.mjs.map +1 -0
  116. package/dist/chunk-XPSOKBRZ.mjs +12 -0
  117. package/dist/chunk-XPSOKBRZ.mjs.map +1 -0
  118. package/dist/error/AbortError.mjs +1 -1
  119. package/dist/error/index.mjs +1 -1
  120. package/dist/function/debounce.mjs +1 -1
  121. package/dist/function/index.d.mts +1 -0
  122. package/dist/function/index.d.ts +1 -0
  123. package/dist/function/index.js +7 -0
  124. package/dist/function/index.js.map +1 -1
  125. package/dist/function/index.mjs +6 -2
  126. package/dist/function/negate.d.mts +10 -0
  127. package/dist/function/negate.d.ts +10 -0
  128. package/dist/function/negate.js +33 -0
  129. package/dist/function/negate.js.map +1 -0
  130. package/dist/function/negate.mjs +8 -0
  131. package/dist/function/negate.mjs.map +1 -0
  132. package/dist/function/noop.mjs +1 -1
  133. package/dist/function/once.mjs +1 -1
  134. package/dist/function/throttle.mjs +1 -1
  135. package/dist/index.d.mts +12 -0
  136. package/dist/index.d.ts +12 -0
  137. package/dist/index.js +5681 -3
  138. package/dist/index.js.map +1 -1
  139. package/dist/index.mjs +125 -75
  140. package/dist/math/clamp.mjs +1 -1
  141. package/dist/math/inRange.mjs +1 -1
  142. package/dist/math/index.js +2 -2
  143. package/dist/math/index.js.map +1 -1
  144. package/dist/math/index.mjs +10 -10
  145. package/dist/math/mean.js +2 -2
  146. package/dist/math/mean.js.map +1 -1
  147. package/dist/math/mean.mjs +3 -3
  148. package/dist/math/meanBy.js +2 -2
  149. package/dist/math/meanBy.js.map +1 -1
  150. package/dist/math/meanBy.mjs +4 -4
  151. package/dist/math/random.mjs +1 -1
  152. package/dist/math/randomInt.mjs +1 -1
  153. package/dist/math/range.mjs +1 -1
  154. package/dist/math/round.mjs +1 -1
  155. package/dist/math/sum.js +2 -2
  156. package/dist/math/sum.js.map +1 -1
  157. package/dist/math/sum.mjs +2 -2
  158. package/dist/object/clone.d.mts +31 -0
  159. package/dist/object/clone.d.ts +31 -0
  160. package/dist/object/clone.js +65 -0
  161. package/dist/object/clone.js.map +1 -0
  162. package/dist/object/clone.mjs +8 -0
  163. package/dist/object/clone.mjs.map +1 -0
  164. package/dist/object/index.d.mts +1 -0
  165. package/dist/object/index.d.ts +1 -0
  166. package/dist/object/index.js +39 -0
  167. package/dist/object/index.js.map +1 -1
  168. package/dist/object/index.mjs +7 -3
  169. package/dist/object/invert.mjs +1 -1
  170. package/dist/object/omit.mjs +2 -2
  171. package/dist/object/omitBy.mjs +1 -1
  172. package/dist/object/pick.mjs +1 -1
  173. package/dist/object/pickBy.mjs +1 -1
  174. package/dist/predicate/index.d.mts +1 -0
  175. package/dist/predicate/index.d.ts +1 -0
  176. package/dist/predicate/index.js +46 -1
  177. package/dist/predicate/index.js.map +1 -1
  178. package/dist/predicate/index.mjs +11 -5
  179. package/dist/predicate/isEqual.d.mts +17 -0
  180. package/dist/predicate/isEqual.d.ts +17 -0
  181. package/dist/predicate/isEqual.js +73 -0
  182. package/dist/predicate/isEqual.js.map +1 -0
  183. package/dist/predicate/isEqual.mjs +10 -0
  184. package/dist/predicate/isEqual.mjs.map +1 -0
  185. package/dist/predicate/isNil.js +1 -1
  186. package/dist/predicate/isNil.js.map +1 -1
  187. package/dist/predicate/isNil.mjs +2 -2
  188. package/dist/predicate/isNotNil.mjs +1 -1
  189. package/dist/predicate/isNull.mjs +1 -1
  190. package/dist/predicate/isUndefined.mjs +1 -1
  191. package/dist/promise/delay.mjs +1 -1
  192. package/dist/promise/index.mjs +1 -1
  193. package/dist/string/camelCase.d.mts +17 -0
  194. package/dist/string/camelCase.d.ts +17 -0
  195. package/dist/string/camelCase.js +5554 -0
  196. package/dist/string/camelCase.js.map +1 -0
  197. package/dist/string/camelCase.mjs +9 -0
  198. package/dist/string/camelCase.mjs.map +1 -0
  199. package/dist/string/capitalize.d.mts +14 -0
  200. package/dist/string/capitalize.d.ts +14 -0
  201. package/dist/string/capitalize.js +33 -0
  202. package/dist/string/capitalize.js.map +1 -0
  203. package/dist/string/capitalize.mjs +8 -0
  204. package/dist/string/capitalize.mjs.map +1 -0
  205. package/dist/string/index.d.mts +5 -0
  206. package/dist/string/index.d.ts +5 -0
  207. package/dist/string/index.js +5587 -0
  208. package/dist/string/index.js.map +1 -0
  209. package/dist/string/index.mjs +26 -0
  210. package/dist/string/index.mjs.map +1 -0
  211. package/dist/string/kebabCase.d.mts +17 -0
  212. package/dist/string/kebabCase.d.ts +17 -0
  213. package/dist/string/kebabCase.js +43 -0
  214. package/dist/string/kebabCase.js.map +1 -0
  215. package/dist/string/kebabCase.mjs +9 -0
  216. package/dist/string/kebabCase.mjs.map +1 -0
  217. package/dist/string/lowerCase.d.mts +17 -0
  218. package/dist/string/lowerCase.d.ts +17 -0
  219. package/dist/string/lowerCase.js +43 -0
  220. package/dist/string/lowerCase.js.map +1 -0
  221. package/dist/string/lowerCase.mjs +9 -0
  222. package/dist/string/lowerCase.mjs.map +1 -0
  223. package/dist/string/snakeCase.d.mts +17 -0
  224. package/dist/string/snakeCase.d.ts +17 -0
  225. package/dist/string/snakeCase.js +43 -0
  226. package/dist/string/snakeCase.js.map +1 -0
  227. package/dist/string/snakeCase.mjs +9 -0
  228. package/dist/string/snakeCase.mjs.map +1 -0
  229. package/package.json +21 -1
  230. package/string.d.ts +1 -0
  231. package/dist/chunk-2MM5EJJX.mjs +0 -21
  232. package/dist/chunk-LOY6PATI.mjs +0 -1
  233. package/dist/chunk-MAJSPFA6.mjs +0 -1
  234. package/dist/chunk-N6EM6ETS.mjs +0 -1
  235. package/dist/chunk-NOFHNJ5C.mjs +0 -13
  236. package/dist/chunk-OHQAR5AU.mjs +0 -9
  237. package/dist/chunk-PMHULJNL.mjs +0 -1
  238. /package/dist/{chunk-2MM5EJJX.mjs.map → array/flattenDeep.mjs.map} +0 -0
  239. /package/dist/{chunk-LOY6PATI.mjs.map → array/initial.mjs.map} +0 -0
  240. /package/dist/{chunk-MAJSPFA6.mjs.map → array/last.mjs.map} +0 -0
  241. /package/dist/{chunk-N6EM6ETS.mjs.map → array/toFilled.mjs.map} +0 -0
  242. /package/dist/{chunk-PMHULJNL.mjs.map → chunk-236H5JZJ.mjs.map} +0 -0
  243. /package/dist/{chunk-QZITBKWX.mjs.map → chunk-4E4D3BMI.mjs.map} +0 -0
  244. /package/dist/{chunk-LT6E4Y4Z.mjs.map → chunk-GDC64SYJ.mjs.map} +0 -0
  245. /package/dist/{chunk-SDIMTYZW.mjs.map → chunk-IZAD2S7R.mjs.map} +0 -0
@@ -0,0 +1,12 @@
1
+ // src/array/initial.ts
2
+ function initial(arr) {
3
+ if (arr.length <= 1) {
4
+ return [];
5
+ }
6
+ return arr.slice(0, -1);
7
+ }
8
+
9
+ export {
10
+ initial
11
+ };
12
+ //# sourceMappingURL=chunk-XPSOKBRZ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/array/initial.ts"],"sourcesContent":["/**\n * Returns a new array containing all elements except the last one from the input array.\n * If the input array is empty or has only one element, the function returns an empty array.\n *\n * @template T The type of elements in the array.\n * @param {T[]} arr - The input array to query.\n * @returns {T[]} A new array containing all but the last element of the input array.\n *\n * @example\n * const arr = [1, 2, 3, 4];\n * const newArr = initial(arr);\n * // newArr will be [1, 2, 3]\n *\n * @example\n * const emptyArr: number[] = [];\n * const newEmptyArr = initial(emptyArr);\n * // newEmptyArr will be []\n *\n * @example\n * const singleElementArr = ['only one'];\n * const newSingleElementArr = initial(singleElementArr);\n * // newSingleElementArr will be []\n */\nexport function initial<T>(arr: T[]): T[] {\n if (arr.length <= 1) {\n return [];\n }\n return arr.slice(0, -1);\n}\n"],"mappings":";AAuBO,SAAS,QAAW,KAAe;AACxC,MAAI,IAAI,UAAU,GAAG;AACnB,WAAO,CAAC;AAAA,EACV;AACA,SAAO,IAAI,MAAM,GAAG,EAAE;AACxB;","names":[]}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  AbortError
3
3
  } from "../chunk-DXB7EZUQ.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-2HIMLZE3.mjs";
5
5
  export {
6
6
  AbortError
7
7
  };
@@ -2,7 +2,7 @@ import "../chunk-FZEZH22H.mjs";
2
2
  import {
3
3
  AbortError
4
4
  } from "../chunk-DXB7EZUQ.mjs";
5
- import "../chunk-2MM5EJJX.mjs";
5
+ import "../chunk-2HIMLZE3.mjs";
6
6
  export {
7
7
  AbortError
8
8
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  debounce
3
3
  } from "../chunk-3IP4JVLL.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-2HIMLZE3.mjs";
5
5
  export {
6
6
  debounce
7
7
  };
@@ -2,3 +2,4 @@ export { debounce } from './debounce.mjs';
2
2
  export { noop } from './noop.mjs';
3
3
  export { once } from './once.mjs';
4
4
  export { throttle } from './throttle.mjs';
5
+ export { negate } from './negate.mjs';
@@ -2,3 +2,4 @@ export { debounce } from './debounce.js';
2
2
  export { noop } from './noop.js';
3
3
  export { once } from './once.js';
4
4
  export { throttle } from './throttle.js';
5
+ export { negate } from './negate.js';
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var function_exports = {};
22
22
  __export(function_exports, {
23
23
  debounce: () => debounce,
24
+ negate: () => negate,
24
25
  noop: () => noop,
25
26
  once: () => once,
26
27
  throttle: () => throttle
@@ -86,9 +87,15 @@ function throttle(func, throttleMs) {
86
87
  };
87
88
  return throttledFunction;
88
89
  }
90
+
91
+ // src/function/negate.ts
92
+ function negate(func) {
93
+ return (...args) => !func(...args);
94
+ }
89
95
  // Annotate the CommonJS export names for ESM import in node:
90
96
  0 && (module.exports = {
91
97
  debounce,
98
+ negate,
92
99
  noop,
93
100
  once,
94
101
  throttle
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/function/index.ts","../../src/function/debounce.ts","../../src/function/noop.ts","../../src/function/once.ts","../../src/function/throttle.ts"],"sourcesContent":["export { debounce } from './debounce.ts';\nexport { noop } from './noop.ts';\nexport { once } from './once.ts';\nexport { throttle } from './throttle.ts';\n","interface DebounceOptions {\n signal?: AbortSignal;\n}\n\n/**\n * Creates a debounced function that delays invoking the provided function until after `debounceMs` milliseconds\n * have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel`\n * method to cancel any pending execution.\n *\n * @template F - The type of function.\n * @param {F} func - The function to debounce.\n * @param {number} debounceMs - The number of milliseconds to delay.\n * @param {DebounceOptions} options - The options object.\n * @param {AbortSignal} options.signal - An optional AbortSignal to cancel the debounced function.\n * @returns {F & { cancel: () => void }} A new debounced function with a `cancel` method.\n *\n * @example\n * const debouncedFunction = debounce(() => {\n * console.log('Function executed');\n * }, 1000);\n *\n * // Will log 'Function executed' after 1 second if not called again in that time\n * debouncedFunction();\n *\n * // Will not log anything as the previous call is canceled\n * debouncedFunction.cancel();\n *\n * // With AbortSignal\n * const controller = new AbortController();\n * const signal = controller.signal;\n * const debouncedWithSignal = debounce(() => {\n * console.log('Function executed');\n * }, 1000, { signal });\n *\n * debouncedWithSignal();\n *\n * // Will cancel the debounced function call\n * controller.abort();\n */\nexport function debounce<F extends (...args: any[]) => void>(\n func: F,\n debounceMs: number,\n { signal }: DebounceOptions = {}\n): F & { cancel: () => void } {\n let timeoutId: number | null = null;\n\n const debounced = function (...args: Parameters<F>) {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n }\n\n if (signal?.aborted) {\n return;\n }\n\n timeoutId = setTimeout(() => {\n func(...args);\n timeoutId = null;\n }, debounceMs) as any;\n } as F & { cancel: () => void };\n\n const onAbort = function () {\n debounced.cancel();\n };\n\n debounced.cancel = function () {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n };\n\n signal?.addEventListener('abort', onAbort, { once: true });\n\n return debounced;\n}\n","/**\n * A no-operation function that does nothing.\n * This can be used as a placeholder or default function.\n *\n * @example\n * noop(); // Does nothing\n *\n * @returns {void} This function does not return anything.\n */\nexport function noop(): void {}\n","/**\n * Creates a function that is restricted to invoking the provided function `func` once.\n * Repeated calls to the function will return the value from the first invocation.\n *\n * @template F - The type of function.\n * @param {F} func - The function to restrict.\n * @returns {F} A new function that invokes `func` once and caches the result.\n *\n * @example\n * const initialize = once(() => {\n * console.log('Initialized!');\n * return true;\n * });\n *\n * initialize(); // Logs: 'Initialized!' and returns true\n * initialize(); // Returns true without logging\n */\nexport function once<F extends () => any>(func: F): F {\n let called = false;\n let cache: ReturnType<F> | undefined;\n\n return function () {\n if (called) {\n return cache;\n }\n\n const result = func();\n\n called = true;\n cache = result;\n\n return result;\n } as F;\n}\n","/**\n * Creates a throttled function that only invokes the provided function at most once\n * per every `throttleMs` milliseconds. Subsequent calls to the throttled function\n * within the wait time will not trigger the execution of the original function.\n *\n * @template F - The type of function.\n * @param {F} func - The function to throttle.\n * @param {number} throttleMs - The number of milliseconds to throttle executions to.\n * @returns {F} A new throttled function that accepts the same parameters as the original function.\n *\n * @example\n * const throttledFunction = throttle(() => {\n * console.log('Function executed');\n * }, 1000);\n *\n * // Will log 'Function executed' immediately\n * throttledFunction();\n *\n * // Will not log anything as it is within the throttle time\n * throttledFunction();\n *\n * // After 1 second\n * setTimeout(() => {\n * throttledFunction(); // Will log 'Function executed'\n * }, 1000);\n */\nexport function throttle<F extends (...args: any[]) => void>(func: F, throttleMs: number): F {\n let lastCallTime: number | null;\n\n const throttledFunction = function (...args: Parameters<F>) {\n const now = Date.now();\n\n if (lastCallTime == null || now - lastCallTime >= throttleMs) {\n lastCallTime = now;\n func(...args);\n }\n } as F;\n\n return throttledFunction;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACuCO,SAAS,SACd,MACA,YACA,EAAE,OAAO,IAAqB,CAAC,GACH;AAC5B,MAAI,YAA2B;AAE/B,QAAM,YAAY,YAAa,MAAqB;AAClD,QAAI,cAAc,MAAM;AACtB,mBAAa,SAAS;AAAA,IACxB;AAEA,QAAI,iCAAQ,SAAS;AACnB;AAAA,IACF;AAEA,gBAAY,WAAW,MAAM;AAC3B,WAAK,GAAG,IAAI;AACZ,kBAAY;AAAA,IACd,GAAG,UAAU;AAAA,EACf;AAEA,QAAM,UAAU,WAAY;AAC1B,cAAU,OAAO;AAAA,EACnB;AAEA,YAAU,SAAS,WAAY;AAC7B,QAAI,cAAc,MAAM;AACtB,mBAAa,SAAS;AACtB,kBAAY;AAAA,IACd;AAAA,EACF;AAEA,mCAAQ,iBAAiB,SAAS,SAAS,EAAE,MAAM,KAAK;AAExD,SAAO;AACT;;;AClEO,SAAS,OAAa;AAAC;;;ACQvB,SAAS,KAA0B,MAAY;AACpD,MAAI,SAAS;AACb,MAAI;AAEJ,SAAO,WAAY;AACjB,QAAI,QAAQ;AACV,aAAO;AAAA,IACT;AAEA,UAAM,SAAS,KAAK;AAEpB,aAAS;AACT,YAAQ;AAER,WAAO;AAAA,EACT;AACF;;;ACPO,SAAS,SAA6C,MAAS,YAAuB;AAC3F,MAAI;AAEJ,QAAM,oBAAoB,YAAa,MAAqB;AAC1D,UAAM,MAAM,KAAK,IAAI;AAErB,QAAI,gBAAgB,QAAQ,MAAM,gBAAgB,YAAY;AAC5D,qBAAe;AACf,WAAK,GAAG,IAAI;AAAA,IACd;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/function/index.ts","../../src/function/debounce.ts","../../src/function/noop.ts","../../src/function/once.ts","../../src/function/throttle.ts","../../src/function/negate.ts"],"sourcesContent":["export { debounce } from './debounce.ts';\nexport { noop } from './noop.ts';\nexport { once } from './once.ts';\nexport { throttle } from './throttle.ts';\nexport { negate } from './negate.ts';\n","interface DebounceOptions {\n signal?: AbortSignal;\n}\n\n/**\n * Creates a debounced function that delays invoking the provided function until after `debounceMs` milliseconds\n * have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel`\n * method to cancel any pending execution.\n *\n * @template F - The type of function.\n * @param {F} func - The function to debounce.\n * @param {number} debounceMs - The number of milliseconds to delay.\n * @param {DebounceOptions} options - The options object.\n * @param {AbortSignal} options.signal - An optional AbortSignal to cancel the debounced function.\n * @returns {F & { cancel: () => void }} A new debounced function with a `cancel` method.\n *\n * @example\n * const debouncedFunction = debounce(() => {\n * console.log('Function executed');\n * }, 1000);\n *\n * // Will log 'Function executed' after 1 second if not called again in that time\n * debouncedFunction();\n *\n * // Will not log anything as the previous call is canceled\n * debouncedFunction.cancel();\n *\n * // With AbortSignal\n * const controller = new AbortController();\n * const signal = controller.signal;\n * const debouncedWithSignal = debounce(() => {\n * console.log('Function executed');\n * }, 1000, { signal });\n *\n * debouncedWithSignal();\n *\n * // Will cancel the debounced function call\n * controller.abort();\n */\nexport function debounce<F extends (...args: any[]) => void>(\n func: F,\n debounceMs: number,\n { signal }: DebounceOptions = {}\n): F & { cancel: () => void } {\n let timeoutId: number | null = null;\n\n const debounced = function (...args: Parameters<F>) {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n }\n\n if (signal?.aborted) {\n return;\n }\n\n timeoutId = setTimeout(() => {\n func(...args);\n timeoutId = null;\n }, debounceMs) as any;\n } as F & { cancel: () => void };\n\n const onAbort = function () {\n debounced.cancel();\n };\n\n debounced.cancel = function () {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n };\n\n signal?.addEventListener('abort', onAbort, { once: true });\n\n return debounced;\n}\n","/**\n * A no-operation function that does nothing.\n * This can be used as a placeholder or default function.\n *\n * @example\n * noop(); // Does nothing\n *\n * @returns {void} This function does not return anything.\n */\nexport function noop(): void {}\n","/**\n * Creates a function that is restricted to invoking the provided function `func` once.\n * Repeated calls to the function will return the value from the first invocation.\n *\n * @template F - The type of function.\n * @param {F} func - The function to restrict.\n * @returns {F} A new function that invokes `func` once and caches the result.\n *\n * @example\n * const initialize = once(() => {\n * console.log('Initialized!');\n * return true;\n * });\n *\n * initialize(); // Logs: 'Initialized!' and returns true\n * initialize(); // Returns true without logging\n */\nexport function once<F extends () => any>(func: F): F {\n let called = false;\n let cache: ReturnType<F> | undefined;\n\n return function () {\n if (called) {\n return cache;\n }\n\n const result = func();\n\n called = true;\n cache = result;\n\n return result;\n } as F;\n}\n","/**\n * Creates a throttled function that only invokes the provided function at most once\n * per every `throttleMs` milliseconds. Subsequent calls to the throttled function\n * within the wait time will not trigger the execution of the original function.\n *\n * @template F - The type of function.\n * @param {F} func - The function to throttle.\n * @param {number} throttleMs - The number of milliseconds to throttle executions to.\n * @returns {F} A new throttled function that accepts the same parameters as the original function.\n *\n * @example\n * const throttledFunction = throttle(() => {\n * console.log('Function executed');\n * }, 1000);\n *\n * // Will log 'Function executed' immediately\n * throttledFunction();\n *\n * // Will not log anything as it is within the throttle time\n * throttledFunction();\n *\n * // After 1 second\n * setTimeout(() => {\n * throttledFunction(); // Will log 'Function executed'\n * }, 1000);\n */\nexport function throttle<F extends (...args: any[]) => void>(func: F, throttleMs: number): F {\n let lastCallTime: number | null;\n\n const throttledFunction = function (...args: Parameters<F>) {\n const now = Date.now();\n\n if (lastCallTime == null || now - lastCallTime >= throttleMs) {\n lastCallTime = now;\n func(...args);\n }\n } as F;\n\n return throttledFunction;\n}\n","/**\n * Creates a function that negates the result of the predicate function.\n *\n * @template F - The type of the function to negate.\n * @param {F} func - The function to negate.\n * @returns {F} The new negated function, which negates the boolean result of `func`.\n */\nexport function negate<F extends (...args: unknown[]) => boolean>(func: F): F {\n return ((...args: any[]) => !func(...args)) as F;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACuCO,SAAS,SACd,MACA,YACA,EAAE,OAAO,IAAqB,CAAC,GACH;AAC5B,MAAI,YAA2B;AAE/B,QAAM,YAAY,YAAa,MAAqB;AAClD,QAAI,cAAc,MAAM;AACtB,mBAAa,SAAS;AAAA,IACxB;AAEA,QAAI,iCAAQ,SAAS;AACnB;AAAA,IACF;AAEA,gBAAY,WAAW,MAAM;AAC3B,WAAK,GAAG,IAAI;AACZ,kBAAY;AAAA,IACd,GAAG,UAAU;AAAA,EACf;AAEA,QAAM,UAAU,WAAY;AAC1B,cAAU,OAAO;AAAA,EACnB;AAEA,YAAU,SAAS,WAAY;AAC7B,QAAI,cAAc,MAAM;AACtB,mBAAa,SAAS;AACtB,kBAAY;AAAA,IACd;AAAA,EACF;AAEA,mCAAQ,iBAAiB,SAAS,SAAS,EAAE,MAAM,KAAK;AAExD,SAAO;AACT;;;AClEO,SAAS,OAAa;AAAC;;;ACQvB,SAAS,KAA0B,MAAY;AACpD,MAAI,SAAS;AACb,MAAI;AAEJ,SAAO,WAAY;AACjB,QAAI,QAAQ;AACV,aAAO;AAAA,IACT;AAEA,UAAM,SAAS,KAAK;AAEpB,aAAS;AACT,YAAQ;AAER,WAAO;AAAA,EACT;AACF;;;ACPO,SAAS,SAA6C,MAAS,YAAuB;AAC3F,MAAI;AAEJ,QAAM,oBAAoB,YAAa,MAAqB;AAC1D,UAAM,MAAM,KAAK,IAAI;AAErB,QAAI,gBAAgB,QAAQ,MAAM,gBAAgB,YAAY;AAC5D,qBAAe;AACf,WAAK,GAAG,IAAI;AAAA,IACd;AAAA,EACF;AAEA,SAAO;AACT;;;AChCO,SAAS,OAAkD,MAAY;AAC1E,SAAQ,IAAI,SAAgB,CAAC,KAAK,GAAG,IAAI;AAC7C;","names":[]}
@@ -1,7 +1,10 @@
1
- import "../chunk-N6EM6ETS.mjs";
1
+ import "../chunk-236H5JZJ.mjs";
2
2
  import {
3
3
  debounce
4
4
  } from "../chunk-3IP4JVLL.mjs";
5
+ import {
6
+ negate
7
+ } from "../chunk-BOOQBJN2.mjs";
5
8
  import {
6
9
  noop
7
10
  } from "../chunk-LKXCOLNY.mjs";
@@ -11,9 +14,10 @@ import {
11
14
  import {
12
15
  throttle
13
16
  } from "../chunk-QOJGMVVR.mjs";
14
- import "../chunk-2MM5EJJX.mjs";
17
+ import "../chunk-2HIMLZE3.mjs";
15
18
  export {
16
19
  debounce,
20
+ negate,
17
21
  noop,
18
22
  once,
19
23
  throttle
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Creates a function that negates the result of the predicate function.
3
+ *
4
+ * @template F - The type of the function to negate.
5
+ * @param {F} func - The function to negate.
6
+ * @returns {F} The new negated function, which negates the boolean result of `func`.
7
+ */
8
+ declare function negate<F extends (...args: unknown[]) => boolean>(func: F): F;
9
+
10
+ export { negate };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Creates a function that negates the result of the predicate function.
3
+ *
4
+ * @template F - The type of the function to negate.
5
+ * @param {F} func - The function to negate.
6
+ * @returns {F} The new negated function, which negates the boolean result of `func`.
7
+ */
8
+ declare function negate<F extends (...args: unknown[]) => boolean>(func: F): F;
9
+
10
+ export { negate };
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/function/negate.ts
21
+ var negate_exports = {};
22
+ __export(negate_exports, {
23
+ negate: () => negate
24
+ });
25
+ module.exports = __toCommonJS(negate_exports);
26
+ function negate(func) {
27
+ return (...args) => !func(...args);
28
+ }
29
+ // Annotate the CommonJS export names for ESM import in node:
30
+ 0 && (module.exports = {
31
+ negate
32
+ });
33
+ //# sourceMappingURL=negate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/function/negate.ts"],"sourcesContent":["/**\n * Creates a function that negates the result of the predicate function.\n *\n * @template F - The type of the function to negate.\n * @param {F} func - The function to negate.\n * @returns {F} The new negated function, which negates the boolean result of `func`.\n */\nexport function negate<F extends (...args: unknown[]) => boolean>(func: F): F {\n return ((...args: any[]) => !func(...args)) as F;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,SAAS,OAAkD,MAAY;AAC1E,SAAQ,IAAI,SAAgB,CAAC,KAAK,GAAG,IAAI;AAC7C;","names":[]}
@@ -0,0 +1,8 @@
1
+ import {
2
+ negate
3
+ } from "../chunk-BOOQBJN2.mjs";
4
+ import "../chunk-2HIMLZE3.mjs";
5
+ export {
6
+ negate
7
+ };
8
+ //# sourceMappingURL=negate.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  noop
3
3
  } from "../chunk-LKXCOLNY.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-2HIMLZE3.mjs";
5
5
  export {
6
6
  noop
7
7
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  once
3
3
  } from "../chunk-CMBC4MXG.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-2HIMLZE3.mjs";
5
5
  export {
6
6
  once
7
7
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  throttle
3
3
  } from "../chunk-QOJGMVVR.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-2HIMLZE3.mjs";
5
5
  export {
6
6
  throttle
7
7
  };
package/dist/index.d.mts CHANGED
@@ -10,6 +10,7 @@ export { dropRightWhile } from './array/dropRightWhile.mjs';
10
10
  export { dropWhile } from './array/dropWhile.mjs';
11
11
  export { fill } from './array/fill.mjs';
12
12
  export { flatten } from './array/flatten.mjs';
13
+ export { flattenDeep } from './array/flattenDeep.mjs';
13
14
  export { forEachRight } from './array/forEachRight.mjs';
14
15
  export { groupBy } from './array/groupBy.mjs';
15
16
  export { intersection } from './array/intersection.mjs';
@@ -44,11 +45,15 @@ export { zipWith } from './array/zipWith.mjs';
44
45
  export { without } from './array/without.mjs';
45
46
  export { head } from './array/head.mjs';
46
47
  export { tail } from './array/tail.mjs';
48
+ export { toFilled } from './array/toFilled.mjs';
49
+ export { last } from './array/last.mjs';
50
+ export { initial } from './array/initial.mjs';
47
51
  export { AbortError } from './error/AbortError.mjs';
48
52
  export { debounce } from './function/debounce.mjs';
49
53
  export { noop } from './function/noop.mjs';
50
54
  export { once } from './function/once.mjs';
51
55
  export { throttle } from './function/throttle.mjs';
56
+ export { negate } from './function/negate.mjs';
52
57
  export { clamp } from './math/clamp.mjs';
53
58
  export { inRange } from './math/inRange.mjs';
54
59
  export { mean } from './math/mean.mjs';
@@ -63,8 +68,15 @@ export { omitBy } from './object/omitBy.mjs';
63
68
  export { pick } from './object/pick.mjs';
64
69
  export { pickBy } from './object/pickBy.mjs';
65
70
  export { invert } from './object/invert.mjs';
71
+ export { clone } from './object/clone.mjs';
72
+ export { isEqual } from './predicate/isEqual.mjs';
66
73
  export { isNil } from './predicate/isNil.mjs';
67
74
  export { isNotNil } from './predicate/isNotNil.mjs';
68
75
  export { isNull } from './predicate/isNull.mjs';
69
76
  export { isUndefined } from './predicate/isUndefined.mjs';
70
77
  export { delay } from './promise/delay.mjs';
78
+ export { camelCase } from './string/camelCase.mjs';
79
+ export { snakeCase } from './string/snakeCase.mjs';
80
+ export { kebabCase } from './string/kebabCase.mjs';
81
+ export { lowerCase } from './string/lowerCase.mjs';
82
+ export { capitalize } from './string/capitalize.mjs';
package/dist/index.d.ts CHANGED
@@ -10,6 +10,7 @@ export { dropRightWhile } from './array/dropRightWhile.js';
10
10
  export { dropWhile } from './array/dropWhile.js';
11
11
  export { fill } from './array/fill.js';
12
12
  export { flatten } from './array/flatten.js';
13
+ export { flattenDeep } from './array/flattenDeep.js';
13
14
  export { forEachRight } from './array/forEachRight.js';
14
15
  export { groupBy } from './array/groupBy.js';
15
16
  export { intersection } from './array/intersection.js';
@@ -44,11 +45,15 @@ export { zipWith } from './array/zipWith.js';
44
45
  export { without } from './array/without.js';
45
46
  export { head } from './array/head.js';
46
47
  export { tail } from './array/tail.js';
48
+ export { toFilled } from './array/toFilled.js';
49
+ export { last } from './array/last.js';
50
+ export { initial } from './array/initial.js';
47
51
  export { AbortError } from './error/AbortError.js';
48
52
  export { debounce } from './function/debounce.js';
49
53
  export { noop } from './function/noop.js';
50
54
  export { once } from './function/once.js';
51
55
  export { throttle } from './function/throttle.js';
56
+ export { negate } from './function/negate.js';
52
57
  export { clamp } from './math/clamp.js';
53
58
  export { inRange } from './math/inRange.js';
54
59
  export { mean } from './math/mean.js';
@@ -63,8 +68,15 @@ export { omitBy } from './object/omitBy.js';
63
68
  export { pick } from './object/pick.js';
64
69
  export { pickBy } from './object/pickBy.js';
65
70
  export { invert } from './object/invert.js';
71
+ export { clone } from './object/clone.js';
72
+ export { isEqual } from './predicate/isEqual.js';
66
73
  export { isNil } from './predicate/isNil.js';
67
74
  export { isNotNil } from './predicate/isNotNil.js';
68
75
  export { isNull } from './predicate/isNull.js';
69
76
  export { isUndefined } from './predicate/isUndefined.js';
70
77
  export { delay } from './promise/delay.js';
78
+ export { camelCase } from './string/camelCase.js';
79
+ export { snakeCase } from './string/snakeCase.js';
80
+ export { kebabCase } from './string/kebabCase.js';
81
+ export { lowerCase } from './string/lowerCase.js';
82
+ export { capitalize } from './string/capitalize.js';