@kdtlabs/utils 0.0.4 → 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 (447) 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/{common → dist/common}/types.d.ts +1 -1
  5. package/{common → dist/common}/types.d.ts.map +1 -1
  6. package/{functions → dist/functions}/executions.d.ts +1 -1
  7. package/{functions → dist/functions}/executions.d.ts.map +1 -1
  8. package/dist/index.js +7 -0
  9. package/dist/index.js.map +99 -0
  10. package/{objects → dist/objects}/transformations.d.ts +1 -1
  11. package/{objects → dist/objects}/transformations.d.ts.map +1 -1
  12. package/{objects → dist/objects}/types.d.ts +1 -1
  13. package/{objects → dist/objects}/types.d.ts.map +1 -1
  14. package/{promises → dist/promises}/deferred.d.ts +1 -1
  15. package/{promises → dist/promises}/deferred.d.ts.map +1 -1
  16. package/{promises → dist/promises}/timers.d.ts +1 -1
  17. package/{promises → dist/promises}/timers.d.ts.map +1 -1
  18. package/{serializer → dist/serializer}/context.d.ts +1 -1
  19. package/{serializer → dist/serializer}/context.d.ts.map +1 -1
  20. package/{serializer → dist/serializer}/serialize.d.ts +1 -1
  21. package/{serializer → dist/serializer}/serialize.d.ts.map +1 -1
  22. package/{serializer → dist/serializer}/serializers/array.d.ts +1 -1
  23. package/{serializer → dist/serializer}/serializers/array.d.ts.map +1 -1
  24. package/{serializer → dist/serializer}/serializers/binary.d.ts +1 -1
  25. package/dist/serializer/serializers/binary.d.ts.map +1 -0
  26. package/{serializer → dist/serializer}/serializers/blob.d.ts +1 -1
  27. package/dist/serializer/serializers/blob.d.ts.map +1 -0
  28. package/{serializer → dist/serializer}/serializers/collection.d.ts +1 -1
  29. package/{serializer → dist/serializer}/serializers/collection.d.ts.map +1 -1
  30. package/{serializer → dist/serializer}/serializers/compound.d.ts +1 -1
  31. package/{serializer → dist/serializer}/serializers/compound.d.ts.map +1 -1
  32. package/{serializer → dist/serializer}/serializers/error.d.ts +1 -1
  33. package/{serializer → dist/serializer}/serializers/error.d.ts.map +1 -1
  34. package/{serializer → dist/serializer}/serializers/function.d.ts +1 -1
  35. package/{serializer → dist/serializer}/serializers/function.d.ts.map +1 -1
  36. package/{serializer → dist/serializer}/serializers/leaf-object.d.ts +1 -1
  37. package/{serializer → dist/serializer}/serializers/leaf-object.d.ts.map +1 -1
  38. package/{serializer → dist/serializer}/serializers/number.d.ts +1 -1
  39. package/dist/serializer/serializers/number.d.ts.map +1 -0
  40. package/{serializer → dist/serializer}/serializers/object.d.ts +1 -1
  41. package/{serializer → dist/serializer}/serializers/object.d.ts.map +1 -1
  42. package/{serializer → dist/serializer}/serializers/opaque.d.ts +1 -1
  43. package/dist/serializer/serializers/opaque.d.ts.map +1 -0
  44. package/{serializer → dist/serializer}/serializers/primitive.d.ts +1 -1
  45. package/{serializer → dist/serializer}/serializers/primitive.d.ts.map +1 -1
  46. package/{serializer → dist/serializer}/types.d.ts +1 -1
  47. package/{serializer → dist/serializer}/types.d.ts.map +1 -1
  48. package/{serializer → dist/serializer}/utils.d.ts +1 -1
  49. package/{serializer → dist/serializer}/utils.d.ts.map +1 -1
  50. package/{system → dist/system}/fetch.d.ts +2 -2
  51. package/{system → dist/system}/fetch.d.ts.map +1 -1
  52. package/dist/system/types.d.ts +3 -0
  53. package/{system → dist/system}/types.d.ts.map +1 -1
  54. package/{times → dist/times}/conversions.d.ts +1 -1
  55. package/{times → dist/times}/conversions.d.ts.map +1 -1
  56. package/package.json +11 -73
  57. package/src/arrays/accessors.ts +25 -0
  58. package/src/arrays/conversions.ts +16 -0
  59. package/src/arrays/factories.ts +13 -0
  60. package/src/arrays/guards.ts +7 -0
  61. package/src/arrays/index.ts +8 -0
  62. package/src/arrays/operations.ts +103 -0
  63. package/src/arrays/set-operations.ts +11 -0
  64. package/src/arrays/types.ts +21 -0
  65. package/src/buffers/conversions.ts +26 -0
  66. package/src/buffers/guards.ts +13 -0
  67. package/src/buffers/index.ts +5 -0
  68. package/src/buffers/operations.ts +44 -0
  69. package/src/buffers/types.ts +1 -0
  70. package/src/collections/fifo-map.ts +33 -0
  71. package/src/collections/fifo-set.ts +29 -0
  72. package/src/collections/guards.ts +11 -0
  73. package/src/collections/index.ts +10 -0
  74. package/src/collections/linked-base.ts +117 -0
  75. package/src/collections/linked-map.ts +82 -0
  76. package/src/collections/linked-set.ts +69 -0
  77. package/src/collections/lru-map.ts +36 -0
  78. package/src/collections/lru-set.ts +25 -0
  79. package/src/collections/types.ts +12 -0
  80. package/src/common/assertions.ts +11 -0
  81. package/src/common/guards.ts +58 -0
  82. package/src/common/index.ts +5 -0
  83. package/src/common/transformations.ts +20 -0
  84. package/src/common/types.ts +3 -0
  85. package/src/core/constants.ts +1 -0
  86. package/src/core/conversions.ts +9 -0
  87. package/src/core/guards.ts +57 -0
  88. package/src/core/index.ts +5 -0
  89. package/src/core/types.ts +15 -0
  90. package/src/errors/base-error.ts +48 -0
  91. package/src/errors/factories.ts +74 -0
  92. package/src/errors/guards.ts +12 -0
  93. package/src/errors/index.ts +7 -0
  94. package/src/errors/operations.ts +15 -0
  95. package/src/errors/stringify.ts +131 -0
  96. package/src/errors/types.ts +11 -0
  97. package/src/events/emitter.ts +117 -0
  98. package/src/events/index.ts +2 -0
  99. package/src/events/types.ts +11 -0
  100. package/src/functions/compositions.ts +17 -0
  101. package/src/functions/debounce.ts +34 -0
  102. package/src/functions/executions.ts +12 -0
  103. package/src/functions/guards.ts +5 -0
  104. package/src/functions/index.ts +11 -0
  105. package/src/functions/memoize.ts +33 -0
  106. package/src/functions/once.ts +33 -0
  107. package/src/functions/pipe.ts +39 -0
  108. package/src/functions/throttle.ts +59 -0
  109. package/src/functions/timer-state.ts +33 -0
  110. package/src/functions/types.ts +8 -0
  111. package/src/index.ts +16 -0
  112. package/src/json-rpc/constants.ts +15 -0
  113. package/src/json-rpc/factories.ts +22 -0
  114. package/src/json-rpc/guards.ts +58 -0
  115. package/src/json-rpc/index.ts +5 -0
  116. package/src/json-rpc/types.ts +48 -0
  117. package/src/numbers/bigint-math.ts +163 -0
  118. package/src/numbers/constants.ts +14 -0
  119. package/src/numbers/conversions.ts +83 -0
  120. package/src/numbers/factories.ts +6 -0
  121. package/src/numbers/formats.ts +52 -0
  122. package/src/numbers/guards.ts +22 -0
  123. package/src/numbers/index.ts +10 -0
  124. package/src/numbers/maths.ts +28 -0
  125. package/src/numbers/ranges.ts +17 -0
  126. package/src/numbers/types.ts +7 -0
  127. package/src/objects/deep-merge.ts +76 -0
  128. package/src/objects/guards.ts +21 -0
  129. package/src/objects/index.ts +5 -0
  130. package/src/objects/transformations.ts +34 -0
  131. package/src/objects/types.ts +33 -0
  132. package/src/promises/abortable.ts +37 -0
  133. package/src/promises/compositions.ts +18 -0
  134. package/src/promises/deferred.ts +131 -0
  135. package/src/promises/guards.ts +8 -0
  136. package/src/promises/index.ts +10 -0
  137. package/src/promises/pipe.ts +39 -0
  138. package/src/promises/poll.ts +92 -0
  139. package/src/promises/retry.ts +138 -0
  140. package/src/promises/timers.ts +16 -0
  141. package/src/promises/types.ts +1 -0
  142. package/src/serializer/constants.ts +5 -0
  143. package/src/serializer/context.ts +24 -0
  144. package/src/serializer/index.ts +8 -0
  145. package/src/serializer/serialize.ts +51 -0
  146. package/src/serializer/serializers/array.ts +17 -0
  147. package/src/serializer/serializers/binary.ts +24 -0
  148. package/src/serializer/serializers/blob.ts +18 -0
  149. package/src/serializer/serializers/collection.ts +25 -0
  150. package/src/serializer/serializers/compound.ts +79 -0
  151. package/src/serializer/serializers/error.ts +75 -0
  152. package/src/serializer/serializers/function.ts +13 -0
  153. package/src/serializer/serializers/index.ts +12 -0
  154. package/src/serializer/serializers/leaf-object.ts +18 -0
  155. package/src/serializer/serializers/number.ts +14 -0
  156. package/src/serializer/serializers/object.ts +62 -0
  157. package/src/serializer/serializers/opaque.ts +36 -0
  158. package/src/serializer/serializers/primitive.ts +32 -0
  159. package/src/serializer/symbol-registry.ts +28 -0
  160. package/src/serializer/types.ts +42 -0
  161. package/src/serializer/utils.ts +15 -0
  162. package/src/strings/constants.ts +1 -0
  163. package/src/strings/factories.ts +9 -0
  164. package/src/strings/guards.ts +51 -0
  165. package/src/strings/index.ts +6 -0
  166. package/src/strings/manipulations.ts +99 -0
  167. package/src/strings/types.ts +3 -0
  168. package/src/system/env.ts +32 -0
  169. package/src/system/fetch.ts +23 -0
  170. package/src/system/graceful-exit.ts +46 -0
  171. package/src/system/index.ts +6 -0
  172. package/src/system/path.ts +12 -0
  173. package/src/system/types.ts +3 -0
  174. package/src/times/constants.ts +6 -0
  175. package/src/times/conversions.ts +85 -0
  176. package/src/times/factories.ts +3 -0
  177. package/src/times/guards.ts +3 -0
  178. package/src/times/index.ts +5 -0
  179. package/src/times/operations.ts +9 -0
  180. package/CHANGELOG.md +0 -57
  181. package/arrays/index.js +0 -4
  182. package/arrays/index.js.map +0 -9
  183. package/buffers/index.js +0 -4
  184. package/buffers/index.js.map +0 -9
  185. package/chunk-25ja9350.js +0 -4
  186. package/chunk-25ja9350.js.map +0 -13
  187. package/chunk-3w6nt7kb.js +0 -4
  188. package/chunk-3w6nt7kb.js.map +0 -12
  189. package/chunk-5txwcr6j.js +0 -4
  190. package/chunk-5txwcr6j.js.map +0 -17
  191. package/chunk-6dxad51h.js +0 -4
  192. package/chunk-6dxad51h.js.map +0 -12
  193. package/chunk-6kdnnxe0.js +0 -4
  194. package/chunk-6kdnnxe0.js.map +0 -17
  195. package/chunk-7cndek91.js +0 -4
  196. package/chunk-7cndek91.js.map +0 -15
  197. package/chunk-bee0nxse.js +0 -6
  198. package/chunk-bee0nxse.js.map +0 -14
  199. package/chunk-bjmntg2y.js +0 -4
  200. package/chunk-bjmntg2y.js.map +0 -18
  201. package/chunk-d0d0d285.js +0 -4
  202. package/chunk-d0d0d285.js.map +0 -26
  203. package/chunk-jny2gdyy.js +0 -4
  204. package/chunk-jny2gdyy.js.map +0 -12
  205. package/chunk-kbzgn0z4.js +0 -4
  206. package/chunk-kbzgn0z4.js.map +0 -10
  207. package/chunk-qmbgp0vr.js +0 -4
  208. package/chunk-qmbgp0vr.js.map +0 -12
  209. package/chunk-qn6n0ff5.js +0 -4
  210. package/chunk-qn6n0ff5.js.map +0 -17
  211. package/chunk-r3maskdb.js +0 -5
  212. package/chunk-r3maskdb.js.map +0 -13
  213. package/chunk-st3dxvqt.js +0 -4
  214. package/chunk-st3dxvqt.js.map +0 -14
  215. package/chunk-xp18wdk6.js +0 -4
  216. package/chunk-xp18wdk6.js.map +0 -12
  217. package/collections/index.js +0 -4
  218. package/collections/index.js.map +0 -9
  219. package/common/index.js +0 -4
  220. package/common/index.js.map +0 -9
  221. package/core/index.js +0 -4
  222. package/core/index.js.map +0 -9
  223. package/errors/index.js +0 -4
  224. package/errors/index.js.map +0 -9
  225. package/events/index.js +0 -4
  226. package/events/index.js.map +0 -9
  227. package/functions/index.js +0 -4
  228. package/functions/index.js.map +0 -9
  229. package/index.js +0 -4
  230. package/index.js.map +0 -9
  231. package/json-rpc/index.js +0 -4
  232. package/json-rpc/index.js.map +0 -9
  233. package/meta.json +0 -2998
  234. package/meta.md +0 -1816
  235. package/numbers/index.js +0 -4
  236. package/numbers/index.js.map +0 -9
  237. package/objects/index.js +0 -4
  238. package/objects/index.js.map +0 -9
  239. package/promises/index.js +0 -4
  240. package/promises/index.js.map +0 -9
  241. package/serializer/index.js +0 -4
  242. package/serializer/index.js.map +0 -9
  243. package/serializer/serializers/binary.d.ts.map +0 -1
  244. package/serializer/serializers/blob.d.ts.map +0 -1
  245. package/serializer/serializers/number.d.ts.map +0 -1
  246. package/serializer/serializers/opaque.d.ts.map +0 -1
  247. package/strings/index.js +0 -4
  248. package/strings/index.js.map +0 -9
  249. package/system/index.js +0 -4
  250. package/system/index.js.map +0 -9
  251. package/system/types.d.ts +0 -3
  252. package/times/index.js +0 -4
  253. package/times/index.js.map +0 -9
  254. /package/{arrays → dist/arrays}/accessors.d.ts +0 -0
  255. /package/{arrays → dist/arrays}/accessors.d.ts.map +0 -0
  256. /package/{arrays → dist/arrays}/conversions.d.ts +0 -0
  257. /package/{arrays → dist/arrays}/conversions.d.ts.map +0 -0
  258. /package/{arrays → dist/arrays}/factories.d.ts +0 -0
  259. /package/{arrays → dist/arrays}/factories.d.ts.map +0 -0
  260. /package/{arrays → dist/arrays}/guards.d.ts +0 -0
  261. /package/{arrays → dist/arrays}/guards.d.ts.map +0 -0
  262. /package/{arrays → dist/arrays}/index.d.ts +0 -0
  263. /package/{arrays → dist/arrays}/index.d.ts.map +0 -0
  264. /package/{arrays → dist/arrays}/operations.d.ts +0 -0
  265. /package/{arrays → dist/arrays}/operations.d.ts.map +0 -0
  266. /package/{arrays → dist/arrays}/set-operations.d.ts +0 -0
  267. /package/{arrays → dist/arrays}/set-operations.d.ts.map +0 -0
  268. /package/{arrays → dist/arrays}/types.d.ts +0 -0
  269. /package/{arrays → dist/arrays}/types.d.ts.map +0 -0
  270. /package/{buffers → dist/buffers}/conversions.d.ts +0 -0
  271. /package/{buffers → dist/buffers}/conversions.d.ts.map +0 -0
  272. /package/{buffers → dist/buffers}/guards.d.ts +0 -0
  273. /package/{buffers → dist/buffers}/guards.d.ts.map +0 -0
  274. /package/{buffers → dist/buffers}/index.d.ts +0 -0
  275. /package/{buffers → dist/buffers}/index.d.ts.map +0 -0
  276. /package/{buffers → dist/buffers}/operations.d.ts +0 -0
  277. /package/{buffers → dist/buffers}/operations.d.ts.map +0 -0
  278. /package/{buffers → dist/buffers}/types.d.ts +0 -0
  279. /package/{buffers → dist/buffers}/types.d.ts.map +0 -0
  280. /package/{collections → dist/collections}/fifo-map.d.ts +0 -0
  281. /package/{collections → dist/collections}/fifo-map.d.ts.map +0 -0
  282. /package/{collections → dist/collections}/fifo-set.d.ts +0 -0
  283. /package/{collections → dist/collections}/fifo-set.d.ts.map +0 -0
  284. /package/{collections → dist/collections}/guards.d.ts +0 -0
  285. /package/{collections → dist/collections}/guards.d.ts.map +0 -0
  286. /package/{collections → dist/collections}/index.d.ts +0 -0
  287. /package/{collections → dist/collections}/index.d.ts.map +0 -0
  288. /package/{collections → dist/collections}/linked-base.d.ts +0 -0
  289. /package/{collections → dist/collections}/linked-base.d.ts.map +0 -0
  290. /package/{collections → dist/collections}/linked-map.d.ts +0 -0
  291. /package/{collections → dist/collections}/linked-map.d.ts.map +0 -0
  292. /package/{collections → dist/collections}/linked-set.d.ts +0 -0
  293. /package/{collections → dist/collections}/linked-set.d.ts.map +0 -0
  294. /package/{collections → dist/collections}/lru-map.d.ts +0 -0
  295. /package/{collections → dist/collections}/lru-map.d.ts.map +0 -0
  296. /package/{collections → dist/collections}/lru-set.d.ts +0 -0
  297. /package/{collections → dist/collections}/lru-set.d.ts.map +0 -0
  298. /package/{collections → dist/collections}/types.d.ts +0 -0
  299. /package/{collections → dist/collections}/types.d.ts.map +0 -0
  300. /package/{common → dist/common}/guards.d.ts +0 -0
  301. /package/{common → dist/common}/guards.d.ts.map +0 -0
  302. /package/{common → dist/common}/index.d.ts +0 -0
  303. /package/{common → dist/common}/index.d.ts.map +0 -0
  304. /package/{common → dist/common}/transformations.d.ts +0 -0
  305. /package/{common → dist/common}/transformations.d.ts.map +0 -0
  306. /package/{core → dist/core}/constants.d.ts +0 -0
  307. /package/{core → dist/core}/constants.d.ts.map +0 -0
  308. /package/{core → dist/core}/conversions.d.ts +0 -0
  309. /package/{core → dist/core}/conversions.d.ts.map +0 -0
  310. /package/{core → dist/core}/guards.d.ts +0 -0
  311. /package/{core → dist/core}/guards.d.ts.map +0 -0
  312. /package/{core → dist/core}/index.d.ts +0 -0
  313. /package/{core → dist/core}/index.d.ts.map +0 -0
  314. /package/{core → dist/core}/types.d.ts +0 -0
  315. /package/{core → dist/core}/types.d.ts.map +0 -0
  316. /package/{errors → dist/errors}/base-error.d.ts +0 -0
  317. /package/{errors → dist/errors}/base-error.d.ts.map +0 -0
  318. /package/{errors → dist/errors}/factories.d.ts +0 -0
  319. /package/{errors → dist/errors}/factories.d.ts.map +0 -0
  320. /package/{errors → dist/errors}/guards.d.ts +0 -0
  321. /package/{errors → dist/errors}/guards.d.ts.map +0 -0
  322. /package/{errors → dist/errors}/index.d.ts +0 -0
  323. /package/{errors → dist/errors}/index.d.ts.map +0 -0
  324. /package/{errors → dist/errors}/operations.d.ts +0 -0
  325. /package/{errors → dist/errors}/operations.d.ts.map +0 -0
  326. /package/{errors → dist/errors}/stringify.d.ts +0 -0
  327. /package/{errors → dist/errors}/stringify.d.ts.map +0 -0
  328. /package/{errors → dist/errors}/types.d.ts +0 -0
  329. /package/{errors → dist/errors}/types.d.ts.map +0 -0
  330. /package/{events → dist/events}/emitter.d.ts +0 -0
  331. /package/{events → dist/events}/emitter.d.ts.map +0 -0
  332. /package/{events → dist/events}/index.d.ts +0 -0
  333. /package/{events → dist/events}/index.d.ts.map +0 -0
  334. /package/{events → dist/events}/types.d.ts +0 -0
  335. /package/{events → dist/events}/types.d.ts.map +0 -0
  336. /package/{functions → dist/functions}/compositions.d.ts +0 -0
  337. /package/{functions → dist/functions}/compositions.d.ts.map +0 -0
  338. /package/{functions → dist/functions}/debounce.d.ts +0 -0
  339. /package/{functions → dist/functions}/debounce.d.ts.map +0 -0
  340. /package/{functions → dist/functions}/guards.d.ts +0 -0
  341. /package/{functions → dist/functions}/guards.d.ts.map +0 -0
  342. /package/{functions → dist/functions}/index.d.ts +0 -0
  343. /package/{functions → dist/functions}/index.d.ts.map +0 -0
  344. /package/{functions → dist/functions}/memoize.d.ts +0 -0
  345. /package/{functions → dist/functions}/memoize.d.ts.map +0 -0
  346. /package/{functions → dist/functions}/once.d.ts +0 -0
  347. /package/{functions → dist/functions}/once.d.ts.map +0 -0
  348. /package/{functions → dist/functions}/pipe.d.ts +0 -0
  349. /package/{functions → dist/functions}/pipe.d.ts.map +0 -0
  350. /package/{functions → dist/functions}/throttle.d.ts +0 -0
  351. /package/{functions → dist/functions}/throttle.d.ts.map +0 -0
  352. /package/{functions → dist/functions}/timer-state.d.ts +0 -0
  353. /package/{functions → dist/functions}/timer-state.d.ts.map +0 -0
  354. /package/{functions → dist/functions}/types.d.ts +0 -0
  355. /package/{functions → dist/functions}/types.d.ts.map +0 -0
  356. /package/{index.d.ts → dist/index.d.ts} +0 -0
  357. /package/{index.d.ts.map → dist/index.d.ts.map} +0 -0
  358. /package/{json-rpc → dist/json-rpc}/constants.d.ts +0 -0
  359. /package/{json-rpc → dist/json-rpc}/constants.d.ts.map +0 -0
  360. /package/{json-rpc → dist/json-rpc}/factories.d.ts +0 -0
  361. /package/{json-rpc → dist/json-rpc}/factories.d.ts.map +0 -0
  362. /package/{json-rpc → dist/json-rpc}/guards.d.ts +0 -0
  363. /package/{json-rpc → dist/json-rpc}/guards.d.ts.map +0 -0
  364. /package/{json-rpc → dist/json-rpc}/index.d.ts +0 -0
  365. /package/{json-rpc → dist/json-rpc}/index.d.ts.map +0 -0
  366. /package/{json-rpc → dist/json-rpc}/types.d.ts +0 -0
  367. /package/{json-rpc → dist/json-rpc}/types.d.ts.map +0 -0
  368. /package/{numbers → dist/numbers}/bigint-math.d.ts +0 -0
  369. /package/{numbers → dist/numbers}/bigint-math.d.ts.map +0 -0
  370. /package/{numbers → dist/numbers}/constants.d.ts +0 -0
  371. /package/{numbers → dist/numbers}/constants.d.ts.map +0 -0
  372. /package/{numbers → dist/numbers}/conversions.d.ts +0 -0
  373. /package/{numbers → dist/numbers}/conversions.d.ts.map +0 -0
  374. /package/{numbers → dist/numbers}/factories.d.ts +0 -0
  375. /package/{numbers → dist/numbers}/factories.d.ts.map +0 -0
  376. /package/{numbers → dist/numbers}/formats.d.ts +0 -0
  377. /package/{numbers → dist/numbers}/formats.d.ts.map +0 -0
  378. /package/{numbers → dist/numbers}/guards.d.ts +0 -0
  379. /package/{numbers → dist/numbers}/guards.d.ts.map +0 -0
  380. /package/{numbers → dist/numbers}/index.d.ts +0 -0
  381. /package/{numbers → dist/numbers}/index.d.ts.map +0 -0
  382. /package/{numbers → dist/numbers}/maths.d.ts +0 -0
  383. /package/{numbers → dist/numbers}/maths.d.ts.map +0 -0
  384. /package/{numbers → dist/numbers}/ranges.d.ts +0 -0
  385. /package/{numbers → dist/numbers}/ranges.d.ts.map +0 -0
  386. /package/{numbers → dist/numbers}/types.d.ts +0 -0
  387. /package/{numbers → dist/numbers}/types.d.ts.map +0 -0
  388. /package/{objects → dist/objects}/deep-merge.d.ts +0 -0
  389. /package/{objects → dist/objects}/deep-merge.d.ts.map +0 -0
  390. /package/{objects → dist/objects}/guards.d.ts +0 -0
  391. /package/{objects → dist/objects}/guards.d.ts.map +0 -0
  392. /package/{objects → dist/objects}/index.d.ts +0 -0
  393. /package/{objects → dist/objects}/index.d.ts.map +0 -0
  394. /package/{promises → dist/promises}/abortable.d.ts +0 -0
  395. /package/{promises → dist/promises}/abortable.d.ts.map +0 -0
  396. /package/{promises → dist/promises}/compositions.d.ts +0 -0
  397. /package/{promises → dist/promises}/compositions.d.ts.map +0 -0
  398. /package/{promises → dist/promises}/guards.d.ts +0 -0
  399. /package/{promises → dist/promises}/guards.d.ts.map +0 -0
  400. /package/{promises → dist/promises}/index.d.ts +0 -0
  401. /package/{promises → dist/promises}/index.d.ts.map +0 -0
  402. /package/{promises → dist/promises}/pipe.d.ts +0 -0
  403. /package/{promises → dist/promises}/pipe.d.ts.map +0 -0
  404. /package/{promises → dist/promises}/poll.d.ts +0 -0
  405. /package/{promises → dist/promises}/poll.d.ts.map +0 -0
  406. /package/{promises → dist/promises}/retry.d.ts +0 -0
  407. /package/{promises → dist/promises}/retry.d.ts.map +0 -0
  408. /package/{promises → dist/promises}/types.d.ts +0 -0
  409. /package/{promises → dist/promises}/types.d.ts.map +0 -0
  410. /package/{serializer → dist/serializer}/constants.d.ts +0 -0
  411. /package/{serializer → dist/serializer}/constants.d.ts.map +0 -0
  412. /package/{serializer → dist/serializer}/index.d.ts +0 -0
  413. /package/{serializer → dist/serializer}/index.d.ts.map +0 -0
  414. /package/{serializer → dist/serializer}/serializers/index.d.ts +0 -0
  415. /package/{serializer → dist/serializer}/serializers/index.d.ts.map +0 -0
  416. /package/{serializer → dist/serializer}/symbol-registry.d.ts +0 -0
  417. /package/{serializer → dist/serializer}/symbol-registry.d.ts.map +0 -0
  418. /package/{strings → dist/strings}/constants.d.ts +0 -0
  419. /package/{strings → dist/strings}/constants.d.ts.map +0 -0
  420. /package/{strings → dist/strings}/factories.d.ts +0 -0
  421. /package/{strings → dist/strings}/factories.d.ts.map +0 -0
  422. /package/{strings → dist/strings}/guards.d.ts +0 -0
  423. /package/{strings → dist/strings}/guards.d.ts.map +0 -0
  424. /package/{strings → dist/strings}/index.d.ts +0 -0
  425. /package/{strings → dist/strings}/index.d.ts.map +0 -0
  426. /package/{strings → dist/strings}/manipulations.d.ts +0 -0
  427. /package/{strings → dist/strings}/manipulations.d.ts.map +0 -0
  428. /package/{strings → dist/strings}/types.d.ts +0 -0
  429. /package/{strings → dist/strings}/types.d.ts.map +0 -0
  430. /package/{system → dist/system}/env.d.ts +0 -0
  431. /package/{system → dist/system}/env.d.ts.map +0 -0
  432. /package/{system → dist/system}/graceful-exit.d.ts +0 -0
  433. /package/{system → dist/system}/graceful-exit.d.ts.map +0 -0
  434. /package/{system → dist/system}/index.d.ts +0 -0
  435. /package/{system → dist/system}/index.d.ts.map +0 -0
  436. /package/{system → dist/system}/path.d.ts +0 -0
  437. /package/{system → dist/system}/path.d.ts.map +0 -0
  438. /package/{times → dist/times}/constants.d.ts +0 -0
  439. /package/{times → dist/times}/constants.d.ts.map +0 -0
  440. /package/{times → dist/times}/factories.d.ts +0 -0
  441. /package/{times → dist/times}/factories.d.ts.map +0 -0
  442. /package/{times → dist/times}/guards.d.ts +0 -0
  443. /package/{times → dist/times}/guards.d.ts.map +0 -0
  444. /package/{times → dist/times}/index.d.ts +0 -0
  445. /package/{times → dist/times}/index.d.ts.map +0 -0
  446. /package/{times → dist/times}/operations.d.ts +0 -0
  447. /package/{times → dist/times}/operations.d.ts.map +0 -0
@@ -0,0 +1,13 @@
1
+ import type { BufferLike } from './types'
2
+
3
+ export const isBuffer = (value: unknown): value is Buffer => Buffer.isBuffer(value)
4
+
5
+ export const isArrayBuffer = (value: unknown): value is ArrayBuffer => value instanceof ArrayBuffer
6
+
7
+ export const isSharedArrayBuffer = (value: unknown): value is SharedArrayBuffer => value instanceof SharedArrayBuffer
8
+
9
+ export const isArrayBufferView = (value: unknown): value is ArrayBufferView => ArrayBuffer.isView(value)
10
+
11
+ export const isBufferLike = (value: unknown): value is BufferLike => (
12
+ isBuffer(value) || isArrayBuffer(value) || isSharedArrayBuffer(value) || isArrayBufferView(value)
13
+ )
@@ -0,0 +1,5 @@
1
+ export * from './conversions'
2
+ export * from './guards'
3
+ export * from './operations'
4
+
5
+ export type * from './types'
@@ -0,0 +1,44 @@
1
+ import type { BufferLike } from './types'
2
+ import { toUint8Array } from './conversions'
3
+
4
+ export function concatBuffers(buffers: BufferLike[]) {
5
+ if (buffers.length === 0) {
6
+ return new Uint8Array(0)
7
+ }
8
+
9
+ const normalized = buffers.map(toUint8Array)
10
+
11
+ let totalLength = 0
12
+ let offset = 0
13
+
14
+ for (const buf of normalized) {
15
+ totalLength += buf.byteLength
16
+ }
17
+
18
+ const result = new Uint8Array(totalLength)
19
+
20
+ for (const buf of normalized) {
21
+ result.set(buf, offset)
22
+ offset += buf.byteLength
23
+ }
24
+
25
+ return result
26
+ }
27
+
28
+ export function bufferEquals(a: BufferLike, b: BufferLike) {
29
+ if (a === b) {
30
+ return true
31
+ }
32
+
33
+ const u8a = toUint8Array(a)
34
+ const u8b = toUint8Array(b)
35
+
36
+ if (u8a.byteLength !== u8b.byteLength) {
37
+ return false
38
+ }
39
+
40
+ const bufA = Buffer.from(u8a.buffer, u8a.byteOffset, u8a.byteLength)
41
+ const bufB = Buffer.from(u8b.buffer, u8b.byteOffset, u8b.byteLength)
42
+
43
+ return bufA.equals(bufB)
44
+ }
@@ -0,0 +1 @@
1
+ export type BufferLike = ArrayBuffer | ArrayBufferView | Buffer | SharedArrayBuffer
@@ -0,0 +1,33 @@
1
+ import { LinkedMap } from './linked-map'
2
+
3
+ export class FifoMap<K, V> extends LinkedMap<K, V> {
4
+ public override peekNewest(): [K, V] | undefined {
5
+ return this.tail ? [this.tail.key, this.tail.value] : undefined
6
+ }
7
+
8
+ public override peekOldest(): [K, V] | undefined {
9
+ return this.head ? [this.head.key, this.head.value] : undefined
10
+ }
11
+
12
+ public set(key: K, value: V): this {
13
+ const existingNode = this.nodeMap.get(key)
14
+
15
+ if (existingNode) {
16
+ existingNode.value = value
17
+
18
+ return this
19
+ }
20
+
21
+ const newNode = this.createNode(key, value)
22
+
23
+ this.nodeMap.set(key, newNode)
24
+ this.addToTail(newNode)
25
+ this.currentSize++
26
+
27
+ if (this.maxSize && this.currentSize > this.maxSize) {
28
+ this.removeHead()
29
+ }
30
+
31
+ return this
32
+ }
33
+ }
@@ -0,0 +1,29 @@
1
+ import { LinkedSet } from './linked-set'
2
+
3
+ export class FifoSet<T> extends LinkedSet<T> {
4
+ public add(value: T): this {
5
+ if (this.nodeMap.has(value)) {
6
+ return this
7
+ }
8
+
9
+ const newNode = this.createNode(value)
10
+
11
+ this.nodeMap.set(value, newNode)
12
+ this.addToTail(newNode)
13
+ this.currentSize++
14
+
15
+ if (this.maxSize && this.currentSize > this.maxSize) {
16
+ this.removeHead()
17
+ }
18
+
19
+ return this
20
+ }
21
+
22
+ public override peekOldest(): T | undefined {
23
+ return this.head?.value
24
+ }
25
+
26
+ public override peekNewest(): T | undefined {
27
+ return this.tail?.value
28
+ }
29
+ }
@@ -0,0 +1,11 @@
1
+ import type { CollectionLike, MapLike, SetLike } from './types'
2
+
3
+ export const isIterable = <T>(value: unknown): value is Iterable<T> => value != null && typeof value === 'object' && Symbol.iterator in value && typeof value[Symbol.iterator] === 'function'
4
+
5
+ export const isCollectionLike = <T>(value: unknown): value is CollectionLike<T> => isIterable(value) && 'size' in value && typeof value.size === 'number'
6
+
7
+ export const isEmptyCollection = (value: CollectionLike) => value.size === 0
8
+
9
+ export const isSetLike = <T>(value: unknown): value is SetLike<T> => isCollectionLike(value) && 'has' in value && typeof value.has === 'function'
10
+
11
+ export const isMapLike = <K, V>(value: unknown): value is MapLike<K, V> => isCollectionLike(value) && 'get' in value && typeof value.get === 'function' && 'entries' in value && typeof value.entries === 'function'
@@ -0,0 +1,10 @@
1
+ export * from './fifo-map'
2
+ export * from './fifo-set'
3
+ export * from './guards'
4
+ export * from './linked-base'
5
+ export * from './linked-map'
6
+ export * from './linked-set'
7
+ export * from './lru-map'
8
+ export * from './lru-set'
9
+
10
+ export type * from './types'
@@ -0,0 +1,117 @@
1
+ export interface LinkedBaseNode {
2
+ next: LinkedBaseNode | null
3
+ prev: LinkedBaseNode | null
4
+ }
5
+
6
+ export abstract class LinkedBase<NodeKey, N extends LinkedBaseNode> {
7
+ protected readonly nodeMap = new Map<NodeKey, N>()
8
+
9
+ protected currentSize = 0
10
+ protected head: N | null = null
11
+ protected tail: N | null = null
12
+
13
+ public constructor(public readonly maxSize?: number) {
14
+ if (maxSize != null && (maxSize < 1 || !Number.isInteger(maxSize))) {
15
+ throw new RangeError('maxSize must be a positive integer')
16
+ }
17
+ }
18
+
19
+ public get size() {
20
+ return this.currentSize
21
+ }
22
+
23
+ public get [Symbol.toStringTag]() {
24
+ return this.constructor.name
25
+ }
26
+
27
+ public clear() {
28
+ this.nodeMap.clear()
29
+ this.head = null
30
+ this.tail = null
31
+ this.currentSize = 0
32
+ }
33
+
34
+ protected abstract getNodeKey(node: N): NodeKey
35
+
36
+ protected addToHead(node: N) {
37
+ node.prev = null
38
+ node.next = this.head
39
+
40
+ if (this.head) {
41
+ this.head.prev = node
42
+ } else {
43
+ this.tail = node
44
+ }
45
+
46
+ this.head = node
47
+ }
48
+
49
+ protected addToTail(node: N) {
50
+ node.next = null
51
+ node.prev = this.tail
52
+
53
+ if (this.tail) {
54
+ this.tail.next = node
55
+ } else {
56
+ this.head = node
57
+ }
58
+
59
+ this.tail = node
60
+ }
61
+
62
+ protected deleteByKey(key: NodeKey) {
63
+ const node = this.nodeMap.get(key)
64
+
65
+ if (!node) {
66
+ return false
67
+ }
68
+
69
+ this.nodeMap.delete(key)
70
+ this.removeNode(node)
71
+ this.currentSize--
72
+
73
+ return true
74
+ }
75
+
76
+ protected moveToHead(node: N) {
77
+ this.removeNode(node)
78
+ this.addToHead(node)
79
+ }
80
+
81
+ protected removeHead() {
82
+ if (!this.head) {
83
+ return
84
+ }
85
+
86
+ this.nodeMap.delete(this.getNodeKey(this.head))
87
+ this.removeNode(this.head)
88
+ this.currentSize--
89
+ }
90
+
91
+ protected removeNode(node: N) {
92
+ if (node.prev) {
93
+ node.prev.next = node.next
94
+ } else {
95
+ this.head = node.next as N | null
96
+ }
97
+
98
+ if (node.next) {
99
+ node.next.prev = node.prev
100
+ } else {
101
+ this.tail = node.prev as N | null
102
+ }
103
+
104
+ node.prev = null
105
+ node.next = null
106
+ }
107
+
108
+ protected removeTail() {
109
+ if (!this.tail) {
110
+ return
111
+ }
112
+
113
+ this.nodeMap.delete(this.getNodeKey(this.tail))
114
+ this.removeNode(this.tail)
115
+ this.currentSize--
116
+ }
117
+ }
@@ -0,0 +1,82 @@
1
+ import type { MapLike } from './types'
2
+ import { LinkedBase, type LinkedBaseNode } from './linked-base'
3
+
4
+ export interface LinkedMapNode<K, V> extends LinkedBaseNode {
5
+ key: K
6
+ next: LinkedMapNode<K, V> | null
7
+ prev: LinkedMapNode<K, V> | null
8
+ value: V
9
+ }
10
+
11
+ export abstract class LinkedMap<K, V> extends LinkedBase<K, LinkedMapNode<K, V>> implements MapLike<K, V> {
12
+ public delete(key: K) {
13
+ return this.deleteByKey(key)
14
+ }
15
+
16
+ public * entries(): IterableIterator<[K, V]> {
17
+ let current = this.head
18
+
19
+ while (current) {
20
+ yield [current.key, current.value]
21
+ current = current.next
22
+ }
23
+ }
24
+
25
+ public forEach(callback: (value: V, key: K, map: this) => void) {
26
+ for (const [key, value] of this.entries()) {
27
+ callback(value, key, this)
28
+ }
29
+ }
30
+
31
+ public get(key: K) {
32
+ return this.nodeMap.get(key)?.value
33
+ }
34
+
35
+ public has(key: K) {
36
+ return this.nodeMap.has(key)
37
+ }
38
+
39
+ public * keys(): IterableIterator<K> {
40
+ let current = this.head
41
+
42
+ while (current) {
43
+ yield current.key
44
+ current = current.next
45
+ }
46
+ }
47
+
48
+ public peekNewest(): [K, V] | undefined {
49
+ return this.head ? [this.head.key, this.head.value] : undefined
50
+ }
51
+
52
+ public peekOldest(): [K, V] | undefined {
53
+ return this.tail ? [this.tail.key, this.tail.value] : undefined
54
+ }
55
+
56
+ public abstract set(key: K, value: V): this
57
+
58
+ public [Symbol.iterator](): IterableIterator<[K, V]> {
59
+ return this.entries()
60
+ }
61
+
62
+ public toJSON(): Array<[K, V]> {
63
+ return [...this.entries()]
64
+ }
65
+
66
+ public * values(): IterableIterator<V> {
67
+ let current = this.head
68
+
69
+ while (current) {
70
+ yield current.value
71
+ current = current.next
72
+ }
73
+ }
74
+
75
+ protected createNode(key: K, value: V): LinkedMapNode<K, V> {
76
+ return { key, next: null, prev: null, value }
77
+ }
78
+
79
+ protected getNodeKey(node: LinkedMapNode<K, V>) {
80
+ return node.key
81
+ }
82
+ }
@@ -0,0 +1,69 @@
1
+ import type { SetLike } from './types'
2
+ import { LinkedBase, type LinkedBaseNode } from './linked-base'
3
+
4
+ export interface LinkedSetNode<T> extends LinkedBaseNode {
5
+ next: LinkedSetNode<T> | null
6
+ prev: LinkedSetNode<T> | null
7
+ value: T
8
+ }
9
+
10
+ export abstract class LinkedSet<T> extends LinkedBase<T, LinkedSetNode<T>> implements SetLike<T> {
11
+ public abstract add(value: T): this
12
+
13
+ public delete(value: T) {
14
+ return this.deleteByKey(value)
15
+ }
16
+
17
+ public * entries(): IterableIterator<[T, T]> {
18
+ for (const value of this.values()) {
19
+ yield [value, value]
20
+ }
21
+ }
22
+
23
+ public forEach(callback: (value: T, value2: T, set: this) => void) {
24
+ for (const value of this.values()) {
25
+ callback(value, value, this)
26
+ }
27
+ }
28
+
29
+ public has(value: T) {
30
+ return this.nodeMap.has(value)
31
+ }
32
+
33
+ public keys() {
34
+ return this.values()
35
+ }
36
+
37
+ public peekNewest(): T | undefined {
38
+ return this.head?.value
39
+ }
40
+
41
+ public peekOldest(): T | undefined {
42
+ return this.tail?.value
43
+ }
44
+
45
+ public [Symbol.iterator]() {
46
+ return this.values()
47
+ }
48
+
49
+ public toJSON(): T[] {
50
+ return [...this.values()]
51
+ }
52
+
53
+ public * values(): IterableIterator<T> {
54
+ let current = this.head
55
+
56
+ while (current) {
57
+ yield current.value
58
+ current = current.next
59
+ }
60
+ }
61
+
62
+ protected createNode(value: T): LinkedSetNode<T> {
63
+ return { next: null, prev: null, value }
64
+ }
65
+
66
+ protected getNodeKey(node: LinkedSetNode<T>) {
67
+ return node.value
68
+ }
69
+ }
@@ -0,0 +1,36 @@
1
+ import { LinkedMap } from './linked-map'
2
+
3
+ export class LruMap<K, V> extends LinkedMap<K, V> {
4
+ public override get(key: K) {
5
+ const node = this.nodeMap.get(key)
6
+
7
+ if (node) {
8
+ this.moveToHead(node)
9
+ }
10
+
11
+ return node?.value
12
+ }
13
+
14
+ public set(key: K, value: V): this {
15
+ const existingNode = this.nodeMap.get(key)
16
+
17
+ if (existingNode) {
18
+ existingNode.value = value
19
+ this.moveToHead(existingNode)
20
+
21
+ return this
22
+ }
23
+
24
+ const newNode = this.createNode(key, value)
25
+
26
+ this.nodeMap.set(key, newNode)
27
+ this.addToHead(newNode)
28
+ this.currentSize++
29
+
30
+ if (this.maxSize && this.currentSize > this.maxSize) {
31
+ this.removeTail()
32
+ }
33
+
34
+ return this
35
+ }
36
+ }
@@ -0,0 +1,25 @@
1
+ import { LinkedSet } from './linked-set'
2
+
3
+ export class LruSet<T> extends LinkedSet<T> {
4
+ public add(value: T): this {
5
+ const existingNode = this.nodeMap.get(value)
6
+
7
+ if (existingNode) {
8
+ this.moveToHead(existingNode)
9
+
10
+ return this
11
+ }
12
+
13
+ const newNode = this.createNode(value)
14
+
15
+ this.nodeMap.set(value, newNode)
16
+ this.addToHead(newNode)
17
+ this.currentSize++
18
+
19
+ if (this.maxSize && this.currentSize > this.maxSize) {
20
+ this.removeTail()
21
+ }
22
+
23
+ return this
24
+ }
25
+ }
@@ -0,0 +1,12 @@
1
+ export type CollectionLike<T = unknown> = Iterable<T> & {
2
+ readonly size: number
3
+ }
4
+
5
+ export type SetLike<T = unknown> = CollectionLike<T> & {
6
+ has(value: T): boolean
7
+ }
8
+
9
+ export type MapLike<K = unknown, V = unknown> = CollectionLike<[K, V]> & {
10
+ entries(): Iterable<[K, V]>
11
+ get(key: K): V | undefined
12
+ }
@@ -0,0 +1,11 @@
1
+ import { ensureError, type Errorable, type ErrorCtor } from '../errors'
2
+
3
+ export function assert(condition: unknown, message: Errorable, ctor?: ErrorCtor): asserts condition {
4
+ if (!condition) {
5
+ throw ensureError(message, ctor)
6
+ }
7
+ }
8
+
9
+ export function assertParam(condition: unknown, message: Errorable, ctor?: ErrorCtor): asserts condition {
10
+ assert(condition, message, ctor ?? TypeError)
11
+ }
@@ -0,0 +1,58 @@
1
+ import { isArray, isEmptyArray } from '../arrays'
2
+ import { isCollectionLike, isEmptyCollection } from '../collections'
3
+ import { isNullish, isPrimitive, isString } from '../core'
4
+ import { isEmptyObject, isPlainObject } from '../objects'
5
+
6
+ export function isEmpty(value: unknown) {
7
+ if (isNullish(value)) {
8
+ return true
9
+ }
10
+
11
+ if (isArray(value)) {
12
+ return isEmptyArray(value)
13
+ }
14
+
15
+ if (isPrimitive(value)) {
16
+ if (isString(value)) {
17
+ return value.length === 0
18
+ }
19
+
20
+ return false
21
+ }
22
+
23
+ if (isPlainObject(value)) {
24
+ return isEmptyObject(value)
25
+ }
26
+
27
+ if (isCollectionLike(value)) {
28
+ return isEmptyCollection(value)
29
+ }
30
+
31
+ return false
32
+ }
33
+
34
+ export function isDeepEqual(a: unknown, b: unknown): boolean {
35
+ if (a === b) {
36
+ return true
37
+ }
38
+
39
+ if (isArray(a) && isArray(b)) {
40
+ if (a.length !== b.length) {
41
+ return false
42
+ }
43
+
44
+ return a.every((item, i) => isDeepEqual(item, b[i]))
45
+ }
46
+
47
+ if (isPlainObject(a) && isPlainObject(b)) {
48
+ const keysA = Object.keys(a)
49
+
50
+ if (keysA.length !== Object.keys(b).length) {
51
+ return false
52
+ }
53
+
54
+ return keysA.every((key) => isDeepEqual(a[key], b[key]))
55
+ }
56
+
57
+ return Object.is(a, b)
58
+ }
@@ -0,0 +1,5 @@
1
+ export * from './assertions'
2
+ export * from './guards'
3
+ export * from './transformations'
4
+
5
+ export type * from './types'
@@ -0,0 +1,20 @@
1
+ import type { NullToUndefined } from './types'
2
+ import { isArray } from '../arrays'
3
+ import { isNullish } from '../core'
4
+ import { isPlainObject, map } from '../objects'
5
+
6
+ export function nullToUndefined<T>(value: T): NullToUndefined<T> {
7
+ if (isNullish(value)) {
8
+ return undefined as NullToUndefined<T>
9
+ }
10
+
11
+ if (isArray(value)) {
12
+ return value.map(nullToUndefined) as NullToUndefined<T>
13
+ }
14
+
15
+ if (isPlainObject(value)) {
16
+ return map(value, (k, v) => [k, nullToUndefined(v)]) as NullToUndefined<T>
17
+ }
18
+
19
+ return value as NullToUndefined<T>
20
+ }
@@ -0,0 +1,3 @@
1
+ import type { AnyObject } from '../objects'
2
+
3
+ export type NullToUndefined<T> = T extends null ? undefined : T extends Array<infer U> ? Array<NullToUndefined<U>> : T extends AnyObject ? { [K in keyof T]: NullToUndefined<T[K]> } : T
@@ -0,0 +1 @@
1
+ export const DEFAULT_TRUE_STRINGS = new Set(['1', 'on', 'true', 'yes'])
@@ -0,0 +1,9 @@
1
+ export const toString = (value: unknown) => Object.prototype.toString.call(value)
2
+
3
+ export function typeOf(value: unknown): string {
4
+ if (value === null) {
5
+ return 'null'
6
+ }
7
+
8
+ return typeof value === 'object' || typeof value === 'function' ? toString(value).slice(8, -1).toLowerCase() : typeof value
9
+ }
@@ -0,0 +1,57 @@
1
+ import type { JsonablePrimitive, Primitive } from './types'
2
+ import { DEFAULT_TRUE_STRINGS } from './constants'
3
+
4
+ export const isNull = (value: unknown): value is null => value === null
5
+ export const isUndefined = (value: unknown): value is undefined => value === undefined
6
+ export const isNullish = (value: unknown): value is null | undefined => isNull(value) || isUndefined(value)
7
+
8
+ export const notNull = <T>(value: T): value is Exclude<T, null> => !isNull(value)
9
+ export const notUndefined = <T>(value: T): value is Exclude<T, undefined> => !isUndefined(value)
10
+ export const notNullish = <T>(value: T): value is NonNullable<T> => !isNullish(value)
11
+
12
+ export const isBoolean = (value: unknown): value is boolean => typeof value === 'boolean'
13
+ export const isSymbol = (value: unknown): value is symbol => typeof value === 'symbol'
14
+ export const isBigInt = (value: unknown): value is bigint => typeof value === 'bigint'
15
+ export const isNumber = (value: unknown): value is number => typeof value === 'number'
16
+ export const isString = (value: unknown): value is string => typeof value === 'string'
17
+ export const isDate = (value: unknown): value is Date => value instanceof Date
18
+
19
+ export const isPrimitive = (value: unknown): value is Primitive => value === null || (typeof value !== 'object' && typeof value !== 'function')
20
+
21
+ export const isJsonablePrimitive = (value: unknown): value is JsonablePrimitive => (
22
+ isNull(value) || isString(value) || isBoolean(value) || (isNumber(value) && Number.isFinite(value))
23
+ )
24
+
25
+ export interface IsTrueLikeOptions {
26
+ anyNonZeroNumber?: boolean
27
+ trueStrings?: Set<string>
28
+ }
29
+
30
+ export function isTrueLike(value: unknown, options: IsTrueLikeOptions = {}) {
31
+ const { anyNonZeroNumber = false, trueStrings = DEFAULT_TRUE_STRINGS } = options
32
+
33
+ if (isBoolean(value)) {
34
+ return value
35
+ }
36
+
37
+ if (isString(value)) {
38
+ return trueStrings.has(value.toLowerCase())
39
+ }
40
+
41
+ if (isNumber(value)) {
42
+ return anyNonZeroNumber ? value !== 0 && Number.isFinite(value) : value === 1
43
+ }
44
+
45
+ if (isBigInt(value)) {
46
+ return anyNonZeroNumber ? value !== 0n : value === 1n
47
+ }
48
+
49
+ return false
50
+ }
51
+
52
+ export const isGenerator = (value: unknown): boolean => (
53
+ typeof value === 'object' &&
54
+ value !== null &&
55
+ typeof (value as Record<PropertyKey, unknown>).next === 'function' &&
56
+ typeof (value as Record<PropertyKey, unknown>)[Symbol.iterator] === 'function'
57
+ )
@@ -0,0 +1,5 @@
1
+ export * from './constants'
2
+ export * from './conversions'
3
+ export * from './guards'
4
+
5
+ export type * from './types'