@kdtlabs/utils 0.0.3 → 0.0.5

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 (451) hide show
  1. package/SKILL.md +7 -9
  2. package/{common → dist/common}/assertions.d.ts +1 -1
  3. package/{common → dist/common}/assertions.d.ts.map +1 -1
  4. package/dist/common/guards.d.ts +3 -0
  5. package/{common → dist/common}/guards.d.ts.map +1 -1
  6. package/dist/common/index.d.ts +5 -0
  7. package/{common → dist/common}/index.d.ts.map +1 -1
  8. package/dist/common/transformations.d.ts +3 -0
  9. package/dist/common/transformations.d.ts.map +1 -0
  10. package/dist/common/types.d.ts +5 -0
  11. package/dist/common/types.d.ts.map +1 -0
  12. package/dist/core/conversions.d.ts +3 -0
  13. package/dist/core/conversions.d.ts.map +1 -0
  14. package/{core → dist/core}/guards.d.ts +0 -2
  15. package/dist/core/guards.d.ts.map +1 -0
  16. package/{core → dist/core}/index.d.ts +1 -0
  17. package/{core → dist/core}/index.d.ts.map +1 -1
  18. package/{functions → dist/functions}/executions.d.ts +1 -1
  19. package/{functions → dist/functions}/executions.d.ts.map +1 -1
  20. package/dist/index.js +7 -0
  21. package/dist/index.js.map +99 -0
  22. package/{objects → dist/objects}/transformations.d.ts +1 -1
  23. package/{objects → dist/objects}/transformations.d.ts.map +1 -1
  24. package/{objects → dist/objects}/types.d.ts +1 -1
  25. package/{objects → dist/objects}/types.d.ts.map +1 -1
  26. package/{promises → dist/promises}/deferred.d.ts +1 -1
  27. package/{promises → dist/promises}/deferred.d.ts.map +1 -1
  28. package/{promises → dist/promises}/timers.d.ts +1 -1
  29. package/{promises → dist/promises}/timers.d.ts.map +1 -1
  30. package/{serializer → dist/serializer}/context.d.ts +1 -1
  31. package/{serializer → dist/serializer}/context.d.ts.map +1 -1
  32. package/{serializer → dist/serializer}/serialize.d.ts +1 -1
  33. package/{serializer → dist/serializer}/serialize.d.ts.map +1 -1
  34. package/{serializer → dist/serializer}/serializers/array.d.ts +1 -1
  35. package/{serializer → dist/serializer}/serializers/array.d.ts.map +1 -1
  36. package/{serializer → dist/serializer}/serializers/binary.d.ts +1 -1
  37. package/dist/serializer/serializers/binary.d.ts.map +1 -0
  38. package/{serializer → dist/serializer}/serializers/blob.d.ts +1 -1
  39. package/dist/serializer/serializers/blob.d.ts.map +1 -0
  40. package/{serializer → dist/serializer}/serializers/collection.d.ts +1 -1
  41. package/{serializer → dist/serializer}/serializers/collection.d.ts.map +1 -1
  42. package/{serializer → dist/serializer}/serializers/compound.d.ts +1 -1
  43. package/{serializer → dist/serializer}/serializers/compound.d.ts.map +1 -1
  44. package/{serializer → dist/serializer}/serializers/error.d.ts +1 -1
  45. package/{serializer → dist/serializer}/serializers/error.d.ts.map +1 -1
  46. package/{serializer → dist/serializer}/serializers/function.d.ts +1 -1
  47. package/{serializer → dist/serializer}/serializers/function.d.ts.map +1 -1
  48. package/{serializer → dist/serializer}/serializers/leaf-object.d.ts +1 -1
  49. package/{serializer → dist/serializer}/serializers/leaf-object.d.ts.map +1 -1
  50. package/{serializer → dist/serializer}/serializers/number.d.ts +1 -1
  51. package/dist/serializer/serializers/number.d.ts.map +1 -0
  52. package/{serializer → dist/serializer}/serializers/object.d.ts +1 -1
  53. package/{serializer → dist/serializer}/serializers/object.d.ts.map +1 -1
  54. package/{serializer → dist/serializer}/serializers/opaque.d.ts +1 -1
  55. package/dist/serializer/serializers/opaque.d.ts.map +1 -0
  56. package/{serializer → dist/serializer}/serializers/primitive.d.ts +1 -1
  57. package/{serializer → dist/serializer}/serializers/primitive.d.ts.map +1 -1
  58. package/{serializer → dist/serializer}/types.d.ts +1 -1
  59. package/{serializer → dist/serializer}/types.d.ts.map +1 -1
  60. package/{serializer → dist/serializer}/utils.d.ts +1 -1
  61. package/{serializer → dist/serializer}/utils.d.ts.map +1 -1
  62. package/{system → dist/system}/env.d.ts +6 -0
  63. package/dist/system/env.d.ts.map +1 -0
  64. package/{system → dist/system}/fetch.d.ts +2 -2
  65. package/{system → dist/system}/fetch.d.ts.map +1 -1
  66. package/dist/system/types.d.ts +3 -0
  67. package/{system → dist/system}/types.d.ts.map +1 -1
  68. package/{times → dist/times}/conversions.d.ts +1 -1
  69. package/{times → dist/times}/conversions.d.ts.map +1 -1
  70. package/package.json +11 -73
  71. package/src/arrays/accessors.ts +25 -0
  72. package/src/arrays/conversions.ts +16 -0
  73. package/src/arrays/factories.ts +13 -0
  74. package/src/arrays/guards.ts +7 -0
  75. package/src/arrays/index.ts +8 -0
  76. package/src/arrays/operations.ts +103 -0
  77. package/src/arrays/set-operations.ts +11 -0
  78. package/src/arrays/types.ts +21 -0
  79. package/src/buffers/conversions.ts +26 -0
  80. package/src/buffers/guards.ts +13 -0
  81. package/src/buffers/index.ts +5 -0
  82. package/src/buffers/operations.ts +44 -0
  83. package/src/buffers/types.ts +1 -0
  84. package/src/collections/fifo-map.ts +33 -0
  85. package/src/collections/fifo-set.ts +29 -0
  86. package/src/collections/guards.ts +11 -0
  87. package/src/collections/index.ts +10 -0
  88. package/src/collections/linked-base.ts +117 -0
  89. package/src/collections/linked-map.ts +82 -0
  90. package/src/collections/linked-set.ts +69 -0
  91. package/src/collections/lru-map.ts +36 -0
  92. package/src/collections/lru-set.ts +25 -0
  93. package/src/collections/types.ts +12 -0
  94. package/src/common/assertions.ts +11 -0
  95. package/src/common/guards.ts +58 -0
  96. package/src/common/index.ts +5 -0
  97. package/src/common/transformations.ts +20 -0
  98. package/src/common/types.ts +3 -0
  99. package/src/core/constants.ts +1 -0
  100. package/src/core/conversions.ts +9 -0
  101. package/src/core/guards.ts +57 -0
  102. package/src/core/index.ts +5 -0
  103. package/src/core/types.ts +15 -0
  104. package/src/errors/base-error.ts +48 -0
  105. package/src/errors/factories.ts +74 -0
  106. package/src/errors/guards.ts +12 -0
  107. package/src/errors/index.ts +7 -0
  108. package/src/errors/operations.ts +15 -0
  109. package/src/errors/stringify.ts +131 -0
  110. package/src/errors/types.ts +11 -0
  111. package/src/events/emitter.ts +117 -0
  112. package/src/events/index.ts +2 -0
  113. package/src/events/types.ts +11 -0
  114. package/src/functions/compositions.ts +17 -0
  115. package/src/functions/debounce.ts +34 -0
  116. package/src/functions/executions.ts +12 -0
  117. package/src/functions/guards.ts +5 -0
  118. package/src/functions/index.ts +11 -0
  119. package/src/functions/memoize.ts +33 -0
  120. package/src/functions/once.ts +33 -0
  121. package/src/functions/pipe.ts +39 -0
  122. package/src/functions/throttle.ts +59 -0
  123. package/src/functions/timer-state.ts +33 -0
  124. package/src/functions/types.ts +8 -0
  125. package/src/index.ts +16 -0
  126. package/src/json-rpc/constants.ts +15 -0
  127. package/src/json-rpc/factories.ts +22 -0
  128. package/src/json-rpc/guards.ts +58 -0
  129. package/src/json-rpc/index.ts +5 -0
  130. package/src/json-rpc/types.ts +48 -0
  131. package/src/numbers/bigint-math.ts +163 -0
  132. package/src/numbers/constants.ts +14 -0
  133. package/src/numbers/conversions.ts +83 -0
  134. package/src/numbers/factories.ts +6 -0
  135. package/src/numbers/formats.ts +52 -0
  136. package/src/numbers/guards.ts +22 -0
  137. package/src/numbers/index.ts +10 -0
  138. package/src/numbers/maths.ts +28 -0
  139. package/src/numbers/ranges.ts +17 -0
  140. package/src/numbers/types.ts +7 -0
  141. package/src/objects/deep-merge.ts +76 -0
  142. package/src/objects/guards.ts +21 -0
  143. package/src/objects/index.ts +5 -0
  144. package/src/objects/transformations.ts +34 -0
  145. package/src/objects/types.ts +33 -0
  146. package/src/promises/abortable.ts +37 -0
  147. package/src/promises/compositions.ts +18 -0
  148. package/src/promises/deferred.ts +131 -0
  149. package/src/promises/guards.ts +8 -0
  150. package/src/promises/index.ts +10 -0
  151. package/src/promises/pipe.ts +39 -0
  152. package/src/promises/poll.ts +92 -0
  153. package/src/promises/retry.ts +138 -0
  154. package/src/promises/timers.ts +16 -0
  155. package/src/promises/types.ts +1 -0
  156. package/src/serializer/constants.ts +5 -0
  157. package/src/serializer/context.ts +24 -0
  158. package/src/serializer/index.ts +8 -0
  159. package/src/serializer/serialize.ts +51 -0
  160. package/src/serializer/serializers/array.ts +17 -0
  161. package/src/serializer/serializers/binary.ts +24 -0
  162. package/src/serializer/serializers/blob.ts +18 -0
  163. package/src/serializer/serializers/collection.ts +25 -0
  164. package/src/serializer/serializers/compound.ts +79 -0
  165. package/src/serializer/serializers/error.ts +75 -0
  166. package/src/serializer/serializers/function.ts +13 -0
  167. package/src/serializer/serializers/index.ts +12 -0
  168. package/src/serializer/serializers/leaf-object.ts +18 -0
  169. package/src/serializer/serializers/number.ts +14 -0
  170. package/src/serializer/serializers/object.ts +62 -0
  171. package/src/serializer/serializers/opaque.ts +36 -0
  172. package/src/serializer/serializers/primitive.ts +32 -0
  173. package/src/serializer/symbol-registry.ts +28 -0
  174. package/src/serializer/types.ts +42 -0
  175. package/src/serializer/utils.ts +15 -0
  176. package/src/strings/constants.ts +1 -0
  177. package/src/strings/factories.ts +9 -0
  178. package/src/strings/guards.ts +51 -0
  179. package/src/strings/index.ts +6 -0
  180. package/src/strings/manipulations.ts +99 -0
  181. package/src/strings/types.ts +3 -0
  182. package/src/system/env.ts +32 -0
  183. package/src/system/fetch.ts +23 -0
  184. package/src/system/graceful-exit.ts +46 -0
  185. package/src/system/index.ts +6 -0
  186. package/src/system/path.ts +12 -0
  187. package/src/system/types.ts +3 -0
  188. package/src/times/constants.ts +6 -0
  189. package/src/times/conversions.ts +85 -0
  190. package/src/times/factories.ts +3 -0
  191. package/src/times/guards.ts +3 -0
  192. package/src/times/index.ts +5 -0
  193. package/src/times/operations.ts +9 -0
  194. package/CHANGELOG.md +0 -39
  195. package/arrays/index.js +0 -4
  196. package/arrays/index.js.map +0 -9
  197. package/buffers/index.js +0 -4
  198. package/buffers/index.js.map +0 -9
  199. package/chunk-4w1emwv7.js +0 -6
  200. package/chunk-4w1emwv7.js.map +0 -14
  201. package/chunk-6kdnnxe0.js +0 -4
  202. package/chunk-6kdnnxe0.js.map +0 -17
  203. package/chunk-6whsm14p.js +0 -4
  204. package/chunk-6whsm14p.js.map +0 -13
  205. package/chunk-6wkh99v0.js +0 -4
  206. package/chunk-6wkh99v0.js.map +0 -11
  207. package/chunk-84hxmrk7.js +0 -4
  208. package/chunk-84hxmrk7.js.map +0 -12
  209. package/chunk-bham5jvm.js +0 -5
  210. package/chunk-bham5jvm.js.map +0 -13
  211. package/chunk-bjmntg2y.js +0 -4
  212. package/chunk-bjmntg2y.js.map +0 -18
  213. package/chunk-bx5gjsp0.js +0 -4
  214. package/chunk-bx5gjsp0.js.map +0 -17
  215. package/chunk-c0p3wm8m.js +0 -4
  216. package/chunk-c0p3wm8m.js.map +0 -15
  217. package/chunk-c9mm50vv.js +0 -4
  218. package/chunk-c9mm50vv.js.map +0 -11
  219. package/chunk-f2rvwnb6.js +0 -4
  220. package/chunk-f2rvwnb6.js.map +0 -26
  221. package/chunk-kbzgn0z4.js +0 -4
  222. package/chunk-kbzgn0z4.js.map +0 -10
  223. package/chunk-m4svr349.js +0 -4
  224. package/chunk-m4svr349.js.map +0 -12
  225. package/chunk-qn6n0ff5.js +0 -4
  226. package/chunk-qn6n0ff5.js.map +0 -17
  227. package/chunk-sajy7qk7.js +0 -4
  228. package/chunk-sajy7qk7.js.map +0 -14
  229. package/chunk-xp18wdk6.js +0 -4
  230. package/chunk-xp18wdk6.js.map +0 -12
  231. package/collections/index.js +0 -4
  232. package/collections/index.js.map +0 -9
  233. package/common/guards.d.ts +0 -2
  234. package/common/index.d.ts +0 -3
  235. package/common/index.js +0 -4
  236. package/common/index.js.map +0 -9
  237. package/core/guards.d.ts.map +0 -1
  238. package/core/index.js +0 -4
  239. package/core/index.js.map +0 -9
  240. package/errors/index.js +0 -4
  241. package/errors/index.js.map +0 -9
  242. package/events/index.js +0 -4
  243. package/events/index.js.map +0 -9
  244. package/functions/index.js +0 -4
  245. package/functions/index.js.map +0 -9
  246. package/index.js +0 -4
  247. package/index.js.map +0 -9
  248. package/json-rpc/index.js +0 -4
  249. package/json-rpc/index.js.map +0 -9
  250. package/meta.json +0 -2944
  251. package/meta.md +0 -1782
  252. package/numbers/index.js +0 -4
  253. package/numbers/index.js.map +0 -9
  254. package/objects/index.js +0 -4
  255. package/objects/index.js.map +0 -9
  256. package/promises/index.js +0 -4
  257. package/promises/index.js.map +0 -9
  258. package/serializer/index.js +0 -4
  259. package/serializer/index.js.map +0 -9
  260. package/serializer/serializers/binary.d.ts.map +0 -1
  261. package/serializer/serializers/blob.d.ts.map +0 -1
  262. package/serializer/serializers/number.d.ts.map +0 -1
  263. package/serializer/serializers/opaque.d.ts.map +0 -1
  264. package/strings/index.js +0 -4
  265. package/strings/index.js.map +0 -9
  266. package/system/env.d.ts.map +0 -1
  267. package/system/index.js +0 -4
  268. package/system/index.js.map +0 -9
  269. package/system/types.d.ts +0 -3
  270. package/times/index.js +0 -4
  271. package/times/index.js.map +0 -9
  272. /package/{arrays → dist/arrays}/accessors.d.ts +0 -0
  273. /package/{arrays → dist/arrays}/accessors.d.ts.map +0 -0
  274. /package/{arrays → dist/arrays}/conversions.d.ts +0 -0
  275. /package/{arrays → dist/arrays}/conversions.d.ts.map +0 -0
  276. /package/{arrays → dist/arrays}/factories.d.ts +0 -0
  277. /package/{arrays → dist/arrays}/factories.d.ts.map +0 -0
  278. /package/{arrays → dist/arrays}/guards.d.ts +0 -0
  279. /package/{arrays → dist/arrays}/guards.d.ts.map +0 -0
  280. /package/{arrays → dist/arrays}/index.d.ts +0 -0
  281. /package/{arrays → dist/arrays}/index.d.ts.map +0 -0
  282. /package/{arrays → dist/arrays}/operations.d.ts +0 -0
  283. /package/{arrays → dist/arrays}/operations.d.ts.map +0 -0
  284. /package/{arrays → dist/arrays}/set-operations.d.ts +0 -0
  285. /package/{arrays → dist/arrays}/set-operations.d.ts.map +0 -0
  286. /package/{arrays → dist/arrays}/types.d.ts +0 -0
  287. /package/{arrays → dist/arrays}/types.d.ts.map +0 -0
  288. /package/{buffers → dist/buffers}/conversions.d.ts +0 -0
  289. /package/{buffers → dist/buffers}/conversions.d.ts.map +0 -0
  290. /package/{buffers → dist/buffers}/guards.d.ts +0 -0
  291. /package/{buffers → dist/buffers}/guards.d.ts.map +0 -0
  292. /package/{buffers → dist/buffers}/index.d.ts +0 -0
  293. /package/{buffers → dist/buffers}/index.d.ts.map +0 -0
  294. /package/{buffers → dist/buffers}/operations.d.ts +0 -0
  295. /package/{buffers → dist/buffers}/operations.d.ts.map +0 -0
  296. /package/{buffers → dist/buffers}/types.d.ts +0 -0
  297. /package/{buffers → dist/buffers}/types.d.ts.map +0 -0
  298. /package/{collections → dist/collections}/fifo-map.d.ts +0 -0
  299. /package/{collections → dist/collections}/fifo-map.d.ts.map +0 -0
  300. /package/{collections → dist/collections}/fifo-set.d.ts +0 -0
  301. /package/{collections → dist/collections}/fifo-set.d.ts.map +0 -0
  302. /package/{collections → dist/collections}/guards.d.ts +0 -0
  303. /package/{collections → dist/collections}/guards.d.ts.map +0 -0
  304. /package/{collections → dist/collections}/index.d.ts +0 -0
  305. /package/{collections → dist/collections}/index.d.ts.map +0 -0
  306. /package/{collections → dist/collections}/linked-base.d.ts +0 -0
  307. /package/{collections → dist/collections}/linked-base.d.ts.map +0 -0
  308. /package/{collections → dist/collections}/linked-map.d.ts +0 -0
  309. /package/{collections → dist/collections}/linked-map.d.ts.map +0 -0
  310. /package/{collections → dist/collections}/linked-set.d.ts +0 -0
  311. /package/{collections → dist/collections}/linked-set.d.ts.map +0 -0
  312. /package/{collections → dist/collections}/lru-map.d.ts +0 -0
  313. /package/{collections → dist/collections}/lru-map.d.ts.map +0 -0
  314. /package/{collections → dist/collections}/lru-set.d.ts +0 -0
  315. /package/{collections → dist/collections}/lru-set.d.ts.map +0 -0
  316. /package/{collections → dist/collections}/types.d.ts +0 -0
  317. /package/{collections → dist/collections}/types.d.ts.map +0 -0
  318. /package/{core → dist/core}/constants.d.ts +0 -0
  319. /package/{core → dist/core}/constants.d.ts.map +0 -0
  320. /package/{core → dist/core}/types.d.ts +0 -0
  321. /package/{core → dist/core}/types.d.ts.map +0 -0
  322. /package/{errors → dist/errors}/base-error.d.ts +0 -0
  323. /package/{errors → dist/errors}/base-error.d.ts.map +0 -0
  324. /package/{errors → dist/errors}/factories.d.ts +0 -0
  325. /package/{errors → dist/errors}/factories.d.ts.map +0 -0
  326. /package/{errors → dist/errors}/guards.d.ts +0 -0
  327. /package/{errors → dist/errors}/guards.d.ts.map +0 -0
  328. /package/{errors → dist/errors}/index.d.ts +0 -0
  329. /package/{errors → dist/errors}/index.d.ts.map +0 -0
  330. /package/{errors → dist/errors}/operations.d.ts +0 -0
  331. /package/{errors → dist/errors}/operations.d.ts.map +0 -0
  332. /package/{errors → dist/errors}/stringify.d.ts +0 -0
  333. /package/{errors → dist/errors}/stringify.d.ts.map +0 -0
  334. /package/{errors → dist/errors}/types.d.ts +0 -0
  335. /package/{errors → dist/errors}/types.d.ts.map +0 -0
  336. /package/{events → dist/events}/emitter.d.ts +0 -0
  337. /package/{events → dist/events}/emitter.d.ts.map +0 -0
  338. /package/{events → dist/events}/index.d.ts +0 -0
  339. /package/{events → dist/events}/index.d.ts.map +0 -0
  340. /package/{events → dist/events}/types.d.ts +0 -0
  341. /package/{events → dist/events}/types.d.ts.map +0 -0
  342. /package/{functions → dist/functions}/compositions.d.ts +0 -0
  343. /package/{functions → dist/functions}/compositions.d.ts.map +0 -0
  344. /package/{functions → dist/functions}/debounce.d.ts +0 -0
  345. /package/{functions → dist/functions}/debounce.d.ts.map +0 -0
  346. /package/{functions → dist/functions}/guards.d.ts +0 -0
  347. /package/{functions → dist/functions}/guards.d.ts.map +0 -0
  348. /package/{functions → dist/functions}/index.d.ts +0 -0
  349. /package/{functions → dist/functions}/index.d.ts.map +0 -0
  350. /package/{functions → dist/functions}/memoize.d.ts +0 -0
  351. /package/{functions → dist/functions}/memoize.d.ts.map +0 -0
  352. /package/{functions → dist/functions}/once.d.ts +0 -0
  353. /package/{functions → dist/functions}/once.d.ts.map +0 -0
  354. /package/{functions → dist/functions}/pipe.d.ts +0 -0
  355. /package/{functions → dist/functions}/pipe.d.ts.map +0 -0
  356. /package/{functions → dist/functions}/throttle.d.ts +0 -0
  357. /package/{functions → dist/functions}/throttle.d.ts.map +0 -0
  358. /package/{functions → dist/functions}/timer-state.d.ts +0 -0
  359. /package/{functions → dist/functions}/timer-state.d.ts.map +0 -0
  360. /package/{functions → dist/functions}/types.d.ts +0 -0
  361. /package/{functions → dist/functions}/types.d.ts.map +0 -0
  362. /package/{index.d.ts → dist/index.d.ts} +0 -0
  363. /package/{index.d.ts.map → dist/index.d.ts.map} +0 -0
  364. /package/{json-rpc → dist/json-rpc}/constants.d.ts +0 -0
  365. /package/{json-rpc → dist/json-rpc}/constants.d.ts.map +0 -0
  366. /package/{json-rpc → dist/json-rpc}/factories.d.ts +0 -0
  367. /package/{json-rpc → dist/json-rpc}/factories.d.ts.map +0 -0
  368. /package/{json-rpc → dist/json-rpc}/guards.d.ts +0 -0
  369. /package/{json-rpc → dist/json-rpc}/guards.d.ts.map +0 -0
  370. /package/{json-rpc → dist/json-rpc}/index.d.ts +0 -0
  371. /package/{json-rpc → dist/json-rpc}/index.d.ts.map +0 -0
  372. /package/{json-rpc → dist/json-rpc}/types.d.ts +0 -0
  373. /package/{json-rpc → dist/json-rpc}/types.d.ts.map +0 -0
  374. /package/{numbers → dist/numbers}/bigint-math.d.ts +0 -0
  375. /package/{numbers → dist/numbers}/bigint-math.d.ts.map +0 -0
  376. /package/{numbers → dist/numbers}/constants.d.ts +0 -0
  377. /package/{numbers → dist/numbers}/constants.d.ts.map +0 -0
  378. /package/{numbers → dist/numbers}/conversions.d.ts +0 -0
  379. /package/{numbers → dist/numbers}/conversions.d.ts.map +0 -0
  380. /package/{numbers → dist/numbers}/factories.d.ts +0 -0
  381. /package/{numbers → dist/numbers}/factories.d.ts.map +0 -0
  382. /package/{numbers → dist/numbers}/formats.d.ts +0 -0
  383. /package/{numbers → dist/numbers}/formats.d.ts.map +0 -0
  384. /package/{numbers → dist/numbers}/guards.d.ts +0 -0
  385. /package/{numbers → dist/numbers}/guards.d.ts.map +0 -0
  386. /package/{numbers → dist/numbers}/index.d.ts +0 -0
  387. /package/{numbers → dist/numbers}/index.d.ts.map +0 -0
  388. /package/{numbers → dist/numbers}/maths.d.ts +0 -0
  389. /package/{numbers → dist/numbers}/maths.d.ts.map +0 -0
  390. /package/{numbers → dist/numbers}/ranges.d.ts +0 -0
  391. /package/{numbers → dist/numbers}/ranges.d.ts.map +0 -0
  392. /package/{numbers → dist/numbers}/types.d.ts +0 -0
  393. /package/{numbers → dist/numbers}/types.d.ts.map +0 -0
  394. /package/{objects → dist/objects}/deep-merge.d.ts +0 -0
  395. /package/{objects → dist/objects}/deep-merge.d.ts.map +0 -0
  396. /package/{objects → dist/objects}/guards.d.ts +0 -0
  397. /package/{objects → dist/objects}/guards.d.ts.map +0 -0
  398. /package/{objects → dist/objects}/index.d.ts +0 -0
  399. /package/{objects → dist/objects}/index.d.ts.map +0 -0
  400. /package/{promises → dist/promises}/abortable.d.ts +0 -0
  401. /package/{promises → dist/promises}/abortable.d.ts.map +0 -0
  402. /package/{promises → dist/promises}/compositions.d.ts +0 -0
  403. /package/{promises → dist/promises}/compositions.d.ts.map +0 -0
  404. /package/{promises → dist/promises}/guards.d.ts +0 -0
  405. /package/{promises → dist/promises}/guards.d.ts.map +0 -0
  406. /package/{promises → dist/promises}/index.d.ts +0 -0
  407. /package/{promises → dist/promises}/index.d.ts.map +0 -0
  408. /package/{promises → dist/promises}/pipe.d.ts +0 -0
  409. /package/{promises → dist/promises}/pipe.d.ts.map +0 -0
  410. /package/{promises → dist/promises}/poll.d.ts +0 -0
  411. /package/{promises → dist/promises}/poll.d.ts.map +0 -0
  412. /package/{promises → dist/promises}/retry.d.ts +0 -0
  413. /package/{promises → dist/promises}/retry.d.ts.map +0 -0
  414. /package/{promises → dist/promises}/types.d.ts +0 -0
  415. /package/{promises → dist/promises}/types.d.ts.map +0 -0
  416. /package/{serializer → dist/serializer}/constants.d.ts +0 -0
  417. /package/{serializer → dist/serializer}/constants.d.ts.map +0 -0
  418. /package/{serializer → dist/serializer}/index.d.ts +0 -0
  419. /package/{serializer → dist/serializer}/index.d.ts.map +0 -0
  420. /package/{serializer → dist/serializer}/serializers/index.d.ts +0 -0
  421. /package/{serializer → dist/serializer}/serializers/index.d.ts.map +0 -0
  422. /package/{serializer → dist/serializer}/symbol-registry.d.ts +0 -0
  423. /package/{serializer → dist/serializer}/symbol-registry.d.ts.map +0 -0
  424. /package/{strings → dist/strings}/constants.d.ts +0 -0
  425. /package/{strings → dist/strings}/constants.d.ts.map +0 -0
  426. /package/{strings → dist/strings}/factories.d.ts +0 -0
  427. /package/{strings → dist/strings}/factories.d.ts.map +0 -0
  428. /package/{strings → dist/strings}/guards.d.ts +0 -0
  429. /package/{strings → dist/strings}/guards.d.ts.map +0 -0
  430. /package/{strings → dist/strings}/index.d.ts +0 -0
  431. /package/{strings → dist/strings}/index.d.ts.map +0 -0
  432. /package/{strings → dist/strings}/manipulations.d.ts +0 -0
  433. /package/{strings → dist/strings}/manipulations.d.ts.map +0 -0
  434. /package/{strings → dist/strings}/types.d.ts +0 -0
  435. /package/{strings → dist/strings}/types.d.ts.map +0 -0
  436. /package/{system → dist/system}/graceful-exit.d.ts +0 -0
  437. /package/{system → dist/system}/graceful-exit.d.ts.map +0 -0
  438. /package/{system → dist/system}/index.d.ts +0 -0
  439. /package/{system → dist/system}/index.d.ts.map +0 -0
  440. /package/{system → dist/system}/path.d.ts +0 -0
  441. /package/{system → dist/system}/path.d.ts.map +0 -0
  442. /package/{times → dist/times}/constants.d.ts +0 -0
  443. /package/{times → dist/times}/constants.d.ts.map +0 -0
  444. /package/{times → dist/times}/factories.d.ts +0 -0
  445. /package/{times → dist/times}/factories.d.ts.map +0 -0
  446. /package/{times → dist/times}/guards.d.ts +0 -0
  447. /package/{times → dist/times}/guards.d.ts.map +0 -0
  448. /package/{times → dist/times}/index.d.ts +0 -0
  449. /package/{times → dist/times}/index.d.ts.map +0 -0
  450. /package/{times → dist/times}/operations.d.ts +0 -0
  451. /package/{times → dist/times}/operations.d.ts.map +0 -0
@@ -0,0 +1,32 @@
1
+ import type { Jsonable } from '../../core'
2
+ import type { SerializeContext } from '../types'
3
+ import { isBigInt, isJsonablePrimitive, isNumber, isSymbol } from '../../core'
4
+ import { serializeNumber } from './number'
5
+
6
+ export function serializePrimitive(value: unknown, ctx: SerializeContext): Jsonable | undefined {
7
+ if (value === null) {
8
+ return null
9
+ }
10
+
11
+ if (value === undefined) {
12
+ return ctx.replacer({ type: 'undefined', value: null })
13
+ }
14
+
15
+ if (isNumber(value)) {
16
+ return serializeNumber(value, ctx)
17
+ }
18
+
19
+ if (isJsonablePrimitive(value)) {
20
+ return value
21
+ }
22
+
23
+ if (isBigInt(value)) {
24
+ return ctx.replacer({ type: 'bigint', value: value.toString() })
25
+ }
26
+
27
+ if (isSymbol(value)) {
28
+ return ctx.replacer({ type: 'symbol', value: ctx.symbolRegistry(value) })
29
+ }
30
+
31
+ return undefined
32
+ }
@@ -0,0 +1,28 @@
1
+ export function createSymbolKeySerializer() {
2
+ const cache = new Map<symbol, string>()
3
+ const usedKeys = new Set<string>()
4
+
5
+ let counter = 0
6
+
7
+ return (symbol: symbol): string => {
8
+ const cached = cache.get(symbol)
9
+
10
+ if (cached !== undefined) {
11
+ return cached
12
+ }
13
+
14
+ const desc = symbol.description
15
+ const base = desc?.length ? desc : `@@${++counter}`
16
+
17
+ let key = `[Symbol(${base})]`
18
+
19
+ while (usedKeys.has(key)) {
20
+ key = `[Symbol(${base}@@${++counter})]`
21
+ }
22
+
23
+ usedKeys.add(key)
24
+ cache.set(symbol, key)
25
+
26
+ return key
27
+ }
28
+ }
@@ -0,0 +1,42 @@
1
+ import type { Jsonable } from '../core'
2
+ import type { OMIT_SENTINEL } from './constants'
3
+
4
+ export interface SerializedValue {
5
+ __serialized__: true
6
+ metadata?: Record<string, Jsonable>
7
+ type: string
8
+ value: Jsonable
9
+ }
10
+
11
+ export type SerializeReplacer = (value: Omit<SerializedValue, '__serialized__'>) => Jsonable
12
+
13
+ export type SerializeErrorStrategy = 'omit' | 'placeholder' | 'throw'
14
+
15
+ export interface SerializeErrorHandlers {
16
+ circularRef?: SerializeErrorStrategy
17
+ maxDepth?: SerializeErrorStrategy
18
+ propertyAccess?: SerializeErrorStrategy
19
+ }
20
+
21
+ export interface SerializeOptions {
22
+ maxDepth?: number
23
+ onError?: SerializeErrorHandlers | SerializeErrorStrategy
24
+ onUnserializable?: ((value: unknown) => Jsonable) | false
25
+ replacer?: SerializeReplacer
26
+ }
27
+
28
+ export interface SerializeContext {
29
+ depth: number
30
+ readonly maxDepth: number
31
+ readonly onCircularRef: SerializeErrorStrategy
32
+ readonly onMaxDepth: SerializeErrorStrategy
33
+ readonly onPropertyAccess: SerializeErrorStrategy
34
+ readonly onUnserializable: ((value: unknown) => Jsonable) | false
35
+ readonly replacer: SerializeReplacer
36
+ readonly symbolRegistry: (symbol: symbol) => string
37
+ readonly visited: Set<object>
38
+ }
39
+
40
+ export type SerializeValueFn = (value: unknown, ctx: SerializeContext) => Jsonable | typeof OMIT_SENTINEL
41
+
42
+ export type ErrorPropertyValue = Jsonable | typeof OMIT_SENTINEL | undefined
@@ -0,0 +1,15 @@
1
+ import type { Jsonable } from '../core'
2
+ import type { SerializeContext, SerializeErrorStrategy } from './types'
3
+ import { OMIT_SENTINEL } from './constants'
4
+
5
+ export function handleError(strategy: SerializeErrorStrategy, type: string, placeholder: string, ctx: SerializeContext): Jsonable | typeof OMIT_SENTINEL {
6
+ if (strategy === 'throw') {
7
+ throw new Error(placeholder)
8
+ }
9
+
10
+ if (strategy === 'omit') {
11
+ return OMIT_SENTINEL
12
+ }
13
+
14
+ return ctx.replacer({ type, value: placeholder })
15
+ }
@@ -0,0 +1 @@
1
+ export const WHITESPACE_CHARACTERS = new Set([' ', '\n', '\r', '\t', '\v', '\f'])
@@ -0,0 +1,9 @@
1
+ export function randomStr(length = 16, characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789') {
2
+ let result = ''
3
+
4
+ for (let i = 0; i < length; i++) {
5
+ result += characters.charAt(Math.floor(Math.random() * characters.length))
6
+ }
7
+
8
+ return result
9
+ }
@@ -0,0 +1,51 @@
1
+ import type { Nullish } from '../core'
2
+ import type { HexString, UrlLike } from './types'
3
+ import { wrap } from '../arrays'
4
+ import { transform, tryCatch } from '../functions'
5
+
6
+ export const isEmptyString = (value: string) => value.length === 0
7
+
8
+ export function isValidProtocol({ protocol }: URL, protocols?: Nullish<string[]>) {
9
+ if (!protocols?.length) {
10
+ return true
11
+ }
12
+
13
+ return protocols.some((x) => `${x.toLowerCase()}:` === protocol)
14
+ }
15
+
16
+ export function isValidUrl(url: UrlLike, protocols?: Nullish<string[]>) {
17
+ if (url instanceof URL) {
18
+ return isValidProtocol(url, protocols)
19
+ }
20
+
21
+ return tryCatch(() => isValidProtocol(new URL(url), protocols), false)
22
+ }
23
+
24
+ export const isWebSocketUrl = (url: UrlLike, wsProtocols = ['ws', 'wss']) => isValidUrl(url, wsProtocols)
25
+
26
+ export const isHttpUrl = (url: UrlLike, httpProtocols = ['http', 'https']) => isValidUrl(url, httpProtocols)
27
+
28
+ export const isStringEquals = (str: string, ...others: string[]) => others.length > 0 && others.every((other) => str === other)
29
+
30
+ export const isStringEqualsIgnoreCase = (str: string, ...others: string[]) => (
31
+ others.length > 0 && transform(str.toLowerCase(), (x) => others.every((other) => x === other.toLowerCase()))
32
+ )
33
+
34
+ export const isIncludesAll = (str: string, search: string[]) => search.every((s) => str.includes(s))
35
+
36
+ export const isIncludesAny = (str: string, search: string[]) => search.some((s) => str.includes(s))
37
+
38
+ export const isIncludes = (str: string, search: string[] | string, type: 'all' | 'any' = 'all') => (
39
+ type === 'all' ? isIncludesAll(str, wrap(search)) : isIncludesAny(str, wrap(search))
40
+ )
41
+
42
+ export function isHexString(value: string, length?: number) {
43
+ const len = length ? `{${length * 2}}` : '+'
44
+ const regex = new RegExp(`^(?:0x)?[0-9a-f]${len}$`, 'iu')
45
+
46
+ return regex.test(value)
47
+ }
48
+
49
+ export const isStrictHexString = (value: string, length?: number): value is HexString => (
50
+ value.startsWith('0x') && isHexString(value, length)
51
+ )
@@ -0,0 +1,6 @@
1
+ export * from './constants'
2
+ export * from './factories'
3
+ export * from './guards'
4
+ export * from './manipulations'
5
+
6
+ export type * from './types'
@@ -0,0 +1,99 @@
1
+ import type { Numberish } from '../numbers'
2
+ import { WHITESPACE_CHARACTERS } from './constants'
3
+
4
+ export const ensurePrefix = (str: string, prefix: string) => (str.startsWith(prefix) ? str : prefix + str)
5
+
6
+ export const ensureSuffix = (str: string, suffix: string) => (str.endsWith(suffix) ? str : str + suffix)
7
+
8
+ export const stripPrefix = (str: string, prefix: string) => (str.startsWith(prefix) ? str.slice(prefix.length) : str)
9
+
10
+ export const stripSuffix = (str: string, suffix: string) => (suffix.length > 0 && str.endsWith(suffix) ? str.slice(0, -suffix.length) : str)
11
+
12
+ export const capitalize = (str: string) => str.charAt(0).toUpperCase() + str.slice(1)
13
+
14
+ export const escapeRegExp = (input: string) => (
15
+ input.replaceAll(/[$()*+.?[\\\]^{|}]/gu, String.raw`\$&`).replaceAll('-', String.raw`\x2d`)
16
+ )
17
+
18
+ export function * chunkStr(str: string, size: number) {
19
+ if (size <= 0) {
20
+ throw new RangeError(`chunk size must be a positive number, got ${size}`)
21
+ }
22
+
23
+ const len = str.length
24
+
25
+ for (let i = 0; i < len; i += size) {
26
+ yield str.slice(i, i + size)
27
+ }
28
+ }
29
+
30
+ export const padStart = (str: string, targetLength: number, padString = ' ') => (
31
+ str.padStart(targetLength, padString)
32
+ )
33
+
34
+ export const padZeroStart = (num: Numberish | string, targetLength: number) => padStart(num.toString(), targetLength, '0')
35
+
36
+ export function truncate(str: string, maxLength: number, omission = '...') {
37
+ if (str.length <= maxLength) {
38
+ return str
39
+ }
40
+
41
+ if (omission.length >= maxLength) {
42
+ return omission.slice(0, maxLength)
43
+ }
44
+
45
+ return str.slice(0, maxLength - omission.length) + omission
46
+ }
47
+
48
+ export function truncateMiddle(str: string, maxLength: number, omission = '...') {
49
+ if (str.length <= maxLength) {
50
+ return str
51
+ }
52
+
53
+ if (omission.length >= maxLength) {
54
+ return omission.slice(0, maxLength)
55
+ }
56
+
57
+ const left = Math.floor((maxLength - omission.length) / 2)
58
+ const right = maxLength - omission.length - left
59
+
60
+ return str.slice(0, left) + omission + str.slice(-right)
61
+ }
62
+
63
+ export function ltrim(str: string, characters: Set<string> | string = WHITESPACE_CHARACTERS) {
64
+ if (typeof characters === 'string') {
65
+ characters = new Set(characters)
66
+ }
67
+
68
+ const end = str.length
69
+
70
+ let start = 0
71
+
72
+ while (start < end && characters.has(str[start]!)) {
73
+ start++
74
+ }
75
+
76
+ return start > 0 ? str.slice(start, end) : str
77
+ }
78
+
79
+ export function rtrim(str: string, characters: Set<string> | string = WHITESPACE_CHARACTERS) {
80
+ if (typeof characters === 'string') {
81
+ characters = new Set(characters)
82
+ }
83
+
84
+ let end = str.length
85
+
86
+ while (end > 0 && characters.has(str[end - 1]!)) {
87
+ end--
88
+ }
89
+
90
+ return end < str.length ? str.slice(0, end) : str
91
+ }
92
+
93
+ export const trim = (str: string, characters: Set<string> | string = WHITESPACE_CHARACTERS) => (
94
+ ltrim(rtrim(str, characters), characters)
95
+ )
96
+
97
+ export const trimRepeated = (input: string, target: string) => (
98
+ input.replaceAll(new RegExp(`(?:${escapeRegExp(target)}){2,}`, 'g'), target)
99
+ )
@@ -0,0 +1,3 @@
1
+ export type UrlLike = URL | string
2
+
3
+ export type HexString = `0x${string}`
@@ -0,0 +1,32 @@
1
+ import { isUndefined } from '../core'
2
+
3
+ export const isInMode = (key: string) => process.env.NODE_ENV === key
4
+
5
+ export const isInDevelopment = () => isInMode('development') || isInMode('dev')
6
+ export const isInDev = isInDevelopment
7
+
8
+ export const isInProduction = () => isInMode('production') || isInMode('prod')
9
+ export const isInProd = isInProduction
10
+
11
+ export const isInStaging = () => isInMode('staging') || isInMode('stage')
12
+ export const isInStage = isInStaging
13
+
14
+ export interface GetEnvOptions {
15
+ env?: NodeJS.ProcessEnv
16
+ includeNonePrefix?: boolean
17
+ prefix?: string
18
+ }
19
+
20
+ export function getEnv<T extends string>(key: T[], { env = process.env, includeNonePrefix = false, prefix }: GetEnvOptions = {}) {
21
+ const result: Record<string, string | undefined> = {}
22
+
23
+ for (const k of key) {
24
+ result[k] = env[prefix ? `${prefix}${k}` : k]
25
+
26
+ if (includeNonePrefix && isUndefined(result[k])) {
27
+ result[k] = env[k]
28
+ }
29
+ }
30
+
31
+ return result as Record<T, string | undefined>
32
+ }
@@ -0,0 +1,23 @@
1
+ import type { UrlLike } from '../strings'
2
+ import { combineSignals, createAbortController } from '../errors'
3
+ import { resolveOptions } from '../objects'
4
+ import { withRetry, type WithRetryOptions } from '../promises'
5
+
6
+ export interface FetchOptions extends Omit<RequestInit, 'signal'> {
7
+ retry?: Omit<WithRetryOptions<Response>, 'signal'> & { enabled?: boolean } | boolean
8
+ signal?: AbortSignal
9
+ timeout?: number
10
+ }
11
+
12
+ export async function fetch(request: RequestInfo | UrlLike, { retry = true, signal, timeout = 10_000, ...options }: FetchOptions = {}) {
13
+ const retryOptions = { enabled: true, ...(resolveOptions(retry, {}) || { enabled: false }) }
14
+
15
+ const execute = async (retrySignal?: AbortSignal) => {
16
+ const controller = createAbortController(timeout)
17
+ const fetchSignal = combineSignals(controller.signal, signal, retrySignal)
18
+
19
+ return globalThis.fetch(request, { ...options, signal: fetchSignal }).finally(() => controller.abort())
20
+ }
21
+
22
+ return retryOptions.enabled ? await withRetry(execute, { ...retryOptions, signal }) : await execute()
23
+ }
@@ -0,0 +1,46 @@
1
+ export type ExitHandler = (exitCode?: number) => Promise<void>
2
+
3
+ const exitTasks = new Map<ExitHandler, number>()
4
+
5
+ export function addExitHandler(handler: ExitHandler, maxWaitTime = 3000) {
6
+ exitTasks.set(handler, maxWaitTime)
7
+
8
+ return () => {
9
+ exitTasks.delete(handler)
10
+ }
11
+ }
12
+
13
+ let _isExiting = false
14
+ let _exitPromise: Promise<never> | undefined
15
+
16
+ export const isExiting = () => {
17
+ return _isExiting
18
+ }
19
+
20
+ export function gracefulExit(exitCode = 0, maxWaitTime = 3000): Promise<never> {
21
+ if (_exitPromise) {
22
+ return _exitPromise
23
+ }
24
+
25
+ _isExiting = true
26
+
27
+ if (exitTasks.size === 0) {
28
+ process.exit(exitCode)
29
+ }
30
+
31
+ const promises: Array<Promise<void>> = []
32
+
33
+ for (const [handler, wait] of exitTasks) {
34
+ promises.push(Promise.resolve().then(() => handler(exitCode)))
35
+ maxWaitTime = Math.max(maxWaitTime, wait)
36
+ }
37
+
38
+ const timer = setTimeout(() => process.exit(exitCode), maxWaitTime)
39
+
40
+ function finish(): never {
41
+ clearTimeout(timer)
42
+ process.exit(exitCode)
43
+ }
44
+
45
+ return _exitPromise = Promise.allSettled(promises).then(finish)
46
+ }
@@ -0,0 +1,6 @@
1
+ export * from './env'
2
+ export * from './fetch'
3
+ export * from './graceful-exit'
4
+ export * from './path'
5
+
6
+ export type * from './types'
@@ -0,0 +1,12 @@
1
+ import type { PathLike } from './types'
2
+ import { dirname, join } from 'node:path'
3
+ import { fileURLToPath } from 'node:url'
4
+ import { bufferToString, isBufferLike } from '../buffers'
5
+
6
+ export const pathToString = (path: PathLike) => (
7
+ isBufferLike(path) ? bufferToString(path) : path.toString()
8
+ )
9
+
10
+ export const pwd = (importMeta: ImportMeta, ...path: PathLike[]) => (
11
+ join(dirname(fileURLToPath(importMeta.url)), ...path.map(pathToString))
12
+ )
@@ -0,0 +1,3 @@
1
+ import type { BufferLike } from '../buffers'
2
+
3
+ export type PathLike = BufferLike | URL | string
@@ -0,0 +1,6 @@
1
+ export const MS_PER_SECOND = 1000
2
+ export const MS_PER_MINUTE = 60_000
3
+ export const MS_PER_HOUR = 3_600_000
4
+ export const MS_PER_DAY = 86_400_000
5
+ export const MS_PER_MONTH = MS_PER_DAY * 30
6
+ export const MS_PER_YEAR = MS_PER_DAY * 365
@@ -0,0 +1,85 @@
1
+ import { isString } from '../core'
2
+ import { BigIntMath, isSpecialNumberString, type Numberish } from '../numbers'
3
+ import { padZeroStart } from '../strings'
4
+
5
+ export const toUnixTimestamp = (date: Date) => Math.floor(date.getTime() / 1000)
6
+
7
+ export const fromUnixTimestamp = (timestamp: number) => new Date(timestamp * 1000)
8
+
9
+ const FORMAT_TOKEN_REGEX = /y{4}|S{3}|MM|dd|HH|mm|ss/gu
10
+ const pad2 = (n: number) => padZeroStart(n, 2)
11
+
12
+ export function formatDate(date: Date, format = 'HH:mm:ss.SSS dd/MM/yyyy') {
13
+ if (Number.isNaN(date.getTime())) {
14
+ throw new TypeError('Invalid Date')
15
+ }
16
+
17
+ const tokens: Record<string, () => string> = {
18
+ dd: () => pad2(date.getDate()),
19
+ HH: () => pad2(date.getHours()),
20
+ MM: () => pad2(date.getMonth() + 1),
21
+ mm: () => pad2(date.getMinutes()),
22
+ ss: () => pad2(date.getSeconds()),
23
+ SSS: () => padZeroStart(date.getMilliseconds(), 3),
24
+ yyyy: () => padZeroStart(date.getFullYear(), 4),
25
+ }
26
+
27
+ return format.replaceAll(FORMAT_TOKEN_REGEX, (match) => tokens[match]!())
28
+ }
29
+
30
+ const NANOSECOND_UNITS: Array<[label: string, value: bigint]> = [
31
+ ['h', 3_600_000_000_000n],
32
+ ['m', 60_000_000_000n],
33
+ ['s', 1_000_000_000n],
34
+ ['ms', 1_000_000n],
35
+ ['\u03BCs', 1000n],
36
+ ['ns', 1n],
37
+ ]
38
+
39
+ export function humanizeNanoseconds(ns: Numberish) {
40
+ if (isString(ns) && isSpecialNumberString(ns)) {
41
+ return ns
42
+ }
43
+
44
+ let remaining: bigint
45
+
46
+ try {
47
+ remaining = BigInt(ns)
48
+ } catch {
49
+ return ns.toString()
50
+ }
51
+
52
+ if (remaining === 0n) {
53
+ return '0ns'
54
+ }
55
+
56
+ const sign = remaining < 0n ? '-' : ''
57
+ const parts: string[] = []
58
+
59
+ remaining = BigIntMath.abs(remaining)
60
+
61
+ for (const [label, value] of NANOSECOND_UNITS) {
62
+ if (remaining >= value) {
63
+ parts.push(`${remaining / value}${label}`)
64
+ remaining %= value
65
+ }
66
+ }
67
+
68
+ return sign + parts.join(' ')
69
+ }
70
+
71
+ export function humanizeWithMultiplier(value: Numberish, multiplier: bigint) {
72
+ if (isString(value) && isSpecialNumberString(value)) {
73
+ return value
74
+ }
75
+
76
+ try {
77
+ return humanizeNanoseconds(BigInt(value) * multiplier)
78
+ } catch {
79
+ return value.toString()
80
+ }
81
+ }
82
+
83
+ export const humanizeMilliseconds = (ms: Numberish) => humanizeWithMultiplier(ms, 1_000_000n)
84
+
85
+ export const humanizeSeconds = (s: Numberish) => humanizeWithMultiplier(s, 1_000_000_000n)
@@ -0,0 +1,3 @@
1
+ import { toUnixTimestamp } from './conversions'
2
+
3
+ export const timestamp = () => toUnixTimestamp(new Date())
@@ -0,0 +1,3 @@
1
+ export const isValidDate = (value: unknown): value is Date => (
2
+ value instanceof Date && !Number.isNaN(value.getTime())
3
+ )
@@ -0,0 +1,5 @@
1
+ export * from './constants'
2
+ export * from './conversions'
3
+ export * from './factories'
4
+ export * from './guards'
5
+ export * from './operations'
@@ -0,0 +1,9 @@
1
+ import { tap } from '../functions'
2
+
3
+ export const startOfDay = (date: Date) => tap(new Date(date), (r) => {
4
+ r.setHours(0, 0, 0, 0)
5
+ })
6
+
7
+ export const endOfDay = (date: Date) => tap(new Date(date), (r) => {
8
+ r.setHours(23, 59, 59, 999)
9
+ })
package/CHANGELOG.md DELETED
@@ -1,39 +0,0 @@
1
- # Changelog
2
-
3
-
4
- ## v0.0.3
5
-
6
- [compare changes](https://github.com/kdtlabs/utils/compare/v0.0.2...v0.0.3)
7
-
8
- ## v0.0.2
9
-
10
- [compare changes](https://github.com/kdtlabs/utils/compare/v0.0.1...v0.0.2)
11
-
12
- ### 🩹 Fixes
13
-
14
- - **release:** Build after changelog gen to prevent package.json version error ([459f06c](https://github.com/kdtlabs/utils/commit/459f06c))
15
-
16
- ### ❤️ Contributors
17
-
18
- - Diep Dang <kdt310722@gmail.com>
19
-
20
- ## v0.0.1
21
-
22
-
23
- ### 🚀 Enhancements
24
-
25
- - Add SKILL.md for AI tool discovery of available utils ([e1dde1a](https://github.com/kdtlabs/utils/commit/e1dde1a))
26
-
27
- ### 🩹 Fixes
28
-
29
- - **release:** Fix release script and add CHANGELOG.md to eslint ignore ([a72208c](https://github.com/kdtlabs/utils/commit/a72208c))
30
-
31
- ### 🏡 Chore
32
-
33
- - Initial commit ([058e414](https://github.com/kdtlabs/utils/commit/058e414))
34
- - Add gitnexus to ignore files ([88c2d38](https://github.com/kdtlabs/utils/commit/88c2d38))
35
-
36
- ### ❤️ Contributors
37
-
38
- - Diep Dang <kdt310722@gmail.com>
39
-
package/arrays/index.js DELETED
@@ -1,4 +0,0 @@
1
- import{$b as w,Fb as a,Gb as b,Hb as c,Ib as d,Jb as e,Kb as f,Lb as g,Mb as h,Nb as i,Ob as j,Pb as k,Qb as l,Rb as m,Sb as n,Tb as o,Ub as p,Vb as q,Wb as r,Xb as s,Yb as t,Zb as u,_b as v,ac as x,bc as y}from"../chunk-c0p3wm8m.js";import"../chunk-qn6n0ff5.js";import"../chunk-c9mm50vv.js";export{g as wrap,v as uniqueBy,u as unique,h as toArray,y as symmetricDiff,s as sortBy,o as shuffle,l as sample,k as range,t as partition,a as nth,m as merge,c as last,q as keyBy,f as isNonEmptyArray,e as isEmptyArray,d as isArray,w as intersection,p as groupBy,n as flatten,b as first,x as diff,j as createArray,i as compact,r as chunk};
2
-
3
- //# debugId=7FF7885B231E2BF464756E2164756E21
4
- //# sourceMappingURL=index.js.map
@@ -1,9 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": [],
4
- "sourcesContent": [
5
- ],
6
- "mappings": "",
7
- "debugId": "7FF7885B231E2BF464756E2164756E21",
8
- "names": []
9
- }
package/buffers/index.js DELETED
@@ -1,4 +0,0 @@
1
- import{gb as a,hb as b,ib as c,jb as d,kb as e,lb as f,mb as g,nb as h,ob as i}from"../chunk-xp18wdk6.js";export{g as toUint8Array,c as isSharedArrayBuffer,e as isBufferLike,a as isBuffer,d as isArrayBufferView,b as isArrayBuffer,h as concatBuffers,f as bufferToString,i as bufferEquals};
2
-
3
- //# debugId=58E6E050C983599364756E2164756E21
4
- //# sourceMappingURL=index.js.map
@@ -1,9 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": [],
4
- "sourcesContent": [
5
- ],
6
- "mappings": "",
7
- "debugId": "58E6E050C983599364756E2164756E21",
8
- "names": []
9
- }
package/chunk-4w1emwv7.js DELETED
@@ -1,6 +0,0 @@
1
- import{pd as f,td as b}from"./chunk-m4svr349.js";import{Kd as c,Pd as u}from"./chunk-c9mm50vv.js";class p extends Error{constructor(r,{code:e,details:t,exitCode:n,name:o,retryable:i,timestamp:s,...a}={}){super(r,a);Object.setPrototypeOf(this,new.target.prototype),this.defineValue("name",o??this.constructor.name),this.defineValue("timestamp",s??new Date),this.defineValue("cause",a.cause),this.defineValue("code",e),this.defineValue("details",t),this.defineValue("exitCode",n),this.defineValue("retryable",i)}withValue(r,e){if(Object.hasOwn(this,r))throw TypeError(`Cannot redefine property '${r}' on ${this.name}`);return this.defineValue(r,e)}defineValue(r,e){return Object.defineProperty(this,r,{configurable:!1,enumerable:!0,value:e,writable:!1}),this}}var v=(r)=>r instanceof Error,P=(r)=>r instanceof p,R=(r)=>r instanceof DOMException&&r.name==="AbortError",x=(r)=>f(r)&&b(r,"name")&&u(r.name);var O=(r="This operation was aborted",e="AbortError")=>new DOMException(r,e),C=(r="The operation was aborted due to a timeout",e="TimeoutError")=>O(r,e);function B(r,e){let t=new AbortController;if(c(r)&&r>0&&r<=Number.MAX_SAFE_INTEGER){let n,o=()=>{clearTimeout(n),t.signal.removeEventListener("abort",o)};t.signal.addEventListener("abort",o),n=setTimeout(()=>t.abort(d(e??C())),r)}return t}function d(r,e){if(typeof r==="string")return e?new e(r):Error(r);if(typeof r==="function")return d(r(),e);return r}function k({cause:r,message:e,name:t,stack:n,...o},i){let a=new(i??Error)(e,{cause:r});Object.defineProperty(a,"name",{configurable:!0,enumerable:!1,value:t,writable:!0}),Object.defineProperty(a,"stack",{configurable:!0,enumerable:!1,value:n,writable:!0});for(let[l,m]of Object.entries(o))Object.defineProperty(a,l,Object.getOwnPropertyDescriptor(o,l)??{configurable:!0,enumerable:!0,value:m,writable:!0});return a}function y(r,{defaultMessage:e="Unknown error",errorConstructor:t}={}){let n=t??Error;if(r instanceof n)return r;if(u(r))return d(r,t);if(x(r))return k(r,t);return new n(e,{cause:r})}function K(...r){let e=r.filter(c);if(e.length===0)return new AbortController().signal;if(e.length===1)return e[0];return AbortSignal.any(e)}var N={code:(r)=>`[${r}]`,message:(r)=>r,name:(r)=>`${r}:`};function A(r,e,t,n){let o=t+" ".repeat(n.causeIndent),i=[];if(r instanceof AggregateError&&r.errors.length>0)for(let s of r.errors)i.push(g(s,e-1,o,n.causePrefix,n));if(f(r.cause)||u(r.cause))i.push(g(r.cause,e-1,o,n.causePrefix,n));return i}function h(r,e,t,n,o,i){if(!i.includeCause||n<=0||e!==t&&e.cause===t)return;let s=A(e,n,o,i);if(s.length>0)r.push(`
2
- ${s.join(`
3
- `)}`)}function M(r,e){let t=[];if(e.includeCode&&"code"in r&&c(r.code))t.push(e.formatters.code(String(r.code)));if(e.includeName)t.push(e.formatters.name(r.name));return t.push(e.formatters.message(r.message||e.defaultMessage)),t}function g(r,e,t,n,o){if(o.visited.has(r))return`${t}${n}${o.circularReferenceMessage}`;if(r instanceof Error)o.visited.add(r);if(r instanceof Error&&r.toString!==Error.prototype.toString){let a=[r.toString()];return h(a,r,r,e,t,o),t+n+a.join(" ")}let i=y(r,{...o.normalizeOptions,defaultMessage:o.defaultMessage});o.visited.add(i);let s=M(i,o);return h(s,i,r,e,t,o),t+n+s.join(" ")}function J(r,e={}){let{causeIndent:t=2,causePrefix:n="-> ",circularReferenceMessage:o="[Circular Reference]",defaultMessage:i="Unknown error",formatters:s={},includeCause:a=!0,includeCode:l=!0,includeName:m=!0,maxCauseDepth:E=Number.POSITIVE_INFINITY,...w}=e,S={causeIndent:t,causePrefix:n,circularReferenceMessage:o,defaultMessage:i,formatters:{...N,...s},includeCause:a,includeCode:l,includeName:m,maxCauseDepth:E,normalizeOptions:w,visited:new Set};return g(r,E,"","",S)}export{p as Zc,v as _c,P as $c,R as ad,x as bd,O as cd,C as dd,B as ed,d as fd,k as gd,y as hd,K as id,N as jd,A as kd,h as ld,M as md,g as nd,J as od};
4
-
5
- //# debugId=89966F1E1B5C279064756E2164756E21
6
- //# sourceMappingURL=chunk-4w1emwv7.js.map