ts-data-forge 3.2.0 → 3.3.1

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 (426) hide show
  1. package/README.md +45 -21
  2. package/dist/array/impl/array-utils-creation.d.mts +116 -0
  3. package/dist/array/impl/array-utils-creation.d.mts.map +1 -0
  4. package/dist/array/impl/array-utils-creation.mjs +110 -0
  5. package/dist/array/impl/array-utils-creation.mjs.map +1 -0
  6. package/dist/array/impl/array-utils-element-access.d.mts +61 -0
  7. package/dist/array/impl/array-utils-element-access.d.mts.map +1 -0
  8. package/dist/array/impl/array-utils-element-access.mjs +66 -0
  9. package/dist/array/impl/array-utils-element-access.mjs.map +1 -0
  10. package/dist/array/impl/array-utils-iterators.d.mts +59 -0
  11. package/dist/array/impl/array-utils-iterators.d.mts.map +1 -0
  12. package/dist/array/impl/array-utils-iterators.mjs +104 -0
  13. package/dist/array/impl/array-utils-iterators.mjs.map +1 -0
  14. package/dist/array/impl/array-utils-modification.d.mts +154 -0
  15. package/dist/array/impl/array-utils-modification.d.mts.map +1 -0
  16. package/dist/array/impl/array-utils-modification.mjs +139 -0
  17. package/dist/array/impl/array-utils-modification.mjs.map +1 -0
  18. package/dist/array/impl/array-utils-reducing-value.d.mts +214 -0
  19. package/dist/array/impl/array-utils-reducing-value.d.mts.map +1 -0
  20. package/dist/array/impl/array-utils-reducing-value.mjs +160 -0
  21. package/dist/array/impl/array-utils-reducing-value.mjs.map +1 -0
  22. package/dist/array/impl/array-utils-search.d.mts +179 -0
  23. package/dist/array/impl/array-utils-search.d.mts.map +1 -0
  24. package/dist/array/impl/array-utils-search.mjs +153 -0
  25. package/dist/array/impl/array-utils-search.mjs.map +1 -0
  26. package/dist/array/impl/array-utils-set-op.d.mts +100 -0
  27. package/dist/array/impl/array-utils-set-op.d.mts.map +1 -0
  28. package/dist/array/impl/array-utils-set-op.mjs +137 -0
  29. package/dist/array/impl/array-utils-set-op.mjs.map +1 -0
  30. package/dist/array/impl/array-utils-size.d.mts +24 -0
  31. package/dist/array/impl/array-utils-size.d.mts.map +1 -0
  32. package/dist/array/impl/array-utils-size.mjs +28 -0
  33. package/dist/array/impl/array-utils-size.mjs.map +1 -0
  34. package/dist/array/impl/array-utils-slice-clamped.d.mts +18 -0
  35. package/dist/array/impl/array-utils-slice-clamped.d.mts.map +1 -0
  36. package/dist/array/impl/array-utils-slice-clamped.mjs +49 -0
  37. package/dist/array/impl/array-utils-slice-clamped.mjs.map +1 -0
  38. package/dist/array/impl/array-utils-slicing.d.mts +120 -0
  39. package/dist/array/impl/array-utils-slicing.d.mts.map +1 -0
  40. package/dist/array/impl/array-utils-slicing.mjs +140 -0
  41. package/dist/array/impl/array-utils-slicing.mjs.map +1 -0
  42. package/dist/array/impl/array-utils-transformation.d.mts +348 -0
  43. package/dist/array/impl/array-utils-transformation.d.mts.map +1 -0
  44. package/dist/array/impl/array-utils-transformation.mjs +331 -0
  45. package/dist/array/impl/array-utils-transformation.mjs.map +1 -0
  46. package/dist/array/impl/array-utils-validation.d.mts +149 -0
  47. package/dist/array/impl/array-utils-validation.d.mts.map +1 -0
  48. package/dist/array/impl/array-utils-validation.mjs +166 -0
  49. package/dist/array/impl/array-utils-validation.mjs.map +1 -0
  50. package/dist/array/impl/index.d.mts +13 -0
  51. package/dist/array/impl/index.d.mts.map +1 -0
  52. package/dist/array/impl/index.mjs +13 -0
  53. package/dist/array/impl/index.mjs.map +1 -0
  54. package/dist/array/index.d.mts +1 -1
  55. package/dist/array/index.d.mts.map +1 -1
  56. package/dist/array/index.mjs +2 -1
  57. package/dist/array/index.mjs.map +1 -1
  58. package/dist/collections/imap-mapped.d.mts +83 -253
  59. package/dist/collections/imap-mapped.d.mts.map +1 -1
  60. package/dist/collections/imap-mapped.mjs +33 -164
  61. package/dist/collections/imap-mapped.mjs.map +1 -1
  62. package/dist/collections/imap.d.mts +436 -163
  63. package/dist/collections/imap.d.mts.map +1 -1
  64. package/dist/collections/imap.mjs +74 -94
  65. package/dist/collections/imap.mjs.map +1 -1
  66. package/dist/collections/iset-mapped.d.mts +828 -345
  67. package/dist/collections/iset-mapped.d.mts.map +1 -1
  68. package/dist/collections/iset-mapped.mjs +200 -242
  69. package/dist/collections/iset-mapped.mjs.map +1 -1
  70. package/dist/collections/iset.d.mts +397 -205
  71. package/dist/collections/iset.d.mts.map +1 -1
  72. package/dist/collections/iset.mjs +102 -184
  73. package/dist/collections/iset.mjs.map +1 -1
  74. package/dist/collections/queue.d.mts +155 -135
  75. package/dist/collections/queue.d.mts.map +1 -1
  76. package/dist/collections/queue.mjs +55 -156
  77. package/dist/collections/queue.mjs.map +1 -1
  78. package/dist/collections/stack.d.mts +154 -154
  79. package/dist/collections/stack.d.mts.map +1 -1
  80. package/dist/collections/stack.mjs +54 -203
  81. package/dist/collections/stack.mjs.map +1 -1
  82. package/dist/entry-point.d.mts +3 -0
  83. package/dist/entry-point.d.mts.map +1 -0
  84. package/dist/entry-point.mjs +62 -0
  85. package/dist/entry-point.mjs.map +1 -0
  86. package/dist/expect-type.d.mts +43 -172
  87. package/dist/expect-type.d.mts.map +1 -1
  88. package/dist/expect-type.mjs +43 -172
  89. package/dist/expect-type.mjs.map +1 -1
  90. package/dist/functional/match.d.mts +35 -140
  91. package/dist/functional/match.d.mts.map +1 -1
  92. package/dist/functional/match.mjs.map +1 -1
  93. package/dist/functional/optional.d.mts +282 -160
  94. package/dist/functional/optional.d.mts.map +1 -1
  95. package/dist/functional/optional.mjs +131 -71
  96. package/dist/functional/optional.mjs.map +1 -1
  97. package/dist/functional/pipe.d.mts +59 -113
  98. package/dist/functional/pipe.d.mts.map +1 -1
  99. package/dist/functional/pipe.mjs.map +1 -1
  100. package/dist/functional/result.d.mts +433 -332
  101. package/dist/functional/result.d.mts.map +1 -1
  102. package/dist/functional/result.mjs +233 -239
  103. package/dist/functional/result.mjs.map +1 -1
  104. package/dist/globals.d.mts +12 -5
  105. package/dist/guard/has-key.d.mts +23 -74
  106. package/dist/guard/has-key.d.mts.map +1 -1
  107. package/dist/guard/has-key.mjs +23 -74
  108. package/dist/guard/has-key.mjs.map +1 -1
  109. package/dist/guard/is-non-empty-string.d.mts +20 -87
  110. package/dist/guard/is-non-empty-string.d.mts.map +1 -1
  111. package/dist/guard/is-non-empty-string.mjs +20 -87
  112. package/dist/guard/is-non-empty-string.mjs.map +1 -1
  113. package/dist/guard/is-non-null-object.d.mts +14 -84
  114. package/dist/guard/is-non-null-object.d.mts.map +1 -1
  115. package/dist/guard/is-non-null-object.mjs +14 -84
  116. package/dist/guard/is-non-null-object.mjs.map +1 -1
  117. package/dist/guard/is-primitive.d.mts +13 -126
  118. package/dist/guard/is-primitive.d.mts.map +1 -1
  119. package/dist/guard/is-primitive.mjs +13 -126
  120. package/dist/guard/is-primitive.mjs.map +1 -1
  121. package/dist/guard/is-record.d.mts +21 -132
  122. package/dist/guard/is-record.d.mts.map +1 -1
  123. package/dist/guard/is-record.mjs +21 -132
  124. package/dist/guard/is-record.mjs.map +1 -1
  125. package/dist/guard/is-type.d.mts +201 -238
  126. package/dist/guard/is-type.d.mts.map +1 -1
  127. package/dist/guard/is-type.mjs +201 -238
  128. package/dist/guard/is-type.mjs.map +1 -1
  129. package/dist/guard/key-is-in.d.mts +22 -139
  130. package/dist/guard/key-is-in.d.mts.map +1 -1
  131. package/dist/guard/key-is-in.mjs +22 -139
  132. package/dist/guard/key-is-in.mjs.map +1 -1
  133. package/dist/index.d.mts +0 -1
  134. package/dist/index.d.mts.map +1 -1
  135. package/dist/index.mjs +0 -1
  136. package/dist/index.mjs.map +1 -1
  137. package/dist/iterator/range.d.mts +29 -62
  138. package/dist/iterator/range.d.mts.map +1 -1
  139. package/dist/iterator/range.mjs.map +1 -1
  140. package/dist/json/json.d.mts +191 -121
  141. package/dist/json/json.d.mts.map +1 -1
  142. package/dist/json/json.mjs +238 -136
  143. package/dist/json/json.mjs.map +1 -1
  144. package/dist/number/branded-types/finite-number.d.mts +24 -156
  145. package/dist/number/branded-types/finite-number.d.mts.map +1 -1
  146. package/dist/number/branded-types/finite-number.mjs +27 -159
  147. package/dist/number/branded-types/finite-number.mjs.map +1 -1
  148. package/dist/number/branded-types/int.d.mts +122 -120
  149. package/dist/number/branded-types/int.d.mts.map +1 -1
  150. package/dist/number/branded-types/int.mjs +122 -120
  151. package/dist/number/branded-types/int.mjs.map +1 -1
  152. package/dist/number/branded-types/int16.d.mts +22 -30
  153. package/dist/number/branded-types/int16.d.mts.map +1 -1
  154. package/dist/number/branded-types/int16.mjs +22 -30
  155. package/dist/number/branded-types/int16.mjs.map +1 -1
  156. package/dist/number/branded-types/int32.d.mts +22 -31
  157. package/dist/number/branded-types/int32.d.mts.map +1 -1
  158. package/dist/number/branded-types/int32.mjs +22 -31
  159. package/dist/number/branded-types/int32.mjs.map +1 -1
  160. package/dist/number/branded-types/non-negative-finite-number.d.mts +28 -36
  161. package/dist/number/branded-types/non-negative-finite-number.d.mts.map +1 -1
  162. package/dist/number/branded-types/non-negative-finite-number.mjs +31 -39
  163. package/dist/number/branded-types/non-negative-finite-number.mjs.map +1 -1
  164. package/dist/number/branded-types/non-negative-int16.d.mts +24 -34
  165. package/dist/number/branded-types/non-negative-int16.d.mts.map +1 -1
  166. package/dist/number/branded-types/non-negative-int16.mjs +24 -34
  167. package/dist/number/branded-types/non-negative-int16.mjs.map +1 -1
  168. package/dist/number/branded-types/non-negative-int32.d.mts +26 -35
  169. package/dist/number/branded-types/non-negative-int32.d.mts.map +1 -1
  170. package/dist/number/branded-types/non-negative-int32.mjs +26 -35
  171. package/dist/number/branded-types/non-negative-int32.mjs.map +1 -1
  172. package/dist/number/branded-types/non-zero-finite-number.d.mts +22 -37
  173. package/dist/number/branded-types/non-zero-finite-number.d.mts.map +1 -1
  174. package/dist/number/branded-types/non-zero-finite-number.mjs +25 -40
  175. package/dist/number/branded-types/non-zero-finite-number.mjs.map +1 -1
  176. package/dist/number/branded-types/non-zero-int.d.mts +15 -30
  177. package/dist/number/branded-types/non-zero-int.d.mts.map +1 -1
  178. package/dist/number/branded-types/non-zero-int.mjs +15 -30
  179. package/dist/number/branded-types/non-zero-int.mjs.map +1 -1
  180. package/dist/number/branded-types/non-zero-int16.d.mts +27 -35
  181. package/dist/number/branded-types/non-zero-int16.d.mts.map +1 -1
  182. package/dist/number/branded-types/non-zero-int16.mjs +27 -35
  183. package/dist/number/branded-types/non-zero-int16.mjs.map +1 -1
  184. package/dist/number/branded-types/non-zero-int32.d.mts +29 -36
  185. package/dist/number/branded-types/non-zero-int32.d.mts.map +1 -1
  186. package/dist/number/branded-types/non-zero-int32.mjs +29 -36
  187. package/dist/number/branded-types/non-zero-int32.mjs.map +1 -1
  188. package/dist/number/branded-types/non-zero-safe-int.d.mts +37 -38
  189. package/dist/number/branded-types/non-zero-safe-int.d.mts.map +1 -1
  190. package/dist/number/branded-types/non-zero-safe-int.mjs +39 -40
  191. package/dist/number/branded-types/non-zero-safe-int.mjs.map +1 -1
  192. package/dist/number/branded-types/non-zero-uint16.d.mts +24 -35
  193. package/dist/number/branded-types/non-zero-uint16.d.mts.map +1 -1
  194. package/dist/number/branded-types/non-zero-uint16.mjs +24 -35
  195. package/dist/number/branded-types/non-zero-uint16.mjs.map +1 -1
  196. package/dist/number/branded-types/non-zero-uint32.d.mts +24 -35
  197. package/dist/number/branded-types/non-zero-uint32.d.mts.map +1 -1
  198. package/dist/number/branded-types/non-zero-uint32.mjs +24 -35
  199. package/dist/number/branded-types/non-zero-uint32.mjs.map +1 -1
  200. package/dist/number/branded-types/positive-finite-number.d.mts +26 -40
  201. package/dist/number/branded-types/positive-finite-number.d.mts.map +1 -1
  202. package/dist/number/branded-types/positive-finite-number.mjs +29 -43
  203. package/dist/number/branded-types/positive-finite-number.mjs.map +1 -1
  204. package/dist/number/branded-types/positive-int.d.mts +133 -123
  205. package/dist/number/branded-types/positive-int.d.mts.map +1 -1
  206. package/dist/number/branded-types/positive-int.mjs +133 -123
  207. package/dist/number/branded-types/positive-int.mjs.map +1 -1
  208. package/dist/number/branded-types/positive-int16.d.mts +24 -35
  209. package/dist/number/branded-types/positive-int16.d.mts.map +1 -1
  210. package/dist/number/branded-types/positive-int16.mjs +24 -35
  211. package/dist/number/branded-types/positive-int16.mjs.map +1 -1
  212. package/dist/number/branded-types/positive-int32.d.mts +24 -35
  213. package/dist/number/branded-types/positive-int32.d.mts.map +1 -1
  214. package/dist/number/branded-types/positive-int32.mjs +24 -35
  215. package/dist/number/branded-types/positive-int32.mjs.map +1 -1
  216. package/dist/number/branded-types/positive-safe-int.d.mts +159 -33
  217. package/dist/number/branded-types/positive-safe-int.d.mts.map +1 -1
  218. package/dist/number/branded-types/positive-safe-int.mjs +160 -34
  219. package/dist/number/branded-types/positive-safe-int.mjs.map +1 -1
  220. package/dist/number/branded-types/positive-uint16.d.mts +24 -35
  221. package/dist/number/branded-types/positive-uint16.d.mts.map +1 -1
  222. package/dist/number/branded-types/positive-uint16.mjs +24 -35
  223. package/dist/number/branded-types/positive-uint16.mjs.map +1 -1
  224. package/dist/number/branded-types/positive-uint32.d.mts +26 -36
  225. package/dist/number/branded-types/positive-uint32.d.mts.map +1 -1
  226. package/dist/number/branded-types/positive-uint32.mjs +26 -36
  227. package/dist/number/branded-types/positive-uint32.mjs.map +1 -1
  228. package/dist/number/branded-types/safe-int.d.mts +140 -99
  229. package/dist/number/branded-types/safe-int.d.mts.map +1 -1
  230. package/dist/number/branded-types/safe-int.mjs +142 -101
  231. package/dist/number/branded-types/safe-int.mjs.map +1 -1
  232. package/dist/number/branded-types/safe-uint.d.mts +24 -33
  233. package/dist/number/branded-types/safe-uint.d.mts.map +1 -1
  234. package/dist/number/branded-types/safe-uint.mjs +25 -34
  235. package/dist/number/branded-types/safe-uint.mjs.map +1 -1
  236. package/dist/number/branded-types/uint.d.mts +121 -30
  237. package/dist/number/branded-types/uint.d.mts.map +1 -1
  238. package/dist/number/branded-types/uint.mjs +121 -30
  239. package/dist/number/branded-types/uint.mjs.map +1 -1
  240. package/dist/number/branded-types/uint16.d.mts +26 -34
  241. package/dist/number/branded-types/uint16.d.mts.map +1 -1
  242. package/dist/number/branded-types/uint16.mjs +26 -34
  243. package/dist/number/branded-types/uint16.mjs.map +1 -1
  244. package/dist/number/branded-types/uint32.d.mts +26 -68
  245. package/dist/number/branded-types/uint32.d.mts.map +1 -1
  246. package/dist/number/branded-types/uint32.mjs +26 -68
  247. package/dist/number/branded-types/uint32.mjs.map +1 -1
  248. package/dist/number/enum/int8.d.mts +37 -101
  249. package/dist/number/enum/int8.d.mts.map +1 -1
  250. package/dist/number/enum/int8.mjs +39 -170
  251. package/dist/number/enum/int8.mjs.map +1 -1
  252. package/dist/number/enum/uint8.d.mts +45 -55
  253. package/dist/number/enum/uint8.d.mts.map +1 -1
  254. package/dist/number/enum/uint8.mjs +46 -155
  255. package/dist/number/enum/uint8.mjs.map +1 -1
  256. package/dist/number/num.d.mts +145 -206
  257. package/dist/number/num.d.mts.map +1 -1
  258. package/dist/number/num.mjs +143 -199
  259. package/dist/number/num.mjs.map +1 -1
  260. package/dist/number/refined-number-utils.d.mts +97 -21
  261. package/dist/number/refined-number-utils.d.mts.map +1 -1
  262. package/dist/number/refined-number-utils.mjs +91 -20
  263. package/dist/number/refined-number-utils.mjs.map +1 -1
  264. package/dist/object/object.d.mts +126 -208
  265. package/dist/object/object.d.mts.map +1 -1
  266. package/dist/object/object.mjs +68 -102
  267. package/dist/object/object.mjs.map +1 -1
  268. package/dist/others/cast-mutable.d.mts +12 -88
  269. package/dist/others/cast-mutable.d.mts.map +1 -1
  270. package/dist/others/cast-mutable.mjs +13 -89
  271. package/dist/others/cast-mutable.mjs.map +1 -1
  272. package/dist/others/cast-readonly.d.mts +12 -168
  273. package/dist/others/cast-readonly.d.mts.map +1 -1
  274. package/dist/others/cast-readonly.mjs +13 -169
  275. package/dist/others/cast-readonly.mjs.map +1 -1
  276. package/dist/others/if-then.d.mts +6 -83
  277. package/dist/others/if-then.d.mts.map +1 -1
  278. package/dist/others/if-then.mjs +6 -83
  279. package/dist/others/if-then.mjs.map +1 -1
  280. package/dist/others/map-nullable.d.mts +12 -136
  281. package/dist/others/map-nullable.d.mts.map +1 -1
  282. package/dist/others/map-nullable.mjs.map +1 -1
  283. package/dist/others/memoize-function.d.mts +14 -157
  284. package/dist/others/memoize-function.d.mts.map +1 -1
  285. package/dist/others/memoize-function.mjs +14 -157
  286. package/dist/others/memoize-function.mjs.map +1 -1
  287. package/dist/others/tuple.d.mts +33 -151
  288. package/dist/others/tuple.d.mts.map +1 -1
  289. package/dist/others/tuple.mjs +33 -151
  290. package/dist/others/tuple.mjs.map +1 -1
  291. package/dist/others/unknown-to-string.d.mts +11 -125
  292. package/dist/others/unknown-to-string.d.mts.map +1 -1
  293. package/dist/others/unknown-to-string.mjs +14 -127
  294. package/dist/others/unknown-to-string.mjs.map +1 -1
  295. package/dist/promise/promise.d.mts +33 -20
  296. package/dist/promise/promise.d.mts.map +1 -1
  297. package/dist/promise/promise.mjs +34 -21
  298. package/dist/promise/promise.mjs.map +1 -1
  299. package/dist/types.d.mts +1 -1
  300. package/package.json +54 -50
  301. package/src/array/impl/array-utils-creation.mts +192 -0
  302. package/src/array/{array-utils-creation.test.mts → impl/array-utils-creation.test.mts} +121 -72
  303. package/src/array/impl/array-utils-element-access.mts +115 -0
  304. package/src/array/impl/array-utils-element-access.test.mts +151 -0
  305. package/src/array/impl/array-utils-iterators.mts +79 -0
  306. package/src/array/impl/array-utils-iterators.test.mts +98 -0
  307. package/src/array/impl/array-utils-modification.mts +434 -0
  308. package/src/array/{array-utils-modification.test.mts → impl/array-utils-modification.test.mts} +41 -28
  309. package/src/array/{array-utils-overload-type-error.test.mts → impl/array-utils-overload-type-error.test.mts} +33 -33
  310. package/src/array/impl/array-utils-reducing-value.mts +551 -0
  311. package/src/array/{array-utils-reducing-value.test.mts → impl/array-utils-reducing-value.test.mts} +45 -50
  312. package/src/array/impl/array-utils-search.mts +509 -0
  313. package/src/array/impl/array-utils-search.test.mts +346 -0
  314. package/src/array/impl/array-utils-set-op.mts +166 -0
  315. package/src/array/{array-utils-set-op.test.mts → impl/array-utils-set-op.test.mts} +42 -35
  316. package/src/array/impl/array-utils-size.mts +30 -0
  317. package/src/array/impl/array-utils-size.test.mts +9 -0
  318. package/src/array/impl/array-utils-slice-clamped.mts +51 -0
  319. package/src/array/{array-utils-slice-clamped.test.mts → impl/array-utils-slice-clamped.test.mts} +12 -12
  320. package/src/array/impl/array-utils-slicing.mts +275 -0
  321. package/src/array/impl/array-utils-slicing.test.mts +158 -0
  322. package/src/array/impl/array-utils-transformation.mts +746 -0
  323. package/src/array/{array-utils-transformation.test.mts → impl/array-utils-transformation.test.mts} +662 -889
  324. package/src/array/impl/array-utils-validation.mts +241 -0
  325. package/src/array/{array-utils-validation.test.mts → impl/array-utils-validation.test.mts} +194 -107
  326. package/src/array/{array.test.mts → impl/array.test.mts} +2 -2
  327. package/src/array/impl/index.mts +12 -0
  328. package/src/array/index.mts +1 -1
  329. package/src/collections/imap-mapped.mts +99 -265
  330. package/src/collections/imap.mts +477 -174
  331. package/src/collections/imap.test.mts +12 -19
  332. package/src/collections/iset-mapped.mts +892 -358
  333. package/src/collections/iset.mts +429 -213
  334. package/src/collections/queue.mts +174 -200
  335. package/src/collections/stack.mts +172 -245
  336. package/src/collections/stack.test.mts +9 -1
  337. package/src/entry-point.mts +2 -0
  338. package/src/expect-type.mts +43 -172
  339. package/src/functional/match.mts +35 -145
  340. package/src/functional/optional.mts +285 -163
  341. package/src/functional/optional.test.mts +4 -1
  342. package/src/functional/pipe.mts +60 -113
  343. package/src/functional/result.mts +452 -351
  344. package/src/functional/result.test.mts +9 -2
  345. package/src/globals.d.mts +12 -5
  346. package/src/guard/has-key.mts +23 -74
  347. package/src/guard/is-non-empty-string.mts +20 -87
  348. package/src/guard/is-non-null-object.mts +14 -84
  349. package/src/guard/is-non-null-object.test.mts +1 -1
  350. package/src/guard/is-primitive.mts +13 -126
  351. package/src/guard/is-primitive.test.mts +1 -1
  352. package/src/guard/is-record.mts +21 -132
  353. package/src/guard/is-record.test.mts +0 -1
  354. package/src/guard/is-type.mts +201 -238
  355. package/src/guard/is-type.test.mts +7 -7
  356. package/src/guard/key-is-in.mts +22 -139
  357. package/src/index.mts +0 -1
  358. package/src/iterator/range.mts +29 -62
  359. package/src/json/json.mts +202 -134
  360. package/src/json/json.test.mts +1 -3
  361. package/src/number/branded-types/finite-number.mts +27 -159
  362. package/src/number/branded-types/int.mts +122 -120
  363. package/src/number/branded-types/int16.mts +22 -30
  364. package/src/number/branded-types/int16.test.mts +24 -24
  365. package/src/number/branded-types/int32.mts +22 -31
  366. package/src/number/branded-types/int32.test.mts +39 -39
  367. package/src/number/branded-types/non-negative-finite-number.mts +31 -39
  368. package/src/number/branded-types/non-negative-int16.mts +24 -34
  369. package/src/number/branded-types/non-negative-int16.test.mts +16 -16
  370. package/src/number/branded-types/non-negative-int32.mts +26 -35
  371. package/src/number/branded-types/non-negative-int32.test.mts +30 -30
  372. package/src/number/branded-types/non-zero-finite-number.mts +25 -40
  373. package/src/number/branded-types/non-zero-int.mts +15 -30
  374. package/src/number/branded-types/non-zero-int16.mts +27 -35
  375. package/src/number/branded-types/non-zero-int16.test.mts +26 -26
  376. package/src/number/branded-types/non-zero-int32.mts +29 -36
  377. package/src/number/branded-types/non-zero-int32.test.mts +45 -42
  378. package/src/number/branded-types/non-zero-safe-int.mts +39 -40
  379. package/src/number/branded-types/non-zero-uint16.mts +24 -35
  380. package/src/number/branded-types/non-zero-uint16.test.mts +16 -16
  381. package/src/number/branded-types/non-zero-uint32.mts +24 -35
  382. package/src/number/branded-types/non-zero-uint32.test.mts +28 -28
  383. package/src/number/branded-types/positive-finite-number.mts +29 -43
  384. package/src/number/branded-types/positive-int.mts +134 -124
  385. package/src/number/branded-types/positive-int16.mts +24 -35
  386. package/src/number/branded-types/positive-int16.test.mts +14 -14
  387. package/src/number/branded-types/positive-int32.mts +24 -35
  388. package/src/number/branded-types/positive-int32.test.mts +26 -26
  389. package/src/number/branded-types/positive-safe-int.mts +160 -34
  390. package/src/number/branded-types/positive-uint16.mts +24 -35
  391. package/src/number/branded-types/positive-uint16.test.mts +16 -16
  392. package/src/number/branded-types/positive-uint32.mts +26 -36
  393. package/src/number/branded-types/positive-uint32.test.mts +31 -28
  394. package/src/number/branded-types/safe-int.mts +142 -101
  395. package/src/number/branded-types/safe-uint.mts +25 -34
  396. package/src/number/branded-types/uint.mts +121 -30
  397. package/src/number/branded-types/uint16.mts +26 -34
  398. package/src/number/branded-types/uint16.test.mts +16 -16
  399. package/src/number/branded-types/uint32.mts +26 -68
  400. package/src/number/branded-types/uint32.test.mts +28 -28
  401. package/src/number/enum/int8.mts +39 -170
  402. package/src/number/enum/uint8.mts +46 -155
  403. package/src/number/num.mts +157 -212
  404. package/src/number/num.test.mts +4 -4
  405. package/src/number/refined-number-utils.mts +109 -26
  406. package/src/object/object.mts +130 -212
  407. package/src/object/object.test.mts +29 -0
  408. package/src/others/cast-mutable.mts +13 -89
  409. package/src/others/cast-mutable.test.mts +80 -0
  410. package/src/others/cast-readonly.mts +13 -169
  411. package/src/others/if-then.mts +6 -83
  412. package/src/others/map-nullable.mts +12 -136
  413. package/src/others/map-nullable.test.mts +6 -6
  414. package/src/others/memoize-function.mts +14 -157
  415. package/src/others/tuple.mts +33 -151
  416. package/src/others/unknown-to-string.mts +15 -127
  417. package/src/others/unknown-to-string.test.mts +14 -2
  418. package/src/promise/promise.mts +34 -21
  419. package/src/promise/promise.test.mts +43 -0
  420. package/dist/array/array-utils.d.mts +0 -2956
  421. package/dist/array/array-utils.d.mts.map +0 -1
  422. package/dist/array/array-utils.mjs +0 -1838
  423. package/dist/array/array-utils.mjs.map +0 -1
  424. package/src/array/array-utils-search.test.mts +0 -169
  425. package/src/array/array-utils-slicing.test.mts +0 -274
  426. package/src/array/array-utils.mts +0 -4834
@@ -33,12 +33,13 @@ import '../number/num.mjs';
33
33
  import '../number/refined-number-utils.mjs';
34
34
 
35
35
  /**
36
- * Class implementation for a stack with LIFO (Last-In, First-Out) behavior using a dynamic array.
37
- * This implementation provides O(1) amortized push and O(1) pop operations by using a resizable buffer
38
- * that grows as needed.
36
+ * Class implementation for a stack with LIFO (Last-In, First-Out) behavior
37
+ * using a dynamic array. This implementation provides O(1) amortized push and
38
+ * O(1) pop operations by using a resizable buffer that grows as needed.
39
39
  *
40
- * The underlying array automatically resizes when it becomes full, ensuring that the stack
41
- * can grow to accommodate any number of elements while maintaining efficient operations.
40
+ * The underlying array automatically resizes when it becomes full, ensuring
41
+ * that the stack can grow to accommodate any number of elements while
42
+ * maintaining efficient operations.
42
43
  *
43
44
  * @template T The type of elements in the stack.
44
45
  * @implements Stack
@@ -54,6 +55,7 @@ class StackClass {
54
55
  static #INITIAL_CAPACITY = 8;
55
56
  /**
56
57
  * Constructs a new StackClass instance.
58
+ *
57
59
  * @param initialValues Optional initial values to populate the stack.
58
60
  */
59
61
  constructor(initialValues = []) {
@@ -77,50 +79,16 @@ class StackClass {
77
79
  /**
78
80
  * Removes and returns the element at the top of the stack (LIFO).
79
81
  *
80
- * This operation removes the element that was added most recently (last-in) and returns it.
81
- * If the stack is empty, returns `Optional.none`. The operation is guaranteed to be O(1)
82
- * and does not require any array resizing or memory reallocation.
83
- *
84
- * **Time Complexity:** O(1) - constant time operation
85
- * **Space Complexity:** O(1) - no additional memory allocation
86
- *
87
- * @returns An Optional containing the removed element, or `Optional.none` if the stack is empty.
88
- *
89
- * @example
90
- * ```typescript
91
- * const stack = createStack<string>();
92
- *
93
- * // Add some elements
94
- * stack.push("bottom");
95
- * stack.push("middle");
96
- * stack.push("top");
82
+ * This operation removes the element that was added most recently (last-in)
83
+ * and returns it. If the stack is empty, returns `Optional.none`. The
84
+ * operation is guaranteed to be O(1) and does not require any array resizing
85
+ * or memory reallocation.
97
86
  *
98
- * // Remove elements in LIFO order
99
- * const top = stack.pop();
100
- * if (top.isSome) {
101
- * console.log(top.value); // "top" (last pushed, first popped)
102
- * }
87
+ * **Time Complexity:** O(1) - constant time operation **Space Complexity:**
88
+ * O(1) - no additional memory allocation
103
89
  *
104
- * const middle = stack.pop().unwrap(); // "middle"
105
- * console.log(stack.size); // 1
106
- *
107
- * // Safe handling of empty stack
108
- * const emptyStack = createStack<number>();
109
- * const result = emptyStack.pop();
110
- * if (result.isNone) {
111
- * console.log("Stack is empty");
112
- * }
113
- *
114
- * // Typical usage in algorithms
115
- * const pathStack = createStack<string>();
116
- * pathStack.push("/home");
117
- * pathStack.push("/users");
118
- * pathStack.push("/documents");
119
- *
120
- * // Backtrack one level
121
- * const currentDir = pathStack.pop().unwrap(); // "/documents"
122
- * const parentDir = pathStack.pop().unwrap(); // "/users"
123
- * ```
90
+ * @returns An Optional containing the removed element, or `Optional.none` if
91
+ * the stack is empty.
124
92
  */
125
93
  pop() {
126
94
  if (this.isEmpty) {
@@ -135,60 +103,19 @@ class StackClass {
135
103
  /**
136
104
  * Adds an element to the top of the stack (LIFO).
137
105
  *
138
- * This operation adds the element to the top of the stack, where it will be the first
139
- * to be popped (last-in, first-out ordering). The operation is amortized O(1),
140
- * meaning it's O(1) for most operations with occasional O(n) when the buffer needs resizing.
106
+ * This operation adds the element to the top of the stack, where it will be
107
+ * the first to be popped (last-in, first-out ordering). The operation is
108
+ * amortized O(1), meaning it's O(1) for most operations with occasional O(n)
109
+ * when the buffer needs resizing.
141
110
  *
142
- * **Time Complexity:** O(1) amortized - O(n) only when buffer resize is needed
143
- * **Space Complexity:** O(1) - constant additional memory per element
111
+ * **Time Complexity:** O(1) amortized - O(n) only when buffer resize is
112
+ * needed **Space Complexity:** O(1) - constant additional memory per element
144
113
  *
145
- * **Buffer Resizing:** When the internal buffer becomes full, it automatically doubles
146
- * in size and copies existing elements to maintain the stack structure.
114
+ * **Buffer Resizing:** When the internal buffer becomes full, it
115
+ * automatically doubles in size and copies existing elements to maintain the
116
+ * stack structure.
147
117
  *
148
118
  * @param value The element to add to the top of the stack.
149
- *
150
- * @example
151
- * ```typescript
152
- * const actionStack = createStack<string>();
153
- *
154
- * // Add actions in chronological order
155
- * actionStack.push("open file"); // O(1)
156
- * actionStack.push("edit content"); // O(1)
157
- * actionStack.push("save file"); // O(1)
158
- *
159
- * console.log(actionStack.size); // 3
160
- *
161
- * // Actions will be undone in reverse order (LIFO)
162
- * while (!actionStack.isEmpty) {
163
- * const action = actionStack.pop().unwrap();
164
- * console.log(`Undoing: ${action}`);
165
- * }
166
- * // Output:
167
- * // Undoing: save file
168
- * // Undoing: edit content
169
- * // Undoing: open file
170
- *
171
- * // High-volume pushing (demonstrates amortized O(1) performance)
172
- * const dataStack = createStack<number>();
173
- *
174
- * for (const i of range(1000000)) {
175
- * dataStack.push(i); // Each operation is O(1) amortized
176
- * }
177
- *
178
- * console.log(dataStack.size); // 1000000
179
- *
180
- * // Function call stack simulation
181
- * type StackFrame = { function: string; variables: Record<string, any> };
182
- * const callStack = createStack<StackFrame>();
183
- *
184
- * callStack.push({ function: "main", variables: { argc: 1, argv: ["program"] } });
185
- * callStack.push({ function: "process", variables: { data: [1, 2, 3] } });
186
- * callStack.push({ function: "validate", variables: { input: "test" } });
187
- *
188
- * // Current function context is at the top
189
- * const currentFrame = callStack.pop().unwrap();
190
- * console.log(`Current function: ${currentFrame.function}`);
191
- * ```
192
119
  */
193
120
  push(value) {
194
121
  // Resize if buffer is full
@@ -215,13 +142,16 @@ class StackClass {
215
142
  }
216
143
  }
217
144
  /**
218
- * Creates a new Stack instance with LIFO (Last-In, First-Out) behavior using a high-performance dynamic array.
145
+ * Creates a new Stack instance with LIFO (Last-In, First-Out) behavior using a
146
+ * high-performance dynamic array.
219
147
  *
220
- * This factory function creates an optimized stack implementation that maintains excellent performance
221
- * characteristics for both push and pop operations. The underlying dynamic array automatically
222
- * resizes to accommodate growing workloads while providing predictable O(1) operations.
148
+ * This factory function creates an optimized stack implementation that
149
+ * maintains excellent performance characteristics for both push and pop
150
+ * operations. The underlying dynamic array automatically resizes to accommodate
151
+ * growing workloads while providing predictable O(1) operations.
223
152
  *
224
153
  * **Implementation Features:**
154
+ *
225
155
  * - **O(1) push operations** (amortized - occasionally O(n) when resizing)
226
156
  * - **O(1) pop operations** (always)
227
157
  * - **Automatic buffer resizing** - starts at 8 elements, doubles when full
@@ -229,121 +159,42 @@ class StackClass {
229
159
  * - **Dynamic array design** - eliminates need for complex memory management
230
160
  *
231
161
  * **Performance Benefits:**
162
+ *
232
163
  * - No array shifting required for stack operations
233
164
  * - Minimal memory allocation overhead
234
165
  * - Predictable performance under high load
235
166
  * - Efficient memory usage with automatic cleanup
236
167
  *
237
- * @template T The type of elements stored in the stack.
238
- * @param initialValues Optional array of initial elements to populate the stack.
239
- * Elements will be popped in reverse order of how they appear in the array
240
- * (last array element will be popped first).
241
- * If provided, the initial buffer capacity will be at least twice the array length.
242
- * @returns A new Stack instance optimized for high-performance LIFO operations.
243
- *
244
168
  * @example
245
- * ```typescript
246
- * import { createStack } from './stack';
247
- *
248
- * // Example 1: Function call simulation
249
- * type FunctionCall = { name: string; args: any[]; context: any };
250
- * const callStack = createStack<FunctionCall>();
251
- *
252
- * // Simulate function calls (push onto stack)
253
- * callStack.push({ name: "main", args: [], context: {} }); // O(1)
254
- * callStack.push({ name: "processData", args: [data], context: {} }); // O(1)
255
- * callStack.push({ name: "validateInput", args: [input], context: {} }); // O(1)
256
- *
257
- * // Simulate function returns (pop from stack)
258
- * while (!callStack.isEmpty) {
259
- * const call = callStack.pop().unwrap(); // O(1)
260
- * console.log(`Returning from: ${call.name}`);
261
- * }
262
- * // Output:
263
- * // Returning from: validateInput
264
- * // Returning from: processData
265
- * // Returning from: main
266
- *
267
- * // Example 2: Expression evaluation with operator precedence
268
- * const operatorStack = createStack<string>();
269
- * const operandStack = createStack<number>();
270
- *
271
- * // Simulate parsing "3 + 4 * 2"
272
- * operandStack.push(3);
273
- * operatorStack.push("+");
274
- * operandStack.push(4);
275
- * operatorStack.push("*"); // Higher precedence
276
- * operandStack.push(2);
277
169
  *
278
- * // Process higher precedence first (LIFO)
279
- * const op = operatorStack.pop().unwrap(); // "*"
280
- * const b = operandStack.pop().unwrap(); // 2
281
- * const a = operandStack.pop().unwrap(); // 4
282
- * operandStack.push(a * b); // Push result: 8
170
+ * ```ts
171
+ * const stack = createStack<string>();
283
172
  *
284
- * // Example 3: Undo/Redo functionality
285
- * type EditAction = {
286
- * type: 'insert' | 'delete' | 'modify';
287
- * position: number;
288
- * oldValue: string;
289
- * newValue: string;
290
- * };
173
+ * assert.ok(stack.isEmpty);
174
+ * assert(stack.size === 0);
291
175
  *
292
- * const undoStack = createStack<EditAction>();
293
- * const redoStack = createStack<EditAction>();
176
+ * stack.push('first');
177
+ * // eslint-disable-next-line unicorn/prefer-single-call
178
+ * stack.push('second');
294
179
  *
295
- * // Perform edits (push to undo stack)
296
- * const edit1: EditAction = { type: 'insert', position: 0, oldValue: '', newValue: 'Hello' };
297
- * const edit2: EditAction = { type: 'insert', position: 5, oldValue: '', newValue: ' World' };
180
+ * assert.notOk(stack.isEmpty);
181
+ * assert(stack.size === 2);
182
+ * assert.deepStrictEqual(stack.pop(), Optional.some('second'));
183
+ * assert.deepStrictEqual(stack.pop(), Optional.some('first'));
184
+ * assert.deepStrictEqual(stack.pop(), Optional.none);
298
185
  *
299
- * undoStack.push(edit1);
300
- * undoStack.push(edit2);
186
+ * const seededStack = createStack([10, 20, 30]);
301
187
  *
302
- * // Undo last edit
303
- * if (!undoStack.isEmpty) {
304
- * const lastEdit = undoStack.pop().unwrap();
305
- * redoStack.push(lastEdit);
306
- * console.log(`Undid: ${lastEdit.type} at position ${lastEdit.position}`);
307
- * }
308
- *
309
- * // Example 4: High-throughput data processing
310
- * const processingStack = createStack<number>();
311
- *
312
- * // Add large amount of data (demonstrates amortized O(1) performance)
313
- * for (const i of range(100000)) {
314
- * processingStack.push(i); // Each push is O(1) amortized
315
- * }
316
- *
317
- * // Process data in LIFO order
318
- * let processedCount = 0;
319
- * while (!processingStack.isEmpty) {
320
- * const value = processingStack.pop().unwrap(); // O(1)
321
- * // Process value...
322
- * processedCount++;
323
- * }
324
- * console.log(`Processed ${processedCount} items`); // 100000
325
- *
326
- * // Example 5: Stack with pre-populated data
327
- * const historyStack = createStack<string>([
328
- * "page1.html",
329
- * "page2.html",
330
- * "page3.html",
331
- * "page4.html"
332
- * ]);
333
- *
334
- * console.log(historyStack.size); // Output: 4
335
- *
336
- * // Navigate back through history (LIFO order)
337
- * while (!historyStack.isEmpty) {
338
- * const page = historyStack.pop().unwrap();
339
- * console.log(`Going back to: ${page}`);
340
- * }
341
- * // Output:
342
- * // Going back to: page4.html (last added, first removed)
343
- * // Going back to: page3.html
344
- * // Going back to: page2.html
345
- * // Going back to: page1.html
188
+ * assert(seededStack.size === 3);
189
+ * assert.deepStrictEqual(seededStack.pop(), Optional.some(30));
346
190
  * ```
191
+ *
192
+ * @template T The type of elements stored in the stack.
193
+ * @param initialValues Optional array of initial elements to populate the
194
+ * stack. Elements will be popped in reverse order of how they appear in the
195
+ * array (last array element will be popped first). If provided, the initial
196
+ * buffer capacity will be at least twice the array length.
197
+ * @returns A new Stack instance optimized for high-performance LIFO operations.
347
198
  */
348
199
  const createStack = (initialValues) => new StackClass(initialValues);
349
200
 
@@ -1 +1 @@
1
- {"version":3,"file":"stack.mjs","sources":["../../src/collections/stack.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoFA;;;;;;;;;;AAUG;AACH,MAAM,UAAU,CAAA;;AAEd,IAAA,OAAO;;AAGP,IAAA,SAAS;;AAGT,IAAA,SAAS;;AAGT,IAAA,OAAgB,iBAAiB,GAAG,CAAC;AAErC;;;AAGG;AACH,IAAA,WAAA,CAAY,gBAA8B,EAAE,EAAA;AAC1C,QAAA,MAAM,eAAe,GAAG,QAAQ,CAC9B,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,iBAAiB,EAAE,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC,CACjE;AAED,QAAA,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,IAAI,CACvB,EAAE,MAAM,EAAE,eAAe,EA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D;AAEA;;;;AAIG;IACH,OAAO,GAAA;QACL,MAAM,WAAW,GAAG,QAAQ,CAAC,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;AAChD,QAAA,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAC1B,EAAE,MAAM,EAAE,WAAW,EAAE,EACvB,MAAM,SAAS,CAChB;;QAGD,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;YACrC,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QAChC;AAEA,QAAA,IAAI,CAAC,OAAO,GAAG,SAAS;AACxB,QAAA,IAAI,CAAC,SAAS,GAAG,WAAW;IAC9B;;AAGF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDG;AACI,MAAM,WAAW,GAAG,CAAK,aAA4B,KAC1D,IAAI,UAAU,CAAI,aAAa;;;;"}
@@ -0,0 +1,3 @@
1
+ export * from './array/index.mjs';
2
+ export * from './index.mjs';
3
+ //# sourceMappingURL=entry-point.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entry-point.d.mts","sourceRoot":"","sources":["../src/entry-point.mts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC"}
@@ -0,0 +1,62 @@
1
+ import * as index from './array/impl/index.mjs';
2
+ export { index as Arr };
3
+ export { IMapMapped } from './collections/imap-mapped.mjs';
4
+ export { IMap } from './collections/imap.mjs';
5
+ export { ISetMapped } from './collections/iset-mapped.mjs';
6
+ export { ISet } from './collections/iset.mjs';
7
+ export { createQueue } from './collections/queue.mjs';
8
+ export { createStack } from './collections/stack.mjs';
9
+ export { expectType } from './expect-type.mjs';
10
+ export { match } from './functional/match.mjs';
11
+ export { Optional } from './functional/optional.mjs';
12
+ export { pipe } from './functional/pipe.mjs';
13
+ export { Result } from './functional/result.mjs';
14
+ export { hasKey } from './guard/has-key.mjs';
15
+ export { isNonEmptyString } from './guard/is-non-empty-string.mjs';
16
+ export { isNonNullObject } from './guard/is-non-null-object.mjs';
17
+ export { isPrimitive } from './guard/is-primitive.mjs';
18
+ export { isRecord } from './guard/is-record.mjs';
19
+ export { isBigint, isBoolean, isNonNullish, isNotBigint, isNotBoolean, isNotNull, isNotNumber, isNotString, isNotSymbol, isNotUndefined, isNull, isNullish, isNumber, isString, isSymbol, isUndefined } from './guard/is-type.mjs';
20
+ export { keyIsIn } from './guard/key-is-in.mjs';
21
+ export { range } from './iterator/range.mjs';
22
+ export { Json } from './json/json.mjs';
23
+ export { FiniteNumber, asFiniteNumber, isFiniteNumber } from './number/branded-types/finite-number.mjs';
24
+ export { Int, asInt, isInt } from './number/branded-types/int.mjs';
25
+ export { Int16, asInt16, isInt16 } from './number/branded-types/int16.mjs';
26
+ export { Int32, asInt32, isInt32 } from './number/branded-types/int32.mjs';
27
+ export { NonNegativeFiniteNumber, asNonNegativeFiniteNumber, isNonNegativeFiniteNumber } from './number/branded-types/non-negative-finite-number.mjs';
28
+ export { NonNegativeInt16, asNonNegativeInt16, isNonNegativeInt16 } from './number/branded-types/non-negative-int16.mjs';
29
+ export { NonNegativeInt32, asNonNegativeInt32, isNonNegativeInt32 } from './number/branded-types/non-negative-int32.mjs';
30
+ export { NonZeroFiniteNumber, asNonZeroFiniteNumber, isNonZeroFiniteNumber } from './number/branded-types/non-zero-finite-number.mjs';
31
+ export { NonZeroInt, asNonZeroInt, isNonZeroInt } from './number/branded-types/non-zero-int.mjs';
32
+ export { NonZeroInt16, asNonZeroInt16, isNonZeroInt16 } from './number/branded-types/non-zero-int16.mjs';
33
+ export { NonZeroInt32, asNonZeroInt32, isNonZeroInt32 } from './number/branded-types/non-zero-int32.mjs';
34
+ export { NonZeroSafeInt, asNonZeroSafeInt, isNonZeroSafeInt } from './number/branded-types/non-zero-safe-int.mjs';
35
+ export { NonZeroUint16, asNonZeroUint16, isNonZeroUint16 } from './number/branded-types/non-zero-uint16.mjs';
36
+ export { NonZeroUint32, asNonZeroUint32, isNonZeroUint32 } from './number/branded-types/non-zero-uint32.mjs';
37
+ export { PositiveFiniteNumber, asPositiveFiniteNumber, isPositiveFiniteNumber } from './number/branded-types/positive-finite-number.mjs';
38
+ export { PositiveInt, asPositiveInt, isPositiveInt } from './number/branded-types/positive-int.mjs';
39
+ export { PositiveInt16, asPositiveInt16, isPositiveInt16 } from './number/branded-types/positive-int16.mjs';
40
+ export { PositiveInt32, asPositiveInt32, isPositiveInt32 } from './number/branded-types/positive-int32.mjs';
41
+ export { PositiveSafeInt, asPositiveSafeInt, isPositiveSafeInt } from './number/branded-types/positive-safe-int.mjs';
42
+ export { PositiveUint16, asPositiveUint16, isPositiveUint16 } from './number/branded-types/positive-uint16.mjs';
43
+ export { PositiveUint32, asPositiveUint32, isPositiveUint32 } from './number/branded-types/positive-uint32.mjs';
44
+ export { SafeInt, asSafeInt, isSafeInt } from './number/branded-types/safe-int.mjs';
45
+ export { SafeUint, asSafeUint, isSafeUint } from './number/branded-types/safe-uint.mjs';
46
+ export { Uint, asUint, isUint } from './number/branded-types/uint.mjs';
47
+ export { Uint16, asUint16, isUint16 } from './number/branded-types/uint16.mjs';
48
+ export { Uint32, asUint32, isUint32 } from './number/branded-types/uint32.mjs';
49
+ export { Int8, asInt8, isInt8 } from './number/enum/int8.mjs';
50
+ export { Uint8, asUint8, isUint8 } from './number/enum/uint8.mjs';
51
+ export { Num } from './number/num.mjs';
52
+ export { TsDataForgeInternals } from './number/refined-number-utils.mjs';
53
+ export { Obj } from './object/object.mjs';
54
+ export { castDeepMutable, castMutable } from './others/cast-mutable.mjs';
55
+ export { castDeepReadonly, castReadonly } from './others/cast-readonly.mjs';
56
+ export { ifThen } from './others/if-then.mjs';
57
+ export { mapNullable } from './others/map-nullable.mjs';
58
+ export { memoizeFunction } from './others/memoize-function.mjs';
59
+ export { tp } from './others/tuple.mjs';
60
+ export { unknownToString } from './others/unknown-to-string.mjs';
61
+ export { createPromise } from './promise/promise.mjs';
62
+ //# sourceMappingURL=entry-point.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entry-point.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,199 +1,70 @@
1
1
  /**
2
2
  * Compile-time type assertion utility for TypeScript type testing.
3
3
  *
4
- * This function performs static type relationship checking at compile-time and has no runtime effect.
5
- * It is primarily used in test files to verify that TypeScript's type inference and type relationships
6
- * work as expected. The function will cause TypeScript compilation errors if the specified type
4
+ * This function performs static type relationship checking at compile-time and
5
+ * has no runtime effect. It is primarily used in test files to verify that
6
+ * TypeScript's type inference and type relationships work as expected. The
7
+ * function will cause TypeScript compilation errors if the specified type
7
8
  * relationship does not hold.
8
9
  *
9
10
  * ## Supported Type Relations
10
11
  *
11
12
  * ### Equality Relations
12
- * - **`"="` (strict equality)**: Asserts that types `A` and `B` are exactly the same type.
13
- * Uses TypeScript's internal type equality checking.
14
- * - **`"!="` (strict inequality)**: Asserts that types `A` and `B` are not exactly the same type.
13
+ *
14
+ * - **`"="` (strict equality)**: Asserts that types `A` and `B` are exactly the
15
+ * same type. Uses TypeScript's internal type equality checking.
16
+ * - **`"!="` (strict inequality)**: Asserts that types `A` and `B` are not
17
+ * exactly the same type.
15
18
  *
16
19
  * ### Assignability Relations
17
- * - **`"~="` (mutual assignability)**: Asserts that `A` extends `B` AND `B` extends `A`.
18
- * Types are structurally equivalent and mutually assignable.
19
- * - **`"<="` (subtype relation)**: Asserts that type `A` extends (is assignable to) type `B`.
20
- * Type `A` is a subtype of `B`.
21
- * - **`">="` (supertype relation)**: Asserts that type `B` extends (is assignable to) type `A`.
22
- * Type `A` is a supertype of `B`.
20
+ *
21
+ * - **`"~="` (mutual assignability)**: Asserts that `A` extends `B` AND `B`
22
+ * extends `A`. Types are structurally equivalent and mutually assignable.
23
+ * - **`"<="` (subtype relation)**: Asserts that type `A` extends (is assignable
24
+ * to) type `B`. Type `A` is a subtype of `B`.
25
+ * - **`">="` (supertype relation)**: Asserts that type `B` extends (is assignable
26
+ * to) type `A`. Type `A` is a supertype of `B`.
23
27
  *
24
28
  * ### Negative Assignability Relations
29
+ *
25
30
  * - **`"!<="` (not subtype)**: Asserts that type `A` does NOT extend type `B`.
26
31
  * - **`"!>="` (not supertype)**: Asserts that type `B` does NOT extend type `A`.
27
32
  *
28
33
  * ## Type Parameter Constraints
29
34
  *
30
- * @template A - The first type for comparison. Can be any TypeScript type including:
35
+ * @since 1.0.0
36
+ * @template A - The first type for comparison. Can be any TypeScript type
37
+ * including:
38
+ *
31
39
  * - Primitive types (string, number, boolean, etc.)
32
40
  * - Object types and interfaces
33
41
  * - Union and intersection types
34
42
  * - Generic types and type parameters
35
43
  * - Literal types and branded types
36
44
  * - Function types and return types
37
- * @template B - The second type for comparison. Same constraints as type `A`.
38
- *
39
- * @param _relation - A string literal representing the expected type relationship.
40
- * TypeScript's type system automatically infers and restricts the available operators
41
- * based on the actual relationship between types `A` and `B`. If an invalid relationship
42
- * is specified, TypeScript will show a compilation error.
43
- *
44
- * ## Usage Patterns
45
- *
46
- * ### Basic Type Testing
47
- * @example
48
- * ```typescript
49
- * import { expectType } from './expect-type.mjs';
50
- *
51
- * // Primitive type equality
52
- * expectType<string, string>("="); // ✓ exact match
53
- * expectType<number, string>("!="); // ✓ different types
54
- * expectType<42, number>("<="); // ✓ literal extends primitive
55
- * expectType<number, 42>(">="); // ✓ primitive is supertype
56
- *
57
- * // Type assertions will cause compilation errors for wrong relationships:
58
- * // expectType<string, number>("="); // ❌ TypeScript error
59
- * // expectType<number, string>("<="); // ❌ TypeScript error
60
- * ```
61
- *
62
- * ### Array and Tuple Type Validation
63
- * @example
64
- * ```typescript
65
- * // Testing array utility function return types
66
- * const zeros = Arr.zeros(3);
67
- * expectType<typeof zeros, readonly [0, 0, 0]>("=");
68
- *
69
- * const sequence = Arr.seq(5);
70
- * expectType<typeof sequence, readonly [0, 1, 2, 3, 4]>("=");
71
- *
72
- * // Dynamic length arrays
73
- * const dynamicArray = Arr.zeros(someLength);
74
- * expectType<typeof dynamicArray, readonly 0[]>("=");
75
- * ```
76
- *
77
- * ### Function Return Type Testing
78
- * @example
79
- * ```typescript
80
- * // Testing function return types
81
- * const createUser = () => ({ id: 1, name: 'John' });
82
- * expectType<ReturnType<typeof createUser>, { id: number; name: string }>("~=");
83
- *
84
- * // Generic function type inference
85
- * const identity = <T>(x: T): T => x;
86
- * const result = identity('hello');
87
- * expectType<typeof result, string>("=");
88
- * ```
89
- *
90
- * ### Union and Intersection Types
91
- * @example
92
- * ```typescript
93
- * // Union type relationships
94
- * expectType<string, string | number>("<="); // string extends union
95
- * expectType<string | number, string>(">="); // union contains string
96
- * expectType<string | number, number>(">="); // union contains number
97
- *
98
- * // Intersection type relationships
99
- * type A = { a: number };
100
- * type B = { b: string };
101
- * expectType<A & B, A>(">="); // intersection extends component
102
- * expectType<A, A & B>("<="); // component extends intersection
103
- * ```
104
45
  *
105
- * ### Branded Type Validation
106
- * @example
107
- * ```typescript
108
- * // Testing branded number types
109
- * expectType<PositiveInt, number>("<="); // branded type extends base
110
- * expectType<number, PositiveInt>(">="); // base type is supertype
111
- * expectType<PositiveInt, NegativeInt>("!="); // different branded types
112
- *
113
- * // Type guard function validation
114
- * if (isPositiveInt(value)) {
115
- * expectType<typeof value, PositiveInt>("<=");
116
- * }
117
- * ```
118
- *
119
- * ### Optional and Result Type Testing
120
- * @example
121
- * ```typescript
122
- * // Optional type narrowing
123
- * const optional: Optional<number> = Optional.some(42);
124
- * if (Optional.isSome(optional)) {
125
- * expectType<typeof optional, Optional.Some<number>>("<=");
126
- * }
127
- * if (Optional.isNone(optional)) {
128
- * expectType<typeof optional, Optional.None>("<=");
129
- * }
130
- *
131
- * // Result type validation
132
- * const result: Result<string, Error> = Result.ok('success');
133
- * expectType<typeof result, Result<string, Error>>("<=");
134
- * ```
135
- *
136
- * ### Type Guard and Validation Testing
137
- * @example
138
- * ```typescript
139
- * // Testing type guard functions
140
- * if (isRecord(value)) {
141
- * expectType<typeof value, UnknownRecord>("<=");
142
- * }
143
- *
144
- * // Testing compile-time type predicates
145
- * const obj = { key: 'value' };
146
- * if (hasKey(obj, 'key')) {
147
- * expectType<typeof obj.key, unknown>("<=");
148
- * }
149
- * ```
150
- *
151
- * ## Common Testing Patterns
152
- *
153
- * ### Dual Testing Strategy
154
- * Combine `expectType` with runtime assertions for comprehensive testing:
155
- *
156
- * @example
157
- * ```typescript
158
- * describe('Arr.zeros', () => {
159
- * test('should create array of zeros with correct type', () => {
160
- * const result = Arr.zeros(3);
161
- *
162
- * // Compile-time type assertion
163
- * expectType<typeof result, readonly [0, 0, 0]>("=");
164
- *
165
- * // Runtime behavior assertion
166
- * expect(result).toStrictEqual([0, 0, 0]);
167
- * });
168
- * });
169
- * ```
170
- *
171
- * ### Type Relationship Validation
172
- * Test complex type hierarchies and relationships:
173
- *
174
- * @example
175
- * ```typescript
176
- * // Ensure proper type hierarchy
177
- * expectType<PositiveInt, Int>("<="); // positive is subset of int
178
- * expectType<Int, FiniteNumber>("<="); // int is subset of finite
179
- * expectType<FiniteNumber, number>("<="); // finite is subset of number
180
- *
181
- * // Verify mutual exclusion
182
- * expectType<PositiveInt, NegativeInt>("!="); // different int types
183
- * expectType<PositiveInt, NegativeInt>("!<="); // neither extends the other
184
- * expectType<NegativeInt, PositiveInt>("!<=");
185
- * ```
186
- *
187
- * ## Important Notes
188
- *
189
- * - **Compile-time only**: This function has no runtime behavior and will be optimized away.
190
- * - **Type inference**: The available relation operators are automatically inferred by TypeScript
191
- * based on the actual type relationship between `A` and `B`.
192
- * - **Error feedback**: Invalid type relationships will cause clear TypeScript compilation errors.
193
- * - **Test organization**: Typically used in `.test.mts` files alongside runtime assertions.
194
- * - **Performance**: Has zero runtime overhead as it's purely a compile-time construct.
195
- *
196
- * @since 1.0.0
46
+ * @template B - The second type for comparison. Same constraints as type `A`.
47
+ * @param _relation - A string literal representing the expected type
48
+ * relationship. TypeScript's type system automatically infers and restricts
49
+ * the available operators based on the actual relationship between types `A`
50
+ * and `B`. If an invalid relationship is specified, TypeScript will show a
51
+ * compilation error.
52
+ *
53
+ * Combine `expectType` with runtime assertions for comprehensive testing:
54
+ *
55
+ * ## Important Notes
56
+ *
57
+ * - **Compile-time only**: This function has no runtime behavior and will be
58
+ * optimized away.
59
+ * - **Type inference**: The available relation operators are automatically
60
+ * inferred by TypeScript based on the actual type relationship between
61
+ * `A` and `B`.
62
+ * - **Error feedback**: Invalid type relationships will cause clear TypeScript
63
+ * compilation errors.
64
+ * - **Test organization**: Typically used in `.test.mts` files alongside runtime
65
+ * assertions.
66
+ * - **Performance**: Has zero runtime overhead as it's purely a compile-time
67
+ * construct.
197
68
  */
198
69
  export declare const expectType: <A, B>(_relation: TypeEq<A, B> extends true ? "<=" | "=" | ">=" | "~=" : "!=" | (TypeExtends<A, B> extends true ? "<=" | (TypeExtends<B, A> extends true ? ">=" | "~=" : "!>=") : "!<=" | (TypeExtends<B, A> extends true ? ">=" : "!>="))) => void;
199
70
  //# sourceMappingURL=expect-type.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"expect-type.d.mts","sourceRoot":"","sources":["../src/expect-type.mts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoMG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,EAAE,CAAC,EAC7B,WAAW,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,SAAS,IAAI,GAChC,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,GAEpB,IAAI,GACJ,CA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