ts-data-forge 3.3.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 (424) hide show
  1. package/README.md +37 -13
  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 +1 -0
  83. package/dist/entry-point.d.mts.map +1 -1
  84. package/dist/entry-point.mjs +2 -1
  85. package/dist/entry-point.mjs.map +1 -1
  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 +12 -126
  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/package.json +47 -39
  300. package/src/array/impl/array-utils-creation.mts +192 -0
  301. package/src/array/{array-utils-creation.test.mts → impl/array-utils-creation.test.mts} +121 -72
  302. package/src/array/impl/array-utils-element-access.mts +115 -0
  303. package/src/array/impl/array-utils-element-access.test.mts +151 -0
  304. package/src/array/impl/array-utils-iterators.mts +79 -0
  305. package/src/array/impl/array-utils-iterators.test.mts +98 -0
  306. package/src/array/impl/array-utils-modification.mts +434 -0
  307. package/src/array/{array-utils-modification.test.mts → impl/array-utils-modification.test.mts} +41 -28
  308. package/src/array/{array-utils-overload-type-error.test.mts → impl/array-utils-overload-type-error.test.mts} +33 -33
  309. package/src/array/impl/array-utils-reducing-value.mts +551 -0
  310. package/src/array/{array-utils-reducing-value.test.mts → impl/array-utils-reducing-value.test.mts} +45 -50
  311. package/src/array/impl/array-utils-search.mts +509 -0
  312. package/src/array/impl/array-utils-search.test.mts +346 -0
  313. package/src/array/impl/array-utils-set-op.mts +166 -0
  314. package/src/array/{array-utils-set-op.test.mts → impl/array-utils-set-op.test.mts} +42 -35
  315. package/src/array/impl/array-utils-size.mts +30 -0
  316. package/src/array/impl/array-utils-size.test.mts +9 -0
  317. package/src/array/impl/array-utils-slice-clamped.mts +51 -0
  318. package/src/array/{array-utils-slice-clamped.test.mts → impl/array-utils-slice-clamped.test.mts} +12 -12
  319. package/src/array/impl/array-utils-slicing.mts +275 -0
  320. package/src/array/impl/array-utils-slicing.test.mts +158 -0
  321. package/src/array/impl/array-utils-transformation.mts +746 -0
  322. package/src/array/{array-utils-transformation.test.mts → impl/array-utils-transformation.test.mts} +662 -889
  323. package/src/array/impl/array-utils-validation.mts +241 -0
  324. package/src/array/{array-utils-validation.test.mts → impl/array-utils-validation.test.mts} +194 -107
  325. package/src/array/{array.test.mts → impl/array.test.mts} +2 -2
  326. package/src/array/impl/index.mts +12 -0
  327. package/src/array/index.mts +1 -1
  328. package/src/collections/imap-mapped.mts +99 -265
  329. package/src/collections/imap.mts +477 -174
  330. package/src/collections/imap.test.mts +12 -19
  331. package/src/collections/iset-mapped.mts +892 -358
  332. package/src/collections/iset.mts +429 -213
  333. package/src/collections/queue.mts +174 -200
  334. package/src/collections/stack.mts +172 -245
  335. package/src/collections/stack.test.mts +9 -1
  336. package/src/entry-point.mts +1 -0
  337. package/src/expect-type.mts +43 -172
  338. package/src/functional/match.mts +35 -145
  339. package/src/functional/optional.mts +285 -163
  340. package/src/functional/optional.test.mts +4 -1
  341. package/src/functional/pipe.mts +60 -113
  342. package/src/functional/result.mts +452 -351
  343. package/src/functional/result.test.mts +9 -2
  344. package/src/globals.d.mts +12 -5
  345. package/src/guard/has-key.mts +23 -74
  346. package/src/guard/is-non-empty-string.mts +20 -87
  347. package/src/guard/is-non-null-object.mts +14 -84
  348. package/src/guard/is-non-null-object.test.mts +1 -1
  349. package/src/guard/is-primitive.mts +13 -126
  350. package/src/guard/is-primitive.test.mts +1 -1
  351. package/src/guard/is-record.mts +21 -132
  352. package/src/guard/is-type.mts +201 -238
  353. package/src/guard/is-type.test.mts +7 -7
  354. package/src/guard/key-is-in.mts +22 -139
  355. package/src/index.mts +0 -1
  356. package/src/iterator/range.mts +29 -62
  357. package/src/json/json.mts +202 -134
  358. package/src/json/json.test.mts +1 -3
  359. package/src/number/branded-types/finite-number.mts +27 -159
  360. package/src/number/branded-types/int.mts +122 -120
  361. package/src/number/branded-types/int16.mts +22 -30
  362. package/src/number/branded-types/int16.test.mts +24 -24
  363. package/src/number/branded-types/int32.mts +22 -31
  364. package/src/number/branded-types/int32.test.mts +39 -39
  365. package/src/number/branded-types/non-negative-finite-number.mts +31 -39
  366. package/src/number/branded-types/non-negative-int16.mts +24 -34
  367. package/src/number/branded-types/non-negative-int16.test.mts +16 -16
  368. package/src/number/branded-types/non-negative-int32.mts +26 -35
  369. package/src/number/branded-types/non-negative-int32.test.mts +30 -30
  370. package/src/number/branded-types/non-zero-finite-number.mts +25 -40
  371. package/src/number/branded-types/non-zero-int.mts +15 -30
  372. package/src/number/branded-types/non-zero-int16.mts +27 -35
  373. package/src/number/branded-types/non-zero-int16.test.mts +26 -26
  374. package/src/number/branded-types/non-zero-int32.mts +29 -36
  375. package/src/number/branded-types/non-zero-int32.test.mts +45 -42
  376. package/src/number/branded-types/non-zero-safe-int.mts +39 -40
  377. package/src/number/branded-types/non-zero-uint16.mts +24 -35
  378. package/src/number/branded-types/non-zero-uint16.test.mts +16 -16
  379. package/src/number/branded-types/non-zero-uint32.mts +24 -35
  380. package/src/number/branded-types/non-zero-uint32.test.mts +28 -28
  381. package/src/number/branded-types/positive-finite-number.mts +29 -43
  382. package/src/number/branded-types/positive-int.mts +134 -124
  383. package/src/number/branded-types/positive-int16.mts +24 -35
  384. package/src/number/branded-types/positive-int16.test.mts +14 -14
  385. package/src/number/branded-types/positive-int32.mts +24 -35
  386. package/src/number/branded-types/positive-int32.test.mts +26 -26
  387. package/src/number/branded-types/positive-safe-int.mts +160 -34
  388. package/src/number/branded-types/positive-uint16.mts +24 -35
  389. package/src/number/branded-types/positive-uint16.test.mts +16 -16
  390. package/src/number/branded-types/positive-uint32.mts +26 -36
  391. package/src/number/branded-types/positive-uint32.test.mts +31 -28
  392. package/src/number/branded-types/safe-int.mts +142 -101
  393. package/src/number/branded-types/safe-uint.mts +25 -34
  394. package/src/number/branded-types/uint.mts +121 -30
  395. package/src/number/branded-types/uint16.mts +26 -34
  396. package/src/number/branded-types/uint16.test.mts +16 -16
  397. package/src/number/branded-types/uint32.mts +26 -68
  398. package/src/number/branded-types/uint32.test.mts +28 -28
  399. package/src/number/enum/int8.mts +39 -170
  400. package/src/number/enum/uint8.mts +46 -155
  401. package/src/number/num.mts +157 -212
  402. package/src/number/num.test.mts +4 -4
  403. package/src/number/refined-number-utils.mts +109 -26
  404. package/src/object/object.mts +130 -212
  405. package/src/object/object.test.mts +29 -0
  406. package/src/others/cast-mutable.mts +13 -89
  407. package/src/others/cast-mutable.test.mts +80 -0
  408. package/src/others/cast-readonly.mts +13 -169
  409. package/src/others/if-then.mts +6 -83
  410. package/src/others/map-nullable.mts +12 -136
  411. package/src/others/map-nullable.test.mts +6 -6
  412. package/src/others/memoize-function.mts +14 -157
  413. package/src/others/tuple.mts +33 -151
  414. package/src/others/unknown-to-string.mts +12 -126
  415. package/src/others/unknown-to-string.test.mts +13 -1
  416. package/src/promise/promise.mts +34 -21
  417. package/src/promise/promise.test.mts +43 -0
  418. package/dist/array/array-utils.d.mts +0 -2956
  419. package/dist/array/array-utils.d.mts.map +0 -1
  420. package/dist/array/array-utils.mjs +0 -1838
  421. package/dist/array/array-utils.mjs.map +0 -1
  422. package/src/array/array-utils-search.test.mts +0 -169
  423. package/src/array/array-utils-slicing.test.mts +0 -274
  424. package/src/array/array-utils.mts +0 -4834
@@ -3,49 +3,32 @@ import { asUint32 } from '../number/index.mjs';
3
3
  import { tp } from '../others/index.mjs';
4
4
 
5
5
  /**
6
- * Interface for an immutable map with custom key mapping and O(1) lookup performance.
6
+ * Interface for an immutable map with custom key mapping and lookup operations.
7
7
  *
8
- * IMapMapped allows you to use complex objects as keys by providing transformation functions
9
- * that convert between your custom key type `K` and a primitive `MapSetKeyType` `KM` that can
10
- * be efficiently stored in JavaScript's native Map. This enables high-performance operations
11
- * on maps with complex keys while maintaining type safety and immutability.
8
+ * IMapMapped allows you to use complex objects as keys by providing
9
+ * transformation functions that convert between your custom key type `K` and a
10
+ * primitive `MapSetKeyType` `KM` that can be efficiently stored in JavaScript's
11
+ * native Map. This enables operations on maps with complex keys while
12
+ * maintaining type safety and immutability.
12
13
  *
13
14
  * **Key Features:**
14
- * - **Custom Key Types**: Use any type as keys by providing `toKey`/`fromKey` functions
15
- * - **O(1) Performance**: Maintains O(1) average-case performance for core operations
15
+ *
16
+ * - **Custom Key Types**: Use any type as keys by providing `toKey`/`fromKey`
17
+ * functions
16
18
  * - **Immutable**: All operations return new instances, preserving immutability
17
19
  * - **Type Safe**: Full TypeScript support with generic key/value types
18
20
  *
19
21
  * **Performance Characteristics:**
20
- * - get/has/delete: O(1) average case (plus key transformation overhead)
21
- * - set: O(1) average case (plus key transformation overhead)
22
+ *
23
+ * - get/has: O(1) average case (plus key transformation overhead)
24
+ * - set/delete: O(n) due to copying for immutability (plus key transformation
25
+ * overhead)
22
26
  * - map/filter operations: O(n)
23
- * - Iteration: O(n) (plus key transformation overhead)
27
+ * - iteration: O(n) (plus key transformation overhead)
24
28
  *
25
29
  * @template K The type of the custom keys in the map.
26
30
  * @template V The type of the values in the map.
27
31
  * @template KM The type of the mapped primitive keys (string, number, etc.).
28
- *
29
- * @example
30
- * ```typescript
31
- * // Example with complex object keys
32
- * type UserId = { department: string; employeeId: number };
33
- *
34
- * // Define transformation functions
35
- * const userIdToKey = (id: UserId): string => `${id.department}:${id.employeeId}`;
36
- * const keyToUserId = (key: string): UserId => {
37
- * const [department, employeeId] = key.split(':');
38
- * return { department, employeeId: Number(employeeId) };
39
- * };
40
- *
41
- * declare const userMap: IMapMapped<UserId, UserProfile, string>;
42
- *
43
- * // All operations work with the complex key type
44
- * const userId: UserId = { department: "engineering", employeeId: 123 };
45
- * const hasUser = userMap.has(userId); // O(1)
46
- * const profile = userMap.get(userId).unwrapOr(defaultProfile); // O(1)
47
- * const updated = userMap.set(userId, newProfile); // O(1) - returns new IMapMapped
48
- * ```
49
32
  */
50
33
  type IMapMappedInterface<K, V, KM extends MapSetKeyType> = Readonly<{
51
34
  // Getting information
@@ -55,6 +38,7 @@ type IMapMappedInterface<K, V, KM extends MapSetKeyType> = Readonly<{
55
38
 
56
39
  /**
57
40
  * Checks if a key exists in the map.
41
+ *
58
42
  * @param key The key to check.
59
43
  * @returns `true` if the key exists, `false` otherwise.
60
44
  */
@@ -62,8 +46,10 @@ type IMapMappedInterface<K, V, KM extends MapSetKeyType> = Readonly<{
62
46
 
63
47
  /**
64
48
  * Retrieves the value associated with a key.
49
+ *
65
50
  * @param key The key to retrieve.
66
- * @returns The value associated with the key wrapped with `Optional.some`, or `Optional.none` if the key does not exist.
51
+ * @returns The value associated with the key wrapped with `Optional.some`, or
52
+ * `Optional.none` if the key does not exist.
67
53
  */
68
54
  get: (key: K) => Optional<V>;
69
55
 
@@ -71,13 +57,16 @@ type IMapMappedInterface<K, V, KM extends MapSetKeyType> = Readonly<{
71
57
 
72
58
  /**
73
59
  * Checks if all elements in the map satisfy a predicate.
60
+ *
74
61
  * @param predicate A function to test each key-value pair.
75
62
  * @returns `true` if all elements satisfy the predicate, `false` otherwise.
76
63
  */
77
64
  every: ((predicate: (value: V, key: K) => boolean) => boolean) &
78
65
  /**
79
- * Checks if all elements in the map satisfy a type predicate.
80
- * Narrows the type of values in the map if the predicate returns true for all elements.
66
+ * Checks if all elements in the map satisfy a type predicate. Narrows the
67
+ * type of values in the map if the predicate returns true for all
68
+ * elements.
69
+ *
81
70
  * @template W The narrowed type of the values.
82
71
  * @param predicate A type predicate function.
83
72
  * @returns `true` if all elements satisfy the predicate, `false` otherwise.
@@ -88,14 +77,18 @@ type IMapMappedInterface<K, V, KM extends MapSetKeyType> = Readonly<{
88
77
 
89
78
  /**
90
79
  * Checks if at least one element in the map satisfies a predicate.
80
+ *
91
81
  * @param predicate A function to test each key-value pair.
92
- * @returns `true` if at least one element satisfies the predicate, `false` otherwise.
82
+ * @returns `true` if at least one element satisfies the predicate, `false`
83
+ * otherwise.
93
84
  */
94
85
  some: (predicate: (value: V, key: K) => boolean) => boolean;
95
86
 
96
87
  // Mutation
88
+
97
89
  /**
98
90
  * Deletes a key-value pair from the map.
91
+ *
99
92
  * @param key The key to delete.
100
93
  * @returns A new IMapMapped instance without the specified key.
101
94
  */
@@ -103,6 +96,7 @@ type IMapMappedInterface<K, V, KM extends MapSetKeyType> = Readonly<{
103
96
 
104
97
  /**
105
98
  * Sets a key-value pair in the map.
99
+ *
106
100
  * @param key The key to set.
107
101
  * @param value The value to associate with the key.
108
102
  * @returns A new IMapMapped instance with the specified key-value pair.
@@ -111,14 +105,17 @@ type IMapMappedInterface<K, V, KM extends MapSetKeyType> = Readonly<{
111
105
 
112
106
  /**
113
107
  * Updates the value associated with a key using an updater function.
108
+ *
114
109
  * @param key The key whose value to update.
115
- * @param updater A function that takes the current value and returns the new value.
110
+ * @param updater A function that takes the current value and returns the new
111
+ * value.
116
112
  * @returns A new IMapMapped instance with the updated value.
117
113
  */
118
114
  update: (key: K, updater: (value: V) => V) => IMapMapped<K, V, KM>;
119
115
 
120
116
  /**
121
117
  * Applies a series of mutations to the map.
118
+ *
122
119
  * @param actions An array of mutation actions (delete, set, or update).
123
120
  * @returns A new IMapMapped instance with all mutations applied.
124
121
  */
@@ -134,6 +131,7 @@ type IMapMappedInterface<K, V, KM extends MapSetKeyType> = Readonly<{
134
131
 
135
132
  /**
136
133
  * Maps the values of the map to new values.
134
+ *
137
135
  * @template V2 The type of the new values.
138
136
  * @param mapFn A function that maps a value and key to a new value.
139
137
  * @returns A new IMapMapped instance with mapped values.
@@ -141,8 +139,9 @@ type IMapMappedInterface<K, V, KM extends MapSetKeyType> = Readonly<{
141
139
  map: <V2>(mapFn: (value: V, key: K) => V2) => IMapMapped<K, V2, KM>;
142
140
 
143
141
  /**
144
- * Maps the keys of the map to new keys.
145
- * Note: The key type cannot be changed because `toKey` and `fromKey` would become unusable.
142
+ * Maps the keys of the map to new keys. Note: The key type cannot be changed
143
+ * because `toKey` and `fromKey` would become unusable.
144
+ *
146
145
  * @param mapFn A function that maps a key to a new key of the same type.
147
146
  * @returns A new IMapMapped instance with mapped keys.
148
147
  */
@@ -150,8 +149,10 @@ type IMapMappedInterface<K, V, KM extends MapSetKeyType> = Readonly<{
150
149
 
151
150
  /**
152
151
  * Maps the entries (key-value pairs) of the map to new entries.
152
+ *
153
153
  * @template V2 The type of the new values in the entries.
154
- * @param mapFn A function that maps an entry to a new entry (key must remain the same type).
154
+ * @param mapFn A function that maps an entry to a new entry (key must remain
155
+ * the same type).
155
156
  * @returns A new IMapMapped instance with mapped entries.
156
157
  */
157
158
  mapEntries: <V2>(
@@ -162,6 +163,7 @@ type IMapMappedInterface<K, V, KM extends MapSetKeyType> = Readonly<{
162
163
 
163
164
  /**
164
165
  * Executes a callback function for each key-value pair in the map.
166
+ *
165
167
  * @param callbackfn A function to execute for each element.
166
168
  */
167
169
  forEach: (callbackfn: (value: V, key: K) => void) => void;
@@ -170,18 +172,21 @@ type IMapMappedInterface<K, V, KM extends MapSetKeyType> = Readonly<{
170
172
 
171
173
  /**
172
174
  * Returns an iterator for the keys in the map.
175
+ *
173
176
  * @returns An iterable iterator of keys.
174
177
  */
175
178
  keys: () => IterableIterator<K>;
176
179
 
177
180
  /**
178
181
  * Returns an iterator for the values in the map.
182
+ *
179
183
  * @returns An iterable iterator of values.
180
184
  */
181
185
  values: () => IterableIterator<V>;
182
186
 
183
187
  /**
184
188
  * Returns an iterator for the entries (key-value pairs) in the map.
189
+ *
185
190
  * @returns An iterable iterator of entries.
186
191
  */
187
192
  entries: () => IterableIterator<readonly [K, V]>;
@@ -190,52 +195,62 @@ type IMapMappedInterface<K, V, KM extends MapSetKeyType> = Readonly<{
190
195
 
191
196
  /**
192
197
  * Converts the keys of the map to an array.
198
+ *
193
199
  * @returns A readonly array of keys.
194
200
  */
195
201
  toKeysArray: () => readonly K[];
196
202
 
197
203
  /**
198
204
  * Converts the values of the map to an array.
205
+ *
199
206
  * @returns A readonly array of values.
200
207
  */
201
208
  toValuesArray: () => readonly V[];
202
209
 
203
210
  /**
204
211
  * Converts the entries (key-value pairs) of the map to an array.
212
+ *
205
213
  * @returns A readonly array of entries.
206
214
  */
207
215
  toEntriesArray: () => readonly (readonly [K, V])[];
208
216
 
209
217
  /**
210
- * Converts the map to an array of entries (key-value pairs).
211
- * Alias for `toEntriesArray`.
218
+ * Converts the map to an array of entries (key-value pairs). Alias for
219
+ * `toEntriesArray`.
220
+ *
212
221
  * @returns A readonly array of entries.
213
222
  */
214
223
  toArray: () => readonly (readonly [K, V])[];
215
224
 
216
225
  /**
217
226
  * Returns the underlying readonly JavaScript Map.
227
+ *
218
228
  * @returns The raw ReadonlyMap instance.
219
229
  */
220
230
  toRawMap: () => ReadonlyMap<KM, V>;
221
231
  }>;
222
232
 
223
233
  /**
224
- * Represents an immutable map with custom key transformation and high-performance operations.
234
+ * Represents an immutable map with custom key transformation and
235
+ * high-performance operations.
225
236
  *
226
- * IMapMapped is a specialized persistent data structure that enables using complex objects as map keys
227
- * while maintaining the performance benefits of JavaScript's native Map. It achieves this by requiring
228
- * bidirectional transformation functions that convert between your custom key type and a primitive type
229
- * that can be efficiently stored and compared.
237
+ * IMapMapped is a specialized persistent data structure that enables using
238
+ * complex objects as map keys while maintaining the performance benefits of
239
+ * JavaScript's native Map. It achieves this by requiring bidirectional
240
+ * transformation functions that convert between your custom key type and a
241
+ * primitive type that can be efficiently stored and compared.
230
242
  *
231
243
  * **Key Features:**
244
+ *
232
245
  * - **Complex Keys**: Use objects, arrays, or any custom type as map keys
233
- * - **High Performance**: O(1) operations through efficient key transformation
234
246
  * - **Immutable**: All mutation operations return new instances
235
- * - **Type Safe**: Full TypeScript support with compile-time key/value type checking
236
- * - **Bidirectional**: Maintains ability to reconstruct original keys from mapped keys
247
+ * - **Type Safe**: Full TypeScript support with compile-time key/value type
248
+ * checking
249
+ * - **Bidirectional**: Maintains ability to reconstruct original keys from mapped
250
+ * keys
237
251
  *
238
252
  * **Use Cases:**
253
+ *
239
254
  * - Maps with composite keys (e.g., coordinates, user IDs with metadata)
240
255
  * - Caching with complex cache keys
241
256
  * - State management where entities have multi-part identifiers
@@ -244,75 +259,22 @@ type IMapMappedInterface<K, V, KM extends MapSetKeyType> = Readonly<{
244
259
  * @template K The type of the custom keys in the map.
245
260
  * @template V The type of the values in the map.
246
261
  * @template KM The type of the mapped primitive keys (string, number, etc.).
247
- *
248
- * @example
249
- * ```typescript
250
- * // Example: Product catalog with composite keys
251
- * type ProductKey = { brand: string; model: string; year: number };
252
- * type Product = { name: string; price: number; inStock: boolean };
253
- *
254
- * // Define bidirectional transformation functions
255
- * const productKeyToString = (key: ProductKey): string =>
256
- * `${key.brand}|${key.model}|${key.year}`;
257
- *
258
- * const stringToProductKey = (str: string): ProductKey => {
259
- * const [brand, model, yearStr] = str.split('|');
260
- * return { brand, model, year: Number(yearStr) };
261
- * };
262
- *
263
- * // Create a map with complex keys
264
- * let catalog = IMapMapped.create<ProductKey, Product, string>(
265
- * [],
266
- * productKeyToString,
267
- * stringToProductKey
268
- * );
269
- *
270
- * // Use complex objects as keys naturally
271
- * const toyotaCamry2023: ProductKey = { brand: "Toyota", model: "Camry", year: 2023 };
272
- * const hondaAccord2022: ProductKey = { brand: "Honda", model: "Accord", year: 2022 };
273
- *
274
- * catalog = catalog
275
- * .set(toyotaCamry2023, { name: "Toyota Camry 2023", price: 28000, inStock: true })
276
- * .set(hondaAccord2022, { name: "Honda Accord 2022", price: 26500, inStock: false });
277
- *
278
- * // All operations work with the original key type
279
- * console.log(catalog.get(toyotaCamry2023).unwrapOr(notFound).name);
280
- * // Output: "Toyota Camry 2023"
281
- *
282
- * console.log(catalog.has(hondaAccord2022)); // Output: true
283
- * console.log(catalog.size); // Output: 2
284
- *
285
- * // Iteration preserves original key types
286
- * for (const [productKey, product] of catalog) {
287
- * console.log(`${productKey.brand} ${productKey.model} (${productKey.year}): $${product.price}`);
288
- * }
289
- * // Output:
290
- * // Toyota Camry (2023): $28000
291
- * // Honda Accord (2022): $26500
292
- *
293
- * // Functional transformations work seamlessly
294
- * const discountedCatalog = catalog.map((product, key) => ({
295
- * ...product,
296
- * price: Math.round(product.price * 0.9) // 10% discount
297
- * }));
298
- * ```
299
262
  */
300
263
  export type IMapMapped<K, V, KM extends MapSetKeyType> = Iterable<
301
264
  readonly [K, V]
302
265
  > &
303
266
  IMapMappedInterface<K, V, KM>;
304
267
 
305
- /**
306
- * Provides utility functions for IMapMapped.
307
- */
268
+ /** Provides utility functions for IMapMapped. */
308
269
  export namespace IMapMapped {
309
270
  /**
310
271
  * Creates a new IMapMapped instance with custom key transformation functions.
311
272
  *
312
- * This factory function creates an immutable map that can use complex objects as keys
313
- * by providing bidirectional transformation functions. The `toKey` function converts
314
- * your custom key type to a primitive type that can be efficiently stored, while
315
- * `fromKey` reconstructs the original key type for iteration and access.
273
+ * This factory function creates an immutable map that can use complex objects
274
+ * as keys by providing bidirectional transformation functions. The `toKey`
275
+ * function converts your custom key type to a primitive type that can be
276
+ * efficiently stored, while `fromKey` reconstructs the original key type for
277
+ * iteration and access.
316
278
  *
317
279
  * **Performance:** O(n) where n is the number of entries in the iterable.
318
280
  *
@@ -320,83 +282,13 @@ export namespace IMapMapped {
320
282
  * @template V The type of the values.
321
283
  * @template KM The type of the mapped primitive keys.
322
284
  * @param iterable An iterable of key-value pairs using the custom key type.
323
- * @param toKey A function that converts a custom key `K` to a primitive key `KM`.
324
- * This function must be deterministic and produce unique values for unique keys.
325
- * @param fromKey A function that converts a primitive key `KM` back to the custom key `K`.
326
- * This should be the inverse of `toKey`.
327
- * @returns A new IMapMapped instance containing all entries from the iterable.
328
- *
329
- * @example
330
- * ```typescript
331
- * // Example 1: Geographic coordinates as keys
332
- * type Coordinate = { lat: number; lng: number };
333
- * type LocationInfo = { name: string; population: number };
334
- *
335
- * const coordToString = (coord: Coordinate): string => `${coord.lat},${coord.lng}`;
336
- * const stringToCoord = (str: string): Coordinate => {
337
- * const [lat, lng] = str.split(',').map(Number);
338
- * return { lat, lng };
339
- * };
340
- *
341
- * const locationMap = IMapMapped.create<Coordinate, LocationInfo, string>(
342
- * [
343
- * [{ lat: 40.7128, lng: -74.0060 }, { name: "New York", population: 8000000 }],
344
- * [{ lat: 34.0522, lng: -118.2437 }, { name: "Los Angeles", population: 4000000 }]
345
- * ],
346
- * coordToString,
347
- * stringToCoord
348
- * );
349
- *
350
- * const nyCoord = { lat: 40.7128, lng: -74.0060 };
351
- * console.log(locationMap.get(nyCoord).unwrap().name); // Output: "New York"
352
- *
353
- * // Example 2: Multi-part business keys
354
- * type OrderId = { customerId: string; year: number; orderNumber: number };
355
- *
356
- * const orderIdToKey = (id: OrderId): string =>
357
- * `${id.customerId}:${id.year}:${id.orderNumber}`;
358
- *
359
- * const keyToOrderId = (key: string): OrderId => {
360
- * const [customerId, yearStr, orderNumStr] = key.split(':');
361
- * return {
362
- * customerId,
363
- * year: Number(yearStr),
364
- * orderNumber: Number(orderNumStr)
365
- * };
366
- * };
367
- *
368
- * const orderMap = IMapMapped.create<OrderId, Order, string>(
369
- * [],
370
- * orderIdToKey,
371
- * keyToOrderId
372
- * );
373
- *
374
- * // Example 3: Simple case with string keys (identity transformation)
375
- * const simpleMap = IMapMapped.create<string, number, string>(
376
- * [["key1", 100], ["key2", 200]],
377
- * (s) => s, // identity function
378
- * (s) => s // identity function
379
- * );
380
- *
381
- * // Example 4: From existing data structures
382
- * const existingEntries = new Map([
383
- * [{ id: 1, type: "user" }, { name: "Alice", active: true }],
384
- * [{ id: 2, type: "user" }, { name: "Bob", active: false }]
385
- * ]);
386
- *
387
- * type EntityKey = { id: number; type: string };
388
- * const entityKeyToString = (key: EntityKey): string => `${key.type}_${key.id}`;
389
- * const stringToEntityKey = (str: string): EntityKey => {
390
- * const [type, idStr] = str.split('_');
391
- * return { type, id: Number(idStr) };
392
- * };
393
- *
394
- * const entityMap = IMapMapped.create<EntityKey, Entity, string>(
395
- * existingEntries,
396
- * entityKeyToString,
397
- * stringToEntityKey
398
- * );
399
- * ```
285
+ * @param toKey A function that converts a custom key `K` to a primitive key
286
+ * `KM`. This function must be deterministic and produce unique values for
287
+ * unique keys.
288
+ * @param fromKey A function that converts a primitive key `KM` back to the
289
+ * custom key `K`. This should be the inverse of `toKey`.
290
+ * @returns A new IMapMapped instance containing all entries from the
291
+ * iterable.
400
292
  */
401
293
  export const create = <K, V, KM extends MapSetKeyType>(
402
294
  iterable: Iterable<readonly [K, V]>,
@@ -408,10 +300,11 @@ export namespace IMapMapped {
408
300
  /**
409
301
  * Checks if two IMapMapped instances are structurally equal.
410
302
  *
411
- * Two IMapMapped instances are considered equal if they have the same size and contain
412
- * exactly the same key-value pairs. The comparison is performed on the underlying mapped
413
- * keys and values, so the transformation functions themselves don't need to be identical.
414
- * Values are compared using JavaScript's `===` operator.
303
+ * Two IMapMapped instances are considered equal if they have the same size
304
+ * and contain exactly the same key-value pairs. The comparison is performed
305
+ * on the underlying mapped keys and values, so the transformation functions
306
+ * themselves don't need to be identical. Values are compared using
307
+ * JavaScript's `===` operator.
415
308
  *
416
309
  * **Performance:** O(n) where n is the size of the smaller map.
417
310
  *
@@ -420,70 +313,8 @@ export namespace IMapMapped {
420
313
  * @template KM The type of the mapped primitive keys.
421
314
  * @param a The first IMapMapped instance to compare.
422
315
  * @param b The second IMapMapped instance to compare.
423
- * @returns `true` if the maps contain exactly the same key-value pairs, `false` otherwise.
424
- *
425
- * @example
426
- * ```typescript
427
- * // Example with coordinate keys
428
- * type Point = { x: number; y: number };
429
- * const pointToString = (p: Point): string => `${p.x},${p.y}`;
430
- * const stringToPoint = (s: string): Point => {
431
- * const [x, y] = s.split(',').map(Number);
432
- * return { x, y };
433
- * };
434
- *
435
- * const map1 = IMapMapped.create<Point, string, string>(
436
- * [[{ x: 1, y: 2 }, "point1"], [{ x: 3, y: 4 }, "point2"]],
437
- * pointToString,
438
- * stringToPoint
439
- * );
440
- *
441
- * const map2 = IMapMapped.create<Point, string, string>(
442
- * [[{ x: 1, y: 2 }, "point1"], [{ x: 3, y: 4 }, "point2"]], // Same content
443
- * pointToString,
444
- * stringToPoint
445
- * );
446
- *
447
- * const map3 = IMapMapped.create<Point, string, string>(
448
- * [[{ x: 1, y: 2 }, "point1"], [{ x: 3, y: 4 }, "different"]], // Different value
449
- * pointToString,
450
- * stringToPoint
451
- * );
452
- *
453
- * console.log(IMapMapped.equal(map1, map2)); // true
454
- * console.log(IMapMapped.equal(map1, map3)); // false (different value)
455
- *
456
- * // Order doesn't matter for equality
457
- * const map4 = IMapMapped.create<Point, string, string>(
458
- * [[{ x: 3, y: 4 }, "point2"], [{ x: 1, y: 2 }, "point1"]], // Different order
459
- * pointToString,
460
- * stringToPoint
461
- * );
462
- *
463
- * console.log(IMapMapped.equal(map1, map4)); // true
464
- *
465
- * // Different transformation functions but same logical content
466
- * const alternativePointToString = (p: Point): string => `(${p.x},${p.y})`; // Different format
467
- * const alternativeStringToPoint = (s: string): Point => {
468
- * const match = s.match(/\((\d+),(\d+)\)/);
469
- * return { x: Number(match![1]), y: Number(match![2]) };
470
- * };
471
- *
472
- * const map5 = IMapMapped.create<Point, string, string>(
473
- * [[{ x: 1, y: 2 }, "point1"], [{ x: 3, y: 4 }, "point2"]],
474
- * alternativePointToString,
475
- * alternativeStringToPoint
476
- * );
477
- *
478
- * // This would be false because the underlying mapped keys are different
479
- * // even though the logical content is the same
480
- * console.log(IMapMapped.equal(map1, map5)); // false
481
- *
482
- * // Empty maps
483
- * const empty1 = IMapMapped.create<Point, string, string>([], pointToString, stringToPoint);
484
- * const empty2 = IMapMapped.create<Point, string, string>([], pointToString, stringToPoint);
485
- * console.log(IMapMapped.equal(empty1, empty2)); // true
486
- * ```
316
+ * @returns `true` if the maps contain exactly the same key-value pairs,
317
+ * `false` otherwise.
487
318
  */
488
319
  export const equal = <K, V, KM extends MapSetKeyType>(
489
320
  a: IMapMapped<K, V, KM>,
@@ -492,13 +323,16 @@ export namespace IMapMapped {
492
323
  }
493
324
 
494
325
  /**
495
- * Internal class implementation for IMapMapped providing immutable map operations with key transformation.
326
+ * Internal class implementation for IMapMapped providing immutable map
327
+ * operations with key transformation.
496
328
  *
497
- * This class implements the IMapMapped interface by maintaining a JavaScript Map with primitive keys
498
- * internally while exposing an API that works with custom key types. The transformation between
499
- * custom and primitive keys is handled transparently through the provided `toKey` and `fromKey` functions.
329
+ * This class implements the IMapMapped interface by maintaining a JavaScript
330
+ * Map with primitive keys internally while exposing an API that works with
331
+ * custom key types. The transformation between custom and primitive keys is
332
+ * handled transparently through the provided `toKey` and `fromKey` functions.
500
333
  *
501
334
  * **Implementation Details:**
335
+ *
502
336
  * - Uses ReadonlyMap<KM, V> internally where KM is the primitive key type
503
337
  * - Stores transformation functions for bidirectional key conversion
504
338
  * - Implements copy-on-write semantics for efficiency
@@ -524,12 +358,12 @@ class IMapMappedClass<K, V, KM extends MapSetKeyType>
524
358
  *
525
359
  * @param iterable An iterable of key-value pairs using the custom key type K.
526
360
  * @param toKey A function that converts a custom key K to a primitive key KM.
527
- * Must be deterministic and produce unique values for unique keys.
528
- * @param fromKey A function that converts a primitive key KM back to the custom key K.
529
- * Should be the inverse of the toKey function.
361
+ * Must be deterministic and produce unique values for unique keys.
362
+ * @param fromKey A function that converts a primitive key KM back to the
363
+ * custom key K. Should be the inverse of the toKey function.
530
364
  * @param showNotFoundMessage Whether to log warning messages when operations
531
- * are performed on non-existent keys. Useful for debugging.
532
- * Defaults to false for production use.
365
+ * are performed on non-existent keys. Useful for debugging. Defaults to
366
+ * false for production use.
533
367
  * @internal Use IMapMapped.create() instead of calling this constructor directly.
534
368
  */
535
369
  constructor(
@@ -565,8 +399,10 @@ class IMapMappedClass<K, V, KM extends MapSetKeyType>
565
399
  every<W extends V>(
566
400
  predicate: (value: V, key: K) => value is W,
567
401
  ): this is IMapMapped<K, W, KM>;
402
+
568
403
  /** @inheritdoc */
569
404
  every(predicate: (value: V, key: K) => boolean): boolean;
405
+
570
406
  /** @inheritdoc */
571
407
  every(predicate: (value: V, key: K) => boolean): boolean {
572
408
  for (const [k, v] of this.entries()) {
@@ -744,9 +580,7 @@ class IMapMappedClass<K, V, KM extends MapSetKeyType>
744
580
  }
745
581
  }
746
582
 
747
- /**
748
- * @inheritdoc
749
- */
583
+ /** @inheritdoc */
750
584
  *[Symbol.iterator](): Iterator<readonly [K, V]> {
751
585
  for (const e of this.entries()) {
752
586
  yield e;