ts-data-forge 14.6.1 → 14.6.2

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 (393) hide show
  1. package/dist/array/impl/array-utils-creation.mjs +126 -26
  2. package/dist/array/impl/array-utils-creation.mjs.map +1 -1
  3. package/dist/array/impl/array-utils-element-access.mjs +63 -30
  4. package/dist/array/impl/array-utils-element-access.mjs.map +1 -1
  5. package/dist/array/impl/array-utils-iterators.mjs +69 -53
  6. package/dist/array/impl/array-utils-iterators.mjs.map +1 -1
  7. package/dist/array/impl/array-utils-length-bounded-array-cast.mjs +109 -73
  8. package/dist/array/impl/array-utils-length-bounded-array-cast.mjs.map +1 -1
  9. package/dist/array/impl/array-utils-length-bounded-array-guard.mjs +71 -33
  10. package/dist/array/impl/array-utils-length-bounded-array-guard.mjs.map +1 -1
  11. package/dist/array/impl/array-utils-length-bounded-tuple-cast.mjs +102 -73
  12. package/dist/array/impl/array-utils-length-bounded-tuple-cast.mjs.map +1 -1
  13. package/dist/array/impl/array-utils-length-bounded-tuple-guard.mjs +77 -33
  14. package/dist/array/impl/array-utils-length-bounded-tuple-guard.mjs.map +1 -1
  15. package/dist/array/impl/array-utils-modification.mjs +75 -122
  16. package/dist/array/impl/array-utils-modification.mjs.map +1 -1
  17. package/dist/array/impl/array-utils-reducing-value.mjs +100 -150
  18. package/dist/array/impl/array-utils-reducing-value.mjs.map +1 -1
  19. package/dist/array/impl/array-utils-search.mjs +110 -134
  20. package/dist/array/impl/array-utils-search.mjs.map +1 -1
  21. package/dist/array/impl/array-utils-set-op.mjs +146 -38
  22. package/dist/array/impl/array-utils-set-op.mjs.map +1 -1
  23. package/dist/array/impl/array-utils-size.mjs +10 -8
  24. package/dist/array/impl/array-utils-size.mjs.map +1 -1
  25. package/dist/array/impl/array-utils-slice-clamped.mjs +13 -50
  26. package/dist/array/impl/array-utils-slice-clamped.mjs.map +1 -1
  27. package/dist/array/impl/array-utils-slicing.mjs +94 -78
  28. package/dist/array/impl/array-utils-slicing.mjs.map +1 -1
  29. package/dist/array/impl/array-utils-transformation.mjs +291 -199
  30. package/dist/array/impl/array-utils-transformation.mjs.map +1 -1
  31. package/dist/array/impl/array-utils-validation.mjs +54 -56
  32. package/dist/array/impl/array-utils-validation.mjs.map +1 -1
  33. package/dist/array/impl/index.mjs +17 -17
  34. package/dist/array/impl/index.mjs.map +1 -1
  35. package/dist/array/index.mjs +2 -3
  36. package/dist/array/index.mjs.map +1 -1
  37. package/dist/collections/imap-mapped.mjs +335 -292
  38. package/dist/collections/imap-mapped.mjs.map +1 -1
  39. package/dist/collections/imap.mjs +280 -239
  40. package/dist/collections/imap.mjs.map +1 -1
  41. package/dist/collections/index.mjs +7 -7
  42. package/dist/collections/index.mjs.map +1 -1
  43. package/dist/collections/iset-mapped.mjs +448 -265
  44. package/dist/collections/iset-mapped.mjs.map +1 -1
  45. package/dist/collections/iset.mjs +328 -201
  46. package/dist/collections/iset.mjs.map +1 -1
  47. package/dist/collections/queue.mjs +183 -151
  48. package/dist/collections/queue.mjs.map +1 -1
  49. package/dist/collections/stack.mjs +169 -140
  50. package/dist/collections/stack.mjs.map +1 -1
  51. package/dist/entry-point.mjs +4 -77
  52. package/dist/entry-point.mjs.map +1 -1
  53. package/dist/expect-type.mjs +70 -4
  54. package/dist/expect-type.mjs.map +1 -1
  55. package/dist/functional/async-result/async-result.mjs +2 -3
  56. package/dist/functional/async-result/async-result.mjs.map +1 -1
  57. package/dist/functional/async-result/impl/async-result-flat-map.mjs +19 -21
  58. package/dist/functional/async-result/impl/async-result-flat-map.mjs.map +1 -1
  59. package/dist/functional/async-result/impl/async-result-from-promise.mjs +9 -10
  60. package/dist/functional/async-result/impl/async-result-from-promise.mjs.map +1 -1
  61. package/dist/functional/async-result/impl/async-result-from-throwable.mjs +12 -14
  62. package/dist/functional/async-result/impl/async-result-from-throwable.mjs.map +1 -1
  63. package/dist/functional/async-result/impl/async-result-map-err.mjs +16 -19
  64. package/dist/functional/async-result/impl/async-result-map-err.mjs.map +1 -1
  65. package/dist/functional/async-result/impl/async-result-map.mjs +16 -19
  66. package/dist/functional/async-result/impl/async-result-map.mjs.map +1 -1
  67. package/dist/functional/async-result/impl/async-result-unwrap-or.mjs +36 -9
  68. package/dist/functional/async-result/impl/async-result-unwrap-or.mjs.map +1 -1
  69. package/dist/functional/async-result/impl/index.mjs +8 -7
  70. package/dist/functional/async-result/impl/index.mjs.map +1 -1
  71. package/dist/functional/async-result/impl/types.mjs +2 -2
  72. package/dist/functional/async-result/impl/types.mjs.map +1 -1
  73. package/dist/functional/async-result/index.mjs +2 -3
  74. package/dist/functional/async-result/index.mjs.map +1 -1
  75. package/dist/functional/index.mjs +7 -11
  76. package/dist/functional/index.mjs.map +1 -1
  77. package/dist/functional/match.mjs +27 -13
  78. package/dist/functional/match.mjs.map +1 -1
  79. package/dist/functional/optional/impl/index.mjs +19 -18
  80. package/dist/functional/optional/impl/index.mjs.map +1 -1
  81. package/dist/functional/optional/impl/optional-expect-to-be.mjs +16 -18
  82. package/dist/functional/optional/impl/optional-expect-to-be.mjs.map +1 -1
  83. package/dist/functional/optional/impl/optional-filter.mjs +17 -19
  84. package/dist/functional/optional/impl/optional-filter.mjs.map +1 -1
  85. package/dist/functional/optional/impl/optional-flat-map.mjs +13 -15
  86. package/dist/functional/optional/impl/optional-flat-map.mjs.map +1 -1
  87. package/dist/functional/optional/impl/optional-from-nullable.mjs +26 -5
  88. package/dist/functional/optional/impl/optional-from-nullable.mjs.map +1 -1
  89. package/dist/functional/optional/impl/optional-is-none.mjs +21 -5
  90. package/dist/functional/optional/impl/optional-is-none.mjs.map +1 -1
  91. package/dist/functional/optional/impl/optional-is-optional.mjs +26 -8
  92. package/dist/functional/optional/impl/optional-is-optional.mjs.map +1 -1
  93. package/dist/functional/optional/impl/optional-is-some.mjs +22 -5
  94. package/dist/functional/optional/impl/optional-is-some.mjs.map +1 -1
  95. package/dist/functional/optional/impl/optional-map.mjs +16 -18
  96. package/dist/functional/optional/impl/optional-map.mjs.map +1 -1
  97. package/dist/functional/optional/impl/optional-match.mjs +16 -18
  98. package/dist/functional/optional/impl/optional-match.mjs.map +1 -1
  99. package/dist/functional/optional/impl/optional-none.mjs +18 -5
  100. package/dist/functional/optional/impl/optional-none.mjs.map +1 -1
  101. package/dist/functional/optional/impl/optional-or-else.mjs +13 -15
  102. package/dist/functional/optional/impl/optional-or-else.mjs.map +1 -1
  103. package/dist/functional/optional/impl/optional-some.mjs +23 -7
  104. package/dist/functional/optional/impl/optional-some.mjs.map +1 -1
  105. package/dist/functional/optional/impl/optional-to-nullable.mjs +28 -5
  106. package/dist/functional/optional/impl/optional-to-nullable.mjs.map +1 -1
  107. package/dist/functional/optional/impl/optional-unwrap-or.mjs +12 -14
  108. package/dist/functional/optional/impl/optional-unwrap-or.mjs.map +1 -1
  109. package/dist/functional/optional/impl/optional-unwrap-throw.mjs +34 -9
  110. package/dist/functional/optional/impl/optional-unwrap-throw.mjs.map +1 -1
  111. package/dist/functional/optional/impl/optional-unwrap.mjs +6 -9
  112. package/dist/functional/optional/impl/optional-unwrap.mjs.map +1 -1
  113. package/dist/functional/optional/impl/optional-zip.mjs +36 -5
  114. package/dist/functional/optional/impl/optional-zip.mjs.map +1 -1
  115. package/dist/functional/optional/impl/tag.mjs +4 -5
  116. package/dist/functional/optional/impl/tag.mjs.map +1 -1
  117. package/dist/functional/optional/impl/types.mjs +2 -2
  118. package/dist/functional/optional/impl/types.mjs.map +1 -1
  119. package/dist/functional/optional/index.mjs +2 -3
  120. package/dist/functional/optional/index.mjs.map +1 -1
  121. package/dist/functional/optional/optional.mjs +2 -3
  122. package/dist/functional/optional/optional.mjs.map +1 -1
  123. package/dist/functional/pipe.mjs +42 -14
  124. package/dist/functional/pipe.mjs.map +1 -1
  125. package/dist/functional/result/impl/index.mjs +28 -27
  126. package/dist/functional/result/impl/index.mjs.map +1 -1
  127. package/dist/functional/result/impl/result-err.mjs +29 -7
  128. package/dist/functional/result/impl/result-err.mjs.map +1 -1
  129. package/dist/functional/result/impl/result-expect-to-be.mjs +17 -18
  130. package/dist/functional/result/impl/result-expect-to-be.mjs.map +1 -1
  131. package/dist/functional/result/impl/result-flat-map.mjs +18 -21
  132. package/dist/functional/result/impl/result-flat-map.mjs.map +1 -1
  133. package/dist/functional/result/impl/result-fold.mjs +18 -21
  134. package/dist/functional/result/impl/result-fold.mjs.map +1 -1
  135. package/dist/functional/result/impl/result-from-optional.mjs +17 -20
  136. package/dist/functional/result/impl/result-from-optional.mjs.map +1 -1
  137. package/dist/functional/result/impl/result-from-promise.mjs +37 -8
  138. package/dist/functional/result/impl/result-from-promise.mjs.map +1 -1
  139. package/dist/functional/result/impl/result-from-throwable.mjs +41 -14
  140. package/dist/functional/result/impl/result-from-throwable.mjs.map +1 -1
  141. package/dist/functional/result/impl/result-is-err.mjs +21 -5
  142. package/dist/functional/result/impl/result-is-err.mjs.map +1 -1
  143. package/dist/functional/result/impl/result-is-ok.mjs +21 -5
  144. package/dist/functional/result/impl/result-is-ok.mjs.map +1 -1
  145. package/dist/functional/result/impl/result-is-result.mjs +25 -7
  146. package/dist/functional/result/impl/result-is-result.mjs.map +1 -1
  147. package/dist/functional/result/impl/result-map-err.mjs +18 -21
  148. package/dist/functional/result/impl/result-map-err.mjs.map +1 -1
  149. package/dist/functional/result/impl/result-map.mjs +18 -21
  150. package/dist/functional/result/impl/result-map.mjs.map +1 -1
  151. package/dist/functional/result/impl/result-match.mjs +17 -21
  152. package/dist/functional/result/impl/result-match.mjs.map +1 -1
  153. package/dist/functional/result/impl/result-ok.mjs +29 -7
  154. package/dist/functional/result/impl/result-ok.mjs.map +1 -1
  155. package/dist/functional/result/impl/result-or-else.mjs +14 -15
  156. package/dist/functional/result/impl/result-or-else.mjs.map +1 -1
  157. package/dist/functional/result/impl/result-safe-try.mjs +32 -21
  158. package/dist/functional/result/impl/result-safe-try.mjs.map +1 -1
  159. package/dist/functional/result/impl/result-safe-unwrap.mjs +40 -12
  160. package/dist/functional/result/impl/result-safe-unwrap.mjs.map +1 -1
  161. package/dist/functional/result/impl/result-swap.mjs +23 -8
  162. package/dist/functional/result/impl/result-swap.mjs.map +1 -1
  163. package/dist/functional/result/impl/result-to-optional.mjs +30 -7
  164. package/dist/functional/result/impl/result-to-optional.mjs.map +1 -1
  165. package/dist/functional/result/impl/result-unwrap-err-or.mjs +13 -14
  166. package/dist/functional/result/impl/result-unwrap-err-or.mjs.map +1 -1
  167. package/dist/functional/result/impl/result-unwrap-err-throw.mjs +43 -20
  168. package/dist/functional/result/impl/result-unwrap-err-throw.mjs.map +1 -1
  169. package/dist/functional/result/impl/result-unwrap-err.mjs +33 -8
  170. package/dist/functional/result/impl/result-unwrap-err.mjs.map +1 -1
  171. package/dist/functional/result/impl/result-unwrap-ok-or.mjs +13 -14
  172. package/dist/functional/result/impl/result-unwrap-ok-or.mjs.map +1 -1
  173. package/dist/functional/result/impl/result-unwrap-ok.mjs +6 -9
  174. package/dist/functional/result/impl/result-unwrap-ok.mjs.map +1 -1
  175. package/dist/functional/result/impl/result-unwrap-throw.mjs +38 -11
  176. package/dist/functional/result/impl/result-unwrap-throw.mjs.map +1 -1
  177. package/dist/functional/result/impl/result-zip.mjs +35 -5
  178. package/dist/functional/result/impl/result-zip.mjs.map +1 -1
  179. package/dist/functional/result/impl/tag.mjs +4 -5
  180. package/dist/functional/result/impl/tag.mjs.map +1 -1
  181. package/dist/functional/result/impl/types.mjs +2 -2
  182. package/dist/functional/result/impl/types.mjs.map +1 -1
  183. package/dist/functional/result/index.mjs +2 -3
  184. package/dist/functional/result/index.mjs.map +1 -1
  185. package/dist/functional/result/result.mjs +2 -3
  186. package/dist/functional/result/result.mjs.map +1 -1
  187. package/dist/functional/ternary-result/impl/index.mjs +29 -28
  188. package/dist/functional/ternary-result/impl/index.mjs.map +1 -1
  189. package/dist/functional/ternary-result/impl/tag.mjs +6 -6
  190. package/dist/functional/ternary-result/impl/tag.mjs.map +1 -1
  191. package/dist/functional/ternary-result/impl/ternary-result-err.mjs +17 -7
  192. package/dist/functional/ternary-result/impl/ternary-result-err.mjs.map +1 -1
  193. package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs +15 -18
  194. package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs.map +1 -1
  195. package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs +28 -32
  196. package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs.map +1 -1
  197. package/dist/functional/ternary-result/impl/ternary-result-fold.mjs +24 -26
  198. package/dist/functional/ternary-result/impl/ternary-result-fold.mjs.map +1 -1
  199. package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs +21 -8
  200. package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs.map +1 -1
  201. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs +28 -13
  202. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs.map +1 -1
  203. package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs +19 -5
  204. package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs.map +1 -1
  205. package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs +21 -5
  206. package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs.map +1 -1
  207. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs +28 -8
  208. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs.map +1 -1
  209. package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs +20 -5
  210. package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs.map +1 -1
  211. package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs +17 -18
  212. package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs.map +1 -1
  213. package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs +20 -23
  214. package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs.map +1 -1
  215. package/dist/functional/ternary-result/impl/ternary-result-map.mjs +24 -26
  216. package/dist/functional/ternary-result/impl/ternary-result-map.mjs.map +1 -1
  217. package/dist/functional/ternary-result/impl/ternary-result-ok.mjs +18 -7
  218. package/dist/functional/ternary-result/impl/ternary-result-ok.mjs.map +1 -1
  219. package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs +11 -14
  220. package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs.map +1 -1
  221. package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs +24 -10
  222. package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs.map +1 -1
  223. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs +11 -14
  224. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs.map +1 -1
  225. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs +30 -19
  226. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs.map +1 -1
  227. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs +20 -8
  228. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs.map +1 -1
  229. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs +11 -14
  230. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs.map +1 -1
  231. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs +7 -9
  232. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs.map +1 -1
  233. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs +30 -22
  234. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs.map +1 -1
  235. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs +11 -14
  236. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs.map +1 -1
  237. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs +27 -17
  238. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs.map +1 -1
  239. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs +20 -8
  240. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs.map +1 -1
  241. package/dist/functional/ternary-result/impl/ternary-result-warn.mjs +21 -8
  242. package/dist/functional/ternary-result/impl/ternary-result-warn.mjs.map +1 -1
  243. package/dist/functional/ternary-result/impl/ternary-result-zip.mjs +47 -19
  244. package/dist/functional/ternary-result/impl/ternary-result-zip.mjs.map +1 -1
  245. package/dist/functional/ternary-result/impl/types.mjs +2 -2
  246. package/dist/functional/ternary-result/impl/types.mjs.map +1 -1
  247. package/dist/functional/ternary-result/impl/variant-name.mjs +12 -14
  248. package/dist/functional/ternary-result/impl/variant-name.mjs.map +1 -1
  249. package/dist/functional/ternary-result/index.mjs +2 -3
  250. package/dist/functional/ternary-result/index.mjs.map +1 -1
  251. package/dist/functional/ternary-result/ternary-result.mjs +2 -3
  252. package/dist/functional/ternary-result/ternary-result.mjs.map +1 -1
  253. package/dist/guard/has-key.mjs +43 -4
  254. package/dist/guard/has-key.mjs.map +1 -1
  255. package/dist/guard/index.mjs +8 -8
  256. package/dist/guard/index.mjs.map +1 -1
  257. package/dist/guard/is-non-empty-string.mjs +39 -4
  258. package/dist/guard/is-non-empty-string.mjs.map +1 -1
  259. package/dist/guard/is-non-null-object.mjs +36 -4
  260. package/dist/guard/is-non-null-object.mjs.map +1 -1
  261. package/dist/guard/is-primitive.mjs +46 -15
  262. package/dist/guard/is-primitive.mjs.map +1 -1
  263. package/dist/guard/is-record.mjs +89 -6
  264. package/dist/guard/is-record.mjs.map +1 -1
  265. package/dist/guard/is-type.mjs +404 -19
  266. package/dist/guard/is-type.mjs.map +1 -1
  267. package/dist/guard/key-is-in.mjs +42 -4
  268. package/dist/guard/key-is-in.mjs.map +1 -1
  269. package/dist/index.mjs +12 -65
  270. package/dist/index.mjs.map +1 -1
  271. package/dist/iterator/index.mjs +2 -2
  272. package/dist/iterator/index.mjs.map +1 -1
  273. package/dist/iterator/range.mjs +19 -57
  274. package/dist/iterator/range.mjs.map +1 -1
  275. package/dist/json/index.mjs +2 -2
  276. package/dist/json/index.mjs.map +1 -1
  277. package/dist/json/json.mjs +346 -105
  278. package/dist/json/json.mjs.map +1 -1
  279. package/dist/number/branded-types/finite-number.mjs +148 -137
  280. package/dist/number/branded-types/finite-number.mjs.map +1 -1
  281. package/dist/number/branded-types/index.mjs +33 -33
  282. package/dist/number/branded-types/index.mjs.map +1 -1
  283. package/dist/number/branded-types/int.mjs +245 -209
  284. package/dist/number/branded-types/int.mjs.map +1 -1
  285. package/dist/number/branded-types/int16.mjs +141 -131
  286. package/dist/number/branded-types/int16.mjs.map +1 -1
  287. package/dist/number/branded-types/int32.mjs +141 -131
  288. package/dist/number/branded-types/int32.mjs.map +1 -1
  289. package/dist/number/branded-types/negative-finite-number.mjs +155 -149
  290. package/dist/number/branded-types/negative-finite-number.mjs.map +1 -1
  291. package/dist/number/branded-types/negative-int.mjs +125 -110
  292. package/dist/number/branded-types/negative-int.mjs.map +1 -1
  293. package/dist/number/branded-types/negative-safe-int.mjs +126 -115
  294. package/dist/number/branded-types/negative-safe-int.mjs.map +1 -1
  295. package/dist/number/branded-types/non-negative-finite-number.mjs +164 -154
  296. package/dist/number/branded-types/non-negative-finite-number.mjs.map +1 -1
  297. package/dist/number/branded-types/non-negative-int16.mjs +137 -125
  298. package/dist/number/branded-types/non-negative-int16.mjs.map +1 -1
  299. package/dist/number/branded-types/non-negative-int32.mjs +137 -125
  300. package/dist/number/branded-types/non-negative-int32.mjs.map +1 -1
  301. package/dist/number/branded-types/non-positive-finite-number.mjs +143 -139
  302. package/dist/number/branded-types/non-positive-finite-number.mjs.map +1 -1
  303. package/dist/number/branded-types/non-positive-int.mjs +116 -99
  304. package/dist/number/branded-types/non-positive-int.mjs.map +1 -1
  305. package/dist/number/branded-types/non-positive-safe-int.mjs +118 -107
  306. package/dist/number/branded-types/non-positive-safe-int.mjs.map +1 -1
  307. package/dist/number/branded-types/non-zero-finite-number.mjs +144 -129
  308. package/dist/number/branded-types/non-zero-finite-number.mjs.map +1 -1
  309. package/dist/number/branded-types/non-zero-int.mjs +102 -82
  310. package/dist/number/branded-types/non-zero-int.mjs.map +1 -1
  311. package/dist/number/branded-types/non-zero-int16.mjs +118 -105
  312. package/dist/number/branded-types/non-zero-int16.mjs.map +1 -1
  313. package/dist/number/branded-types/non-zero-int32.mjs +118 -105
  314. package/dist/number/branded-types/non-zero-int32.mjs.map +1 -1
  315. package/dist/number/branded-types/non-zero-safe-int.mjs +122 -108
  316. package/dist/number/branded-types/non-zero-safe-int.mjs.map +1 -1
  317. package/dist/number/branded-types/non-zero-uint16.mjs +118 -104
  318. package/dist/number/branded-types/non-zero-uint16.mjs.map +1 -1
  319. package/dist/number/branded-types/non-zero-uint32.mjs +118 -104
  320. package/dist/number/branded-types/non-zero-uint32.mjs.map +1 -1
  321. package/dist/number/branded-types/positive-finite-number.mjs +167 -160
  322. package/dist/number/branded-types/positive-finite-number.mjs.map +1 -1
  323. package/dist/number/branded-types/positive-int.mjs +260 -224
  324. package/dist/number/branded-types/positive-int.mjs.map +1 -1
  325. package/dist/number/branded-types/positive-int16.mjs +134 -122
  326. package/dist/number/branded-types/positive-int16.mjs.map +1 -1
  327. package/dist/number/branded-types/positive-int32.mjs +134 -122
  328. package/dist/number/branded-types/positive-int32.mjs.map +1 -1
  329. package/dist/number/branded-types/positive-safe-int.mjs +292 -258
  330. package/dist/number/branded-types/positive-safe-int.mjs.map +1 -1
  331. package/dist/number/branded-types/positive-uint16.mjs +134 -122
  332. package/dist/number/branded-types/positive-uint16.mjs.map +1 -1
  333. package/dist/number/branded-types/positive-uint32.mjs +134 -122
  334. package/dist/number/branded-types/positive-uint32.mjs.map +1 -1
  335. package/dist/number/branded-types/safe-int.mjs +284 -255
  336. package/dist/number/branded-types/safe-int.mjs.map +1 -1
  337. package/dist/number/branded-types/safe-uint.mjs +135 -124
  338. package/dist/number/branded-types/safe-uint.mjs.map +1 -1
  339. package/dist/number/branded-types/uint.mjs +248 -211
  340. package/dist/number/branded-types/uint.mjs.map +1 -1
  341. package/dist/number/branded-types/uint16.mjs +132 -121
  342. package/dist/number/branded-types/uint16.mjs.map +1 -1
  343. package/dist/number/branded-types/uint32.mjs +132 -121
  344. package/dist/number/branded-types/uint32.mjs.map +1 -1
  345. package/dist/number/enum/index.mjs +3 -3
  346. package/dist/number/enum/index.mjs.map +1 -1
  347. package/dist/number/enum/int8.mjs +146 -131
  348. package/dist/number/enum/int8.mjs.map +1 -1
  349. package/dist/number/enum/uint8.mjs +133 -119
  350. package/dist/number/enum/uint8.mjs.map +1 -1
  351. package/dist/number/index.mjs +6 -37
  352. package/dist/number/index.mjs.map +1 -1
  353. package/dist/number/num-arithmetic-types.mjs +42 -1
  354. package/dist/number/num-arithmetic-types.mjs.map +1 -1
  355. package/dist/number/num.mjs +541 -83
  356. package/dist/number/num.mjs.map +1 -1
  357. package/dist/number/refined-number-utils.mjs +294 -133
  358. package/dist/number/refined-number-utils.mjs.map +1 -1
  359. package/dist/object/index.mjs +2 -2
  360. package/dist/object/index.mjs.map +1 -1
  361. package/dist/object/object.mjs +355 -202
  362. package/dist/object/object.mjs.map +1 -1
  363. package/dist/others/cast-mutable.mjs +38 -11
  364. package/dist/others/cast-mutable.mjs.map +1 -1
  365. package/dist/others/cast-readonly.mjs +37 -11
  366. package/dist/others/cast-readonly.mjs.map +1 -1
  367. package/dist/others/debounce-function.mjs +22 -11
  368. package/dist/others/debounce-function.mjs.map +1 -1
  369. package/dist/others/fast-deep-equal.mjs +70 -51
  370. package/dist/others/fast-deep-equal.mjs.map +1 -1
  371. package/dist/others/if-then.mjs +32 -5
  372. package/dist/others/if-then.mjs.map +1 -1
  373. package/dist/others/index.mjs +10 -10
  374. package/dist/others/index.mjs.map +1 -1
  375. package/dist/others/map-nullable.mjs +11 -13
  376. package/dist/others/map-nullable.mjs.map +1 -1
  377. package/dist/others/memoize-function.mjs +14 -16
  378. package/dist/others/memoize-function.mjs.map +1 -1
  379. package/dist/others/tuple.mjs +52 -4
  380. package/dist/others/tuple.mjs.map +1 -1
  381. package/dist/others/unknown-to-string.mjs +91 -47
  382. package/dist/others/unknown-to-string.mjs.map +1 -1
  383. package/dist/promise/index.mjs +2 -2
  384. package/dist/promise/index.mjs.map +1 -1
  385. package/dist/promise/promise.mjs +51 -10
  386. package/dist/promise/promise.mjs.map +1 -1
  387. package/dist/string/index.mjs +2 -2
  388. package/dist/string/index.mjs.map +1 -1
  389. package/dist/string/str.mjs +250 -83
  390. package/dist/string/str.mjs.map +1 -1
  391. package/dist/types.mjs +3 -2
  392. package/dist/types.mjs.map +1 -1
  393. package/package.json +5 -6
@@ -1 +1 @@
1
- {"version":3,"file":"object.mjs","sources":["../../src/object/object.mts"],"sourcesContent":["import {\n type ArrayElement,\n type Decrement,\n type DeepOmit,\n type DeepPick,\n type IsFixedLengthList,\n type IsUnion,\n type List,\n type ReadonlyRecord,\n type RelaxedExclude,\n type RelaxedOmit,\n type RelaxedPick,\n type StrictOmit,\n type StrictPick,\n type ToString,\n type TypeEq,\n type UnknownRecord,\n} from 'ts-type-forge';\nimport { Arr } from '../array/index.mjs';\nimport { Optional } from '../functional/index.mjs';\nimport { hasKey, isRecord } from '../guard/index.mjs';\n\n/**\n * A collection of type-safe object utility functions providing functional\n * programming patterns for object manipulation, including pick, omit, shallow\n * equality checks, and more.\n *\n * All functions maintain TypeScript type safety and support both direct and\n * curried usage patterns for better composition with pipe operations.\n */\nexport namespace Obj {\n /**\n * Performs a shallow equality check on two records using a configurable\n * equality function. Verifies that both records have the same number of\n * entries and that for every key in the first record, the corresponding value\n * passes the equality test with the value in the second record.\n *\n * @example\n *\n * ```ts\n * const obj1 = { name: 'Alice', age: 30 } as const;\n *\n * const obj2 = { name: 'Alice', age: 30 } as const;\n *\n * const obj3 = { name: 'Alice', age: 31 } as const;\n *\n * assert.isTrue(Obj.shallowEq(obj1, obj2));\n *\n * assert.isFalse(Obj.shallowEq(obj1, obj3));\n *\n * // Custom equality function\n * const obj4 = { value: 1 } as const;\n *\n * const obj5 = { value: 1.00001 } as const;\n *\n * const closeEnough = (a: unknown, b: unknown): boolean => {\n * if (typeof a === 'number' && typeof b === 'number') {\n * return Math.abs(a - b) < 0.001;\n * }\n *\n * return Object.is(a, b);\n * };\n *\n * assert.isTrue(Obj.shallowEq(obj4, obj5, closeEnough));\n * ```\n *\n * @param a - The first record to compare\n * @param b - The second record to compare\n * @param eq - Optional equality function (defaults to Object.is for strict\n * equality)\n * @returns `true` if the records are shallowly equal according to the\n * equality function, `false` otherwise\n */\n export const shallowEq = (\n a: UnknownRecord,\n b: UnknownRecord,\n eq: (x: unknown, y: unknown) => boolean = Object.is,\n ): boolean => {\n const aEntries = Object.entries(a);\n\n const bEntries = Object.entries(b);\n\n if (aEntries.length !== bEntries.length) return false;\n\n return aEntries.every(([k, v]) => eq(b[k], v));\n };\n\n /**\n * Creates a new record that contains only the specified keys from the source\n * record. This function supports both direct usage and curried form for\n * functional composition.\n *\n * **Type Safety**: Only keys that exist in the source record type are\n * allowed, preventing runtime errors from accessing non-existent properties.\n *\n * @example\n *\n * ```ts\n * const user = {\n * id: 1,\n * name: 'Bob',\n * email: 'bob@example.com',\n * password: 'secret',\n * role: 'admin',\n * } as const;\n *\n * // Direct usage\n * const publicInfo = Obj.pick(user, ['id', 'name', 'role']);\n *\n * assert.deepStrictEqual(publicInfo, {\n * id: 1,\n * name: 'Bob',\n * role: 'admin',\n * });\n *\n * // Curried usage with pipe\n * const nameAndEmail = pipe(user).map(Obj.pick(['name', 'email'])).value;\n *\n * assert.deepStrictEqual(nameAndEmail, {\n * name: 'Bob',\n * email: 'bob@example.com',\n * });\n * ```\n *\n * @template R - The type of the input record\n * @template Keys - The readonly array type of keys to pick from the record\n * @param record - The source record to pick properties from\n * @param keys - A readonly array of keys to include in the result\n * @returns A new record containing only the specified keys and their values\n */\n export function pick<\n const R extends UnknownRecord,\n const Keys extends readonly (keyof R)[],\n >(record: R, keys: Keys): StrictPick<R, ArrayElement<Keys>>;\n\n // Curried version\n export function pick<const Keys extends readonly PropertyKey[]>(\n keys: Keys,\n ): <const R extends UnknownRecord>(\n record: R,\n ) => RelaxedPick<R, ArrayElement<Keys>>;\n\n export function pick<\n const R extends UnknownRecord,\n const Keys extends readonly (keyof R)[],\n >(\n ...args: readonly [record: R, keys: Keys] | readonly [keys: Keys]\n ):\n | StrictPick<R, ArrayElement<Keys>>\n | ((record: R) => RelaxedPick<R, ArrayElement<Keys>>) {\n switch (args.length) {\n case 2: {\n const [record, keys] = args;\n\n const keysSet = new Set<keyof R>(keys);\n\n return (\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Object.fromEntries(\n Object.entries(record).filter(([k, _v]) => keysSet.has(k)),\n ) as never\n );\n }\n\n case 1: {\n const [keys] = args;\n\n return (record: R) => pick(record, keys);\n }\n }\n }\n\n /**\n * Creates a new record that excludes the specified keys from the source\n * record. This function supports both direct usage and curried form for\n * functional composition.\n *\n * **Type Safety**: Only keys that exist in the source record type are\n * allowed, and the return type precisely reflects which properties remain\n * after omission.\n *\n * @example\n *\n * ```ts\n * const user = {\n * id: 1,\n * name: 'Charlie',\n * email: 'charlie@example.com',\n * password: 'secret123',\n * internalNote: 'VIP customer',\n * } as const;\n *\n * // Direct usage - remove sensitive fields\n * const safeUser = Obj.omit(user, ['password', 'internalNote']);\n *\n * assert.deepStrictEqual(safeUser, {\n * id: 1,\n * name: 'Charlie',\n * email: 'charlie@example.com',\n * });\n *\n * // Curried usage with pipe\n * const withoutEmail = pipe(user).map(Obj.omit(['email', 'password'])).value;\n *\n * assert.deepStrictEqual(withoutEmail, {\n * id: 1,\n * name: 'Charlie',\n * internalNote: 'VIP customer',\n * });\n * ```\n *\n * @template R - The type of the input record\n * @template Keys - The readonly array type of keys to omit from the record\n * @param record - The source record to omit properties from\n * @param keys - A readonly array of keys to exclude from the result\n * @returns A new record containing all properties except the specified keys\n */\n export function omit<\n const R extends UnknownRecord,\n const Keys extends readonly (keyof R)[],\n >(record: R, keys: Keys): StrictOmit<R, ArrayElement<Keys>>;\n\n // Curried version\n export function omit<const Keys extends readonly PropertyKey[]>(\n keys: Keys,\n ): <const R extends UnknownRecord>(\n record: R,\n ) => RelaxedOmit<R, ArrayElement<Keys>>;\n\n export function omit<\n const R extends UnknownRecord,\n const Keys extends readonly (keyof R)[],\n >(\n ...args:\n readonly [record: R, keys: Keys] | readonly [keys: readonly PropertyKey[]]\n ):\n | StrictOmit<R, ArrayElement<Keys>>\n | ((record: R) => StrictOmit<R, ArrayElement<Keys>>) {\n switch (args.length) {\n case 2: {\n const [record, keys] = args;\n\n const keysSet = new Set<keyof R>(keys);\n\n return (\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Object.fromEntries(\n Object.entries(record).filter(([k, _v]) => !keysSet.has(k)),\n ) as never\n );\n }\n\n case 1: {\n const [keys] = args;\n\n return <R2 extends UnknownRecord>(record: R2) => {\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n const result = omit(\n record,\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n keys as readonly (keyof R2)[],\n ) as RelaxedOmit<R2, ArrayElement<Keys>>;\n\n return result;\n };\n }\n }\n }\n\n /**\n * Creates an object from an array of key-value pairs with precise TypeScript\n * typing. This is a type-safe wrapper around `Object.fromEntries` that\n * provides better type inference and compile-time guarantees about the\n * resulting object structure.\n *\n * **Type Behavior**:\n *\n * - When entries is a fixed-length tuple, the exact object type is inferred\n * - When entries has dynamic length with union key types, `Partial` is applied\n * to prevent incorrect assumptions about which keys will be present\n *\n * @example\n *\n * ```ts\n * // Fixed-length tuple - exact type inferred\n * const entries1 = [\n * ['name', 'David'],\n * ['age', 25],\n * ['active', true],\n * ] as const;\n *\n * const obj1 = Obj.fromEntries(entries1);\n *\n * assert.deepStrictEqual(obj1, {\n * name: 'David',\n * age: 25,\n * active: true,\n * });\n *\n * // Dynamic length array - Partial type applied\n * const dynamicEntries: readonly (readonly ['x' | 'y', number])[] = [\n * ['x', 10],\n * ['y', 20],\n * ] as const;\n *\n * const obj2 = Obj.fromEntries(dynamicEntries);\n *\n * assert.deepStrictEqual(obj2, { x: 10, y: 20 });\n * ```\n *\n * @template Entries - The readonly array type of key-value entry tuples\n * @param entries - An array of readonly key-value entry tuples `[key, value]`\n * @returns An object created from the entries with precise typing\n */\n export const fromEntries = <\n const Entries extends readonly (readonly [PropertyKey, unknown])[],\n >(\n entries: Entries,\n ): IsFixedLengthList<Entries> extends true\n ? TsDataForgeInternals.EntriesToObject<Entries>\n : TsDataForgeInternals.PartialIfKeyIsUnion<\n TsDataForgeInternals.KeysOfEntries<Entries>,\n ReadonlyRecord<\n TsDataForgeInternals.KeysOfEntries<Entries>,\n TsDataForgeInternals.ValuesOfEntries<Entries>\n >\n > =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Object.fromEntries(entries) as never;\n\n /**\n * Transforms every value of a record, leaving the key set untouched.\n *\n * **Type Behavior**: the result is a mapped type over `keyof R`, so the keys\n * — and their optional modifiers — survive verbatim:\n * `{ a: number; b?: number }` maps to `{ a: V2; b?: V2 }`, and a record with\n * an index signature stays total rather than becoming `Partial`.\n *\n * This is what `Object.fromEntries(Object.entries(record).map(...))` cannot\n * express: an entries array carries no evidence that it still covers every\n * key of the record it came from, so its element type is all the return type\n * can be built from. Going through a mapped type instead states the\n * invariant that a value-only transform preserves the key set.\n *\n * **Key handling**: keys reach the callback the way `Object.entries` yields\n * them, so a numeric key `1` arrives as `'1'`. Symbol-keyed properties are\n * not enumerated by `Object.entries`; they are dropped from both the result\n * and its type.\n *\n * @example\n *\n * <!-- doc:embed:jsdoc:example:./samples/src/object/map-example.mts -->\n *\n * ```ts\n * const scores = { alice: 1, bob: 2 } as const;\n *\n * const doubled = Obj.map(scores, (value) => value * 2);\n *\n * assert.deepStrictEqual(doubled, { alice: 2, bob: 4 });\n *\n * // The key is available as the second argument.\n * const labelled = Obj.map(scores, (value, key) => `${key}=${value}`);\n *\n * assert.deepStrictEqual(labelled, { alice: 'alice=1', bob: 'bob=2' });\n * ```\n *\n * <!-- /doc:embed:jsdoc:example:./samples/src/object/map-example.mts -->\n *\n * @template R - The type of the source record\n * @template V2 - The type the callback returns for every key\n * @param record - The record whose values are transformed\n * @param mapFn - Called once per own enumerable string key, with the value\n * and the key\n * @returns A new record with the same keys as `record` and the mapped values\n */\n export const map = <const R extends UnknownRecord, V2>(\n record: R,\n mapFn: (\n value: R[keyof R],\n key: TsDataForgeInternals.MappedRecordKey<R>,\n ) => V2,\n ): TsDataForgeInternals.MappedRecord<R, V2> => {\n // `Object.entries` erases both the key and the value type of `R`, so the\n // callback is widened once here instead of asserting on every entry.\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n const mapFnWidened = mapFn as (value: unknown, key: string) => V2;\n\n return (\n // `Object.entries` enumerates exactly the own enumerable string keys of\n // `record`, and nothing here adds or removes an entry, so the result has\n // the key set `MappedRecord` claims.\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Object.fromEntries(\n Object.entries(record).map(\n ([k, v]) => [k, mapFnWidened(v, k)] as const,\n ),\n ) as never\n );\n };\n\n /**\n * Keeps the entries whose value the predicate accepts, leaving the values\n * themselves untouched.\n *\n * **Type Behavior**: the surviving keys are the keys of the source record,\n * made optional — the predicate may reject any of them. A record keyed by an\n * index signature stays total instead, because it names no specific key that\n * could go missing.\n *\n * Passing a type guard narrows the value type of the result, which is what\n * `Object.fromEntries(Object.entries(record).filter(guard))` loses.\n *\n * **Key handling**: keys reach the callback the way `Object.entries` yields\n * them, so a numeric key `1` arrives as `'1'`. Symbol-keyed properties are\n * not enumerated by `Object.entries`; they are dropped from both the result\n * and its type.\n *\n * @example\n *\n * <!-- doc:embed:jsdoc:example:./samples/src/object/filter-example.mts -->\n *\n * ```ts\n * const scores = { alice: 1, bob: 2 } as const;\n *\n * const passing = Obj.filter(scores, (value) => value > 1);\n *\n * assert.deepStrictEqual(passing, { bob: 2 });\n *\n * // The key is available as the second argument.\n * const notAlice = Obj.filter(scores, (_value, key) => key !== 'alice');\n *\n * assert.deepStrictEqual(notAlice, { bob: 2 });\n *\n * // A type guard narrows the value type of the result.\n * const mixed: UnknownRecord = { a: 1, b: 'x' } as const;\n *\n * const strings = Obj.filter(mixed, isString);\n *\n * assert.deepStrictEqual(strings, { b: 'x' });\n * ```\n *\n * <!-- /doc:embed:jsdoc:example:./samples/src/object/filter-example.mts -->\n *\n * @template R - The type of the source record\n * @template V2 - The type the guard narrows values to\n * @param record - The record whose entries are filtered\n * @param predicate - Called once per own enumerable string key, with the\n * value and the key\n * @returns A new record holding only the accepted entries\n */\n export function filter<const R extends UnknownRecord, V2 extends R[keyof R]>(\n record: R,\n predicate: (\n value: R[keyof R],\n key: TsDataForgeInternals.MappedRecordKey<R>,\n ) => value is V2,\n ): TsDataForgeInternals.FilteredRecord<\n TsDataForgeInternals.MappedRecord<R, V2>\n >;\n\n export function filter<const R extends UnknownRecord>(\n record: R,\n predicate: (\n value: R[keyof R],\n key: TsDataForgeInternals.MappedRecordKey<R>,\n ) => boolean,\n ): TsDataForgeInternals.FilteredRecord<R>;\n\n export function filter<const R extends UnknownRecord>(\n record: R,\n predicate: (\n value: R[keyof R],\n key: TsDataForgeInternals.MappedRecordKey<R>,\n ) => boolean,\n ): TsDataForgeInternals.FilteredRecord<R> {\n // `Object.entries` erases both the key and the value type of `R`, so the\n // callback is widened once here instead of asserting on every entry.\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n const predicateWidened = predicate as (\n value: unknown,\n key: string,\n ) => boolean;\n\n return (\n // `Object.entries` enumerates exactly the own enumerable string keys of\n // `record`, and filtering only ever removes entries, so the result has a\n // subset of those keys — which is what `FilteredRecord` claims.\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Object.fromEntries(\n Object.entries(record).filter(([k, v]) => predicateWidened(v, k)),\n ) as never\n );\n }\n\n /**\n * Transforms and drops entries in one pass: the callback returns\n * `Optional.some(value)` to keep an entry with a new value, or\n * `Optional.none` to drop it.\n *\n * **Type Behavior**: as with {@link filter}, the surviving keys are the keys\n * of the source record made optional, and a record keyed by an index\n * signature stays total. Unlike {@link filter}, every kept value takes the\n * type the callback returns.\n *\n * `Optional` rather than `undefined` marks the dropped entries, so a record\n * whose values are legitimately `undefined` stays expressible.\n *\n * **Key handling**: keys reach the callback the way `Object.entries` yields\n * them, so a numeric key `1` arrives as `'1'`. Symbol-keyed properties are\n * not enumerated by `Object.entries`; they are dropped from both the result\n * and its type.\n *\n * @example\n *\n * <!-- doc:embed:jsdoc:example:./samples/src/object/filter-map-example.mts -->\n *\n * ```ts\n * const scores = { alice: 1, bob: 2 } as const;\n *\n * // `Optional.some` keeps an entry with a new value, `Optional.none` drops it.\n * const labelled = Obj.filterMap(scores, (value, key) =>\n * value > 1 ? Optional.some(`${key}=${value}`) : Optional.none,\n * );\n *\n * assert.deepStrictEqual(labelled, { bob: 'bob=2' });\n * ```\n *\n * <!-- /doc:embed:jsdoc:example:./samples/src/object/filter-map-example.mts -->\n *\n * @template R - The type of the source record\n * @template V2 - The type the callback returns for the entries it keeps\n * @param record - The record whose entries are transformed and filtered\n * @param mapFn - Called once per own enumerable string key, with the value\n * and the key\n * @returns A new record holding only the kept entries, with mapped values\n */\n export const filterMap = <const R extends UnknownRecord, V2>(\n record: R,\n mapFn: (\n value: R[keyof R],\n key: TsDataForgeInternals.MappedRecordKey<R>,\n ) => Optional<V2>,\n ): TsDataForgeInternals.FilteredRecord<\n TsDataForgeInternals.MappedRecord<R, V2>\n > => {\n // `Object.entries` erases both the key and the value type of `R`, so the\n // callback is widened once here instead of asserting on every entry.\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n const mapFnWidened = mapFn as (value: unknown, key: string) => Optional<V2>;\n\n return (\n // `Object.entries` enumerates exactly the own enumerable string keys of\n // `record`, and this only ever drops entries or replaces their values, so\n // the result has a subset of those keys with `V2` values.\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Object.fromEntries(\n Object.entries(record).flatMap(([k, v]) => {\n const mapped = mapFnWidened(v, k);\n\n return Optional.isSome(mapped) ? [[k, mapped.value] as const] : [];\n }),\n ) as never\n );\n };\n\n /**\n * Merges multiple records into a single record using `Object.assign`.\n * Later records override properties from earlier records with the same key.\n *\n * @example\n *\n * <!-- doc:embed:jsdoc:example:./samples/src/object/merge-example.mts -->\n *\n * ```ts\n * const a = { a: 0, b: 0 } as const;\n *\n * const b = { b: 1, c: 0 } as const;\n *\n * const result = Obj.merge(a, b);\n *\n * assert.deepStrictEqual(result, { a: 0, b: 1, c: 0 });\n * ```\n *\n * <!-- /doc:embed:jsdoc:example:./samples/src/object/merge-example.mts -->\n *\n * @param records - The records to merge\n * @returns A new record with all properties merged\n */\n export const merge = <const Records extends readonly UnknownRecord[]>(\n ...records: Records\n ): TsDataForgeInternals.MergeAll<Records> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Object.fromEntries(records.flatMap((r) => Object.entries(r))) as never;\n\n /**\n * Deeply picks a nested property from an object along the specified key path.\n * Supports both direct and curried usage.\n *\n * @example\n *\n * ```ts\n * const data = { a: { b: { c: 1, d: 2 }, e: 3 }, f: 4 } as const;\n *\n * // Direct usage\n * const result = Obj.deepPick(data, ['a', 'b', 'c']);\n *\n * assert.deepStrictEqual(result, { a: { b: { c: 1 } } });\n *\n * // Curried usage with pipe\n * const pickAB = Obj.deepPick(['a', 'b']);\n *\n * const result2 = pipe(data).map(pickAB).value;\n *\n * assert.deepStrictEqual(result2, { a: { b: { c: 1, d: 2 } } });\n * ```\n *\n * @template R - The type of the input record\n * @template Path - The key path tuple\n * @param record - The source record\n * @param path - A readonly tuple of keys representing the nested path\n * @returns A new record containing only the nested property at the path\n */\n export function deepPick<\n const R extends UnknownRecord,\n const Path extends readonly (string | number)[],\n >(record: R, path: Path): DeepPick<R, Path>;\n\n // Curried version\n export function deepPick<const Path extends readonly (string | number)[]>(\n path: Path,\n ): <const R extends UnknownRecord>(record: R) => DeepPick<R, Path>;\n\n export function deepPick<\n const R extends UnknownRecord,\n const Path extends readonly (string | number)[],\n >(\n ...args: readonly [record: R, path: Path] | readonly [path: Path]\n ): DeepPick<R, Path> | ((record: R) => DeepPick<R, Path>) {\n switch (args.length) {\n case 2: {\n const [record, path] = args;\n\n return (\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n deepPickImpl(record, path) as never\n );\n }\n\n case 1: {\n const [path] = args;\n\n return (record: R) => deepPick(record, path);\n }\n }\n }\n\n /**\n * Deeply omits a nested property from an object along the specified key path.\n * Supports both direct and curried usage.\n *\n * @example\n *\n * ```ts\n * const data = { a: { b: { c: 1, d: 2 }, e: 3 }, f: 4 } as const;\n *\n * // Direct usage\n * const result = Obj.deepOmit(data, ['a', 'b', 'c']);\n *\n * assert.deepStrictEqual(result, { a: { b: { d: 2 }, e: 3 }, f: 4 });\n *\n * // Curried usage with pipe\n * const omitAB = Obj.deepOmit(['a', 'b']);\n *\n * const result2 = pipe(data).map(omitAB).value;\n *\n * assert.deepStrictEqual(result2, { a: { e: 3 }, f: 4 });\n * ```\n *\n * @template R - The type of the input record\n * @template Path - The key path tuple\n * @param record - The source record\n * @param path - A readonly tuple of keys representing the nested path to omit\n * @returns A new record with the nested property at the path removed\n */\n export function deepOmit<\n const R extends UnknownRecord,\n const Path extends readonly (string | number)[],\n >(record: R, path: Path): DeepOmit<R, Path>;\n\n // Curried version\n export function deepOmit<const Path extends readonly (string | number)[]>(\n path: Path,\n ): <const R extends UnknownRecord>(record: R) => DeepOmit<R, Path>;\n\n export function deepOmit<\n const R extends UnknownRecord,\n const Path extends readonly (string | number)[],\n >(\n ...args: readonly [record: R, path: Path] | readonly [path: Path]\n ): DeepOmit<R, Path> | ((record: R) => DeepOmit<R, Path>) {\n switch (args.length) {\n case 2: {\n const [record, path] = args;\n\n return (\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n deepOmitImpl(record, path) as never\n );\n }\n\n case 1: {\n const [path] = args;\n\n return (record: R) => deepOmit(record, path);\n }\n }\n }\n}\n\nconst deepPickImpl = (\n record: UnknownRecord,\n path: readonly (string | number)[],\n): UnknownRecord => {\n if (!Arr.isNonEmpty(path)) return record;\n\n const head = path[0];\n\n if (!hasKey(record, head)) return {};\n\n const value = record[head];\n\n const tail = path.slice(1);\n\n if (!Arr.isNonEmpty(tail)) return { [head]: value };\n\n if (!isRecord(value)) return { [head]: {} };\n\n return {\n [head]: deepPickImpl(value, tail),\n };\n};\n\nconst deepOmitImpl = (\n record: UnknownRecord,\n path: readonly (string | number)[],\n): UnknownRecord => {\n if (!Arr.isNonEmpty(path)) return record;\n\n const head = path[0];\n\n if (!hasKey(record, head)) return record;\n\n const tail = path.slice(1);\n\n if (!Arr.isNonEmpty(tail)) {\n return Object.fromEntries(\n Object.entries(record).filter(([k]) => k !== head),\n );\n }\n\n const value = record[head];\n\n if (!isRecord(value)) return record;\n\n return {\n ...record,\n [head]: deepOmitImpl(value, tail),\n };\n};\n\n/**\n * @internal\n * Internal type utilities for the Obj module.\n */\ndeclare namespace TsDataForgeInternals {\n type RecursionLimit = 20;\n\n /** - `[['x', 1], ['y', 3]]` -> `{ x: 1, y: 3 }` */\n export type EntriesToObject<\n Entries extends readonly (readonly [PropertyKey, unknown])[],\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n > = Readonly<EntriesToObjectImpl<{}, Entries>>;\n\n /** @internal */\n type EntriesToObjectImpl<\n R,\n Entries extends readonly (readonly [PropertyKey, unknown])[],\n > =\n TypeEq<Entries['length'], 0> extends true\n ? R\n : EntriesToObjectImpl<\n R & ReadonlyRecord<Entries[0][0], Entries[0][1]>,\n List.Tail<Entries>\n >;\n\n /**\n * - `['x' | 'y' | 'z', number][]]` -> `'x' | 'y' | 'z'`\n * - `[['a' | 'b' | 'c', number], ...['x' | 'y' | 'z', number][]]` -> `'a' |\n * 'b' | 'c' | 'x' | 'y' | 'z'`\n *\n * @note To handle the second example above, recursion needs to be performed on infinite-length Entries,\n * but since the timing to stop cannot be determined, a recursion limit is set.\n */\n export type KeysOfEntries<\n Entries extends readonly (readonly [PropertyKey, unknown])[],\n > = KeysOfEntriesImpl<never, Entries, RecursionLimit>;\n\n type KeysOfEntriesImpl<\n K,\n Entries extends readonly (readonly [PropertyKey, unknown])[],\n RemainingNumRecursions extends number,\n > =\n TypeEq<RemainingNumRecursions, 0> extends true\n ? K\n : TypeEq<Entries['length'], 0> extends true\n ? K\n : KeysOfEntriesImpl<\n K | Entries[0][0],\n List.Tail<Entries>,\n Decrement<RemainingNumRecursions>\n >;\n\n export type ValuesOfEntries<\n Entries extends readonly (readonly [PropertyKey, unknown])[],\n > = ValuesOfEntriesImpl<never, Entries, RecursionLimit>;\n\n type ValuesOfEntriesImpl<\n K,\n Entries extends readonly (readonly [PropertyKey, unknown])[],\n RemainingNumRecursions extends number,\n > =\n TypeEq<RemainingNumRecursions, 0> extends true\n ? K\n : TypeEq<Entries['length'], 0> extends true\n ? K\n : ValuesOfEntriesImpl<\n K | Entries[0][1],\n List.Tail<Entries>,\n Decrement<RemainingNumRecursions>\n >;\n\n export type PartialIfKeyIsUnion<K, T> =\n IsUnion<K> extends true ? Partial<T> : T;\n\n /**\n * The keys `Object.entries` yields for `R`: symbol keys are not enumerated,\n * and a numeric key `1` arrives as the string `'1'`.\n */\n export type MappedRecordKey<R> = ToString<RelaxedExclude<keyof R, symbol>>;\n\n /**\n * `R` with every value replaced by `V2`. Homomorphic over `keyof R`, so\n * optional modifiers and index signatures are preserved; the key remapping\n * drops the symbol keys that `Object.entries` would not have visited.\n */\n export type MappedRecord<R, V2> = Readonly<{\n [K in keyof R as K extends symbol ? never : K]: V2;\n }>;\n\n /** `R` without the symbol keys `Object.entries` never visits. */\n type StringKeyedRecord<R> = Readonly<{\n [K in keyof R as K extends symbol ? never : K]: R[K];\n }>;\n\n /**\n * The result of dropping entries from `R`: symbol keys go away, and the\n * remaining keys become optional because a predicate may reject any of them.\n *\n * A record keyed by an index signature stays total instead. It names no\n * specific key that could go missing, and `noUncheckedIndexedAccess` already\n * adds `| undefined` on access, so making it `Partial` would add nothing and\n * would only stop the result from being assignable back to the record type it\n * came from.\n */\n export type FilteredRecord<R> = string extends keyof R\n ? StringKeyedRecord<R>\n : number extends keyof R\n ? StringKeyedRecord<R>\n : Readonly<{ [K in keyof R as K extends symbol ? never : K]?: R[K] }>;\n\n /**\n * Merges two object types where keys in B override keys in A, preserving optional modifiers.\n *\n * This implementation uses a sophisticated technique to preserve optional property modifiers (`?`)\n * during the merge operation, which would otherwise be lost in a naive mapped type implementation.\n *\n * ## Core Technique: Optional Property Detection\n *\n * Uses `{} extends Pick<T, K>` to determine if a property is optional:\n * - **Required property**: `Pick<T, 'x'>` = `{ x: number }` → `{}` does NOT extend it (false)\n * - **Optional property**: `Pick<T, 'y'>` = `{ y?: string }` → `{}` DOES extend it (true)\n *\n * This works because `{}` (empty object) is assignable to objects with only optional properties\n * but not to objects with required properties.\n *\n * ## Implementation Strategy\n *\n * The type is constructed as an intersection of five mapped types:\n *\n * 1. **Required properties from B** - Properties in B that are required (override A completely)\n * 2. **Optional properties from B (not in A)** - New optional properties from B\n * 3. **Optional properties from B (in A)** - Union of A[K] | B[K] to preserve both possibilities\n * 4. **Required properties only in A** - Properties in A but not in B that are required\n * 5. **Optional properties only in A** - Properties in A but not in B that are optional (with `?` modifier)\n *\n * Finally, the intersection is flattened using an optional-preserving identity mapping that\n * re-applies the optional detection logic to maintain the `?` modifiers in the final type.\n *\n * @example\n * ```ts\n * type A = Readonly<{ x: number; y?: string }>;\n *\n * type B = Readonly<{ y?: number; z?: boolean }>;\n *\n * type Result = MergeTwo<A, B>;\n * // Result: Readonly<{ x: number; y?: string | number; z?: boolean }>\n * ```\n */\n // transformer-ignore-next-line\n type MergeTwo<A extends UnknownRecord, B extends UnknownRecord> = {\n // 1. Required properties from B (override A completely)\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n readonly [K in keyof B as {} extends StrictPick<B, K> ? never : K]: B[K];\n } & {\n // 2. Optional properties from B that are NOT in A\n readonly [\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n K in keyof B as {} extends StrictPick<B, K>\n ? K extends keyof A\n ? never\n : K\n : never\n ]?: B[K];\n } & {\n // 3. Optional properties from B that ARE in A (create union)\n readonly [\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n K in keyof B as {} extends StrictPick<B, K>\n ? K extends keyof A\n ? K\n : never\n : never\n ]?: K extends keyof A ? A[K] | B[K] : never;\n } & {\n // 4. Required properties only in A (not overridden by B)\n readonly [\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n K in RelaxedExclude<keyof A, keyof B> as {} extends StrictPick<A, K>\n ? never\n : K\n ]: A[K];\n } & {\n // 5. Optional properties only in A (not overridden by B)\n readonly [\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n K in RelaxedExclude<keyof A, keyof B> as {} extends StrictPick<A, K>\n ? K\n : never\n ]?: A[K];\n } extends infer O\n ? Readonly<\n {\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n [K in keyof O as {} extends StrictPick<O, K> ? never : K]: O[K];\n } & {\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n [K in keyof O as {} extends StrictPick<O, K> ? K : never]?: O[K];\n }\n >\n : never;\n\n /** Sequentially merges a tuple of object types from left to right. */\n export type MergeAll<\n Records extends readonly UnknownRecord[],\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n Acc extends UnknownRecord = {},\n > =\n IsFixedLengthList<Records> extends false\n ? ArrayElement<Records>\n : Records extends readonly [\n infer First extends UnknownRecord,\n ...infer Rest extends readonly UnknownRecord[],\n ]\n ? MergeAll<Rest, MergeTwo<Acc, First>>\n : Acc;\n}\n"],"names":["Obj","Optional.isSome","Arr.isNonEmpty"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BO,IAAU;AAAA,CAAV,CAAUA,IAAAA,KAAV;AA2CE,EAAMA,KAAA,SAAA,GAAY,CACvB,GACA,CAAA,EACA,EAAA,GAA0C,OAAO,EAAA,KACrC;AACZ,IAAA,MAAM,QAAA,GAAW,MAAA,CAAO,OAAA,CAAQ,CAA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M,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CACnD,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IAE3B,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,MAAM,CAAC;IAEpC,OAAO;QACL,GAAG,MAAM;QACT,CAAC,IAAI,CAAC,EAAE,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC;KAClC,CAAC;AACJ,CAAC,CAAC"}
@@ -1,11 +1,38 @@
1
- const castMutable = (readonlyValue) => (
2
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
3
- readonlyValue
4
- );
5
- const castDeepMutable = (readonlyValue) => (
6
- // eslint-disable-next-line total-functions/no-unsafe-type-assertion
7
- readonlyValue
8
- );
9
-
10
- export { castDeepMutable, castMutable };
11
- //# sourceMappingURL=cast-mutable.mjs.map
1
+ /**
2
+ * Casts a readonly type `T` to its `Mutable<T>` equivalent.
3
+ *
4
+ * **⚠️ Safety Warning**: This is a type assertion that bypasses TypeScript's
5
+ * immutability guarantees. The runtime value remains unchanged - only the type
6
+ * system's view of it changes. Use with caution as it can lead to unexpected
7
+ * mutations of data that was intended to be immutable.
8
+ *
9
+ * @template T - The type of the readonly value
10
+ * @param readonlyValue - The readonly value to cast to mutable
11
+ * @returns The same value with readonly modifiers removed from its type
12
+ * @see castDeepMutable - For deeply nested readonly structures
13
+ * @see castReadonly - For the opposite operation
14
+ */
15
+ export const castMutable = (readonlyValue) =>
16
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
17
+ readonlyValue;
18
+ /**
19
+ * Casts a readonly type `T` to its `DeepMutable<T>` equivalent, recursively
20
+ * removing all readonly modifiers.
21
+ *
22
+ * **⚠️ Safety Warning**: This recursively bypasses ALL immutability guarantees
23
+ * in nested structures. Extremely dangerous for complex data structures as it
24
+ * allows mutation at any depth. The runtime value is unchanged - only
25
+ * TypeScript's type checking is affected.
26
+ *
27
+ * @template T - The type of the deeply readonly value
28
+ * @param readonlyValue - The deeply readonly value to cast to deeply mutable
29
+ * @returns The same value with all readonly modifiers recursively removed from
30
+ * its type
31
+ * @see castMutable - For shallow mutability casting
32
+ * @see castDeepReadonly - For the opposite operation
33
+ * @see structuredClone - Recommended for creating safe copies before mutation
34
+ */
35
+ export const castDeepMutable = (readonlyValue) =>
36
+ // eslint-disable-next-line total-functions/no-unsafe-type-assertion
37
+ readonlyValue;
38
+ //# sourceMappingURL=cast-mutable.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"cast-mutable.mjs","sources":["../../src/others/cast-mutable.mts"],"sourcesContent":["import { type DeepMutable, type Mutable } from 'ts-type-forge';\n\n/**\n * Casts a readonly type `T` to its `Mutable<T>` equivalent.\n *\n * **⚠️ Safety Warning**: This is a type assertion that bypasses TypeScript's\n * immutability guarantees. The runtime value remains unchanged - only the type\n * system's view of it changes. Use with caution as it can lead to unexpected\n * mutations of data that was intended to be immutable.\n *\n * @template T - The type of the readonly value\n * @param readonlyValue - The readonly value to cast to mutable\n * @returns The same value with readonly modifiers removed from its type\n * @see castDeepMutable - For deeply nested readonly structures\n * @see castReadonly - For the opposite operation\n */\nexport const castMutable = <T,>(readonlyValue: T): Mutable<T> =>\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n readonlyValue as Mutable<T>;\n\n/**\n * Casts a readonly type `T` to its `DeepMutable<T>` equivalent, recursively\n * removing all readonly modifiers.\n *\n * **⚠️ Safety Warning**: This recursively bypasses ALL immutability guarantees\n * in nested structures. Extremely dangerous for complex data structures as it\n * allows mutation at any depth. The runtime value is unchanged - only\n * TypeScript's type checking is affected.\n *\n * @template T - The type of the deeply readonly value\n * @param readonlyValue - The deeply readonly value to cast to deeply mutable\n * @returns The same value with all readonly modifiers recursively removed from\n * its type\n * @see castMutable - For shallow mutability casting\n * @see castDeepReadonly - For the opposite operation\n * @see structuredClone - Recommended for creating safe copies before mutation\n */\nexport const castDeepMutable = <T,>(readonlyValue: T): DeepMutable<T> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n readonlyValue as DeepMutable<T>;\n"],"names":[],"mappings":"AAgBO,MAAM,cAAc,CAAK,aAAA;AAAA;AAAA,EAE9B;AAAA;AAmBK,MAAM,kBAAkB,CAAK,aAAA;AAAA;AAAA,EAElC;AAAA;;;;"}
1
+ {"version":3,"file":"cast-mutable.mjs","sourceRoot":"","sources":["../../src/others/cast-mutable.mts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAK,aAAgB,EAAc,EAAE;AAC9D,4EAA4E;AAC5E,aAA2B,CAAC;AAE9B;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAK,aAAgB,EAAkB,EAAE;AACtE,oEAAoE;AACpE,aAA+B,CAAC"}
@@ -1,11 +1,37 @@
1
- const castReadonly = (mutable) => (
2
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
3
- mutable
4
- );
5
- const castDeepReadonly = (mutable) => (
6
- // eslint-disable-next-line total-functions/no-unsafe-type-assertion
7
- mutable
8
- );
9
-
10
- export { castDeepReadonly, castReadonly };
11
- //# sourceMappingURL=cast-readonly.mjs.map
1
+ /**
2
+ * Casts a mutable type `T` to its `Readonly<T>` equivalent.
3
+ *
4
+ * This is a safe type assertion that adds immutability constraints at the type
5
+ * level. The runtime value remains unchanged - only TypeScript's view of it
6
+ * becomes readonly. This helps prevent accidental mutations and makes code
7
+ * intentions clearer.
8
+ *
9
+ * @template T - The type of the mutable value
10
+ * @param mutable - The mutable value to cast to readonly
11
+ * @returns The same value with readonly modifiers added to its type
12
+ * @see castDeepReadonly - For deeply nested structures
13
+ * @see castMutable - For the opposite operation (use with caution)
14
+ */
15
+ export const castReadonly = (mutable) =>
16
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
17
+ mutable;
18
+ /**
19
+ * Casts a mutable type `T` to its `DeepReadonly<T>` equivalent, recursively
20
+ * adding readonly modifiers.
21
+ *
22
+ * This is a safe type assertion that adds immutability constraints at ALL
23
+ * levels of nesting. Provides complete protection against mutations in complex
24
+ * data structures. The runtime value is unchanged - only TypeScript's type
25
+ * checking is enhanced.
26
+ *
27
+ * @template T - The type of the mutable value
28
+ * @param mutable - The mutable value to cast to deeply readonly
29
+ * @returns The same value with readonly modifiers recursively added to all
30
+ * properties
31
+ * @see castReadonly - For shallow readonly casting
32
+ * @see castDeepMutable - For the opposite operation (use with extreme caution)
33
+ */
34
+ export const castDeepReadonly = (mutable) =>
35
+ // eslint-disable-next-line total-functions/no-unsafe-type-assertion
36
+ mutable;
37
+ //# sourceMappingURL=cast-readonly.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"cast-readonly.mjs","sources":["../../src/others/cast-readonly.mts"],"sourcesContent":["import { type DeepReadonly } from 'ts-type-forge';\n\n/**\n * Casts a mutable type `T` to its `Readonly<T>` equivalent.\n *\n * This is a safe type assertion that adds immutability constraints at the type\n * level. The runtime value remains unchanged - only TypeScript's view of it\n * becomes readonly. This helps prevent accidental mutations and makes code\n * intentions clearer.\n *\n * @template T - The type of the mutable value\n * @param mutable - The mutable value to cast to readonly\n * @returns The same value with readonly modifiers added to its type\n * @see castDeepReadonly - For deeply nested structures\n * @see castMutable - For the opposite operation (use with caution)\n */\nexport const castReadonly = <T,>(mutable: T): Readonly<T> =>\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n mutable as Readonly<T>;\n\n/**\n * Casts a mutable type `T` to its `DeepReadonly<T>` equivalent, recursively\n * adding readonly modifiers.\n *\n * This is a safe type assertion that adds immutability constraints at ALL\n * levels of nesting. Provides complete protection against mutations in complex\n * data structures. The runtime value is unchanged - only TypeScript's type\n * checking is enhanced.\n *\n * @template T - The type of the mutable value\n * @param mutable - The mutable value to cast to deeply readonly\n * @returns The same value with readonly modifiers recursively added to all\n * properties\n * @see castReadonly - For shallow readonly casting\n * @see castDeepMutable - For the opposite operation (use with extreme caution)\n */\nexport const castDeepReadonly = <T,>(mutable: T): DeepReadonly<T> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n mutable as DeepReadonly<T>;\n"],"names":[],"mappings":"AAgBO,MAAM,eAAe,CAAK,OAAA;AAAA;AAAA,EAE/B;AAAA;AAkBK,MAAM,mBAAmB,CAAK,OAAA;AAAA;AAAA,EAEnC;AAAA;;;;"}
1
+ {"version":3,"file":"cast-readonly.mjs","sourceRoot":"","sources":["../../src/others/cast-readonly.mts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAK,OAAU,EAAe,EAAE;AAC1D,4EAA4E;AAC5E,OAAsB,CAAC;AAEzB;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAK,OAAU,EAAmB,EAAE;AAClE,oEAAoE;AACpE,OAA0B,CAAC"}
@@ -1,12 +1,23 @@
1
- const debounce = (func, waitMilliseconds) => {
2
- let mut_timeoutId;
3
- return (...args) => {
4
- clearTimeout(mut_timeoutId);
5
- mut_timeoutId = setTimeout(() => {
6
- func(...args);
7
- }, waitMilliseconds);
8
- };
1
+ /**
2
+ * Creates a debounced function that delays invoking `func` until after `waitMilliseconds`
3
+ * have elapsed since the last time the debounced function was invoked.
4
+ *
5
+ * @template F The type of the function to debounce.
6
+ * @param func The function to debounce.
7
+ * @param waitMilliseconds The number of milliseconds to delay.
8
+ * @returns The new debounced function.
9
+ */
10
+ export const debounce = (func, waitMilliseconds) => {
11
+ // Not `ReturnType<typeof setTimeout>`: with both the DOM and Node
12
+ // declarations in scope that resolves to `unknown`, which `clearTimeout`
13
+ // will not take. Naming what `clearTimeout` accepts says the same thing and
14
+ // stays true in either environment.
15
+ let mut_timeoutId;
16
+ return (...args) => {
17
+ clearTimeout(mut_timeoutId);
18
+ mut_timeoutId = setTimeout(() => {
19
+ func(...args);
20
+ }, waitMilliseconds);
21
+ };
9
22
  };
10
-
11
- export { debounce };
12
- //# sourceMappingURL=debounce-function.mjs.map
23
+ //# sourceMappingURL=debounce-function.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"debounce-function.mjs","sources":["../../src/others/debounce-function.mts"],"sourcesContent":["/**\n * Creates a debounced function that delays invoking `func` until after `waitMilliseconds`\n * have elapsed since the last time the debounced function was invoked.\n *\n * @template F The type of the function to debounce.\n * @param func The function to debounce.\n * @param waitMilliseconds The number of milliseconds to delay.\n * @returns The new debounced function.\n */\nexport const debounce = <Args extends readonly unknown[]>(\n func: (...args: Args) => void,\n waitMilliseconds: number,\n): ((...args: Args) => void) => {\n // Not `ReturnType<typeof setTimeout>`: with both the DOM and Node\n // declarations in scope that resolves to `unknown`, which `clearTimeout`\n // will not take. Naming what `clearTimeout` accepts says the same thing and\n // stays true in either environment.\n let mut_timeoutId: Parameters<typeof clearTimeout>[0];\n\n return (...args: Args): void => {\n clearTimeout(mut_timeoutId);\n\n mut_timeoutId = setTimeout(() => {\n func(...args);\n }, waitMilliseconds);\n };\n};\n"],"names":[],"mappings":"AASO,MAAM,QAAA,GAAW,CACtB,IAAA,EACA,gBAAA,KAC8B;AAK9B,EAAA,IAAI,aAAA;AAEJ,EAAA,OAAO,IAAI,IAAA,KAAqB;AAC9B,IAAA,YAAA,CAAa,aAAa,CAAA;AAE1B,IAAA,aAAA,GAAgB,WAAW,MAAM;AAC/B,MAAA,IAAA,CAAK,GAAG,IAAI,CAAA;AAAA,IACd,GAAG,gBAAgB,CAAA;AAAA,EACrB,CAAA;AACF;;;;"}
1
+ {"version":3,"file":"debounce-function.mjs","sourceRoot":"","sources":["../../src/others/debounce-function.mts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,IAA6B,EAC7B,gBAAwB,EACG,EAAE;IAC7B,kEAAkE;IAClE,yEAAyE;IACzE,4EAA4E;IAC5E,oCAAoC;IACpC,IAAI,aAAiD,CAAC;IAEtD,OAAO,CAAC,GAAG,IAAU,EAAQ,EAAE;QAC7B,YAAY,CAAC,aAAa,CAAC,CAAC;QAE5B,aAAa,GAAG,UAAU,CAAC,GAAG,EAAE;YAC9B,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;QAChB,CAAC,EAAE,gBAAgB,CAAC,CAAC;IACvB,CAAC,CAAC;AACJ,CAAC,CAAC"}
@@ -1,56 +1,75 @@
1
- import { isMap, isSet, isTypedArray, isRegExp } from '@sindresorhus/is';
2
- import { hasKey } from '../guard/has-key.mjs';
3
- import { isRecord } from '../guard/is-record.mjs';
4
-
5
- const fastDeepEqual = (a, b) => {
6
- if (a === b) {
7
- return true;
8
- }
9
- if (typeof a !== typeof b) {
10
- return false;
11
- }
12
- if (Array.isArray(a)) {
13
- return Array.isArray(b) && a.constructor === b.constructor && a.length === b.length && a.every((ai, index) => fastDeepEqual(ai, b[index]));
14
- }
15
- if (isRecord(a)) {
16
- if (!isRecord(b)) {
17
- return false;
1
+ import { isMap, isRegExp, isSet, isTypedArray } from '@sindresorhus/is';
2
+ import { hasKey, isRecord } from '../guard/index.mjs';
3
+ /**
4
+ * The fastest deep equal with ES6 Map, Set and Typed arrays support.
5
+ * Checks equality of Date and RegExp objects by value.
6
+ *
7
+ * Forked from https://github.com/epoberezkin/fast-deep-equal/blob/v3.1.3/src/index.jst
8
+ */
9
+ export const fastDeepEqual = (a, b) => {
10
+ if (a === b) {
11
+ return true;
18
12
  }
19
- if (a.constructor !== b.constructor) {
20
- return false;
13
+ if (typeof a !== typeof b) {
14
+ return false;
21
15
  }
22
- if (isMap(a)) {
23
- return isMap(b) && a.size === b.size && a.entries().every(
24
- ([key, value]) => b.has(key) && fastDeepEqual(value, b.get(key))
25
- );
16
+ // Arrays are handled before `isRecord`, which excludes them.
17
+ if (Array.isArray(a)) {
18
+ return (Array.isArray(b) &&
19
+ a.constructor === b.constructor &&
20
+ a.length === b.length &&
21
+ a.every((ai, index) => fastDeepEqual(ai, b[index])));
26
22
  }
27
- if (isSet(a)) {
28
- return isSet(b) && a.size === b.size && a.entries().every(([value]) => b.has(value));
23
+ if (isRecord(a)) {
24
+ if (!isRecord(b)) {
25
+ return false;
26
+ }
27
+ if (a.constructor !== b.constructor) {
28
+ return false;
29
+ }
30
+ if (isMap(a)) {
31
+ return (isMap(b) &&
32
+ a.size === b.size &&
33
+ a
34
+ .entries()
35
+ .every(([key, value]) => b.has(key) && fastDeepEqual(value, b.get(key))));
36
+ }
37
+ if (isSet(a)) {
38
+ return (isSet(b) &&
39
+ a.size === b.size &&
40
+ a.entries().every(([value]) => b.has(value)));
41
+ }
42
+ if (isTypedArray(a)) {
43
+ return (isTypedArray(b) &&
44
+ a.length === b.length &&
45
+ a.every((value, index) => value === b[index]));
46
+ }
47
+ if (isRegExp(a)) {
48
+ return isRegExp(b) && a.source === b.source && a.flags === b.flags;
49
+ }
50
+ if (a.valueOf !== Object.prototype.valueOf) {
51
+ return a.valueOf() === b.valueOf();
52
+ }
53
+ if (a.toString !== Object.prototype.toString) {
54
+ return a.toString() === b.toString();
55
+ }
56
+ const aKeys = Object.keys(a);
57
+ const bKeys = Object.keys(b);
58
+ return (aKeys.length === bKeys.length &&
59
+ aKeys.every((key) => hasKey(b, key) &&
60
+ // React-specific: avoid traversing React elements' _owner.
61
+ // _owner contains circular references
62
+ // and is not needed when comparing the actual elements (and not their owners)
63
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
64
+ !(key === '_owner' && a['$$typeof']) &&
65
+ fastDeepEqual(a[key], b[key])));
29
66
  }
30
- if (isTypedArray(a)) {
31
- return isTypedArray(b) && a.length === b.length && a.every((value, index) => value === b[index]);
32
- }
33
- if (isRegExp(a)) {
34
- return isRegExp(b) && a.source === b.source && a.flags === b.flags;
35
- }
36
- if (a.valueOf !== Object.prototype.valueOf) {
37
- return a.valueOf() === b.valueOf();
38
- }
39
- if (a.toString !== Object.prototype.toString) {
40
- return a.toString() === b.toString();
41
- }
42
- const aKeys = Object.keys(a);
43
- const bKeys = Object.keys(b);
44
- return aKeys.length === bKeys.length && aKeys.every(
45
- (key) => hasKey(b, key) && // React-specific: avoid traversing React elements' _owner.
46
- // _owner contains circular references
47
- // and is not needed when comparing the actual elements (and not their owners)
48
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
49
- !(key === "_owner" && a["$$typeof"]) && fastDeepEqual(a[key], b[key])
50
- );
51
- }
52
- return typeof a === "number" && typeof b === "number" && Number.isNaN(a) && Number.isNaN(b);
67
+ // true if both NaN, false otherwise. `Number.isNaN` takes a number: called
68
+ // with anything else it is always false, so the check belongs behind a
69
+ // `typeof` guard rather than relying on that.
70
+ return (typeof a === 'number' &&
71
+ typeof b === 'number' &&
72
+ Number.isNaN(a) &&
73
+ Number.isNaN(b));
53
74
  };
54
-
55
- export { fastDeepEqual };
56
- //# sourceMappingURL=fast-deep-equal.mjs.map
75
+ //# sourceMappingURL=fast-deep-equal.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"fast-deep-equal.mjs","sources":["../../src/others/fast-deep-equal.mts"],"sourcesContent":["import { isMap, isRegExp, isSet, isTypedArray } from '@sindresorhus/is';\nimport { hasKey, isRecord } from '../guard/index.mjs';\n\n/**\n * The fastest deep equal with ES6 Map, Set and Typed arrays support.\n * Checks equality of Date and RegExp objects by value.\n *\n * Forked from https://github.com/epoberezkin/fast-deep-equal/blob/v3.1.3/src/index.jst\n */\nexport const fastDeepEqual = <T,>(a: T, b: T): boolean => {\n if (a === b) {\n return true;\n }\n\n if (typeof a !== typeof b) {\n return false;\n }\n\n // Arrays are handled before `isRecord`, which excludes them.\n if (Array.isArray(a)) {\n return (\n Array.isArray(b) &&\n a.constructor === b.constructor &&\n a.length === b.length &&\n a.every((ai, index) => fastDeepEqual(ai, b[index]))\n );\n }\n\n if (isRecord(a)) {\n if (!isRecord(b)) {\n return false;\n }\n\n if (a.constructor !== b.constructor) {\n return false;\n }\n\n if (isMap(a)) {\n return (\n isMap(b) &&\n a.size === b.size &&\n a\n .entries()\n .every(\n ([key, value]) => b.has(key) && fastDeepEqual(value, b.get(key)),\n )\n );\n }\n\n if (isSet(a)) {\n return (\n isSet(b) &&\n a.size === b.size &&\n a.entries().every(([value]) => b.has(value))\n );\n }\n\n if (isTypedArray(a)) {\n return (\n isTypedArray(b) &&\n a.length === b.length &&\n a.every((value, index) => value === b[index])\n );\n }\n\n if (isRegExp(a)) {\n return isRegExp(b) && a.source === b.source && a.flags === b.flags;\n }\n\n if (a.valueOf !== Object.prototype.valueOf) {\n return a.valueOf() === b.valueOf();\n }\n\n if (a.toString !== Object.prototype.toString) {\n return a.toString() === b.toString();\n }\n\n const aKeys: readonly string[] = Object.keys(a);\n\n const bKeys: readonly string[] = Object.keys(b);\n\n return (\n aKeys.length === bKeys.length &&\n aKeys.every(\n (key) =>\n hasKey(b, key) &&\n // React-specific: avoid traversing React elements' _owner.\n // _owner contains circular references\n // and is not needed when comparing the actual elements (and not their owners)\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n !(key === '_owner' && a['$$typeof']) &&\n fastDeepEqual(a[key], b[key]),\n )\n );\n }\n\n // true if both NaN, false otherwise. `Number.isNaN` takes a number: called\n // with anything else it is always false, so the check belongs behind a\n // `typeof` guard rather than relying on that.\n return (\n typeof a === 'number' &&\n typeof b === 'number' &&\n Number.isNaN(a) &&\n Number.isNaN(b)\n );\n};\n"],"names":[],"mappings":";;;;AASO,MAAM,aAAA,GAAgB,CAAK,CAAA,EAAM,CAAA,KAAkB;AACxD,EAAA,IAAI,MAAM,CAAA,EAAG;AACX,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,IAAI,OAAO,CAAA,KAAM,OAAO,CAAA,EAAG;AACzB,IAAA,OAAO,KAAA;AAAA,EACT;AAGA,EAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,CAAC,CAAA,EAAG;AACpB,I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AQ,KAAK,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;YAC7C,OAAO,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC;QACvC,CAAC;QAED,MAAM,KAAK,GAAsB,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAEhD,MAAM,KAAK,GAAsB,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAEhD,OAAO,CACL,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM;YAC7B,KAAK,CAAC,KAAK,CACT,CAAC,GAAG,EAAE,EAAE,CACN,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC;gBACd,2DAA2D;gBAC3D,uCAAuC;gBACvC,8EAA8E;gBAC9E,yEAAyE;gBACzE,CAAC,CAAC,GAAG,KAAK,QAAQ,IAAI,CAAC,CAAC,UAAU,CAAC,CAAC;gBACpC,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAChC,CACF,CAAC;IACJ,CAAC;IAED,2EAA2E;IAC3E,uEAAuE;IACvE,8CAA8C;IAC9C,OAAO,CACL,OAAO,CAAC,KAAK,QAAQ;QACrB,OAAO,CAAC,KAAK,QAAQ;QACrB,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAChB,CAAC;AACJ,CAAC,CAAC"}
@@ -1,5 +1,32 @@
1
- const ifThen = (antecedent, consequent) => !antecedent || consequent;
2
- const implies = ifThen;
3
-
4
- export { ifThen, implies };
5
- //# sourceMappingURL=if-then.mjs.map
1
+ /**
2
+ * Implements the logical implication (if-then) operator.
3
+ *
4
+ * Returns `true` if the antecedent is `false` or the consequent is `true`. In
5
+ * logical terms: `antecedent → consequent` is equivalent to `¬antecedent ∨
6
+ * consequent`.
7
+ *
8
+ * **Truth table:**
9
+ *
10
+ * - `true → true` = `true` (valid implication)
11
+ * - `true → false` = `false` (invalid implication)
12
+ * - `false → true` = `true` (vacuously true)
13
+ * - `false → false` = `true` (vacuously true)
14
+ *
15
+ * @param antecedent - The condition (if part)
16
+ * @param consequent - The result that should hold if the condition is true
17
+ * (then part)
18
+ * @returns `true` if the implication holds, `false` otherwise
19
+ */
20
+ export const ifThen = (antecedent, consequent) => !antecedent || consequent;
21
+ /**
22
+ * Alias for {@link ifThen}.
23
+ *
24
+ * Implements the logical implication (if-then) operator.
25
+ *
26
+ * @param antecedent - The condition (if part)
27
+ * @param consequent - The result that should hold if the condition is true
28
+ * (then part)
29
+ * @returns `true` if the implication holds, `false` otherwise
30
+ */
31
+ export const implies = ifThen;
32
+ //# sourceMappingURL=if-then.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"if-then.mjs","sources":["../../src/others/if-then.mts"],"sourcesContent":["/**\n * Implements the logical implication (if-then) operator.\n *\n * Returns `true` if the antecedent is `false` or the consequent is `true`. In\n * logical terms: `antecedent → consequent` is equivalent to `¬antecedent ∨\n * consequent`.\n *\n * **Truth table:**\n *\n * - `true → true` = `true` (valid implication)\n * - `true → false` = `false` (invalid implication)\n * - `false → true` = `true` (vacuously true)\n * - `false → false` = `true` (vacuously true)\n *\n * @param antecedent - The condition (if part)\n * @param consequent - The result that should hold if the condition is true\n * (then part)\n * @returns `true` if the implication holds, `false` otherwise\n */\nexport const ifThen = (antecedent: boolean, consequent: boolean): boolean =>\n !antecedent || consequent;\n\n/**\n * Alias for {@link ifThen}.\n *\n * Implements the logical implication (if-then) operator.\n *\n * @param antecedent - The condition (if part)\n * @param consequent - The result that should hold if the condition is true\n * (then part)\n * @returns `true` if the implication holds, `false` otherwise\n */\nexport const implies = ifThen;\n"],"names":[],"mappings":"AAmBO,MAAM,MAAA,GAAS,CAAC,UAAA,EAAqB,UAAA,KAC1C,CAAC,UAAA,IAAc;AAYV,MAAM,OAAA,GAAU;;;;"}
1
+ {"version":3,"file":"if-then.mjs","sourceRoot":"","sources":["../../src/others/if-then.mts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,UAAmB,EAAE,UAAmB,EAAW,EAAE,CAC1E,CAAC,UAAU,IAAI,UAAU,CAAC;AAE5B;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC"}
@@ -1,10 +1,10 @@
1
- export { castDeepMutable, castMutable } from './cast-mutable.mjs';
2
- export { castDeepReadonly, castReadonly } from './cast-readonly.mjs';
3
- export { debounce } from './debounce-function.mjs';
4
- export { fastDeepEqual } from './fast-deep-equal.mjs';
5
- export { ifThen, implies } from './if-then.mjs';
6
- export { mapNullable } from './map-nullable.mjs';
7
- export { memoizeFunction } from './memoize-function.mjs';
8
- export { tp } from './tuple.mjs';
9
- export { unknownToString } from './unknown-to-string.mjs';
10
- //# sourceMappingURL=index.mjs.map
1
+ export * from './cast-mutable.mjs';
2
+ export * from './cast-readonly.mjs';
3
+ export * from './debounce-function.mjs';
4
+ export * from './fast-deep-equal.mjs';
5
+ export * from './if-then.mjs';
6
+ export * from './map-nullable.mjs';
7
+ export * from './memoize-function.mjs';
8
+ export * from './tuple.mjs';
9
+ export * from './unknown-to-string.mjs';
10
+ //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/others/index.mts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,yBAAyB,CAAC"}
@@ -1,15 +1,13 @@
1
- function mapNullable(...args) {
2
- switch (args.length) {
3
- case 2: {
4
- const [value, mapFn] = args;
5
- return value == null ? void 0 : mapFn(value);
1
+ export function mapNullable(...args) {
2
+ switch (args.length) {
3
+ case 2: {
4
+ const [value, mapFn] = args;
5
+ return value == null ? undefined : mapFn(value);
6
+ }
7
+ case 1: {
8
+ const [mapFn] = args;
9
+ return (value) => mapNullable(value, mapFn);
10
+ }
6
11
  }
7
- case 1: {
8
- const [mapFn] = args;
9
- return (value) => mapNullable(value, mapFn);
10
- }
11
- }
12
12
  }
13
-
14
- export { mapNullable };
15
- //# sourceMappingURL=map-nullable.mjs.map
13
+ //# sourceMappingURL=map-nullable.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"map-nullable.mjs","sources":["../../src/others/map-nullable.mts"],"sourcesContent":["/**\n * Applies a function to a value if the value is not `null` or `undefined`. If\n * the value is `null` or `undefined`, it returns `undefined`.\n *\n * This function provides a safe way to transform nullable values without\n * explicit null checks. It's similar to Optional.map() but works directly with\n * TypeScript's nullable types. Supports both regular and curried usage for\n * functional composition.\n *\n * @template A - The type of the input value (excluding null/undefined)\n * @template B - The type of the value returned by the mapping function\n * @param value - The value to potentially transform (can be `A`, `null`, or\n * `undefined`)\n * @param mapFn - A function that transforms a non-nullable value of type `A` to\n * type `B`\n * @returns The result of applying `mapFn` to `value` if value is not\n * null/undefined; otherwise `undefined`\n * @see Optional - For more complex optional value handling\n * @see Result - For error handling with detailed error information\n */\nexport function mapNullable<const A, const B>(\n value: A | null | undefined,\n mapFn: (v: A) => B,\n): B | undefined;\n\n// Curried version\nexport function mapNullable<const A, const B>(\n mapFn: (v: A) => B,\n): (value: A | null | undefined) => B | undefined;\n\nexport function mapNullable<const A, const B>(\n ...args:\n | readonly [value: A | null | undefined, mapFn: (v: A) => B]\n | readonly [mapFn: (v: A) => B]\n): (B | undefined) | ((value: A | null | undefined) => B | undefined) {\n switch (args.length) {\n case 2: {\n const [value, mapFn] = args;\n\n return value == null ? undefined : mapFn(value);\n }\n\n case 1: {\n const [mapFn] = args;\n\n return (value: A | null | undefined) => mapNullable(value, mapFn);\n }\n }\n}\n"],"names":[],"mappings":"AA8BO,SAAS,eACX,IAAA,EAGiE;AACpE,EAAA,QAAQ,KAAK,MAAA;AAAQ,IACnB,KAAK,CAAA,EAAG;AACN,MAAA,MAAM,CAAC,KAAA,EAAO,KAAK,CAAA,GAAI,IAAA;AAEvB,MAAA,OAAO,KAAA,IAAS,IAAA,GAAO,MAAA,GAAY,KAAA,CAAM,KAAK,CAAA;AAAA,IAChD;AAAA,IAEA,KAAK,CAAA,EAAG;AACN,MAAA,MAAM,CAAC,KAAK,CAAA,GAAI,IAAA;AAEhB,MAAA,OAAO,CAAC,KAAA,KAAgC,WAAA,CAAY,KAAA,EAAO,KAAK,CAAA;AAAA,IAClE;AAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"map-nullable.mjs","sourceRoot":"","sources":["../../src/others/map-nullable.mts"],"names":[],"mappings":"AA8BA,MAAM,UAAU,WAAW,CACzB,GAAG,IAE8B;IAEjC,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;QACpB,KAAK,CAAC,EAAE,CAAC;YACP,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;YAE5B,OAAO,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAClD,CAAC;QAED,KAAK,CAAC,EAAE,CAAC;YACP,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;YAErB,OAAO,CAAC,KAA2B,EAAE,EAAE,CAAC,WAAW,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACpE,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -1,17 +1,15 @@
1
- function memoizeFunction(fn, argsToCacheKey) {
2
- const mut_cache = /* @__PURE__ */ new Map();
3
- const defaultKey = /* @__PURE__ */ Symbol("memoize-default-key");
4
- return (...args) => {
5
- const key = argsToCacheKey === void 0 ? defaultKey : argsToCacheKey(...args);
6
- const cached = mut_cache.get(key);
7
- if (cached !== void 0) {
8
- return cached.value;
9
- }
10
- const result = fn(...args);
11
- mut_cache.set(key, { value: result });
12
- return result;
13
- };
1
+ export function memoizeFunction(fn, argsToCacheKey) {
2
+ const mut_cache = new Map();
3
+ const defaultKey = Symbol('memoize-default-key');
4
+ return (...args) => {
5
+ const key = argsToCacheKey === undefined ? defaultKey : argsToCacheKey(...args);
6
+ const cached = mut_cache.get(key);
7
+ if (cached !== undefined) {
8
+ return cached.value;
9
+ }
10
+ const result = fn(...args);
11
+ mut_cache.set(key, { value: result });
12
+ return result;
13
+ };
14
14
  }
15
-
16
- export { memoizeFunction };
17
- //# sourceMappingURL=memoize-function.mjs.map
15
+ //# sourceMappingURL=memoize-function.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"memoize-function.mjs","sources":["../../src/others/memoize-function.mts"],"sourcesContent":["import { type Primitive } from 'ts-type-forge';\n\n/**\n * Creates a memoized version of a function that caches results based on input\n * arguments.\n *\n * The memoized function stores results in an internal Map and returns cached\n * values for repeated calls with the same arguments. This can significantly\n * improve performance for expensive computations or I/O operations.\n *\n * **Important considerations:**\n *\n * - The cache grows unbounded - consider memory implications for long-running\n * applications\n * - Cache keys must be primitives (string, number, boolean, symbol, null,\n * undefined, bigint)\n * - Object arguments require careful key generation to ensure uniqueness\n * - Pure functions only - memoizing functions with side effects can lead to bugs\n *\n * @template A - The tuple type of the function arguments\n * @template R - The return type of the function\n * @template K - The primitive type used as the cache key (must be valid Map\n * key)\n * @param fn - The pure function to memoize\n * @param argsToCacheKey - Function that converts arguments to a unique cache\n * key. Optional for zero-argument functions.\n * @returns A memoized version of the input function with the same signature\n *\n * @see https://en.wikipedia.org/wiki/Memoization\n */\nexport function memoizeFunction<R>(fn: () => R): () => R;\n\nexport function memoizeFunction<\n Arg0,\n const RestArgs extends readonly unknown[],\n R,\n K extends Primitive,\n>(\n fn: (arg0: Arg0, ...args: RestArgs) => R,\n argsToCacheKey: (arg0: Arg0, ...args: RestArgs) => K,\n): (arg0: Arg0, ...args: RestArgs) => R;\n\nexport function memoizeFunction<\n const Args extends readonly unknown[],\n R,\n K extends Primitive,\n>(\n fn: (...args: Args) => R,\n argsToCacheKey?: (...args: Args) => K,\n): (...args: Args) => R {\n type CacheEntry = Readonly<{ value: R }>;\n\n const mut_cache = new Map<K | symbol, CacheEntry>();\n\n const defaultKey = Symbol('memoize-default-key');\n\n return (...args: Args): R => {\n const key: K | symbol =\n argsToCacheKey === undefined ? defaultKey : argsToCacheKey(...args);\n\n const cached = mut_cache.get(key);\n\n if (cached !== undefined) {\n return cached.value;\n }\n\n const result = fn(...args);\n\n mut_cache.set(key, { value: result });\n\n return result;\n };\n}\n"],"names":[],"mappings":"AA0CO,SAAS,eAAA,CAKd,IACA,cAAA,EACsB;AAGtB,EAAA,MAAM,SAAA,uBAAgB,GAAA,EAA4B;AAElD,EAAA,MAAM,UAAA,0BAAoB,qBAAqB,CAAA;AAE/C,EAAA,OAAO,IAAI,IAAA,KAAkB;AAC3B,IAAA,MAAM,MACJ,cAAA,KAAmB,MAAA,GAAY,UAAA,GAAa,cAAA,CAAe,GAAG,IAAI,CAAA;AAEpE,IAAA,MAAM,MAAA,GAAS,SAAA,CAAU,GAAA,CAAI,GAAG,CAAA;AAEhC,IAAA,IAAI,WAAW,MAAA,EAAW;AACxB,MAAA,OAAO,MAAA,CAAO,KAAA;AAAA,IAChB;AAEA,IAAA,MAAM,MAAA,GAAS,EAAA,CAAG,GAAG,IAAI,CAAA;AAEzB,IAAA,SAAA,CAAU,GAAA,CAAI,GAAA,EAAK,EAAE,KAAA,EAAO,QAAQ,CAAA;AAEpC,IAAA,OAAO,MAAA;AAAA,EACT,CAAA;AACF;;;;"}
1
+ {"version":3,"file":"memoize-function.mjs","sourceRoot":"","sources":["../../src/others/memoize-function.mts"],"names":[],"mappings":"AA0CA,MAAM,UAAU,eAAe,CAK7B,EAAwB,EACxB,cAAqC;IAIrC,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