umt 2.12.3 → 2.14.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 (463) hide show
  1. package/README.md +60 -0
  2. package/module/Array/arraysJoin.js +1 -1
  3. package/module/Array/arraysJoin.js.map +1 -1
  4. package/module/Array/chunk.js +1 -2
  5. package/module/Array/chunk.js.map +1 -1
  6. package/module/Array/generateNumberArray.js +13 -3
  7. package/module/Array/generateNumberArray.js.map +1 -1
  8. package/module/Array/getArraysDiff.js +5 -1
  9. package/module/Array/getArraysDiff.js.map +1 -1
  10. package/module/Array/mergeSort.js +45 -18
  11. package/module/Array/mergeSort.js.map +1 -1
  12. package/module/Array/pop.js +2 -1
  13. package/module/Array/pop.js.map +1 -1
  14. package/module/Array/randomSelect.js +8 -0
  15. package/module/Array/randomSelect.js.map +1 -1
  16. package/module/Array/sortingHelpers/rangeValidator.js +3 -2
  17. package/module/Array/sortingHelpers/rangeValidator.js.map +1 -1
  18. package/module/Array/timSort.js +25 -23
  19. package/module/Array/timSort.js.map +1 -1
  20. package/module/Array/ultraNumberSort.js +214 -136
  21. package/module/Array/ultraNumberSort.js.map +1 -1
  22. package/module/Async/defer.d.ts +18 -0
  23. package/module/Async/defer.js +19 -0
  24. package/module/Async/defer.js.map +1 -0
  25. package/module/Async/index.d.ts +4 -0
  26. package/module/Async/index.js +5 -0
  27. package/module/Async/index.js.map +1 -0
  28. package/module/Async/parallel.d.ts +10 -0
  29. package/module/Async/parallel.js +44 -0
  30. package/module/Async/parallel.js.map +1 -0
  31. package/module/Async/sleep.d.ts +8 -0
  32. package/module/Async/sleep.js +11 -0
  33. package/module/Async/sleep.js.map +1 -0
  34. package/module/Async/timeout.d.ts +10 -0
  35. package/module/Async/timeout.js +22 -0
  36. package/module/Async/timeout.js.map +1 -0
  37. package/module/Color/cmykToRgba.js +6 -7
  38. package/module/Color/cmykToRgba.js.map +1 -1
  39. package/module/Color/hexaToRgba.js +1 -8
  40. package/module/Color/hexaToRgba.js.map +1 -1
  41. package/module/Color/hslaToRgba.d.ts +0 -1
  42. package/module/Color/hslaToRgba.js +7 -22
  43. package/module/Color/hslaToRgba.js.map +1 -1
  44. package/module/Color/rgbaToCmyk.js +0 -11
  45. package/module/Color/rgbaToCmyk.js.map +1 -1
  46. package/module/Color/rgbaToHexA.js +2 -15
  47. package/module/Color/rgbaToHexA.js.map +1 -1
  48. package/module/Color/rgbaToHsla.d.ts +0 -1
  49. package/module/Color/rgbaToHsla.js +0 -12
  50. package/module/Color/rgbaToHsla.js.map +1 -1
  51. package/module/Crypto/constants.d.ts +2 -0
  52. package/module/Crypto/constants.js +3 -0
  53. package/module/Crypto/constants.js.map +1 -0
  54. package/module/Crypto/decodeBase32.js +4 -5
  55. package/module/Crypto/decodeBase32.js.map +1 -1
  56. package/module/Crypto/decodeBase58.js +7 -6
  57. package/module/Crypto/decodeBase58.js.map +1 -1
  58. package/module/Crypto/encodeBase32.js +2 -1
  59. package/module/Crypto/encodeBase32.js.map +1 -1
  60. package/module/Crypto/encodeBase58.js +7 -3
  61. package/module/Crypto/encodeBase58.js.map +1 -1
  62. package/module/DataStructure/index.d.ts +2 -0
  63. package/module/DataStructure/index.js +2 -0
  64. package/module/DataStructure/index.js.map +1 -1
  65. package/module/DataStructure/lruCache.d.ts +139 -0
  66. package/module/DataStructure/lruCache.js +172 -0
  67. package/module/DataStructure/lruCache.js.map +1 -0
  68. package/module/DataStructure/ttlCache.d.ts +139 -0
  69. package/module/DataStructure/ttlCache.js +172 -0
  70. package/module/DataStructure/ttlCache.js.map +1 -0
  71. package/module/Error/flatMapResult.d.ts +23 -0
  72. package/module/Error/flatMapResult.js +28 -0
  73. package/module/Error/flatMapResult.js.map +1 -0
  74. package/module/Error/index.d.ts +3 -0
  75. package/module/Error/index.js +3 -0
  76. package/module/Error/index.js.map +1 -1
  77. package/module/Error/mapResult.d.ts +21 -0
  78. package/module/Error/mapResult.js +27 -0
  79. package/module/Error/mapResult.js.map +1 -0
  80. package/module/Error/matchResult.d.ts +25 -0
  81. package/module/Error/matchResult.js +27 -0
  82. package/module/Error/matchResult.js.map +1 -0
  83. package/module/Error/safeExecute.d.ts +16 -3
  84. package/module/Error/safeExecute.js +5 -2
  85. package/module/Error/safeExecute.js.map +1 -1
  86. package/module/Function/debounce.d.ts +38 -0
  87. package/module/Function/debounce.js +67 -0
  88. package/module/Function/debounce.js.map +1 -0
  89. package/module/Function/index.d.ts +4 -0
  90. package/module/Function/index.js +4 -0
  91. package/module/Function/index.js.map +1 -1
  92. package/module/Function/memoize.d.ts +36 -0
  93. package/module/Function/memoize.js +54 -0
  94. package/module/Function/memoize.js.map +1 -0
  95. package/module/Function/once.d.ts +18 -0
  96. package/module/Function/once.js +29 -0
  97. package/module/Function/once.js.map +1 -0
  98. package/module/Function/throttle.d.ts +25 -0
  99. package/module/Function/throttle.js +55 -0
  100. package/module/Function/throttle.js.map +1 -0
  101. package/module/IP/cidrToLong.d.ts +0 -1
  102. package/module/IP/cidrToLong.js +0 -4
  103. package/module/IP/cidrToLong.js.map +1 -1
  104. package/module/IP/cidrToSubnetMask.d.ts +0 -1
  105. package/module/IP/cidrToSubnetMask.js +0 -1
  106. package/module/IP/cidrToSubnetMask.js.map +1 -1
  107. package/module/IP/getNetworkAddress.d.ts +0 -1
  108. package/module/IP/getNetworkAddress.js +2 -32
  109. package/module/IP/getNetworkAddress.js.map +1 -1
  110. package/module/IP/ipToBinaryString.d.ts +0 -1
  111. package/module/IP/ipToBinaryString.js +2 -25
  112. package/module/IP/ipToBinaryString.js.map +1 -1
  113. package/module/IP/ipToLong.d.ts +0 -1
  114. package/module/IP/ipToLong.js +0 -1
  115. package/module/IP/ipToLong.js.map +1 -1
  116. package/module/IP/isInRange.d.ts +0 -1
  117. package/module/IP/isInRange.js +5 -28
  118. package/module/IP/isInRange.js.map +1 -1
  119. package/module/IP/isPrivateIp.d.ts +0 -1
  120. package/module/IP/isPrivateIp.js +1 -10
  121. package/module/IP/isPrivateIp.js.map +1 -1
  122. package/module/IP/longToIp.d.ts +0 -1
  123. package/module/IP/longToIp.js +0 -8
  124. package/module/IP/longToIp.js.map +1 -1
  125. package/module/IP/subnetMaskToCidr.d.ts +0 -1
  126. package/module/IP/subnetMaskToCidr.js +2 -23
  127. package/module/IP/subnetMaskToCidr.js.map +1 -1
  128. package/module/Iterator/index.d.ts +3 -0
  129. package/module/Iterator/index.js +4 -0
  130. package/module/Iterator/index.js.map +1 -0
  131. package/module/Iterator/lazyFilter.d.ts +10 -0
  132. package/module/Iterator/lazyFilter.js +19 -0
  133. package/module/Iterator/lazyFilter.js.map +1 -0
  134. package/module/Iterator/lazyMap.d.ts +10 -0
  135. package/module/Iterator/lazyMap.js +17 -0
  136. package/module/Iterator/lazyMap.js.map +1 -0
  137. package/module/Iterator/lazyTake.d.ts +10 -0
  138. package/module/Iterator/lazyTake.js +20 -0
  139. package/module/Iterator/lazyTake.js.map +1 -0
  140. package/module/Math/addition.js +20 -4
  141. package/module/Math/addition.js.map +1 -1
  142. package/module/Math/average.js +3 -3
  143. package/module/Math/average.js.map +1 -1
  144. package/module/Math/bitwise.js +1 -1
  145. package/module/Math/bitwise.js.map +1 -1
  146. package/module/Math/calculator/core.js +2 -1
  147. package/module/Math/calculator/core.js.map +1 -1
  148. package/module/Math/calculator/literalExpression.js +1 -1
  149. package/module/Math/clamp.d.ts +16 -0
  150. package/module/Math/clamp.js +19 -0
  151. package/module/Math/clamp.js.map +1 -0
  152. package/module/Math/correlationCoefficient.js +0 -3
  153. package/module/Math/correlationCoefficient.js.map +1 -1
  154. package/module/Math/inRange.d.ts +19 -0
  155. package/module/Math/inRange.js +24 -0
  156. package/module/Math/inRange.js.map +1 -0
  157. package/module/Math/index.d.ts +3 -0
  158. package/module/Math/index.js +3 -0
  159. package/module/Math/index.js.map +1 -1
  160. package/module/Math/median.js +2 -2
  161. package/module/Math/median.js.map +1 -1
  162. package/module/Math/nCr.js +2 -4
  163. package/module/Math/nCr.js.map +1 -1
  164. package/module/Math/percentile.js +2 -5
  165. package/module/Math/percentile.js.map +1 -1
  166. package/module/Math/primeFactorization.js +1 -1
  167. package/module/Math/primeFactorization.js.map +1 -1
  168. package/module/Math/sumPrecise.d.ts +14 -0
  169. package/module/Math/sumPrecise.js +27 -0
  170. package/module/Math/sumPrecise.js.map +1 -0
  171. package/module/Math/uuidv7.js +56 -22
  172. package/module/Math/uuidv7.js.map +1 -1
  173. package/module/Number/formatNumber.d.ts +42 -0
  174. package/module/Number/formatNumber.js +44 -0
  175. package/module/Number/formatNumber.js.map +1 -0
  176. package/module/Number/index.d.ts +3 -0
  177. package/module/Number/index.js +4 -0
  178. package/module/Number/index.js.map +1 -0
  179. package/module/Number/toOrdinal.d.ts +20 -0
  180. package/module/Number/toOrdinal.js +37 -0
  181. package/module/Number/toOrdinal.js.map +1 -0
  182. package/module/Number/toPercentage.d.ts +20 -0
  183. package/module/Number/toPercentage.js +27 -0
  184. package/module/Number/toPercentage.js.map +1 -0
  185. package/module/Object/deepClone.d.ts +15 -0
  186. package/module/Object/deepClone.js +65 -0
  187. package/module/Object/deepClone.js.map +1 -0
  188. package/module/Object/getObjectsCommon.d.ts +23 -0
  189. package/module/Object/getObjectsCommon.js +60 -0
  190. package/module/Object/getObjectsCommon.js.map +1 -0
  191. package/module/Object/getObjectsDiff.d.ts +25 -0
  192. package/module/Object/getObjectsDiff.js +79 -0
  193. package/module/Object/getObjectsDiff.js.map +1 -0
  194. package/module/Object/index.d.ts +6 -0
  195. package/module/Object/index.js +6 -0
  196. package/module/Object/index.js.map +1 -1
  197. package/module/Object/isPlainObject.d.ts +16 -0
  198. package/module/Object/isPlainObject.js +32 -0
  199. package/module/Object/isPlainObject.js.map +1 -0
  200. package/module/Object/mapKeys.d.ts +15 -0
  201. package/module/Object/mapKeys.js +28 -0
  202. package/module/Object/mapKeys.js.map +1 -0
  203. package/module/Object/mapValues.d.ts +15 -0
  204. package/module/Object/mapValues.js +27 -0
  205. package/module/Object/mapValues.js.map +1 -0
  206. package/module/Object/mergeDeep.js +4 -9
  207. package/module/Object/mergeDeep.js.map +1 -1
  208. package/module/Object/omit.d.ts +1 -1
  209. package/module/Object/omit.js.map +1 -1
  210. package/module/Object/pickDeep.js +6 -1
  211. package/module/Object/pickDeep.js.map +1 -1
  212. package/module/Predicate/every.d.ts +14 -0
  213. package/module/Predicate/every.js +22 -0
  214. package/module/Predicate/every.js.map +1 -0
  215. package/module/Predicate/index.d.ts +6 -0
  216. package/module/Predicate/index.js +7 -0
  217. package/module/Predicate/index.js.map +1 -0
  218. package/module/Predicate/isNotNullish.d.ts +11 -0
  219. package/module/Predicate/isNotNullish.js +12 -0
  220. package/module/Predicate/isNotNullish.js.map +1 -0
  221. package/module/Predicate/isNullish.d.ts +11 -0
  222. package/module/Predicate/isNullish.js +12 -0
  223. package/module/Predicate/isNullish.js.map +1 -0
  224. package/module/Predicate/matches.d.ts +11 -0
  225. package/module/Predicate/matches.js +20 -0
  226. package/module/Predicate/matches.js.map +1 -0
  227. package/module/Predicate/not.d.ts +10 -0
  228. package/module/Predicate/not.js +11 -0
  229. package/module/Predicate/not.js.map +1 -0
  230. package/module/Predicate/some.d.ts +15 -0
  231. package/module/Predicate/some.js +23 -0
  232. package/module/Predicate/some.js.map +1 -0
  233. package/module/String/camelCase.js +2 -2
  234. package/module/String/camelCase.js.map +1 -1
  235. package/module/String/escapeHtml.js +1 -1
  236. package/module/String/formatString/getValue.js +1 -1
  237. package/module/String/formatString/getValue.js.map +1 -1
  238. package/module/String/fromBase64.d.ts +0 -1
  239. package/module/String/fromBase64.js +1 -9
  240. package/module/String/fromBase64.js.map +1 -1
  241. package/module/String/fuzzySearch.js +74 -6
  242. package/module/String/fuzzySearch.js.map +1 -1
  243. package/module/String/kebabCase.js +1 -1
  244. package/module/String/kebabCase.js.map +1 -1
  245. package/module/String/levenshteinDistance.js +1 -2
  246. package/module/String/levenshteinDistance.js.map +1 -1
  247. package/module/String/randomString.js +23 -2
  248. package/module/String/randomString.js.map +1 -1
  249. package/module/String/reverseString.js +1 -1
  250. package/module/String/reverseString.js.map +1 -1
  251. package/module/String/slugify.js +1 -1
  252. package/module/String/toHalfWidth.js +2 -2
  253. package/module/String/toHalfWidth.js.map +1 -1
  254. package/module/String/truncate.js +0 -3
  255. package/module/String/truncate.js.map +1 -1
  256. package/module/String/unescapeHtml.js +1 -1
  257. package/module/String/unescapeHtml.js.map +1 -1
  258. package/module/Time/convertTime.js +4 -3
  259. package/module/Time/convertTime.js.map +1 -1
  260. package/module/Tool/escapeRegExp.d.ts +8 -0
  261. package/module/Tool/escapeRegExp.js +11 -0
  262. package/module/Tool/escapeRegExp.js.map +1 -0
  263. package/module/Tool/index.d.ts +1 -0
  264. package/module/Tool/index.js +1 -0
  265. package/module/Tool/index.js.map +1 -1
  266. package/module/URL/buildUrl.d.ts +17 -0
  267. package/module/URL/buildUrl.js +24 -0
  268. package/module/URL/buildUrl.js.map +1 -0
  269. package/module/URL/index.d.ts +4 -0
  270. package/module/URL/index.js +5 -0
  271. package/module/URL/index.js.map +1 -0
  272. package/module/URL/isAbsoluteUrl.d.ts +20 -0
  273. package/module/URL/isAbsoluteUrl.js +23 -0
  274. package/module/URL/isAbsoluteUrl.js.map +1 -0
  275. package/module/URL/joinPath.d.ts +24 -0
  276. package/module/URL/joinPath.js +43 -0
  277. package/module/URL/joinPath.js.map +1 -0
  278. package/module/URL/parseQueryString.d.ts +22 -0
  279. package/module/URL/parseQueryString.js +34 -0
  280. package/module/URL/parseQueryString.js.map +1 -0
  281. package/module/Validate/parseEmail.js +5 -5
  282. package/module/Validate/parseEmail.js.map +1 -1
  283. package/module/es5/Array/arraysJoin.js +1 -1
  284. package/module/es5/Array/chunk.js +3 -2
  285. package/module/es5/Array/generateNumberArray.js +21 -3
  286. package/module/es5/Array/getArraysDiff.js +5 -3
  287. package/module/es5/Array/mergeSort.js +51 -19
  288. package/module/es5/Array/pop.js +2 -7
  289. package/module/es5/Array/randomSelect.js +8 -0
  290. package/module/es5/Array/sortingHelpers/rangeValidator.js +3 -2
  291. package/module/es5/Array/timSort.js +25 -23
  292. package/module/es5/Array/ultraNumberSort.js +243 -243
  293. package/module/es5/Async/defer.d.ts +18 -0
  294. package/module/es5/Async/defer.js +32 -0
  295. package/module/es5/Async/index.d.ts +4 -0
  296. package/module/es5/Async/index.js +49 -0
  297. package/module/es5/Async/parallel.d.ts +10 -0
  298. package/module/es5/Async/parallel.js +48 -0
  299. package/module/es5/Async/sleep.d.ts +8 -0
  300. package/module/es5/Async/sleep.js +18 -0
  301. package/module/es5/Async/timeout.d.ts +10 -0
  302. package/module/es5/Async/timeout.js +29 -0
  303. package/module/es5/Color/cmykToRgba.js +6 -7
  304. package/module/es5/Color/hexaToRgba.js +7 -5
  305. package/module/es5/Color/hslaToRgba.d.ts +0 -1
  306. package/module/es5/Color/hslaToRgba.js +7 -22
  307. package/module/es5/Color/rgbaToCmyk.js +0 -4
  308. package/module/es5/Color/rgbaToHexA.js +2 -6
  309. package/module/es5/Color/rgbaToHsla.d.ts +0 -1
  310. package/module/es5/Color/rgbaToHsla.js +0 -5
  311. package/module/es5/Crypto/constants.d.ts +2 -0
  312. package/module/es5/Crypto/constants.js +8 -0
  313. package/module/es5/Crypto/decodeBase32.js +12 -5
  314. package/module/es5/Crypto/decodeBase58.js +14 -8
  315. package/module/es5/Crypto/encodeBase32.js +2 -1
  316. package/module/es5/Crypto/encodeBase58.js +8 -3
  317. package/module/es5/DataStructure/index.d.ts +2 -0
  318. package/module/es5/DataStructure/index.js +22 -0
  319. package/module/es5/DataStructure/lruCache.d.ts +139 -0
  320. package/module/es5/DataStructure/lruCache.js +205 -0
  321. package/module/es5/DataStructure/ttlCache.d.ts +139 -0
  322. package/module/es5/DataStructure/ttlCache.js +211 -0
  323. package/module/es5/Error/flatMapResult.d.ts +23 -0
  324. package/module/es5/Error/flatMapResult.js +33 -0
  325. package/module/es5/Error/index.d.ts +3 -0
  326. package/module/es5/Error/index.js +33 -0
  327. package/module/es5/Error/mapResult.d.ts +21 -0
  328. package/module/es5/Error/mapResult.js +32 -0
  329. package/module/es5/Error/matchResult.d.ts +25 -0
  330. package/module/es5/Error/matchResult.js +32 -0
  331. package/module/es5/Error/safeExecute.d.ts +16 -3
  332. package/module/es5/Error/safeExecute.js +3 -3
  333. package/module/es5/Function/debounce.d.ts +38 -0
  334. package/module/es5/Function/debounce.js +88 -0
  335. package/module/es5/Function/index.d.ts +4 -0
  336. package/module/es5/Function/index.js +44 -0
  337. package/module/es5/Function/memoize.d.ts +36 -0
  338. package/module/es5/Function/memoize.js +73 -0
  339. package/module/es5/Function/once.d.ts +18 -0
  340. package/module/es5/Function/once.js +37 -0
  341. package/module/es5/Function/throttle.d.ts +25 -0
  342. package/module/es5/Function/throttle.js +69 -0
  343. package/module/es5/IP/cidrToLong.d.ts +0 -1
  344. package/module/es5/IP/cidrToLong.js +0 -4
  345. package/module/es5/IP/cidrToSubnetMask.d.ts +0 -1
  346. package/module/es5/IP/cidrToSubnetMask.js +0 -1
  347. package/module/es5/IP/getNetworkAddress.d.ts +0 -1
  348. package/module/es5/IP/getNetworkAddress.js +2 -31
  349. package/module/es5/IP/ipToBinaryString.d.ts +0 -1
  350. package/module/es5/IP/ipToBinaryString.js +1 -40
  351. package/module/es5/IP/ipToLong.d.ts +0 -1
  352. package/module/es5/IP/ipToLong.js +0 -1
  353. package/module/es5/IP/isInRange.d.ts +0 -1
  354. package/module/es5/IP/isInRange.js +5 -29
  355. package/module/es5/IP/isPrivateIp.d.ts +0 -1
  356. package/module/es5/IP/isPrivateIp.js +3 -12
  357. package/module/es5/IP/longToIp.d.ts +0 -1
  358. package/module/es5/IP/longToIp.js +0 -6
  359. package/module/es5/IP/subnetMaskToCidr.d.ts +0 -1
  360. package/module/es5/IP/subnetMaskToCidr.js +2 -26
  361. package/module/es5/Iterator/index.d.ts +3 -0
  362. package/module/es5/Iterator/index.js +38 -0
  363. package/module/es5/Iterator/lazyFilter.d.ts +10 -0
  364. package/module/es5/Iterator/lazyFilter.js +63 -0
  365. package/module/es5/Iterator/lazyMap.d.ts +10 -0
  366. package/module/es5/Iterator/lazyMap.js +59 -0
  367. package/module/es5/Iterator/lazyTake.d.ts +10 -0
  368. package/module/es5/Iterator/lazyTake.js +65 -0
  369. package/module/es5/Math/addition.js +24 -14
  370. package/module/es5/Math/average.js +3 -5
  371. package/module/es5/Math/bitwise.js +1 -1
  372. package/module/es5/Math/calculator/core.js +2 -1
  373. package/module/es5/Math/calculator/literalExpression.js +1 -1
  374. package/module/es5/Math/clamp.d.ts +16 -0
  375. package/module/es5/Math/clamp.js +24 -0
  376. package/module/es5/Math/correlationCoefficient.js +0 -3
  377. package/module/es5/Math/inRange.d.ts +19 -0
  378. package/module/es5/Math/inRange.js +29 -0
  379. package/module/es5/Math/index.d.ts +3 -0
  380. package/module/es5/Math/index.js +33 -0
  381. package/module/es5/Math/median.js +2 -2
  382. package/module/es5/Math/nCr.js +2 -4
  383. package/module/es5/Math/percentile.js +2 -11
  384. package/module/es5/Math/primeFactorization.js +1 -1
  385. package/module/es5/Math/sumPrecise.d.ts +14 -0
  386. package/module/es5/Math/sumPrecise.js +41 -0
  387. package/module/es5/Math/uuidv7.js +25 -40
  388. package/module/es5/Number/formatNumber.d.ts +42 -0
  389. package/module/es5/Number/formatNumber.js +58 -0
  390. package/module/es5/Number/index.d.ts +3 -0
  391. package/module/es5/Number/index.js +38 -0
  392. package/module/es5/Number/toOrdinal.d.ts +20 -0
  393. package/module/es5/Number/toOrdinal.js +42 -0
  394. package/module/es5/Number/toPercentage.d.ts +20 -0
  395. package/module/es5/Number/toPercentage.js +33 -0
  396. package/module/es5/Object/deepClone.d.ts +15 -0
  397. package/module/es5/Object/deepClone.js +110 -0
  398. package/module/es5/Object/getObjectsCommon.d.ts +23 -0
  399. package/module/es5/Object/getObjectsCommon.js +92 -0
  400. package/module/es5/Object/getObjectsDiff.d.ts +25 -0
  401. package/module/es5/Object/getObjectsDiff.js +146 -0
  402. package/module/es5/Object/index.d.ts +6 -0
  403. package/module/es5/Object/index.js +66 -0
  404. package/module/es5/Object/isPlainObject.d.ts +16 -0
  405. package/module/es5/Object/isPlainObject.js +39 -0
  406. package/module/es5/Object/mapKeys.d.ts +15 -0
  407. package/module/es5/Object/mapKeys.js +33 -0
  408. package/module/es5/Object/mapValues.d.ts +15 -0
  409. package/module/es5/Object/mapValues.js +32 -0
  410. package/module/es5/Object/mergeDeep.js +7 -10
  411. package/module/es5/Object/omit.d.ts +1 -1
  412. package/module/es5/Object/pickDeep.js +4 -6
  413. package/module/es5/Predicate/every.d.ts +14 -0
  414. package/module/es5/Predicate/every.js +33 -0
  415. package/module/es5/Predicate/index.d.ts +6 -0
  416. package/module/es5/Predicate/index.js +71 -0
  417. package/module/es5/Predicate/isNotNullish.d.ts +11 -0
  418. package/module/es5/Predicate/isNotNullish.js +19 -0
  419. package/module/es5/Predicate/isNullish.d.ts +11 -0
  420. package/module/es5/Predicate/isNullish.js +19 -0
  421. package/module/es5/Predicate/matches.d.ts +11 -0
  422. package/module/es5/Predicate/matches.js +28 -0
  423. package/module/es5/Predicate/not.d.ts +10 -0
  424. package/module/es5/Predicate/not.js +20 -0
  425. package/module/es5/Predicate/some.d.ts +15 -0
  426. package/module/es5/Predicate/some.js +34 -0
  427. package/module/es5/String/camelCase.js +2 -2
  428. package/module/es5/String/escapeHtml.js +1 -1
  429. package/module/es5/String/formatString/getValue.js +1 -1
  430. package/module/es5/String/fromBase64.d.ts +0 -1
  431. package/module/es5/String/fromBase64.js +9 -8
  432. package/module/es5/String/fuzzySearch.js +84 -9
  433. package/module/es5/String/kebabCase.js +1 -1
  434. package/module/es5/String/levenshteinDistance.js +3 -2
  435. package/module/es5/String/randomString.js +24 -2
  436. package/module/es5/String/reverseString.js +7 -1
  437. package/module/es5/String/slugify.js +1 -1
  438. package/module/es5/String/toHalfWidth.js +2 -2
  439. package/module/es5/String/truncate.js +0 -3
  440. package/module/es5/String/unescapeHtml.js +1 -1
  441. package/module/es5/Time/convertTime.js +4 -3
  442. package/module/es5/Tool/escapeRegExp.d.ts +8 -0
  443. package/module/es5/Tool/escapeRegExp.js +18 -0
  444. package/module/es5/Tool/index.d.ts +1 -0
  445. package/module/es5/Tool/index.js +11 -0
  446. package/module/es5/URL/buildUrl.d.ts +17 -0
  447. package/module/es5/URL/buildUrl.js +31 -0
  448. package/module/es5/URL/index.d.ts +4 -0
  449. package/module/es5/URL/index.js +49 -0
  450. package/module/es5/URL/isAbsoluteUrl.d.ts +20 -0
  451. package/module/es5/URL/isAbsoluteUrl.js +28 -0
  452. package/module/es5/URL/joinPath.d.ts +24 -0
  453. package/module/es5/URL/joinPath.js +48 -0
  454. package/module/es5/URL/parseQueryString.d.ts +22 -0
  455. package/module/es5/URL/parseQueryString.js +57 -0
  456. package/module/es5/Validate/parseEmail.js +5 -5
  457. package/module/es5/index.d.ts +5 -0
  458. package/module/es5/index.js +73 -18
  459. package/module/es5/tsconfig.tsbuildinfo +1 -1
  460. package/module/index.d.ts +5 -0
  461. package/module/index.js +5 -0
  462. package/module/index.js.map +1 -1
  463. package/package.json +58 -27
@@ -0,0 +1,139 @@
1
+ /**
2
+ * A Least Recently Used (LRU) cache implementation
3
+ * using a Map for O(1) get/set operations.
4
+ *
5
+ * When the cache exceeds its capacity, the least recently used
6
+ * entry is evicted.
7
+ *
8
+ * ## Features
9
+ * - **get(key)**: Retrieve a value (moves it to most recently used)
10
+ * - **set(key, value)**: Insert or update a value
11
+ * - **has(key)**: Check if a key exists
12
+ * - **delete(key)**: Remove a specific entry
13
+ * - **clear()**: Remove all entries
14
+ * - **size**: Get the number of entries
15
+ *
16
+ * ## Time Complexity
17
+ * - get: O(1)
18
+ * - set: O(1)
19
+ * - has: O(1)
20
+ * - delete: O(1)
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * const cache = new LRUCache<string, number>(3);
25
+ * cache.set("a", 1);
26
+ * cache.set("b", 2);
27
+ * cache.set("c", 3);
28
+ *
29
+ * cache.get("a"); // 1 (moves "a" to most recently used)
30
+ * cache.set("d", 4); // evicts "b" (least recently used)
31
+ *
32
+ * cache.has("b"); // false
33
+ * cache.get("a"); // 1
34
+ * ```
35
+ *
36
+ * @template K - The type of cache keys
37
+ * @template V - The type of cache values
38
+ */
39
+ export declare class LRUCache<K, V> {
40
+ private capacity;
41
+ private map;
42
+ /**
43
+ * Creates a new LRUCache instance.
44
+ * @param capacity - The maximum number of entries the cache can hold
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * const cache = new LRUCache<string, number>(100);
49
+ * ```
50
+ */
51
+ constructor(capacity: number);
52
+ /**
53
+ * Returns the number of entries in the cache.
54
+ * @returns The current number of cached entries
55
+ *
56
+ * @example
57
+ * ```typescript
58
+ * const cache = new LRUCache<string, number>(10);
59
+ * cache.set("a", 1);
60
+ * console.log(cache.size); // 1
61
+ * ```
62
+ */
63
+ get size(): number;
64
+ /**
65
+ * Retrieves a value by key and marks it as most recently used.
66
+ * @param key - The key to look up
67
+ * @returns The value if found, or undefined if not in cache
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * const cache = new LRUCache<string, number>(10);
72
+ * cache.set("a", 1);
73
+ * cache.get("a"); // 1
74
+ * cache.get("b"); // undefined
75
+ * ```
76
+ */
77
+ get(key: K): V | undefined;
78
+ /**
79
+ * Inserts or updates a key-value pair.
80
+ * If the cache is at capacity, the least recently used entry is evicted.
81
+ * @param key - The key to set
82
+ * @param value - The value to associate with the key
83
+ *
84
+ * @example
85
+ * ```typescript
86
+ * const cache = new LRUCache<string, number>(2);
87
+ * cache.set("a", 1);
88
+ * cache.set("b", 2);
89
+ * cache.set("c", 3); // evicts "a"
90
+ * ```
91
+ */
92
+ set(key: K, value: V): void;
93
+ /**
94
+ * Checks whether a key exists in the cache.
95
+ * Does not affect the recently-used order.
96
+ * @param key - The key to check
97
+ * @returns True if the key exists in the cache
98
+ *
99
+ * @example
100
+ * ```typescript
101
+ * const cache = new LRUCache<string, number>(10);
102
+ * cache.set("a", 1);
103
+ * cache.has("a"); // true
104
+ * cache.has("b"); // false
105
+ * ```
106
+ */
107
+ has(key: K): boolean;
108
+ /**
109
+ * Removes an entry from the cache by key.
110
+ * @param key - The key to remove
111
+ * @returns True if the entry was found and removed
112
+ *
113
+ * @example
114
+ * ```typescript
115
+ * const cache = new LRUCache<string, number>(10);
116
+ * cache.set("a", 1);
117
+ * cache.delete("a"); // true
118
+ * cache.delete("b"); // false
119
+ * ```
120
+ */
121
+ delete(key: K): boolean;
122
+ /**
123
+ * Removes all entries from the cache.
124
+ *
125
+ * @example
126
+ * ```typescript
127
+ * const cache = new LRUCache<string, number>(10);
128
+ * cache.set("a", 1);
129
+ * cache.set("b", 2);
130
+ * cache.clear();
131
+ * console.log(cache.size); // 0
132
+ * ```
133
+ */
134
+ clear(): void;
135
+ /**
136
+ * Evicts the least recently used entry (first inserted).
137
+ */
138
+ private evict;
139
+ }
@@ -0,0 +1,205 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.LRUCache = void 0;
7
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
8
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
9
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
10
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
11
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
12
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
13
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
14
+ /**
15
+ * A Least Recently Used (LRU) cache implementation
16
+ * using a Map for O(1) get/set operations.
17
+ *
18
+ * When the cache exceeds its capacity, the least recently used
19
+ * entry is evicted.
20
+ *
21
+ * ## Features
22
+ * - **get(key)**: Retrieve a value (moves it to most recently used)
23
+ * - **set(key, value)**: Insert or update a value
24
+ * - **has(key)**: Check if a key exists
25
+ * - **delete(key)**: Remove a specific entry
26
+ * - **clear()**: Remove all entries
27
+ * - **size**: Get the number of entries
28
+ *
29
+ * ## Time Complexity
30
+ * - get: O(1)
31
+ * - set: O(1)
32
+ * - has: O(1)
33
+ * - delete: O(1)
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * const cache = new LRUCache<string, number>(3);
38
+ * cache.set("a", 1);
39
+ * cache.set("b", 2);
40
+ * cache.set("c", 3);
41
+ *
42
+ * cache.get("a"); // 1 (moves "a" to most recently used)
43
+ * cache.set("d", 4); // evicts "b" (least recently used)
44
+ *
45
+ * cache.has("b"); // false
46
+ * cache.get("a"); // 1
47
+ * ```
48
+ *
49
+ * @template K - The type of cache keys
50
+ * @template V - The type of cache values
51
+ */
52
+ var LRUCache = exports.LRUCache = /*#__PURE__*/function () {
53
+ /**
54
+ * Creates a new LRUCache instance.
55
+ * @param capacity - The maximum number of entries the cache can hold
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * const cache = new LRUCache<string, number>(100);
60
+ * ```
61
+ */
62
+ function LRUCache(capacity) {
63
+ _classCallCheck(this, LRUCache);
64
+ _defineProperty(this, "map", new Map());
65
+ this.capacity = capacity;
66
+ }
67
+
68
+ /**
69
+ * Returns the number of entries in the cache.
70
+ * @returns The current number of cached entries
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * const cache = new LRUCache<string, number>(10);
75
+ * cache.set("a", 1);
76
+ * console.log(cache.size); // 1
77
+ * ```
78
+ */
79
+ return _createClass(LRUCache, [{
80
+ key: "size",
81
+ get: function get() {
82
+ return this.map.size;
83
+ }
84
+
85
+ /**
86
+ * Retrieves a value by key and marks it as most recently used.
87
+ * @param key - The key to look up
88
+ * @returns The value if found, or undefined if not in cache
89
+ *
90
+ * @example
91
+ * ```typescript
92
+ * const cache = new LRUCache<string, number>(10);
93
+ * cache.set("a", 1);
94
+ * cache.get("a"); // 1
95
+ * cache.get("b"); // undefined
96
+ * ```
97
+ */
98
+ }, {
99
+ key: "get",
100
+ value: function get(key) {
101
+ var value = this.map.get(key);
102
+ if (value === undefined && !this.map.has(key)) {
103
+ return undefined;
104
+ }
105
+ // Refresh key: delete and re-insert
106
+ this.map["delete"](key);
107
+ this.map.set(key, value);
108
+ return value;
109
+ }
110
+
111
+ /**
112
+ * Inserts or updates a key-value pair.
113
+ * If the cache is at capacity, the least recently used entry is evicted.
114
+ * @param key - The key to set
115
+ * @param value - The value to associate with the key
116
+ *
117
+ * @example
118
+ * ```typescript
119
+ * const cache = new LRUCache<string, number>(2);
120
+ * cache.set("a", 1);
121
+ * cache.set("b", 2);
122
+ * cache.set("c", 3); // evicts "a"
123
+ * ```
124
+ */
125
+ }, {
126
+ key: "set",
127
+ value: function set(key, value) {
128
+ if (this.map.has(key)) {
129
+ this.map["delete"](key);
130
+ } else if (this.map.size >= this.capacity) {
131
+ this.evict();
132
+ }
133
+ this.map.set(key, value);
134
+ }
135
+
136
+ /**
137
+ * Checks whether a key exists in the cache.
138
+ * Does not affect the recently-used order.
139
+ * @param key - The key to check
140
+ * @returns True if the key exists in the cache
141
+ *
142
+ * @example
143
+ * ```typescript
144
+ * const cache = new LRUCache<string, number>(10);
145
+ * cache.set("a", 1);
146
+ * cache.has("a"); // true
147
+ * cache.has("b"); // false
148
+ * ```
149
+ */
150
+ }, {
151
+ key: "has",
152
+ value: function has(key) {
153
+ return this.map.has(key);
154
+ }
155
+
156
+ /**
157
+ * Removes an entry from the cache by key.
158
+ * @param key - The key to remove
159
+ * @returns True if the entry was found and removed
160
+ *
161
+ * @example
162
+ * ```typescript
163
+ * const cache = new LRUCache<string, number>(10);
164
+ * cache.set("a", 1);
165
+ * cache.delete("a"); // true
166
+ * cache.delete("b"); // false
167
+ * ```
168
+ */
169
+ }, {
170
+ key: "delete",
171
+ value: function _delete(key) {
172
+ return this.map["delete"](key);
173
+ }
174
+
175
+ /**
176
+ * Removes all entries from the cache.
177
+ *
178
+ * @example
179
+ * ```typescript
180
+ * const cache = new LRUCache<string, number>(10);
181
+ * cache.set("a", 1);
182
+ * cache.set("b", 2);
183
+ * cache.clear();
184
+ * console.log(cache.size); // 0
185
+ * ```
186
+ */
187
+ }, {
188
+ key: "clear",
189
+ value: function clear() {
190
+ this.map.clear();
191
+ }
192
+
193
+ /**
194
+ * Evicts the least recently used entry (first inserted).
195
+ */
196
+ }, {
197
+ key: "evict",
198
+ value: function evict() {
199
+ var iterator = this.map.keys().next();
200
+ if (!iterator.done) {
201
+ this.map["delete"](iterator.value);
202
+ }
203
+ }
204
+ }]);
205
+ }();
@@ -0,0 +1,139 @@
1
+ /**
2
+ * Configuration options for TTLCache.
3
+ */
4
+ export interface TTLCacheOptions {
5
+ /** Default time-to-live in milliseconds for cache entries */
6
+ defaultTTL: number;
7
+ /** Optional maximum number of entries */
8
+ maxSize?: number;
9
+ }
10
+ /**
11
+ * A time-to-live (TTL) cache that automatically expires entries
12
+ * after a configured duration.
13
+ *
14
+ * Uses lazy deletion: expired entries are only removed
15
+ * when accessed via get() or has().
16
+ *
17
+ * ## Features
18
+ * - **get(key)**: Retrieve a value (returns undefined if expired)
19
+ * - **set(key, value, ttl?)**: Insert with optional per-entry TTL
20
+ * - **has(key)**: Check if a non-expired key exists
21
+ * - **delete(key)**: Remove a specific entry
22
+ * - **clear()**: Remove all entries
23
+ * - **size**: Get the number of entries (including expired)
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * const cache = new TTLCache<string, number>({ defaultTTL: 5000 });
28
+ * cache.set("a", 1);
29
+ * cache.get("a"); // 1
30
+ *
31
+ * // After 5 seconds...
32
+ * cache.get("a"); // undefined (expired)
33
+ * ```
34
+ *
35
+ * @template K - The type of cache keys
36
+ * @template V - The type of cache values
37
+ */
38
+ export declare class TTLCache<K, V> {
39
+ private defaultTTL;
40
+ private maxSize;
41
+ private map;
42
+ /**
43
+ * Creates a new TTLCache instance.
44
+ * @param options - Configuration options for the cache
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * const cache = new TTLCache<string, number>({
49
+ * defaultTTL: 60000,
50
+ * maxSize: 1000,
51
+ * });
52
+ * ```
53
+ */
54
+ constructor(options: TTLCacheOptions);
55
+ /**
56
+ * Returns the number of entries in the cache
57
+ * (including potentially expired entries).
58
+ * @returns The current number of entries
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * const cache = new TTLCache<string, number>({ defaultTTL: 5000 });
63
+ * cache.set("a", 1);
64
+ * console.log(cache.size); // 1
65
+ * ```
66
+ */
67
+ get size(): number;
68
+ /**
69
+ * Retrieves a value by key. Returns undefined if the key
70
+ * does not exist or has expired.
71
+ * @param key - The key to look up
72
+ * @returns The value if found and not expired, or undefined
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * const cache = new TTLCache<string, number>({ defaultTTL: 5000 });
77
+ * cache.set("a", 1);
78
+ * cache.get("a"); // 1
79
+ * ```
80
+ */
81
+ get(key: K): V | undefined;
82
+ /**
83
+ * Inserts or updates a key-value pair with an optional TTL override.
84
+ * If maxSize is configured and the cache is full, the oldest entry
85
+ * is removed.
86
+ * @param key - The key to set
87
+ * @param value - The value to cache
88
+ * @param ttl - Optional TTL in milliseconds (overrides defaultTTL)
89
+ *
90
+ * @example
91
+ * ```typescript
92
+ * const cache = new TTLCache<string, number>({ defaultTTL: 5000 });
93
+ * cache.set("a", 1);
94
+ * cache.set("b", 2, 10000); // custom 10s TTL
95
+ * ```
96
+ */
97
+ set(key: K, value: V, ttl?: number): void;
98
+ /**
99
+ * Checks whether a non-expired key exists in the cache.
100
+ * Removes the entry if it has expired.
101
+ * @param key - The key to check
102
+ * @returns True if the key exists and has not expired
103
+ *
104
+ * @example
105
+ * ```typescript
106
+ * const cache = new TTLCache<string, number>({ defaultTTL: 5000 });
107
+ * cache.set("a", 1);
108
+ * cache.has("a"); // true
109
+ * cache.has("b"); // false
110
+ * ```
111
+ */
112
+ has(key: K): boolean;
113
+ /**
114
+ * Removes an entry from the cache by key.
115
+ * @param key - The key to remove
116
+ * @returns True if the entry was found and removed
117
+ *
118
+ * @example
119
+ * ```typescript
120
+ * const cache = new TTLCache<string, number>({ defaultTTL: 5000 });
121
+ * cache.set("a", 1);
122
+ * cache.delete("a"); // true
123
+ * cache.delete("b"); // false
124
+ * ```
125
+ */
126
+ delete(key: K): boolean;
127
+ /**
128
+ * Removes all entries from the cache.
129
+ *
130
+ * @example
131
+ * ```typescript
132
+ * const cache = new TTLCache<string, number>({ defaultTTL: 5000 });
133
+ * cache.set("a", 1);
134
+ * cache.clear();
135
+ * console.log(cache.size); // 0
136
+ * ```
137
+ */
138
+ clear(): void;
139
+ }
@@ -0,0 +1,211 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.TTLCache = void 0;
7
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
8
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
9
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
10
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
11
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
12
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
13
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
14
+ /**
15
+ * Configuration options for TTLCache.
16
+ */
17
+ /**
18
+ * A time-to-live (TTL) cache that automatically expires entries
19
+ * after a configured duration.
20
+ *
21
+ * Uses lazy deletion: expired entries are only removed
22
+ * when accessed via get() or has().
23
+ *
24
+ * ## Features
25
+ * - **get(key)**: Retrieve a value (returns undefined if expired)
26
+ * - **set(key, value, ttl?)**: Insert with optional per-entry TTL
27
+ * - **has(key)**: Check if a non-expired key exists
28
+ * - **delete(key)**: Remove a specific entry
29
+ * - **clear()**: Remove all entries
30
+ * - **size**: Get the number of entries (including expired)
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * const cache = new TTLCache<string, number>({ defaultTTL: 5000 });
35
+ * cache.set("a", 1);
36
+ * cache.get("a"); // 1
37
+ *
38
+ * // After 5 seconds...
39
+ * cache.get("a"); // undefined (expired)
40
+ * ```
41
+ *
42
+ * @template K - The type of cache keys
43
+ * @template V - The type of cache values
44
+ */
45
+ var TTLCache = exports.TTLCache = /*#__PURE__*/function () {
46
+ /**
47
+ * Creates a new TTLCache instance.
48
+ * @param options - Configuration options for the cache
49
+ *
50
+ * @example
51
+ * ```typescript
52
+ * const cache = new TTLCache<string, number>({
53
+ * defaultTTL: 60000,
54
+ * maxSize: 1000,
55
+ * });
56
+ * ```
57
+ */
58
+ function TTLCache(options) {
59
+ _classCallCheck(this, TTLCache);
60
+ _defineProperty(this, "map", new Map());
61
+ this.defaultTTL = options.defaultTTL;
62
+ this.maxSize = options.maxSize;
63
+ }
64
+
65
+ /**
66
+ * Returns the number of entries in the cache
67
+ * (including potentially expired entries).
68
+ * @returns The current number of entries
69
+ *
70
+ * @example
71
+ * ```typescript
72
+ * const cache = new TTLCache<string, number>({ defaultTTL: 5000 });
73
+ * cache.set("a", 1);
74
+ * console.log(cache.size); // 1
75
+ * ```
76
+ */
77
+ return _createClass(TTLCache, [{
78
+ key: "size",
79
+ get: function get() {
80
+ return this.map.size;
81
+ }
82
+
83
+ /**
84
+ * Retrieves a value by key. Returns undefined if the key
85
+ * does not exist or has expired.
86
+ * @param key - The key to look up
87
+ * @returns The value if found and not expired, or undefined
88
+ *
89
+ * @example
90
+ * ```typescript
91
+ * const cache = new TTLCache<string, number>({ defaultTTL: 5000 });
92
+ * cache.set("a", 1);
93
+ * cache.get("a"); // 1
94
+ * ```
95
+ */
96
+ }, {
97
+ key: "get",
98
+ value: function get(key) {
99
+ var entry = this.map.get(key);
100
+ if (entry === undefined) {
101
+ return;
102
+ }
103
+ if (Date.now() >= entry.expiresAt) {
104
+ this.map["delete"](key);
105
+ return;
106
+ }
107
+ return entry.value;
108
+ }
109
+
110
+ /**
111
+ * Inserts or updates a key-value pair with an optional TTL override.
112
+ * If maxSize is configured and the cache is full, the oldest entry
113
+ * is removed.
114
+ * @param key - The key to set
115
+ * @param value - The value to cache
116
+ * @param ttl - Optional TTL in milliseconds (overrides defaultTTL)
117
+ *
118
+ * @example
119
+ * ```typescript
120
+ * const cache = new TTLCache<string, number>({ defaultTTL: 5000 });
121
+ * cache.set("a", 1);
122
+ * cache.set("b", 2, 10000); // custom 10s TTL
123
+ * ```
124
+ */
125
+ }, {
126
+ key: "set",
127
+ value: function set(key, value, ttl) {
128
+ var effectiveTTL = ttl !== null && ttl !== void 0 ? ttl : this.defaultTTL;
129
+ var expiresAt = Date.now() + effectiveTTL;
130
+ if (this.map.has(key)) {
131
+ this.map.set(key, {
132
+ value: value,
133
+ expiresAt: expiresAt
134
+ });
135
+ return;
136
+ }
137
+ if (this.maxSize !== undefined && this.map.size >= this.maxSize) {
138
+ var firstKey = this.map.keys().next().value;
139
+ this.map["delete"](firstKey);
140
+ }
141
+ this.map.set(key, {
142
+ value: value,
143
+ expiresAt: expiresAt
144
+ });
145
+ }
146
+
147
+ /**
148
+ * Checks whether a non-expired key exists in the cache.
149
+ * Removes the entry if it has expired.
150
+ * @param key - The key to check
151
+ * @returns True if the key exists and has not expired
152
+ *
153
+ * @example
154
+ * ```typescript
155
+ * const cache = new TTLCache<string, number>({ defaultTTL: 5000 });
156
+ * cache.set("a", 1);
157
+ * cache.has("a"); // true
158
+ * cache.has("b"); // false
159
+ * ```
160
+ */
161
+ }, {
162
+ key: "has",
163
+ value: function has(key) {
164
+ var entry = this.map.get(key);
165
+ if (entry === undefined) {
166
+ return false;
167
+ }
168
+ if (Date.now() >= entry.expiresAt) {
169
+ this.map["delete"](key);
170
+ return false;
171
+ }
172
+ return true;
173
+ }
174
+
175
+ /**
176
+ * Removes an entry from the cache by key.
177
+ * @param key - The key to remove
178
+ * @returns True if the entry was found and removed
179
+ *
180
+ * @example
181
+ * ```typescript
182
+ * const cache = new TTLCache<string, number>({ defaultTTL: 5000 });
183
+ * cache.set("a", 1);
184
+ * cache.delete("a"); // true
185
+ * cache.delete("b"); // false
186
+ * ```
187
+ */
188
+ }, {
189
+ key: "delete",
190
+ value: function _delete(key) {
191
+ return this.map["delete"](key);
192
+ }
193
+
194
+ /**
195
+ * Removes all entries from the cache.
196
+ *
197
+ * @example
198
+ * ```typescript
199
+ * const cache = new TTLCache<string, number>({ defaultTTL: 5000 });
200
+ * cache.set("a", 1);
201
+ * cache.clear();
202
+ * console.log(cache.size); // 0
203
+ * ```
204
+ */
205
+ }, {
206
+ key: "clear",
207
+ value: function clear() {
208
+ this.map.clear();
209
+ }
210
+ }]);
211
+ }();