es-toolkit 1.0.4 → 1.1.0-dev.45

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 (249) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +0 -1
  3. package/dist/array/chunk.js.map +1 -1
  4. package/dist/array/chunk.mjs +1 -1
  5. package/dist/array/difference.d.mts +1 -1
  6. package/dist/array/difference.d.ts +1 -1
  7. package/dist/array/difference.js +2 -3
  8. package/dist/array/difference.js.map +1 -1
  9. package/dist/array/difference.mjs +1 -1
  10. package/dist/array/differenceBy.js.map +1 -1
  11. package/dist/array/differenceBy.mjs +1 -1
  12. package/dist/array/differenceWith.js.map +1 -1
  13. package/dist/array/differenceWith.mjs +1 -1
  14. package/dist/array/drop.js.map +1 -1
  15. package/dist/array/drop.mjs +1 -1
  16. package/dist/array/dropRight.js.map +1 -1
  17. package/dist/array/dropRight.mjs +1 -1
  18. package/dist/array/dropRightWhile.js.map +1 -1
  19. package/dist/array/dropRightWhile.mjs +2 -2
  20. package/dist/array/dropWhile.js.map +1 -1
  21. package/dist/array/dropWhile.mjs +1 -1
  22. package/dist/array/groupBy.js.map +1 -1
  23. package/dist/array/groupBy.mjs +1 -1
  24. package/dist/array/index.js +2 -3
  25. package/dist/array/index.js.map +1 -1
  26. package/dist/array/index.mjs +30 -30
  27. package/dist/array/intersection.js.map +1 -1
  28. package/dist/array/intersection.mjs +1 -1
  29. package/dist/array/intersectionBy.js.map +1 -1
  30. package/dist/array/intersectionBy.mjs +1 -1
  31. package/dist/array/intersectionWith.js.map +1 -1
  32. package/dist/array/intersectionWith.mjs +1 -1
  33. package/dist/array/partition.js.map +1 -1
  34. package/dist/array/partition.mjs +1 -1
  35. package/dist/array/sample.js.map +1 -1
  36. package/dist/array/sample.mjs +1 -1
  37. package/dist/array/shuffle.js.map +1 -1
  38. package/dist/array/shuffle.mjs +1 -1
  39. package/dist/array/take.js.map +1 -1
  40. package/dist/array/take.mjs +1 -1
  41. package/dist/array/takeRight.js.map +1 -1
  42. package/dist/array/takeRight.mjs +1 -1
  43. package/dist/array/takeRightWhile.js.map +1 -1
  44. package/dist/array/takeRightWhile.mjs +1 -1
  45. package/dist/array/takeWhile.js.map +1 -1
  46. package/dist/array/takeWhile.mjs +1 -1
  47. package/dist/array/union.js.map +1 -1
  48. package/dist/array/union.mjs +2 -2
  49. package/dist/array/unionBy.js.map +1 -1
  50. package/dist/array/unionBy.mjs +1 -1
  51. package/dist/array/unionWith.js.map +1 -1
  52. package/dist/array/unionWith.mjs +2 -2
  53. package/dist/array/uniq.js.map +1 -1
  54. package/dist/array/uniq.mjs +1 -1
  55. package/dist/array/uniqBy.js.map +1 -1
  56. package/dist/array/uniqBy.mjs +2 -2
  57. package/dist/array/uniqWith.js.map +1 -1
  58. package/dist/array/uniqWith.mjs +1 -1
  59. package/dist/array/xor.js +2 -3
  60. package/dist/array/xor.js.map +1 -1
  61. package/dist/array/xor.mjs +5 -5
  62. package/dist/array/xorBy.js.map +1 -1
  63. package/dist/array/xorBy.mjs +4 -4
  64. package/dist/array/xorWith.js.map +1 -1
  65. package/dist/array/xorWith.mjs +5 -5
  66. package/dist/array/zip.js.map +1 -1
  67. package/dist/array/zip.mjs +1 -1
  68. package/dist/array/zipWith.js.map +1 -1
  69. package/dist/array/zipWith.mjs +1 -1
  70. package/dist/{chunk-TOLR2FNF.mjs → chunk-23DC774L.mjs} +1 -1
  71. package/dist/chunk-23DC774L.mjs.map +1 -0
  72. package/dist/{chunk-S767XFOS.mjs → chunk-3PFYAKOD.mjs} +1 -1
  73. package/dist/chunk-3PFYAKOD.mjs.map +1 -0
  74. package/dist/{chunk-NYVT33DR.mjs → chunk-6BCRFIEW.mjs} +1 -1
  75. package/dist/chunk-6BCRFIEW.mjs.map +1 -0
  76. package/dist/{chunk-VACGGQOL.mjs → chunk-6GRNTXI3.mjs} +1 -1
  77. package/dist/chunk-6GRNTXI3.mjs.map +1 -0
  78. package/dist/{chunk-SGSQKXDO.mjs → chunk-6LDIBBWQ.mjs} +2 -2
  79. package/dist/chunk-6LDIBBWQ.mjs.map +1 -0
  80. package/dist/{chunk-GJM7F3TH.mjs → chunk-7LAOIS6P.mjs} +1 -1
  81. package/dist/chunk-7LAOIS6P.mjs.map +1 -0
  82. package/dist/{chunk-724PNXPR.mjs → chunk-AFYV2UVZ.mjs} +1 -1
  83. package/dist/chunk-AFYV2UVZ.mjs.map +1 -0
  84. package/dist/{chunk-2VB6XU3I.mjs → chunk-ANJSX6WH.mjs} +1 -1
  85. package/dist/chunk-ANJSX6WH.mjs.map +1 -0
  86. package/dist/{chunk-OBMK7JO2.mjs → chunk-B5P232BA.mjs} +1 -1
  87. package/dist/chunk-B5P232BA.mjs.map +1 -0
  88. package/dist/{chunk-L4Y3G6AJ.mjs → chunk-GELVVASW.mjs} +3 -3
  89. package/dist/chunk-GELVVASW.mjs.map +1 -0
  90. package/dist/{chunk-RLDY4N3Q.mjs → chunk-GLAZTR32.mjs} +2 -2
  91. package/dist/chunk-GLAZTR32.mjs.map +1 -0
  92. package/dist/{chunk-NK2262VG.mjs → chunk-HOQRMBSB.mjs} +1 -1
  93. package/dist/chunk-HOQRMBSB.mjs.map +1 -0
  94. package/dist/{chunk-PWMHSN27.mjs → chunk-IFCX35BI.mjs} +1 -1
  95. package/dist/chunk-IFCX35BI.mjs.map +1 -0
  96. package/dist/{chunk-UZP4YX7I.mjs → chunk-J6SWM4X6.mjs} +1 -1
  97. package/dist/chunk-J6SWM4X6.mjs.map +1 -0
  98. package/dist/{chunk-QRQPLMV4.mjs → chunk-JDMFIUGM.mjs} +1 -1
  99. package/dist/chunk-JDMFIUGM.mjs.map +1 -0
  100. package/dist/{chunk-WFQ3LAHQ.mjs → chunk-KBJTBR5T.mjs} +1 -1
  101. package/dist/chunk-KBJTBR5T.mjs.map +1 -0
  102. package/dist/{chunk-5JWSGT4R.mjs → chunk-L25VRQ54.mjs} +1 -1
  103. package/dist/chunk-L25VRQ54.mjs.map +1 -0
  104. package/dist/{chunk-BAJC3BM7.mjs → chunk-L3C6TG2V.mjs} +1 -1
  105. package/dist/chunk-L3C6TG2V.mjs.map +1 -0
  106. package/dist/{chunk-2KXLTAVK.mjs → chunk-LLOAPSQ6.mjs} +1 -1
  107. package/dist/{chunk-2KXLTAVK.mjs.map → chunk-LLOAPSQ6.mjs.map} +1 -1
  108. package/dist/{chunk-NSYWEYWT.mjs → chunk-M3SHJ3LL.mjs} +1 -1
  109. package/dist/chunk-M3SHJ3LL.mjs.map +1 -0
  110. package/dist/{chunk-HQF6OFGM.mjs → chunk-OLBUAFBX.mjs} +1 -1
  111. package/dist/chunk-OLBUAFBX.mjs.map +1 -0
  112. package/dist/{chunk-35TWSMYS.mjs → chunk-OS5PZ4B4.mjs} +1 -1
  113. package/dist/{chunk-35TWSMYS.mjs.map → chunk-OS5PZ4B4.mjs.map} +1 -1
  114. package/dist/{chunk-J3NTLMAE.mjs → chunk-PHG5JCSW.mjs} +1 -1
  115. package/dist/chunk-PHG5JCSW.mjs.map +1 -0
  116. package/dist/{chunk-RU3RXBUC.mjs → chunk-PRTIPC5X.mjs} +1 -1
  117. package/dist/chunk-PRTIPC5X.mjs.map +1 -0
  118. package/dist/{chunk-EAI6NLXI.mjs → chunk-PUQLVKMB.mjs} +1 -1
  119. package/dist/chunk-PUQLVKMB.mjs.map +1 -0
  120. package/dist/{chunk-Z4IO7EIH.mjs → chunk-SF3V7XXM.mjs} +1 -1
  121. package/dist/chunk-SF3V7XXM.mjs.map +1 -0
  122. package/dist/chunk-SORNYLIU.mjs +10 -0
  123. package/dist/chunk-SORNYLIU.mjs.map +1 -0
  124. package/dist/{chunk-7PPND7QY.mjs → chunk-SPLO5OZW.mjs} +1 -1
  125. package/dist/chunk-SPLO5OZW.mjs.map +1 -0
  126. package/dist/{chunk-EAI4DDCQ.mjs → chunk-SQOYF647.mjs} +1 -1
  127. package/dist/chunk-SQOYF647.mjs.map +1 -0
  128. package/dist/{chunk-XW452I77.mjs → chunk-T2C2WVFL.mjs} +1 -1
  129. package/dist/chunk-T2C2WVFL.mjs.map +1 -0
  130. package/dist/{chunk-XS4ZPJMT.mjs → chunk-TCHT4HCP.mjs} +4 -4
  131. package/dist/chunk-TCHT4HCP.mjs.map +1 -0
  132. package/dist/{chunk-NEMQJ2GF.mjs → chunk-TF6N37OE.mjs} +1 -1
  133. package/dist/chunk-TF6N37OE.mjs.map +1 -0
  134. package/dist/{chunk-JMLFPGZ3.mjs → chunk-TK2EDHSP.mjs} +2 -2
  135. package/dist/chunk-TK2EDHSP.mjs.map +1 -0
  136. package/dist/{chunk-R5DNKXDI.mjs → chunk-TULUUJ3E.mjs} +4 -4
  137. package/dist/chunk-TULUUJ3E.mjs.map +1 -0
  138. package/dist/{chunk-ARWKEQMQ.mjs → chunk-UFAA5WKR.mjs} +1 -1
  139. package/dist/chunk-UFAA5WKR.mjs.map +1 -0
  140. package/dist/{chunk-UNX3KZO2.mjs → chunk-V6LXSPMF.mjs} +1 -1
  141. package/dist/chunk-V6LXSPMF.mjs.map +1 -0
  142. package/dist/{chunk-7OZZODAE.mjs → chunk-VKVA56XG.mjs} +4 -4
  143. package/dist/chunk-VKVA56XG.mjs.map +1 -0
  144. package/dist/{chunk-VAKCSKGR.mjs → chunk-XLO3QZVY.mjs} +3 -3
  145. package/dist/chunk-XLO3QZVY.mjs.map +1 -0
  146. package/dist/{chunk-FUWEG5ZM.mjs → chunk-Y6ZRNII6.mjs} +1 -1
  147. package/dist/chunk-Y6ZRNII6.mjs.map +1 -0
  148. package/dist/{chunk-VJGGYY4Y.mjs → chunk-YEZIGQJG.mjs} +2 -2
  149. package/dist/chunk-YEZIGQJG.mjs.map +1 -0
  150. package/dist/{chunk-LAZNLIBJ.mjs → chunk-YHY2XTJW.mjs} +1 -1
  151. package/dist/chunk-YHY2XTJW.mjs.map +1 -0
  152. package/dist/{chunk-7GWOR247.mjs → chunk-YNRYG5OB.mjs} +1 -1
  153. package/dist/chunk-YNRYG5OB.mjs.map +1 -0
  154. package/dist/{chunk-7SJHJHBN.mjs → chunk-ZBG3EYM3.mjs} +1 -1
  155. package/dist/chunk-ZBG3EYM3.mjs.map +1 -0
  156. package/dist/{chunk-YMNXRH52.mjs → chunk-ZQNAZPSK.mjs} +1 -1
  157. package/dist/chunk-ZQNAZPSK.mjs.map +1 -0
  158. package/dist/function/debounce.d.mts +3 -4
  159. package/dist/function/debounce.d.ts +3 -4
  160. package/dist/function/debounce.js +2 -2
  161. package/dist/function/debounce.js.map +1 -1
  162. package/dist/function/debounce.mjs +1 -1
  163. package/dist/function/index.js +4 -4
  164. package/dist/function/index.js.map +1 -1
  165. package/dist/function/index.mjs +3 -3
  166. package/dist/function/once.js.map +1 -1
  167. package/dist/function/once.mjs +1 -1
  168. package/dist/function/throttle.d.mts +3 -3
  169. package/dist/function/throttle.d.ts +3 -3
  170. package/dist/function/throttle.js +2 -2
  171. package/dist/function/throttle.js.map +1 -1
  172. package/dist/function/throttle.mjs +1 -1
  173. package/dist/index.js +6 -7
  174. package/dist/index.js.map +1 -1
  175. package/dist/index.mjs +44 -44
  176. package/dist/math/index.js.map +1 -1
  177. package/dist/math/index.mjs +2 -2
  178. package/dist/math/round.js.map +1 -1
  179. package/dist/math/round.mjs +1 -1
  180. package/dist/math/sum.js.map +1 -1
  181. package/dist/math/sum.mjs +1 -1
  182. package/dist/object/index.js.map +1 -1
  183. package/dist/object/index.mjs +4 -4
  184. package/dist/object/omit.js.map +1 -1
  185. package/dist/object/omit.mjs +1 -1
  186. package/dist/object/omitBy.js.map +1 -1
  187. package/dist/object/omitBy.mjs +1 -1
  188. package/dist/object/pick.js.map +1 -1
  189. package/dist/object/pick.mjs +1 -1
  190. package/dist/object/pickBy.js.map +1 -1
  191. package/dist/object/pickBy.mjs +1 -1
  192. package/dist/predicate/index.js.map +1 -1
  193. package/dist/predicate/index.mjs +4 -4
  194. package/dist/predicate/isNil.js.map +1 -1
  195. package/dist/predicate/isNil.mjs +1 -1
  196. package/dist/predicate/isNotNil.js.map +1 -1
  197. package/dist/predicate/isNotNil.mjs +1 -1
  198. package/dist/predicate/isNull.js.map +1 -1
  199. package/dist/predicate/isNull.mjs +1 -1
  200. package/dist/predicate/isUndefined.js.map +1 -1
  201. package/dist/predicate/isUndefined.mjs +1 -1
  202. package/dist/promise/delay.js.map +1 -1
  203. package/dist/promise/delay.mjs +1 -1
  204. package/dist/promise/index.js.map +1 -1
  205. package/dist/promise/index.mjs +1 -1
  206. package/package.json +3 -2
  207. package/dist/chunk-2VB6XU3I.mjs.map +0 -1
  208. package/dist/chunk-5JWSGT4R.mjs.map +0 -1
  209. package/dist/chunk-724PNXPR.mjs.map +0 -1
  210. package/dist/chunk-7GWOR247.mjs.map +0 -1
  211. package/dist/chunk-7OZZODAE.mjs.map +0 -1
  212. package/dist/chunk-7PPND7QY.mjs.map +0 -1
  213. package/dist/chunk-7SJHJHBN.mjs.map +0 -1
  214. package/dist/chunk-ARWKEQMQ.mjs.map +0 -1
  215. package/dist/chunk-BAJC3BM7.mjs.map +0 -1
  216. package/dist/chunk-EAI4DDCQ.mjs.map +0 -1
  217. package/dist/chunk-EAI6NLXI.mjs.map +0 -1
  218. package/dist/chunk-FUWEG5ZM.mjs.map +0 -1
  219. package/dist/chunk-GJM7F3TH.mjs.map +0 -1
  220. package/dist/chunk-HQF6OFGM.mjs.map +0 -1
  221. package/dist/chunk-J3NTLMAE.mjs.map +0 -1
  222. package/dist/chunk-JMLFPGZ3.mjs.map +0 -1
  223. package/dist/chunk-L4Y3G6AJ.mjs.map +0 -1
  224. package/dist/chunk-LAZNLIBJ.mjs.map +0 -1
  225. package/dist/chunk-NEMQJ2GF.mjs.map +0 -1
  226. package/dist/chunk-NK2262VG.mjs.map +0 -1
  227. package/dist/chunk-NSYWEYWT.mjs.map +0 -1
  228. package/dist/chunk-NYVT33DR.mjs.map +0 -1
  229. package/dist/chunk-OBMK7JO2.mjs.map +0 -1
  230. package/dist/chunk-PTQLD7TG.mjs +0 -11
  231. package/dist/chunk-PTQLD7TG.mjs.map +0 -1
  232. package/dist/chunk-PWMHSN27.mjs.map +0 -1
  233. package/dist/chunk-QRQPLMV4.mjs.map +0 -1
  234. package/dist/chunk-R5DNKXDI.mjs.map +0 -1
  235. package/dist/chunk-RLDY4N3Q.mjs.map +0 -1
  236. package/dist/chunk-RU3RXBUC.mjs.map +0 -1
  237. package/dist/chunk-S767XFOS.mjs.map +0 -1
  238. package/dist/chunk-SGSQKXDO.mjs.map +0 -1
  239. package/dist/chunk-TOLR2FNF.mjs.map +0 -1
  240. package/dist/chunk-UNX3KZO2.mjs.map +0 -1
  241. package/dist/chunk-UZP4YX7I.mjs.map +0 -1
  242. package/dist/chunk-VACGGQOL.mjs.map +0 -1
  243. package/dist/chunk-VAKCSKGR.mjs.map +0 -1
  244. package/dist/chunk-VJGGYY4Y.mjs.map +0 -1
  245. package/dist/chunk-WFQ3LAHQ.mjs.map +0 -1
  246. package/dist/chunk-XS4ZPJMT.mjs.map +0 -1
  247. package/dist/chunk-XW452I77.mjs.map +0 -1
  248. package/dist/chunk-YMNXRH52.mjs.map +0 -1
  249. package/dist/chunk-Z4IO7EIH.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/math/round.ts"],"sourcesContent":["/**\n * Rounds a number to a specified precision.\n *\n * This function takes a number and an optional precision value, and returns the number rounded\n * to the specified number of decimal places.\n *\n * @param {number} value - The number to round.\n * @param {number} [precision=0] - The number of decimal places to round to. Defaults to 0.\n * @returns {number} The rounded number.\n *\n * @example\n * * const result1 = round(1.2345); // result1 will be 1\n * const result2 = round(1.2345, 2); // result2 will be 1.23\n * const result3 = round(1.2345, 3); // result3 will be 1.235\n */\nexport function round(value: number, precision: number = 0): number {\n const multiplier = Math.pow(10, precision);\n return Math.round(value * multiplier) / multiplier;\n}\n"],"mappings":";AAeO,SAAS,MAAM,OAAe,YAAoB,GAAW;AAClE,QAAM,aAAa,KAAK,IAAI,IAAI,SAAS;AACzC,SAAO,KAAK,MAAM,QAAQ,UAAU,IAAI;AAC1C;","names":[]}
@@ -8,4 +8,4 @@ function intersection(firstArr, secondArr) {
8
8
  export {
9
9
  intersection
10
10
  };
11
- //# sourceMappingURL=chunk-7GWOR247.mjs.map
11
+ //# sourceMappingURL=chunk-YNRYG5OB.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/array/intersection.ts"],"sourcesContent":["/**\n * Returns the intersection of two arrays.\n *\n * This function takes two arrays and returns a new array containing the elements that are\n * present in both arrays. It effectively filters out any elements from the first array that\n * are not found in the second array.\n *\n * @param {T[]} firstArr - The first array to compare.\n * @param {T[]} secondArr - The second array to compare.\n * @returns {T[]} A new array containing the elements that are present in both arrays.\n *\n * @example\n * const array1 = [1, 2, 3, 4, 5];\n * const array2 = [3, 4, 5, 6, 7];\n * const result = intersection(array1, array2);\n * // result will be [3, 4, 5] since these elements are in both arrays.\n */\nexport function intersection<T>(firstArr: T[], secondArr: T[]): T[] {\n return firstArr.filter(item => {\n return secondArr.includes(item);\n });\n}\n"],"mappings":";AAiBO,SAAS,aAAgB,UAAe,WAAqB;AAClE,SAAO,SAAS,OAAO,UAAQ;AAC7B,WAAO,UAAU,SAAS,IAAI;AAAA,EAChC,CAAC;AACH;","names":[]}
@@ -8,4 +8,4 @@ function delay(ms) {
8
8
  export {
9
9
  delay
10
10
  };
11
- //# sourceMappingURL=chunk-7SJHJHBN.mjs.map
11
+ //# sourceMappingURL=chunk-ZBG3EYM3.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/promise/delay.ts"],"sourcesContent":["/**\n * Delays the execution of code for a specified number of milliseconds.\n *\n * This function returns a Promise that resolves after the specified delay, allowing you to use it\n * with async/await to pause execution.\n *\n * @param {number} ms - The number of milliseconds to delay.\n * @returns {Promise<void>} A Promise that resolves after the specified delay.\n *\n * @example\n * async function foo() {\n * console.log('Start');\n * await delay(1000); // Delays execution for 1 second\n * console.log('End');\n * }\n *\n * foo();\n */\nexport function delay(ms: number): Promise<void> {\n return new Promise(resolve => {\n setTimeout(resolve, ms);\n });\n}\n"],"mappings":";AAkBO,SAAS,MAAM,IAA2B;AAC/C,SAAO,IAAI,QAAQ,aAAW;AAC5B,eAAW,SAAS,EAAE;AAAA,EACxB,CAAC;AACH;","names":[]}
@@ -6,4 +6,4 @@ function isNotNil(x) {
6
6
  export {
7
7
  isNotNil
8
8
  };
9
- //# sourceMappingURL=chunk-YMNXRH52.mjs.map
9
+ //# sourceMappingURL=chunk-ZQNAZPSK.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/predicate/isNotNil.ts"],"sourcesContent":["/**\n * Checks if the given value is not null nor undefined.\n *\n * The main use of this function is to be used with TypeScript as a type predicate.\n *\n * @param {T | null | undefined} x - The value to test if it is not null nor undefined.\n * @returns {x is T} True if the value is not null nor undefined, false otherwise.\n *\n * @example\n * // Here the type of `arr` is (number | undefined)[]\n * const arr = [1, undefined, 3];\n * // Here the type of `result` is number[]\n * const result = arr.filter(isNotNil);\n * // result will be [1, 3]\n */\nexport function isNotNil<T>(x: T | null | undefined): x is T {\n return x !== null && x !== undefined;\n}\n"],"mappings":";AAeO,SAAS,SAAY,GAAiC;AAC3D,SAAO,MAAM,QAAQ,MAAM;AAC7B;","names":[]}
@@ -3,9 +3,9 @@
3
3
  * have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel`
4
4
  * method to cancel any pending execution.
5
5
  *
6
- * @param {() => void} func - The function to debounce.
6
+ * @param {F} func - The function to debounce.
7
7
  * @param {number} debounceMs - The number of milliseconds to delay.
8
- * @returns {{ (): void; cancel: () => void }} A new debounced function with a `cancel` method.
8
+ * @returns {F & { cancel: () => void }} A new debounced function with a `cancel` method.
9
9
  *
10
10
  * @example
11
11
  * const debouncedFunction = debounce(() => {
@@ -18,8 +18,7 @@
18
18
  * // Will not log anything as the previous call is canceled
19
19
  * debouncedFunction.cancel();
20
20
  */
21
- declare function debounce(func: () => void, debounceMs: number): {
22
- (): void;
21
+ declare function debounce<F extends (...args: any[]) => void>(func: F, debounceMs: number): F & {
23
22
  cancel: () => void;
24
23
  };
25
24
 
@@ -3,9 +3,9 @@
3
3
  * have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel`
4
4
  * method to cancel any pending execution.
5
5
  *
6
- * @param {() => void} func - The function to debounce.
6
+ * @param {F} func - The function to debounce.
7
7
  * @param {number} debounceMs - The number of milliseconds to delay.
8
- * @returns {{ (): void; cancel: () => void }} A new debounced function with a `cancel` method.
8
+ * @returns {F & { cancel: () => void }} A new debounced function with a `cancel` method.
9
9
  *
10
10
  * @example
11
11
  * const debouncedFunction = debounce(() => {
@@ -18,8 +18,7 @@
18
18
  * // Will not log anything as the previous call is canceled
19
19
  * debouncedFunction.cancel();
20
20
  */
21
- declare function debounce(func: () => void, debounceMs: number): {
22
- (): void;
21
+ declare function debounce<F extends (...args: any[]) => void>(func: F, debounceMs: number): F & {
23
22
  cancel: () => void;
24
23
  };
25
24
 
@@ -25,12 +25,12 @@ __export(debounce_exports, {
25
25
  module.exports = __toCommonJS(debounce_exports);
26
26
  function debounce(func, debounceMs) {
27
27
  let timeoutId = null;
28
- const debounced = function() {
28
+ const debounced = function(...args) {
29
29
  if (timeoutId != null) {
30
30
  clearTimeout(timeoutId);
31
31
  }
32
32
  timeoutId = setTimeout(() => {
33
- func();
33
+ func(...args);
34
34
  }, debounceMs);
35
35
  };
36
36
  debounced.cancel = function() {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/function/debounce.ts"],"sourcesContent":["/**\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 * @param {() => void} func - The function to debounce.\n * @param {number} debounceMs - The number of milliseconds to delay.\n * @returns {{ (): void; 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 */\nexport function debounce(func: () => void, debounceMs: number): { (): void; cancel: () => void } {\n let timeoutId: number | NodeJS.Timeout | null = null;\n\n const debounced = function () {\n if (timeoutId != null) {\n clearTimeout(timeoutId);\n }\n \n \n timeoutId = setTimeout(() => {\n func();\n }, debounceMs);\n };\n\n debounced.cancel = function () {\n if (timeoutId != null) {\n clearTimeout(timeoutId);\n }\n } \n\n return debounced;\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBO,SAAS,SAAS,MAAkB,YAAsD;AAC/F,MAAI,YAA4C;AAEhD,QAAM,YAAY,WAAY;AAC5B,QAAI,aAAa,MAAM;AACrB,mBAAa,SAAS;AAAA,IACxB;AAGA,gBAAY,WAAW,MAAM;AAC3B,WAAK;AAAA,IACP,GAAG,UAAU;AAAA,EACf;AAEA,YAAU,SAAS,WAAY;AAC7B,QAAI,aAAa,MAAM;AACrB,mBAAa,SAAS;AAAA,IACxB;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/function/debounce.ts"],"sourcesContent":["/**\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 * @param {F} func - The function to debounce.\n * @param {number} debounceMs - The number of milliseconds to delay.\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 */\nexport function debounce<F extends (...args: any[]) => void>(func: F, debounceMs: number): F & { cancel: () => void } {\n let timeoutId: number | NodeJS.Timeout | null = null;\n\n const debounced = function (...args: Parameters<F>) {\n if (timeoutId != null) {\n clearTimeout(timeoutId);\n }\n\n timeoutId = setTimeout(() => {\n func(...args);\n }, debounceMs);\n } as F & { cancel: () => void };\n\n debounced.cancel = function () {\n if (timeoutId != null) {\n clearTimeout(timeoutId);\n }\n };\n\n return debounced;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBO,SAAS,SAA6C,MAAS,YAAgD;AACpH,MAAI,YAA4C;AAEhD,QAAM,YAAY,YAAa,MAAqB;AAClD,QAAI,aAAa,MAAM;AACrB,mBAAa,SAAS;AAAA,IACxB;AAEA,gBAAY,WAAW,MAAM;AAC3B,WAAK,GAAG,IAAI;AAAA,IACd,GAAG,UAAU;AAAA,EACf;AAEA,YAAU,SAAS,WAAY;AAC7B,QAAI,aAAa,MAAM;AACrB,mBAAa,SAAS;AAAA,IACxB;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  debounce
3
- } from "../chunk-L4Y3G6AJ.mjs";
3
+ } from "../chunk-GELVVASW.mjs";
4
4
  import "../chunk-2MM5EJJX.mjs";
5
5
  export {
6
6
  debounce
@@ -29,12 +29,12 @@ module.exports = __toCommonJS(function_exports);
29
29
  // src/function/debounce.ts
30
30
  function debounce(func, debounceMs) {
31
31
  let timeoutId = null;
32
- const debounced = function() {
32
+ const debounced = function(...args) {
33
33
  if (timeoutId != null) {
34
34
  clearTimeout(timeoutId);
35
35
  }
36
36
  timeoutId = setTimeout(() => {
37
- func();
37
+ func(...args);
38
38
  }, debounceMs);
39
39
  };
40
40
  debounced.cancel = function() {
@@ -63,11 +63,11 @@ function once(func) {
63
63
  // src/function/throttle.ts
64
64
  function throttle(func, throttleMs) {
65
65
  let lastCallTime;
66
- const throttledFunction = function() {
66
+ const throttledFunction = function(...args) {
67
67
  const now = Date.now();
68
68
  if (lastCallTime == null || now - lastCallTime >= throttleMs) {
69
69
  lastCallTime = now;
70
- func();
70
+ func(...args);
71
71
  }
72
72
  };
73
73
  return throttledFunction;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/function/index.ts","../../src/function/debounce.ts","../../src/function/once.ts","../../src/function/throttle.ts"],"sourcesContent":["export { debounce } from './debounce';\nexport { once } from './once';\nexport { throttle } from './throttle';","/**\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 * @param {() => void} func - The function to debounce.\n * @param {number} debounceMs - The number of milliseconds to delay.\n * @returns {{ (): void; 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 */\nexport function debounce(func: () => void, debounceMs: number): { (): void; cancel: () => void } {\n let timeoutId: number | NodeJS.Timeout | null = null;\n\n const debounced = function () {\n if (timeoutId != null) {\n clearTimeout(timeoutId);\n }\n \n \n timeoutId = setTimeout(() => {\n func();\n }, debounceMs);\n };\n\n debounced.cancel = function () {\n if (timeoutId != null) {\n clearTimeout(timeoutId);\n }\n } \n\n return debounced;\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 * @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 * @param {() => void} func - The function to throttle.\n * @param {number} throttleMs - The number of milliseconds to throttle executions to.\n * @returns {() => void} A new throttled 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(func: () => void, throttleMs: number) {\n let lastCallTime: number | null;\n\n const throttledFunction = function () {\n const now = Date.now();\n\n if (lastCallTime == null || now - lastCallTime >= throttleMs) {\n lastCallTime = now;\n func();\n }\n }\n\n return throttledFunction;\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACoBO,SAAS,SAAS,MAAkB,YAAsD;AAC/F,MAAI,YAA4C;AAEhD,QAAM,YAAY,WAAY;AAC5B,QAAI,aAAa,MAAM;AACrB,mBAAa,SAAS;AAAA,IACxB;AAGA,gBAAY,WAAW,MAAM;AAC3B,WAAK;AAAA,IACP,GAAG,UAAU;AAAA,EACf;AAEA,YAAU,SAAS,WAAY;AAC7B,QAAI,aAAa,MAAM;AACrB,mBAAa,SAAS;AAAA,IACxB;AAAA,EACF;AAEA,SAAO;AACT;;;ACzBO,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,SAAS,MAAkB,YAAoB;AAC7D,MAAI;AAEJ,QAAM,oBAAoB,WAAY;AACpC,UAAM,MAAM,KAAK,IAAI;AAErB,QAAI,gBAAgB,QAAQ,MAAM,gBAAgB,YAAY;AAC5D,qBAAe;AACf,WAAK;AAAA,IACP;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/function/index.ts","../../src/function/debounce.ts","../../src/function/once.ts","../../src/function/throttle.ts"],"sourcesContent":["export { debounce } from './debounce';\nexport { once } from './once';\nexport { throttle } from './throttle';\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 * @param {F} func - The function to debounce.\n * @param {number} debounceMs - The number of milliseconds to delay.\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 */\nexport function debounce<F extends (...args: any[]) => void>(func: F, debounceMs: number): F & { cancel: () => void } {\n let timeoutId: number | NodeJS.Timeout | null = null;\n\n const debounced = function (...args: Parameters<F>) {\n if (timeoutId != null) {\n clearTimeout(timeoutId);\n }\n\n timeoutId = setTimeout(() => {\n func(...args);\n }, debounceMs);\n } as F & { cancel: () => void };\n\n debounced.cancel = function () {\n if (timeoutId != null) {\n clearTimeout(timeoutId);\n }\n };\n\n return debounced;\n}\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 * @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 * @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) {\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;;;ACoBO,SAAS,SAA6C,MAAS,YAAgD;AACpH,MAAI,YAA4C;AAEhD,QAAM,YAAY,YAAa,MAAqB;AAClD,QAAI,aAAa,MAAM;AACrB,mBAAa,SAAS;AAAA,IACxB;AAEA,gBAAY,WAAW,MAAM;AAC3B,WAAK,GAAG,IAAI;AAAA,IACd,GAAG,UAAU;AAAA,EACf;AAEA,YAAU,SAAS,WAAY;AAC7B,QAAI,aAAa,MAAM;AACrB,mBAAa,SAAS;AAAA,IACxB;AAAA,EACF;AAEA,SAAO;AACT;;;ACxBO,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,YAAoB;AACxF,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,13 +1,13 @@
1
1
  import "../chunk-SYQTG4N4.mjs";
2
2
  import {
3
3
  debounce
4
- } from "../chunk-L4Y3G6AJ.mjs";
4
+ } from "../chunk-GELVVASW.mjs";
5
5
  import {
6
6
  once
7
- } from "../chunk-ARWKEQMQ.mjs";
7
+ } from "../chunk-UFAA5WKR.mjs";
8
8
  import {
9
9
  throttle
10
- } from "../chunk-VAKCSKGR.mjs";
10
+ } from "../chunk-XLO3QZVY.mjs";
11
11
  import "../chunk-2MM5EJJX.mjs";
12
12
  export {
13
13
  debounce,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/function/once.ts"],"sourcesContent":["/**\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 * @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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBO,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;","names":[]}
1
+ {"version":3,"sources":["../../src/function/once.ts"],"sourcesContent":["/**\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 * @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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBO,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;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  once
3
- } from "../chunk-ARWKEQMQ.mjs";
3
+ } from "../chunk-UFAA5WKR.mjs";
4
4
  import "../chunk-2MM5EJJX.mjs";
5
5
  export {
6
6
  once
@@ -3,9 +3,9 @@
3
3
  * per every `throttleMs` milliseconds. Subsequent calls to the throttled function
4
4
  * within the wait time will not trigger the execution of the original function.
5
5
  *
6
- * @param {() => void} func - The function to throttle.
6
+ * @param {F} func - The function to throttle.
7
7
  * @param {number} throttleMs - The number of milliseconds to throttle executions to.
8
- * @returns {() => void} A new throttled function.
8
+ * @returns {F} A new throttled function that accepts the same parameters as the original function.
9
9
  *
10
10
  * @example
11
11
  * const throttledFunction = throttle(() => {
@@ -23,6 +23,6 @@
23
23
  * throttledFunction(); // Will log 'Function executed'
24
24
  * }, 1000);
25
25
  */
26
- declare function throttle(func: () => void, throttleMs: number): () => void;
26
+ declare function throttle<F extends (...args: any[]) => void>(func: F, throttleMs: number): F;
27
27
 
28
28
  export { throttle };
@@ -3,9 +3,9 @@
3
3
  * per every `throttleMs` milliseconds. Subsequent calls to the throttled function
4
4
  * within the wait time will not trigger the execution of the original function.
5
5
  *
6
- * @param {() => void} func - The function to throttle.
6
+ * @param {F} func - The function to throttle.
7
7
  * @param {number} throttleMs - The number of milliseconds to throttle executions to.
8
- * @returns {() => void} A new throttled function.
8
+ * @returns {F} A new throttled function that accepts the same parameters as the original function.
9
9
  *
10
10
  * @example
11
11
  * const throttledFunction = throttle(() => {
@@ -23,6 +23,6 @@
23
23
  * throttledFunction(); // Will log 'Function executed'
24
24
  * }, 1000);
25
25
  */
26
- declare function throttle(func: () => void, throttleMs: number): () => void;
26
+ declare function throttle<F extends (...args: any[]) => void>(func: F, throttleMs: number): F;
27
27
 
28
28
  export { throttle };
@@ -25,11 +25,11 @@ __export(throttle_exports, {
25
25
  module.exports = __toCommonJS(throttle_exports);
26
26
  function throttle(func, throttleMs) {
27
27
  let lastCallTime;
28
- const throttledFunction = function() {
28
+ const throttledFunction = function(...args) {
29
29
  const now = Date.now();
30
30
  if (lastCallTime == null || now - lastCallTime >= throttleMs) {
31
31
  lastCallTime = now;
32
- func();
32
+ func(...args);
33
33
  }
34
34
  };
35
35
  return throttledFunction;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/function/throttle.ts"],"sourcesContent":["/**\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 * @param {() => void} func - The function to throttle.\n * @param {number} throttleMs - The number of milliseconds to throttle executions to.\n * @returns {() => void} A new throttled 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(func: () => void, throttleMs: number) {\n let lastCallTime: number | null;\n\n const throttledFunction = function () {\n const now = Date.now();\n\n if (lastCallTime == null || now - lastCallTime >= throttleMs) {\n lastCallTime = now;\n func();\n }\n }\n\n return throttledFunction;\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAyBO,SAAS,SAAS,MAAkB,YAAoB;AAC7D,MAAI;AAEJ,QAAM,oBAAoB,WAAY;AACpC,UAAM,MAAM,KAAK,IAAI;AAErB,QAAI,gBAAgB,QAAQ,MAAM,gBAAgB,YAAY;AAC5D,qBAAe;AACf,WAAK;AAAA,IACP;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/function/throttle.ts"],"sourcesContent":["/**\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 * @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) {\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;AAyBO,SAAS,SAA6C,MAAS,YAAoB;AACxF,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,6 +1,6 @@
1
1
  import {
2
2
  throttle
3
- } from "../chunk-VAKCSKGR.mjs";
3
+ } from "../chunk-XLO3QZVY.mjs";
4
4
  import "../chunk-2MM5EJJX.mjs";
5
5
  export {
6
6
  throttle
package/dist/index.js CHANGED
@@ -99,9 +99,8 @@ function chunk(arr, size) {
99
99
 
100
100
  // src/array/difference.ts
101
101
  function difference(firstArr, secondArr) {
102
- return firstArr.filter((item) => {
103
- return !secondArr.includes(item);
104
- });
102
+ const secondSet = new Set(secondArr);
103
+ return firstArr.filter((item) => !secondSet.has(item));
105
104
  }
106
105
 
107
106
  // src/array/differenceBy.ts
@@ -345,12 +344,12 @@ function zipWith(arr1, ...rest) {
345
344
  // src/function/debounce.ts
346
345
  function debounce(func, debounceMs) {
347
346
  let timeoutId = null;
348
- const debounced = function() {
347
+ const debounced = function(...args) {
349
348
  if (timeoutId != null) {
350
349
  clearTimeout(timeoutId);
351
350
  }
352
351
  timeoutId = setTimeout(() => {
353
- func();
352
+ func(...args);
354
353
  }, debounceMs);
355
354
  };
356
355
  debounced.cancel = function() {
@@ -379,11 +378,11 @@ function once(func) {
379
378
  // src/function/throttle.ts
380
379
  function throttle(func, throttleMs) {
381
380
  let lastCallTime;
382
- const throttledFunction = function() {
381
+ const throttledFunction = function(...args) {
383
382
  const now = Date.now();
384
383
  if (lastCallTime == null || now - lastCallTime >= throttleMs) {
385
384
  lastCallTime = now;
386
- func();
385
+ func(...args);
387
386
  }
388
387
  };
389
388
  return throttledFunction;