@duplojs/utils 1.1.15 → 1.2.16

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 (480) hide show
  1. package/dist/array/reduce.cjs +25 -0
  2. package/dist/array/reduce.mjs +25 -0
  3. package/dist/array/reduceRight.cjs +25 -0
  4. package/dist/array/reduceRight.mjs +25 -0
  5. package/dist/array/types/extractTuple.d.ts +1 -1
  6. package/dist/common/asyncInnerPipe.d.ts +16 -11
  7. package/dist/common/asyncPipe.d.ts +16 -11
  8. package/dist/common/builder.cjs +5 -11
  9. package/dist/common/builder.d.ts +7 -7
  10. package/dist/common/builder.mjs +4 -10
  11. package/dist/common/createKindIdentifier.cjs +23 -0
  12. package/dist/common/createKindIdentifier.mjs +23 -0
  13. package/dist/common/equal.d.ts +4 -4
  14. package/dist/common/errorKindNamespace.cjs +9 -0
  15. package/dist/common/errorKindNamespace.d.ts +1 -0
  16. package/dist/common/errorKindNamespace.mjs +7 -0
  17. package/dist/common/forwardLog.cjs +8 -0
  18. package/dist/common/forwardLog.d.ts +1 -0
  19. package/dist/common/forwardLog.mjs +6 -0
  20. package/dist/common/index.d.ts +3 -0
  21. package/dist/common/innerPipe.d.ts +16 -11
  22. package/dist/common/instanceOf.cjs +25 -0
  23. package/dist/common/instanceOf.mjs +25 -0
  24. package/dist/common/kind.d.ts +1 -0
  25. package/dist/common/override.cjs +61 -0
  26. package/dist/common/override.d.ts +18 -0
  27. package/dist/common/override.mjs +59 -0
  28. package/dist/common/pipe.d.ts +16 -11
  29. package/dist/common/stringToBytes.cjs +4 -9
  30. package/dist/common/stringToBytes.d.ts +4 -4
  31. package/dist/common/stringToBytes.mjs +4 -9
  32. package/dist/common/stringToMillisecond.cjs +4 -9
  33. package/dist/common/stringToMillisecond.d.ts +4 -4
  34. package/dist/common/stringToMillisecond.mjs +4 -9
  35. package/dist/common/types/objectEntry.d.ts +1 -1
  36. package/dist/dataParser/base.cjs +27 -2
  37. package/dist/dataParser/base.d.ts +3 -0
  38. package/dist/dataParser/base.mjs +27 -2
  39. package/dist/dataParser/baseExtended.cjs +65 -5
  40. package/dist/dataParser/baseExtended.d.ts +3 -0
  41. package/dist/dataParser/baseExtended.mjs +65 -5
  42. package/dist/dataParser/extended/array.cjs +50 -4
  43. package/dist/dataParser/extended/array.d.ts +3 -0
  44. package/dist/dataParser/extended/array.mjs +50 -4
  45. package/dist/dataParser/extended/bigint.cjs +50 -4
  46. package/dist/dataParser/extended/bigint.d.ts +3 -0
  47. package/dist/dataParser/extended/bigint.mjs +50 -4
  48. package/dist/dataParser/extended/boolean.cjs +50 -4
  49. package/dist/dataParser/extended/boolean.d.ts +3 -0
  50. package/dist/dataParser/extended/boolean.mjs +50 -4
  51. package/dist/dataParser/extended/coerce/bigint.cjs +21 -4
  52. package/dist/dataParser/extended/coerce/bigint.mjs +21 -4
  53. package/dist/dataParser/extended/coerce/boolean.cjs +21 -4
  54. package/dist/dataParser/extended/coerce/boolean.mjs +21 -4
  55. package/dist/dataParser/extended/coerce/date.cjs +33 -0
  56. package/dist/dataParser/extended/coerce/date.d.ts +7 -0
  57. package/dist/dataParser/extended/coerce/date.mjs +31 -0
  58. package/dist/dataParser/extended/coerce/empty.cjs +21 -4
  59. package/dist/dataParser/extended/coerce/empty.mjs +21 -4
  60. package/dist/dataParser/extended/coerce/index.cjs +2 -0
  61. package/dist/dataParser/extended/coerce/index.d.ts +1 -0
  62. package/dist/dataParser/extended/coerce/index.mjs +1 -0
  63. package/dist/dataParser/extended/coerce/nil.cjs +21 -4
  64. package/dist/dataParser/extended/coerce/nil.mjs +21 -4
  65. package/dist/dataParser/extended/coerce/number.cjs +21 -4
  66. package/dist/dataParser/extended/coerce/number.mjs +21 -4
  67. package/dist/dataParser/extended/coerce/string.cjs +21 -4
  68. package/dist/dataParser/extended/coerce/string.mjs +21 -4
  69. package/dist/dataParser/extended/date.cjs +60 -0
  70. package/dist/dataParser/extended/date.d.ts +23 -0
  71. package/dist/dataParser/extended/date.mjs +58 -0
  72. package/dist/dataParser/extended/empty.cjs +50 -4
  73. package/dist/dataParser/extended/empty.d.ts +3 -0
  74. package/dist/dataParser/extended/empty.mjs +50 -4
  75. package/dist/dataParser/extended/index.cjs +15 -0
  76. package/dist/dataParser/extended/index.d.ts +3 -0
  77. package/dist/dataParser/extended/index.mjs +2 -0
  78. package/dist/dataParser/extended/lazy.cjs +50 -4
  79. package/dist/dataParser/extended/lazy.d.ts +5 -2
  80. package/dist/dataParser/extended/lazy.mjs +50 -4
  81. package/dist/dataParser/extended/literal.cjs +50 -4
  82. package/dist/dataParser/extended/literal.d.ts +3 -0
  83. package/dist/dataParser/extended/literal.mjs +50 -4
  84. package/dist/dataParser/extended/nil.cjs +50 -4
  85. package/dist/dataParser/extended/nil.d.ts +3 -0
  86. package/dist/dataParser/extended/nil.mjs +50 -4
  87. package/dist/dataParser/extended/nullable.cjs +50 -4
  88. package/dist/dataParser/extended/nullable.d.ts +3 -0
  89. package/dist/dataParser/extended/nullable.mjs +50 -4
  90. package/dist/dataParser/extended/number.cjs +50 -4
  91. package/dist/dataParser/extended/number.d.ts +3 -0
  92. package/dist/dataParser/extended/number.mjs +50 -4
  93. package/dist/dataParser/extended/object.cjs +65 -5
  94. package/dist/dataParser/extended/object.d.ts +5 -0
  95. package/dist/dataParser/extended/object.mjs +65 -5
  96. package/dist/dataParser/extended/optional.cjs +50 -4
  97. package/dist/dataParser/extended/optional.d.ts +3 -0
  98. package/dist/dataParser/extended/optional.mjs +50 -4
  99. package/dist/dataParser/extended/pipe.cjs +50 -4
  100. package/dist/dataParser/extended/pipe.d.ts +3 -0
  101. package/dist/dataParser/extended/pipe.mjs +50 -4
  102. package/dist/dataParser/extended/record.cjs +50 -4
  103. package/dist/dataParser/extended/record.d.ts +3 -0
  104. package/dist/dataParser/extended/record.mjs +50 -4
  105. package/dist/dataParser/extended/recover.cjs +50 -4
  106. package/dist/dataParser/extended/recover.d.ts +3 -0
  107. package/dist/dataParser/extended/recover.mjs +50 -4
  108. package/dist/dataParser/extended/string.cjs +51 -5
  109. package/dist/dataParser/extended/string.d.ts +3 -0
  110. package/dist/dataParser/extended/string.mjs +51 -5
  111. package/dist/dataParser/extended/templateLiteral.cjs +50 -4
  112. package/dist/dataParser/extended/templateLiteral.d.ts +3 -0
  113. package/dist/dataParser/extended/templateLiteral.mjs +50 -4
  114. package/dist/dataParser/extended/transform.cjs +50 -4
  115. package/dist/dataParser/extended/transform.d.ts +3 -0
  116. package/dist/dataParser/extended/transform.mjs +50 -4
  117. package/dist/dataParser/extended/tuple.cjs +52 -6
  118. package/dist/dataParser/extended/tuple.d.ts +3 -0
  119. package/dist/dataParser/extended/tuple.mjs +52 -6
  120. package/dist/dataParser/extended/union.cjs +50 -4
  121. package/dist/dataParser/extended/union.d.ts +3 -0
  122. package/dist/dataParser/extended/union.mjs +50 -4
  123. package/dist/dataParser/extended/unknown.cjs +50 -4
  124. package/dist/dataParser/extended/unknown.d.ts +3 -0
  125. package/dist/dataParser/extended/unknown.mjs +50 -4
  126. package/dist/dataParser/identifier.cjs +3 -0
  127. package/dist/dataParser/identifier.d.ts +52 -10
  128. package/dist/dataParser/identifier.mjs +3 -0
  129. package/dist/dataParser/index.cjs +25 -18
  130. package/dist/dataParser/index.mjs +4 -1
  131. package/dist/dataParser/kind.cjs +25 -0
  132. package/dist/dataParser/kind.mjs +25 -0
  133. package/dist/dataParser/parsers/array/index.cjs +36 -1
  134. package/dist/dataParser/parsers/array/index.d.ts +3 -0
  135. package/dist/dataParser/parsers/array/index.mjs +32 -1
  136. package/dist/dataParser/parsers/bigint/index.cjs +36 -1
  137. package/dist/dataParser/parsers/bigint/index.d.ts +3 -0
  138. package/dist/dataParser/parsers/bigint/index.mjs +32 -1
  139. package/dist/dataParser/parsers/boolean.cjs +30 -1
  140. package/dist/dataParser/parsers/boolean.d.ts +3 -0
  141. package/dist/dataParser/parsers/boolean.mjs +30 -1
  142. package/dist/dataParser/parsers/coerce/bigint.cjs +21 -4
  143. package/dist/dataParser/parsers/coerce/bigint.mjs +21 -4
  144. package/dist/dataParser/parsers/coerce/boolean.cjs +21 -4
  145. package/dist/dataParser/parsers/coerce/boolean.mjs +21 -4
  146. package/dist/dataParser/parsers/coerce/date.cjs +33 -0
  147. package/dist/dataParser/parsers/coerce/date.d.ts +6 -0
  148. package/dist/dataParser/parsers/coerce/date.mjs +31 -0
  149. package/dist/dataParser/parsers/coerce/empty.cjs +21 -4
  150. package/dist/dataParser/parsers/coerce/empty.mjs +21 -4
  151. package/dist/dataParser/parsers/coerce/index.cjs +2 -0
  152. package/dist/dataParser/parsers/coerce/index.d.ts +1 -0
  153. package/dist/dataParser/parsers/coerce/index.mjs +1 -0
  154. package/dist/dataParser/parsers/coerce/nil.cjs +21 -4
  155. package/dist/dataParser/parsers/coerce/nil.mjs +21 -4
  156. package/dist/dataParser/parsers/coerce/number.cjs +21 -4
  157. package/dist/dataParser/parsers/coerce/number.mjs +21 -4
  158. package/dist/dataParser/parsers/coerce/string.cjs +21 -4
  159. package/dist/dataParser/parsers/coerce/string.mjs +21 -4
  160. package/dist/dataParser/parsers/date.cjs +79 -0
  161. package/dist/dataParser/parsers/date.d.ts +28 -0
  162. package/dist/dataParser/parsers/date.mjs +76 -0
  163. package/dist/dataParser/parsers/empty.cjs +30 -1
  164. package/dist/dataParser/parsers/empty.d.ts +3 -0
  165. package/dist/dataParser/parsers/empty.mjs +30 -1
  166. package/dist/dataParser/parsers/index.d.ts +1 -0
  167. package/dist/dataParser/parsers/lazy.cjs +34 -4
  168. package/dist/dataParser/parsers/lazy.d.ts +7 -4
  169. package/dist/dataParser/parsers/lazy.mjs +34 -4
  170. package/dist/dataParser/parsers/literal.cjs +31 -4
  171. package/dist/dataParser/parsers/literal.d.ts +3 -0
  172. package/dist/dataParser/parsers/literal.mjs +31 -4
  173. package/dist/dataParser/parsers/nil.cjs +30 -1
  174. package/dist/dataParser/parsers/nil.d.ts +3 -0
  175. package/dist/dataParser/parsers/nil.mjs +30 -1
  176. package/dist/dataParser/parsers/nullable.cjs +30 -1
  177. package/dist/dataParser/parsers/nullable.d.ts +3 -0
  178. package/dist/dataParser/parsers/nullable.mjs +30 -1
  179. package/dist/dataParser/parsers/number/index.cjs +40 -1
  180. package/dist/dataParser/parsers/number/index.d.ts +3 -0
  181. package/dist/dataParser/parsers/number/index.mjs +33 -1
  182. package/dist/dataParser/parsers/{object.cjs → object/index.cjs} +39 -12
  183. package/dist/dataParser/parsers/{object.d.ts → object/index.d.ts} +16 -12
  184. package/dist/dataParser/parsers/{object.mjs → object/index.mjs} +39 -12
  185. package/dist/dataParser/parsers/object/omit.cjs +42 -0
  186. package/dist/dataParser/parsers/object/omit.d.ts +6 -0
  187. package/dist/dataParser/parsers/object/omit.mjs +40 -0
  188. package/dist/dataParser/parsers/object/pick.cjs +42 -0
  189. package/dist/dataParser/parsers/object/pick.d.ts +6 -0
  190. package/dist/dataParser/parsers/object/pick.mjs +40 -0
  191. package/dist/dataParser/parsers/optional.cjs +30 -1
  192. package/dist/dataParser/parsers/optional.d.ts +3 -0
  193. package/dist/dataParser/parsers/optional.mjs +30 -1
  194. package/dist/dataParser/parsers/pipe.cjs +30 -1
  195. package/dist/dataParser/parsers/pipe.d.ts +3 -0
  196. package/dist/dataParser/parsers/pipe.mjs +30 -1
  197. package/dist/dataParser/parsers/record/findRecordRequiredKey.cjs +26 -0
  198. package/dist/dataParser/parsers/record/findRecordRequiredKey.mjs +26 -0
  199. package/dist/dataParser/parsers/record/index.cjs +30 -1
  200. package/dist/dataParser/parsers/record/index.d.ts +3 -0
  201. package/dist/dataParser/parsers/record/index.mjs +30 -1
  202. package/dist/dataParser/parsers/recover.cjs +30 -1
  203. package/dist/dataParser/parsers/recover.d.ts +3 -0
  204. package/dist/dataParser/parsers/recover.mjs +30 -1
  205. package/dist/dataParser/parsers/string/index.cjs +47 -1
  206. package/dist/dataParser/parsers/string/index.d.ts +3 -0
  207. package/dist/dataParser/parsers/string/index.mjs +35 -1
  208. package/dist/dataParser/parsers/templateLiteral/createTemplateLiteralPattern.cjs +26 -0
  209. package/dist/dataParser/parsers/templateLiteral/createTemplateLiteralPattern.mjs +26 -0
  210. package/dist/dataParser/parsers/templateLiteral/index.cjs +28 -1
  211. package/dist/dataParser/parsers/templateLiteral/index.d.ts +3 -0
  212. package/dist/dataParser/parsers/templateLiteral/index.mjs +28 -1
  213. package/dist/dataParser/parsers/transform.cjs +30 -1
  214. package/dist/dataParser/parsers/transform.d.ts +3 -0
  215. package/dist/dataParser/parsers/transform.mjs +30 -1
  216. package/dist/dataParser/parsers/tuple.cjs +30 -1
  217. package/dist/dataParser/parsers/tuple.d.ts +3 -0
  218. package/dist/dataParser/parsers/tuple.mjs +30 -1
  219. package/dist/dataParser/parsers/union.cjs +30 -1
  220. package/dist/dataParser/parsers/union.d.ts +3 -0
  221. package/dist/dataParser/parsers/union.mjs +30 -1
  222. package/dist/dataParser/parsers/unknown.cjs +30 -1
  223. package/dist/dataParser/parsers/unknown.d.ts +3 -0
  224. package/dist/dataParser/parsers/unknown.mjs +30 -1
  225. package/dist/dataParser/types/dataParsers.d.ts +2 -2
  226. package/dist/date/closestTo.cjs +32 -0
  227. package/dist/date/closestTo.d.ts +7 -0
  228. package/dist/date/closestTo.mjs +30 -0
  229. package/dist/date/constants.cjs +29 -0
  230. package/dist/date/constants.d.ts +13 -0
  231. package/dist/date/constants.mjs +15 -0
  232. package/dist/date/create.cjs +75 -0
  233. package/dist/date/create.d.ts +16 -0
  234. package/dist/date/create.mjs +73 -0
  235. package/dist/date/createOrThrow.cjs +52 -0
  236. package/dist/date/createOrThrow.d.ts +10 -0
  237. package/dist/date/createOrThrow.mjs +49 -0
  238. package/dist/date/each.cjs +47 -0
  239. package/dist/date/each.d.ts +5 -0
  240. package/dist/date/each.mjs +45 -0
  241. package/dist/date/getters/getDayOfMonth.cjs +47 -0
  242. package/dist/date/getters/getDayOfMonth.d.ts +2 -0
  243. package/dist/date/getters/getDayOfMonth.mjs +45 -0
  244. package/dist/date/getters/getDayOfWeek.cjs +57 -0
  245. package/dist/date/getters/getDayOfWeek.d.ts +2 -0
  246. package/dist/date/getters/getDayOfWeek.mjs +55 -0
  247. package/dist/date/getters/getDayOfYear.cjs +64 -0
  248. package/dist/date/getters/getDayOfYear.d.ts +2 -0
  249. package/dist/date/getters/getDayOfYear.mjs +62 -0
  250. package/dist/date/getters/getFirstDayOfMonth.cjs +14 -0
  251. package/dist/date/getters/getFirstDayOfMonth.d.ts +2 -0
  252. package/dist/date/getters/getFirstDayOfMonth.mjs +12 -0
  253. package/dist/date/getters/getFirstDayOfWeek.cjs +16 -0
  254. package/dist/date/getters/getFirstDayOfWeek.d.ts +2 -0
  255. package/dist/date/getters/getFirstDayOfWeek.mjs +14 -0
  256. package/dist/date/getters/getHour.cjs +48 -0
  257. package/dist/date/getters/getHour.d.ts +2 -0
  258. package/dist/date/getters/getHour.mjs +46 -0
  259. package/dist/date/getters/getLastDayOfMonth.cjs +14 -0
  260. package/dist/date/getters/getLastDayOfMonth.d.ts +2 -0
  261. package/dist/date/getters/getLastDayOfMonth.mjs +12 -0
  262. package/dist/date/getters/getLastDayOfWeek.cjs +16 -0
  263. package/dist/date/getters/getLastDayOfWeek.d.ts +2 -0
  264. package/dist/date/getters/getLastDayOfWeek.mjs +14 -0
  265. package/dist/date/getters/getMilliseconds.cjs +40 -0
  266. package/dist/date/getters/getMilliseconds.d.ts +2 -0
  267. package/dist/date/getters/getMilliseconds.mjs +38 -0
  268. package/dist/date/getters/getMinute.cjs +47 -0
  269. package/dist/date/getters/getMinute.d.ts +2 -0
  270. package/dist/date/getters/getMinute.mjs +45 -0
  271. package/dist/date/getters/getMonth.cjs +47 -0
  272. package/dist/date/getters/getMonth.d.ts +2 -0
  273. package/dist/date/getters/getMonth.mjs +45 -0
  274. package/dist/date/getters/getSecond.cjs +47 -0
  275. package/dist/date/getters/getSecond.d.ts +2 -0
  276. package/dist/date/getters/getSecond.mjs +45 -0
  277. package/dist/date/getters/getWeekOfYear.cjs +67 -0
  278. package/dist/date/getters/getWeekOfYear.d.ts +2 -0
  279. package/dist/date/getters/getWeekOfYear.mjs +65 -0
  280. package/dist/date/getters/getYear.cjs +47 -0
  281. package/dist/date/getters/getYear.d.ts +2 -0
  282. package/dist/date/getters/getYear.mjs +45 -0
  283. package/dist/date/getters/index.d.ts +15 -0
  284. package/dist/date/index.cjs +121 -0
  285. package/dist/date/index.d.ts +18 -0
  286. package/dist/date/index.mjs +51 -0
  287. package/dist/date/isSafeTimestamp.cjs +15 -0
  288. package/dist/date/isSafeTimestamp.d.ts +1 -0
  289. package/dist/date/isSafeTimestamp.mjs +13 -0
  290. package/dist/date/now.cjs +8 -0
  291. package/dist/date/now.d.ts +1 -0
  292. package/dist/date/now.mjs +6 -0
  293. package/dist/date/operators/addDays.cjs +20 -0
  294. package/dist/date/operators/addDays.d.ts +4 -0
  295. package/dist/date/operators/addDays.mjs +18 -0
  296. package/dist/date/operators/addHours.cjs +20 -0
  297. package/dist/date/operators/addHours.d.ts +4 -0
  298. package/dist/date/operators/addHours.mjs +18 -0
  299. package/dist/date/operators/addMilliseconds.cjs +19 -0
  300. package/dist/date/operators/addMilliseconds.d.ts +4 -0
  301. package/dist/date/operators/addMilliseconds.mjs +17 -0
  302. package/dist/date/operators/addMinutes.cjs +20 -0
  303. package/dist/date/operators/addMinutes.d.ts +4 -0
  304. package/dist/date/operators/addMinutes.mjs +18 -0
  305. package/dist/date/operators/addMonths.cjs +19 -0
  306. package/dist/date/operators/addMonths.d.ts +4 -0
  307. package/dist/date/operators/addMonths.mjs +17 -0
  308. package/dist/date/operators/addSeconds.cjs +20 -0
  309. package/dist/date/operators/addSeconds.d.ts +4 -0
  310. package/dist/date/operators/addSeconds.mjs +18 -0
  311. package/dist/date/operators/addWeeks.cjs +20 -0
  312. package/dist/date/operators/addWeeks.d.ts +4 -0
  313. package/dist/date/operators/addWeeks.mjs +18 -0
  314. package/dist/date/operators/addYears.cjs +19 -0
  315. package/dist/date/operators/addYears.d.ts +4 -0
  316. package/dist/date/operators/addYears.mjs +17 -0
  317. package/dist/date/operators/between.cjs +17 -0
  318. package/dist/date/operators/between.d.ts +3 -0
  319. package/dist/date/operators/between.mjs +15 -0
  320. package/dist/date/operators/betweenThan.cjs +17 -0
  321. package/dist/date/operators/betweenThan.d.ts +3 -0
  322. package/dist/date/operators/betweenThan.mjs +15 -0
  323. package/dist/date/operators/greater.cjs +16 -0
  324. package/dist/date/operators/greater.d.ts +3 -0
  325. package/dist/date/operators/greater.mjs +14 -0
  326. package/dist/date/operators/greaterThan.cjs +16 -0
  327. package/dist/date/operators/greaterThan.d.ts +3 -0
  328. package/dist/date/operators/greaterThan.mjs +14 -0
  329. package/dist/date/operators/index.d.ts +22 -0
  330. package/dist/date/operators/less.cjs +16 -0
  331. package/dist/date/operators/less.d.ts +3 -0
  332. package/dist/date/operators/less.mjs +14 -0
  333. package/dist/date/operators/lessThan.cjs +16 -0
  334. package/dist/date/operators/lessThan.d.ts +3 -0
  335. package/dist/date/operators/lessThan.mjs +14 -0
  336. package/dist/date/operators/subtractDays.cjs +20 -0
  337. package/dist/date/operators/subtractDays.d.ts +4 -0
  338. package/dist/date/operators/subtractDays.mjs +18 -0
  339. package/dist/date/operators/subtractHours.cjs +20 -0
  340. package/dist/date/operators/subtractHours.d.ts +4 -0
  341. package/dist/date/operators/subtractHours.mjs +18 -0
  342. package/dist/date/operators/subtractMilliseconds.cjs +19 -0
  343. package/dist/date/operators/subtractMilliseconds.d.ts +4 -0
  344. package/dist/date/operators/subtractMilliseconds.mjs +17 -0
  345. package/dist/date/operators/subtractMinutes.cjs +20 -0
  346. package/dist/date/operators/subtractMinutes.d.ts +4 -0
  347. package/dist/date/operators/subtractMinutes.mjs +18 -0
  348. package/dist/date/operators/subtractMonths.cjs +19 -0
  349. package/dist/date/operators/subtractMonths.d.ts +4 -0
  350. package/dist/date/operators/subtractMonths.mjs +17 -0
  351. package/dist/date/operators/subtractSeconds.cjs +20 -0
  352. package/dist/date/operators/subtractSeconds.d.ts +4 -0
  353. package/dist/date/operators/subtractSeconds.mjs +18 -0
  354. package/dist/date/operators/subtractWeeks.cjs +20 -0
  355. package/dist/date/operators/subtractWeeks.d.ts +4 -0
  356. package/dist/date/operators/subtractWeeks.mjs +18 -0
  357. package/dist/date/operators/subtractYears.cjs +19 -0
  358. package/dist/date/operators/subtractYears.d.ts +4 -0
  359. package/dist/date/operators/subtractYears.mjs +17 -0
  360. package/dist/date/round.cjs +23 -0
  361. package/dist/date/round.d.ts +3 -0
  362. package/dist/date/round.mjs +21 -0
  363. package/dist/date/toISOString.cjs +10 -0
  364. package/dist/date/toISOString.d.ts +2 -0
  365. package/dist/date/toISOString.mjs +8 -0
  366. package/dist/date/toNative.cjs +10 -0
  367. package/dist/date/toNative.d.ts +2 -0
  368. package/dist/date/toNative.mjs +8 -0
  369. package/dist/date/toTimestamp.cjs +58 -0
  370. package/dist/date/toTimestamp.d.ts +10 -0
  371. package/dist/date/toTimestamp.mjs +55 -0
  372. package/dist/date/today.cjs +8 -0
  373. package/dist/date/today.d.ts +1 -0
  374. package/dist/date/today.mjs +6 -0
  375. package/dist/date/tomorrow.cjs +10 -0
  376. package/dist/date/tomorrow.d.ts +1 -0
  377. package/dist/date/tomorrow.mjs +8 -0
  378. package/dist/date/types/index.d.ts +6 -0
  379. package/dist/date/types/isLeapYear.d.ts +8 -0
  380. package/dist/date/types/month.d.ts +9 -0
  381. package/dist/date/types/theDate.d.ts +1 -0
  382. package/dist/date/types/time.d.ts +5 -0
  383. package/dist/date/types/timezone.cjs +606 -0
  384. package/dist/date/types/timezone.d.ts +604 -0
  385. package/dist/date/types/timezone.mjs +604 -0
  386. package/dist/date/types/unit.d.ts +1 -0
  387. package/dist/date/yesterday.cjs +10 -0
  388. package/dist/date/yesterday.d.ts +1 -0
  389. package/dist/date/yesterday.mjs +8 -0
  390. package/dist/either/bool/falsy.cjs +22 -1
  391. package/dist/either/bool/falsy.mjs +22 -1
  392. package/dist/either/bool/truthy.cjs +23 -2
  393. package/dist/either/bool/truthy.mjs +23 -2
  394. package/dist/either/future/create.cjs +25 -2
  395. package/dist/either/future/create.mjs +25 -2
  396. package/dist/either/future/error.cjs +21 -0
  397. package/dist/either/future/error.mjs +21 -0
  398. package/dist/either/future/success.cjs +21 -0
  399. package/dist/either/future/success.mjs +21 -0
  400. package/dist/either/hasInformation.cjs +6 -1
  401. package/dist/either/hasInformation.d.ts +1 -0
  402. package/dist/either/hasInformation.mjs +6 -1
  403. package/dist/either/kind.cjs +24 -0
  404. package/dist/either/kind.mjs +24 -0
  405. package/dist/either/left/when.cjs +25 -0
  406. package/dist/either/left/when.mjs +25 -0
  407. package/dist/either/nullable/empty.cjs +22 -1
  408. package/dist/either/nullable/empty.mjs +22 -1
  409. package/dist/either/nullable/filled.cjs +23 -2
  410. package/dist/either/nullable/filled.mjs +23 -2
  411. package/dist/either/nullish/empty.cjs +22 -1
  412. package/dist/either/nullish/empty.mjs +22 -1
  413. package/dist/either/nullish/filled.cjs +23 -2
  414. package/dist/either/nullish/filled.mjs +23 -2
  415. package/dist/either/optional/empty.cjs +21 -0
  416. package/dist/either/optional/empty.mjs +21 -0
  417. package/dist/either/optional/filled.cjs +23 -2
  418. package/dist/either/optional/filled.mjs +23 -2
  419. package/dist/either/right/asyncPipe.cjs +25 -1
  420. package/dist/either/right/asyncPipe.d.ts +5 -0
  421. package/dist/either/right/asyncPipe.mjs +25 -1
  422. package/dist/either/right/pipe.cjs +25 -1
  423. package/dist/either/right/pipe.d.ts +5 -0
  424. package/dist/either/right/pipe.mjs +25 -1
  425. package/dist/either/right/when.cjs +25 -0
  426. package/dist/either/right/when.mjs +25 -0
  427. package/dist/either/whenHasInformation.cjs +25 -1
  428. package/dist/either/whenHasInformation.d.ts +2 -2
  429. package/dist/either/whenHasInformation.mjs +25 -1
  430. package/dist/generator/asyncReduce.cjs +25 -0
  431. package/dist/generator/asyncReduce.mjs +25 -0
  432. package/dist/generator/reduce.cjs +25 -0
  433. package/dist/generator/reduce.mjs +25 -0
  434. package/dist/index.cjs +9 -0
  435. package/dist/index.d.ts +2 -0
  436. package/dist/index.mjs +6 -0
  437. package/dist/number/between.cjs +12 -0
  438. package/dist/number/between.d.ts +2 -0
  439. package/dist/number/between.mjs +10 -0
  440. package/dist/number/betweenThan.cjs +12 -0
  441. package/dist/number/betweenThan.d.ts +2 -0
  442. package/dist/number/betweenThan.mjs +10 -0
  443. package/dist/number/index.cjs +4 -0
  444. package/dist/number/index.d.ts +3 -0
  445. package/dist/number/index.mjs +2 -0
  446. package/dist/number/types/index.d.ts +1 -0
  447. package/dist/number/types/positiveNumber.d.ts +1 -0
  448. package/dist/object/deepDiscriminate.cjs +25 -0
  449. package/dist/object/deepDiscriminate.mjs +25 -0
  450. package/dist/object/discriminate.cjs +25 -0
  451. package/dist/object/discriminate.mjs +25 -0
  452. package/dist/object/entries.cjs +25 -0
  453. package/dist/object/entries.mjs +25 -0
  454. package/dist/object/entry.d.ts +2 -2
  455. package/dist/object/fromEntries.d.ts +5 -3
  456. package/dist/object/keys.cjs +25 -0
  457. package/dist/object/keys.mjs +25 -0
  458. package/dist/object/values.cjs +25 -0
  459. package/dist/object/values.mjs +25 -0
  460. package/dist/pattern/exhaustive.cjs +25 -0
  461. package/dist/pattern/exhaustive.mjs +25 -0
  462. package/dist/pattern/index.cjs +5 -2
  463. package/dist/pattern/index.mjs +2 -1
  464. package/dist/pattern/match/builder.cjs +82 -0
  465. package/dist/pattern/match/builder.d.ts +30 -0
  466. package/dist/pattern/match/builder.mjs +79 -0
  467. package/dist/pattern/match/index.cjs +28 -0
  468. package/dist/pattern/{match.d.ts → match/index.d.ts} +7 -4
  469. package/dist/pattern/match/index.mjs +25 -0
  470. package/dist/pattern/otherwise.cjs +25 -0
  471. package/dist/pattern/otherwise.mjs +25 -0
  472. package/dist/pattern/result.cjs +25 -0
  473. package/dist/pattern/result.mjs +25 -0
  474. package/dist/pattern/types/complexUnMatchedValue/array.d.ts +1 -1
  475. package/dist/string/replace.cjs +15 -0
  476. package/dist/string/replace.d.ts +10 -2
  477. package/dist/string/replace.mjs +15 -0
  478. package/package.json +6 -1
  479. package/dist/pattern/match.cjs +0 -18
  480. package/dist/pattern/match.mjs +0 -16
@@ -1,10 +1,37 @@
1
+ import '../../common/stringToBytes.mjs';
2
+ import '../../common/stringToMillisecond.mjs';
3
+ import '../../common/globalStore.mjs';
4
+ import '../../common/builder.mjs';
5
+ import '../../either/bool/falsy.mjs';
6
+ import '../../either/bool/truthy.mjs';
7
+ import '../../either/bool/base.mjs';
8
+ import '../../either/left/create.mjs';
9
+ import '../../either/left/error.mjs';
10
+ import '../../either/left/fail.mjs';
11
+ import '../../either/kind.mjs';
12
+ import '../../either/right/success.mjs';
13
+ import '../../either/right/create.mjs';
14
+ import '../../either/right/ok.mjs';
15
+ import '../../either/future/success.mjs';
16
+ import '../../either/future/error.mjs';
17
+ import '../../either/future/base.mjs';
18
+ import '../../either/nullable/empty.mjs';
19
+ import '../../either/nullable/filled.mjs';
20
+ import '../../either/nullable/base.mjs';
21
+ import '../../either/nullish/empty.mjs';
22
+ import '../../either/nullish/filled.mjs';
23
+ import '../../either/nullish/base.mjs';
24
+ import '../../either/optional/empty.mjs';
25
+ import '../../either/optional/filled.mjs';
26
+ import '../../either/optional/base.mjs';
27
+ import { createOverride } from '../../common/override.mjs';
1
28
  import { dataParserInit, SymbolDataParserError } from '../base.mjs';
2
29
  import { SymbolDataParserErrorIssue, setErrorPath, popErrorPath } from '../error.mjs';
3
30
  import { createDataParserKind } from '../kind.mjs';
4
31
 
5
32
  const tupleKind = createDataParserKind("tuple");
6
33
  function tuple(shape, definition) {
7
- return dataParserInit(tupleKind, {
34
+ const self = dataParserInit(tupleKind, {
8
35
  definition: {
9
36
  errorMessage: definition?.errorMessage,
10
37
  checkers: definition?.checkers ?? [],
@@ -75,6 +102,8 @@ function tuple(shape, definition) {
75
102
  return output;
76
103
  },
77
104
  });
105
+ return tuple.overrideHandler.apply(self);
78
106
  }
107
+ tuple.overrideHandler = createOverride("@duplojs/utils/data-parser/tuple");
79
108
 
80
109
  export { tuple, tupleKind };
@@ -1,12 +1,39 @@
1
1
  'use strict';
2
2
 
3
+ require('../../common/stringToBytes.cjs');
4
+ require('../../common/stringToMillisecond.cjs');
5
+ require('../../common/globalStore.cjs');
6
+ require('../../common/builder.cjs');
7
+ require('../../either/bool/falsy.cjs');
8
+ require('../../either/bool/truthy.cjs');
9
+ require('../../either/bool/base.cjs');
10
+ require('../../either/left/create.cjs');
11
+ require('../../either/left/error.cjs');
12
+ require('../../either/left/fail.cjs');
13
+ require('../../either/kind.cjs');
14
+ require('../../either/right/success.cjs');
15
+ require('../../either/right/create.cjs');
16
+ require('../../either/right/ok.cjs');
17
+ require('../../either/future/success.cjs');
18
+ require('../../either/future/error.cjs');
19
+ require('../../either/future/base.cjs');
20
+ require('../../either/nullable/empty.cjs');
21
+ require('../../either/nullable/filled.cjs');
22
+ require('../../either/nullable/base.cjs');
23
+ require('../../either/nullish/empty.cjs');
24
+ require('../../either/nullish/filled.cjs');
25
+ require('../../either/nullish/base.cjs');
26
+ require('../../either/optional/empty.cjs');
27
+ require('../../either/optional/filled.cjs');
28
+ require('../../either/optional/base.cjs');
29
+ var override = require('../../common/override.cjs');
3
30
  var base = require('../base.cjs');
4
31
  var error = require('../error.cjs');
5
32
  var kind = require('../kind.cjs');
6
33
 
7
34
  const unionKind = kind.createDataParserKind("union");
8
35
  function union(options, definition) {
9
- return base.dataParserInit(unionKind, {
36
+ const self = base.dataParserInit(unionKind, {
10
37
  definition: {
11
38
  errorMessage: definition?.errorMessage,
12
39
  checkers: definition?.checkers ?? [],
@@ -32,7 +59,9 @@ function union(options, definition) {
32
59
  return error.SymbolDataParserErrorIssue;
33
60
  },
34
61
  });
62
+ return union.overrideHandler.apply(self);
35
63
  }
64
+ union.overrideHandler = override.createOverride("@duplojs/utils/data-parser/union");
36
65
 
37
66
  exports.union = union;
38
67
  exports.unionKind = unionKind;
@@ -24,4 +24,7 @@ export interface DataParserUnion<GenericDefinition extends DataParserDefinitionU
24
24
  export declare function union<GenericOptions extends UnionOptions, const GenericDefinition extends Partial<Omit<DataParserDefinitionUnion, "options">> = never>(options: GenericOptions, definition?: GenericDefinition): DataParserUnion<MergeDefinition<DataParserDefinitionUnion, NeverCoalescing<GenericDefinition, {}> & {
25
25
  options: GenericOptions;
26
26
  }>>;
27
+ export declare namespace union {
28
+ var overrideHandler: import("../../common").OverrideHandler<DataParserUnion<DataParserDefinitionUnion>>;
29
+ }
27
30
  export {};
@@ -1,10 +1,37 @@
1
+ import '../../common/stringToBytes.mjs';
2
+ import '../../common/stringToMillisecond.mjs';
3
+ import '../../common/globalStore.mjs';
4
+ import '../../common/builder.mjs';
5
+ import '../../either/bool/falsy.mjs';
6
+ import '../../either/bool/truthy.mjs';
7
+ import '../../either/bool/base.mjs';
8
+ import '../../either/left/create.mjs';
9
+ import '../../either/left/error.mjs';
10
+ import '../../either/left/fail.mjs';
11
+ import '../../either/kind.mjs';
12
+ import '../../either/right/success.mjs';
13
+ import '../../either/right/create.mjs';
14
+ import '../../either/right/ok.mjs';
15
+ import '../../either/future/success.mjs';
16
+ import '../../either/future/error.mjs';
17
+ import '../../either/future/base.mjs';
18
+ import '../../either/nullable/empty.mjs';
19
+ import '../../either/nullable/filled.mjs';
20
+ import '../../either/nullable/base.mjs';
21
+ import '../../either/nullish/empty.mjs';
22
+ import '../../either/nullish/filled.mjs';
23
+ import '../../either/nullish/base.mjs';
24
+ import '../../either/optional/empty.mjs';
25
+ import '../../either/optional/filled.mjs';
26
+ import '../../either/optional/base.mjs';
27
+ import { createOverride } from '../../common/override.mjs';
1
28
  import { dataParserInit, SymbolDataParserError } from '../base.mjs';
2
29
  import { SymbolDataParserErrorIssue } from '../error.mjs';
3
30
  import { createDataParserKind } from '../kind.mjs';
4
31
 
5
32
  const unionKind = createDataParserKind("union");
6
33
  function union(options, definition) {
7
- return dataParserInit(unionKind, {
34
+ const self = dataParserInit(unionKind, {
8
35
  definition: {
9
36
  errorMessage: definition?.errorMessage,
10
37
  checkers: definition?.checkers ?? [],
@@ -30,6 +57,8 @@ function union(options, definition) {
30
57
  return SymbolDataParserErrorIssue;
31
58
  },
32
59
  });
60
+ return union.overrideHandler.apply(self);
33
61
  }
62
+ union.overrideHandler = createOverride("@duplojs/utils/data-parser/union");
34
63
 
35
64
  export { union, unionKind };
@@ -1,17 +1,46 @@
1
1
  'use strict';
2
2
 
3
+ require('../../common/stringToBytes.cjs');
4
+ require('../../common/stringToMillisecond.cjs');
5
+ require('../../common/globalStore.cjs');
6
+ require('../../common/builder.cjs');
7
+ require('../../either/bool/falsy.cjs');
8
+ require('../../either/bool/truthy.cjs');
9
+ require('../../either/bool/base.cjs');
10
+ require('../../either/left/create.cjs');
11
+ require('../../either/left/error.cjs');
12
+ require('../../either/left/fail.cjs');
13
+ require('../../either/kind.cjs');
14
+ require('../../either/right/success.cjs');
15
+ require('../../either/right/create.cjs');
16
+ require('../../either/right/ok.cjs');
17
+ require('../../either/future/success.cjs');
18
+ require('../../either/future/error.cjs');
19
+ require('../../either/future/base.cjs');
20
+ require('../../either/nullable/empty.cjs');
21
+ require('../../either/nullable/filled.cjs');
22
+ require('../../either/nullable/base.cjs');
23
+ require('../../either/nullish/empty.cjs');
24
+ require('../../either/nullish/filled.cjs');
25
+ require('../../either/nullish/base.cjs');
26
+ require('../../either/optional/empty.cjs');
27
+ require('../../either/optional/filled.cjs');
28
+ require('../../either/optional/base.cjs');
29
+ var override = require('../../common/override.cjs');
3
30
  var base = require('../base.cjs');
4
31
  var kind = require('../kind.cjs');
5
32
 
6
33
  const unknownKind = kind.createDataParserKind("unknown");
7
34
  function unknown(definition) {
8
- return base.dataParserInit(unknownKind, {
35
+ const self = base.dataParserInit(unknownKind, {
9
36
  definition: {
10
37
  errorMessage: definition?.errorMessage,
11
38
  checkers: definition?.checkers ?? [],
12
39
  },
13
40
  }, (data) => data);
41
+ return unknown.overrideHandler.apply(self);
14
42
  }
43
+ unknown.overrideHandler = override.createOverride("@duplojs/utils/data-parser/unknown");
15
44
 
16
45
  exports.unknown = unknown;
17
46
  exports.unknownKind = unknownKind;
@@ -20,4 +20,7 @@ export interface DataParserUnknown<GenericDefinition extends DataParserDefinitio
20
20
  ], GenericChecker>): DataParserUnknown<AddCheckersToDefinition<GenericDefinition, GenericChecker>>;
21
21
  }
22
22
  export declare function unknown<const GenericDefinition extends Partial<DataParserDefinitionUnknown> = never>(definition?: GenericDefinition): DataParserUnknown<MergeDefinition<DataParserDefinitionUnknown, NeverCoalescing<GenericDefinition, {}>>>;
23
+ export declare namespace unknown {
24
+ var overrideHandler: import("../../common").OverrideHandler<DataParserUnknown<DataParserDefinitionUnknown>>;
25
+ }
23
26
  export {};
@@ -1,14 +1,43 @@
1
+ import '../../common/stringToBytes.mjs';
2
+ import '../../common/stringToMillisecond.mjs';
3
+ import '../../common/globalStore.mjs';
4
+ import '../../common/builder.mjs';
5
+ import '../../either/bool/falsy.mjs';
6
+ import '../../either/bool/truthy.mjs';
7
+ import '../../either/bool/base.mjs';
8
+ import '../../either/left/create.mjs';
9
+ import '../../either/left/error.mjs';
10
+ import '../../either/left/fail.mjs';
11
+ import '../../either/kind.mjs';
12
+ import '../../either/right/success.mjs';
13
+ import '../../either/right/create.mjs';
14
+ import '../../either/right/ok.mjs';
15
+ import '../../either/future/success.mjs';
16
+ import '../../either/future/error.mjs';
17
+ import '../../either/future/base.mjs';
18
+ import '../../either/nullable/empty.mjs';
19
+ import '../../either/nullable/filled.mjs';
20
+ import '../../either/nullable/base.mjs';
21
+ import '../../either/nullish/empty.mjs';
22
+ import '../../either/nullish/filled.mjs';
23
+ import '../../either/nullish/base.mjs';
24
+ import '../../either/optional/empty.mjs';
25
+ import '../../either/optional/filled.mjs';
26
+ import '../../either/optional/base.mjs';
27
+ import { createOverride } from '../../common/override.mjs';
1
28
  import { dataParserInit } from '../base.mjs';
2
29
  import { createDataParserKind } from '../kind.mjs';
3
30
 
4
31
  const unknownKind = createDataParserKind("unknown");
5
32
  function unknown(definition) {
6
- return dataParserInit(unknownKind, {
33
+ const self = dataParserInit(unknownKind, {
7
34
  definition: {
8
35
  errorMessage: definition?.errorMessage,
9
36
  checkers: definition?.checkers ?? [],
10
37
  },
11
38
  }, (data) => data);
39
+ return unknown.overrideHandler.apply(self);
12
40
  }
41
+ unknown.overrideHandler = createOverride("@duplojs/utils/data-parser/unknown");
13
42
 
14
43
  export { unknown, unknownKind };
@@ -6,8 +6,8 @@ import { type DataParserExtended } from "../baseExtended";
6
6
  export interface DataParserCustom {
7
7
  base: DataParser;
8
8
  }
9
- export type DataParsers = (DataParserCustom[GetPropsWithValueExtends<DataParserCustom, DataParser>] | AllDataParser.DataParserString | AllDataParser.DataParserObject | AllDataParser.DataParserNumber | AllDataParser.DataParserLiteral | AllDataParser.DataParserUnion | AllDataParser.DataParserArray | AllDataParser.DataParserBigInt | AllDataParser.DataParserTuple | AllDataParser.DataParserTransform | AllDataParser.DataParserBoolean | AllDataParser.DataParserNil | AllDataParser.DataParserEmpty | AllDataParser.DataParserTemplateLiteral | AllDataParser.DataParserPipe | AllDataParser.DataParserNullable | AllDataParser.DataParserOptional | AllDataParser.DataParserLazy | AllDataParser.DataParserUnknown | AllDataParser.DataParserRecord | AllDataParser.DataParserRecover);
9
+ export type DataParsers = (DataParserCustom[GetPropsWithValueExtends<DataParserCustom, DataParser>] | AllDataParser.DataParserString | AllDataParser.DataParserObject | AllDataParser.DataParserNumber | AllDataParser.DataParserLiteral | AllDataParser.DataParserUnion | AllDataParser.DataParserArray | AllDataParser.DataParserBigInt | AllDataParser.DataParserTuple | AllDataParser.DataParserTransform | AllDataParser.DataParserBoolean | AllDataParser.DataParserDate | AllDataParser.DataParserNil | AllDataParser.DataParserEmpty | AllDataParser.DataParserTemplateLiteral | AllDataParser.DataParserPipe | AllDataParser.DataParserNullable | AllDataParser.DataParserOptional | AllDataParser.DataParserLazy | AllDataParser.DataParserUnknown | AllDataParser.DataParserRecord | AllDataParser.DataParserRecover);
10
10
  export interface DataParserExtendedCustom {
11
11
  base: DataParserExtended;
12
12
  }
13
- export type DataParsersExtended = (DataParserExtendedCustom[GetPropsWithValueExtends<DataParserExtendedCustom, DataParserExtended>] | AllDataParserExtended.DataParserStringExtended | AllDataParserExtended.DataParserObjectExtended | AllDataParserExtended.DataParserNumberExtended | AllDataParserExtended.DataParserLiteralExtended | AllDataParserExtended.DataParserUnionExtended | AllDataParserExtended.DataParserArrayExtended | AllDataParserExtended.DataParserBigIntExtended | AllDataParserExtended.DataParserTupleExtended | AllDataParserExtended.DataParserTransformExtended | AllDataParserExtended.DataParserBooleanExtended | AllDataParserExtended.DataParserNilExtended | AllDataParserExtended.DataParserEmptyExtended | AllDataParserExtended.DataParserTemplateLiteralExtended | AllDataParserExtended.DataParserPipeExtended | AllDataParserExtended.DataParserNullableExtended | AllDataParserExtended.DataParserOptionalExtended | AllDataParserExtended.DataParserLazyExtended | AllDataParserExtended.DataParserUnknownExtended | AllDataParserExtended.DataParserRecordExtended | AllDataParserExtended.DataParserRecoverExtended);
13
+ export type DataParsersExtended = (DataParserExtendedCustom[GetPropsWithValueExtends<DataParserExtendedCustom, DataParserExtended>] | AllDataParserExtended.DataParserStringExtended | AllDataParserExtended.DataParserObjectExtended | AllDataParserExtended.DataParserNumberExtended | AllDataParserExtended.DataParserLiteralExtended | AllDataParserExtended.DataParserUnionExtended | AllDataParserExtended.DataParserArrayExtended | AllDataParserExtended.DataParserBigIntExtended | AllDataParserExtended.DataParserTupleExtended | AllDataParserExtended.DataParserTransformExtended | AllDataParserExtended.DataParserBooleanExtended | AllDataParserExtended.DataParserDateExtended | AllDataParserExtended.DataParserNilExtended | AllDataParserExtended.DataParserEmptyExtended | AllDataParserExtended.DataParserTemplateLiteralExtended | AllDataParserExtended.DataParserPipeExtended | AllDataParserExtended.DataParserNullableExtended | AllDataParserExtended.DataParserOptionalExtended | AllDataParserExtended.DataParserLazyExtended | AllDataParserExtended.DataParserUnknownExtended | AllDataParserExtended.DataParserRecordExtended | AllDataParserExtended.DataParserRecoverExtended);
@@ -0,0 +1,32 @@
1
+ 'use strict';
2
+
3
+ var toTimestamp = require('./toTimestamp.cjs');
4
+
5
+ function closestTo(...args) {
6
+ if (typeof args[0] === "string") {
7
+ const [target, params] = args;
8
+ return (input) => closestTo(input, target, params);
9
+ }
10
+ const [input, target, params] = args;
11
+ const { tieBreaker } = params ?? {};
12
+ const targetTimestamp = toTimestamp.toTimestamp(target);
13
+ let closest = undefined;
14
+ let smallestDiff = Number.POSITIVE_INFINITY;
15
+ for (const value of input) {
16
+ const valueTimestamp = toTimestamp.toTimestamp(value);
17
+ if (tieBreaker === "favorPast" && valueTimestamp > targetTimestamp) {
18
+ continue;
19
+ }
20
+ if (tieBreaker === "favorFuture" && valueTimestamp < targetTimestamp) {
21
+ continue;
22
+ }
23
+ const distance = Math.abs(valueTimestamp - targetTimestamp);
24
+ if (distance < smallestDiff) {
25
+ smallestDiff = distance;
26
+ closest = value;
27
+ }
28
+ }
29
+ return closest;
30
+ }
31
+
32
+ exports.closestTo = closestTo;
@@ -0,0 +1,7 @@
1
+ import type { TheDate } from "./types";
2
+ interface ClosestToParams {
3
+ tieBreaker?: "favorPast" | "favorFuture";
4
+ }
5
+ export declare function closestTo<GenericIterable extends Iterable<TheDate>>(target: TheDate, params?: ClosestToParams): (input: GenericIterable) => TheDate | undefined;
6
+ export declare function closestTo<GenericIterable extends Iterable<TheDate>>(input: GenericIterable, target: TheDate, params?: ClosestToParams): TheDate | undefined;
7
+ export {};
@@ -0,0 +1,30 @@
1
+ import { toTimestamp } from './toTimestamp.mjs';
2
+
3
+ function closestTo(...args) {
4
+ if (typeof args[0] === "string") {
5
+ const [target, params] = args;
6
+ return (input) => closestTo(input, target, params);
7
+ }
8
+ const [input, target, params] = args;
9
+ const { tieBreaker } = params ?? {};
10
+ const targetTimestamp = toTimestamp(target);
11
+ let closest = undefined;
12
+ let smallestDiff = Number.POSITIVE_INFINITY;
13
+ for (const value of input) {
14
+ const valueTimestamp = toTimestamp(value);
15
+ if (tieBreaker === "favorPast" && valueTimestamp > targetTimestamp) {
16
+ continue;
17
+ }
18
+ if (tieBreaker === "favorFuture" && valueTimestamp < targetTimestamp) {
19
+ continue;
20
+ }
21
+ const distance = Math.abs(valueTimestamp - targetTimestamp);
22
+ if (distance < smallestDiff) {
23
+ smallestDiff = distance;
24
+ closest = value;
25
+ }
26
+ }
27
+ return closest;
28
+ }
29
+
30
+ export { closestTo };
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ const minTimestamp = -864e13;
4
+ const maxTimestamp = 8640000000000000;
5
+ const millisecondInOneWeek = 604800000;
6
+ const millisecondsInOneDay = 86400000;
7
+ const millisecondInOneHour = 3600000;
8
+ const millisecondInOneMinute = 60000;
9
+ const daysInOneWeek = 7;
10
+ const monthtsInOneYear = 12;
11
+ const minutesInOneHour = 60;
12
+ const secondsInOneMinute = 60;
13
+ const millisecondsInOneSecond = 1000;
14
+ const hoursInOneDay = 24;
15
+ const theDateRegex = /^date(?<value>\d{1,16})(?<sign>[+-])$/;
16
+
17
+ exports.daysInOneWeek = daysInOneWeek;
18
+ exports.hoursInOneDay = hoursInOneDay;
19
+ exports.maxTimestamp = maxTimestamp;
20
+ exports.millisecondInOneHour = millisecondInOneHour;
21
+ exports.millisecondInOneMinute = millisecondInOneMinute;
22
+ exports.millisecondInOneWeek = millisecondInOneWeek;
23
+ exports.millisecondsInOneDay = millisecondsInOneDay;
24
+ exports.millisecondsInOneSecond = millisecondsInOneSecond;
25
+ exports.minTimestamp = minTimestamp;
26
+ exports.minutesInOneHour = minutesInOneHour;
27
+ exports.monthtsInOneYear = monthtsInOneYear;
28
+ exports.secondsInOneMinute = secondsInOneMinute;
29
+ exports.theDateRegex = theDateRegex;
@@ -0,0 +1,13 @@
1
+ export declare const minTimestamp = -8640000000000000;
2
+ export declare const maxTimestamp = 8640000000000000;
3
+ export declare const millisecondInOneWeek = 604800000;
4
+ export declare const millisecondsInOneDay = 86400000;
5
+ export declare const millisecondInOneHour = 3600000;
6
+ export declare const millisecondInOneMinute = 60000;
7
+ export declare const daysInOneWeek = 7;
8
+ export declare const monthtsInOneYear = 12;
9
+ export declare const minutesInOneHour = 60;
10
+ export declare const secondsInOneMinute = 60;
11
+ export declare const millisecondsInOneSecond = 1000;
12
+ export declare const hoursInOneDay = 24;
13
+ export declare const theDateRegex: RegExp;
@@ -0,0 +1,15 @@
1
+ const minTimestamp = -864e13;
2
+ const maxTimestamp = 8640000000000000;
3
+ const millisecondInOneWeek = 604800000;
4
+ const millisecondsInOneDay = 86400000;
5
+ const millisecondInOneHour = 3600000;
6
+ const millisecondInOneMinute = 60000;
7
+ const daysInOneWeek = 7;
8
+ const monthtsInOneYear = 12;
9
+ const minutesInOneHour = 60;
10
+ const secondsInOneMinute = 60;
11
+ const millisecondsInOneSecond = 1000;
12
+ const hoursInOneDay = 24;
13
+ const theDateRegex = /^date(?<value>\d{1,16})(?<sign>[+-])$/;
14
+
15
+ export { daysInOneWeek, hoursInOneDay, maxTimestamp, millisecondInOneHour, millisecondInOneMinute, millisecondInOneWeek, millisecondsInOneDay, millisecondsInOneSecond, minTimestamp, minutesInOneHour, monthtsInOneYear, secondsInOneMinute, theDateRegex };
@@ -0,0 +1,75 @@
1
+ 'use strict';
2
+
3
+ var constants = require('./constants.cjs');
4
+ var isSafeTimestamp = require('./isSafeTimestamp.cjs');
5
+ require('../either/bool/falsy.cjs');
6
+ require('../either/bool/truthy.cjs');
7
+ require('../either/bool/base.cjs');
8
+ var create$1 = require('../either/left/create.cjs');
9
+ require('../either/left/error.cjs');
10
+ require('../either/left/fail.cjs');
11
+ require('../either/kind.cjs');
12
+ require('../common/stringToBytes.cjs');
13
+ require('../common/stringToMillisecond.cjs');
14
+ require('../common/globalStore.cjs');
15
+ require('../common/builder.cjs');
16
+ require('../common/override.cjs');
17
+ require('../either/right/success.cjs');
18
+ var create$2 = require('../either/right/create.cjs');
19
+ require('../either/right/ok.cjs');
20
+ require('../either/future/success.cjs');
21
+ require('../either/future/error.cjs');
22
+ require('../either/future/base.cjs');
23
+ require('../either/nullable/empty.cjs');
24
+ require('../either/nullable/filled.cjs');
25
+ require('../either/nullable/base.cjs');
26
+ require('../either/nullish/empty.cjs');
27
+ require('../either/nullish/filled.cjs');
28
+ require('../either/nullish/base.cjs');
29
+ require('../either/optional/empty.cjs');
30
+ require('../either/optional/filled.cjs');
31
+ require('../either/optional/base.cjs');
32
+
33
+ const safeDateRegex = /^(?<year>-?[0-9]+)-(?<monthWithDay>[0-1][0-9]-[0-3][0-9])$/;
34
+ function create(input, params) {
35
+ if (input instanceof Date) {
36
+ const timestamp = input.getTime();
37
+ if (!isSafeTimestamp.isSafeTimestamp(timestamp)) {
38
+ return create$1.left("date-created-error", null);
39
+ }
40
+ const isNegative = timestamp < 0;
41
+ return create$2.right("date-created", `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`);
42
+ }
43
+ if (typeof input === "number") {
44
+ if (!isSafeTimestamp.isSafeTimestamp(input)) {
45
+ return create$1.left("date-created-error", null);
46
+ }
47
+ const isNegative = input < 0;
48
+ return create$2.right("date-created", `date${Math.abs(input)}${isNegative ? "-" : "+"}`);
49
+ }
50
+ const theDateMatch = typeof input === "string" && input.match(constants.theDateRegex);
51
+ if (theDateMatch) {
52
+ const { value, sign } = theDateMatch.groups;
53
+ const magnitude = Number(value);
54
+ const timestamp = sign === "-" ? -magnitude : magnitude;
55
+ if (!isSafeTimestamp.isSafeTimestamp(timestamp)) {
56
+ return create$1.left("date-created-error", null);
57
+ }
58
+ return create$2.right("date-created", input);
59
+ }
60
+ const safeDateMatch = typeof input === "string" && input.match(safeDateRegex);
61
+ if (safeDateMatch) {
62
+ const { year, monthWithDay } = safeDateMatch.groups;
63
+ const date = new Date(`0000-${monthWithDay}T${params?.hour ?? "00"}:${params?.minute ?? "00"}:${params?.second ?? "00"}.${params?.millisecond ?? "000"}Z`);
64
+ date.setUTCFullYear(Number(year));
65
+ const timestamp = date.getTime();
66
+ if (!isSafeTimestamp.isSafeTimestamp(timestamp)) {
67
+ return "date0+";
68
+ }
69
+ const isNegative = timestamp < 0;
70
+ return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
71
+ }
72
+ return create$1.left("date-created-error", null);
73
+ }
74
+
75
+ exports.create = create;
@@ -0,0 +1,16 @@
1
+ import type { Hour, IsLeapYear, Millisecond, Minute, Second, TheDate } from "./types";
2
+ import { type EitherLeft, type EitherRight } from "../either";
3
+ import { type MonthWithDay } from "./types/month";
4
+ export type MayBe = EitherRight<"date-created", TheDate> | EitherLeft<"date-created-error", null>;
5
+ declare const SymbolErrorIsNotLeapYear: unique symbol;
6
+ interface SafeDateParams {
7
+ hour?: Hour;
8
+ minute?: Minute;
9
+ second?: Second;
10
+ millisecond?: Millisecond;
11
+ }
12
+ export declare function create<GenericInput extends TheDate | Date | number>(input: GenericInput): MayBe;
13
+ export declare function create<GenericInput extends `${"-" | ""}${number}-${MonthWithDay}`>(input: GenericInput & (GenericInput extends `${"-" | ""}${infer InferredYear extends `${number}`}-02-29` ? IsLeapYear<InferredYear> extends true ? GenericInput : {
14
+ [SymbolErrorIsNotLeapYear]: "Is not a leap year.";
15
+ } : GenericInput), params?: SafeDateParams): TheDate;
16
+ export {};
@@ -0,0 +1,73 @@
1
+ import { theDateRegex } from './constants.mjs';
2
+ import { isSafeTimestamp } from './isSafeTimestamp.mjs';
3
+ import '../either/bool/falsy.mjs';
4
+ import '../either/bool/truthy.mjs';
5
+ import '../either/bool/base.mjs';
6
+ import { left } from '../either/left/create.mjs';
7
+ import '../either/left/error.mjs';
8
+ import '../either/left/fail.mjs';
9
+ import '../either/kind.mjs';
10
+ import '../common/stringToBytes.mjs';
11
+ import '../common/stringToMillisecond.mjs';
12
+ import '../common/globalStore.mjs';
13
+ import '../common/builder.mjs';
14
+ import '../common/override.mjs';
15
+ import '../either/right/success.mjs';
16
+ import { right } from '../either/right/create.mjs';
17
+ import '../either/right/ok.mjs';
18
+ import '../either/future/success.mjs';
19
+ import '../either/future/error.mjs';
20
+ import '../either/future/base.mjs';
21
+ import '../either/nullable/empty.mjs';
22
+ import '../either/nullable/filled.mjs';
23
+ import '../either/nullable/base.mjs';
24
+ import '../either/nullish/empty.mjs';
25
+ import '../either/nullish/filled.mjs';
26
+ import '../either/nullish/base.mjs';
27
+ import '../either/optional/empty.mjs';
28
+ import '../either/optional/filled.mjs';
29
+ import '../either/optional/base.mjs';
30
+
31
+ const safeDateRegex = /^(?<year>-?[0-9]+)-(?<monthWithDay>[0-1][0-9]-[0-3][0-9])$/;
32
+ function create(input, params) {
33
+ if (input instanceof Date) {
34
+ const timestamp = input.getTime();
35
+ if (!isSafeTimestamp(timestamp)) {
36
+ return left("date-created-error", null);
37
+ }
38
+ const isNegative = timestamp < 0;
39
+ return right("date-created", `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`);
40
+ }
41
+ if (typeof input === "number") {
42
+ if (!isSafeTimestamp(input)) {
43
+ return left("date-created-error", null);
44
+ }
45
+ const isNegative = input < 0;
46
+ return right("date-created", `date${Math.abs(input)}${isNegative ? "-" : "+"}`);
47
+ }
48
+ const theDateMatch = typeof input === "string" && input.match(theDateRegex);
49
+ if (theDateMatch) {
50
+ const { value, sign } = theDateMatch.groups;
51
+ const magnitude = Number(value);
52
+ const timestamp = sign === "-" ? -magnitude : magnitude;
53
+ if (!isSafeTimestamp(timestamp)) {
54
+ return left("date-created-error", null);
55
+ }
56
+ return right("date-created", input);
57
+ }
58
+ const safeDateMatch = typeof input === "string" && input.match(safeDateRegex);
59
+ if (safeDateMatch) {
60
+ const { year, monthWithDay } = safeDateMatch.groups;
61
+ const date = new Date(`0000-${monthWithDay}T${params?.hour ?? "00"}:${params?.minute ?? "00"}:${params?.second ?? "00"}.${params?.millisecond ?? "000"}Z`);
62
+ date.setUTCFullYear(Number(year));
63
+ const timestamp = date.getTime();
64
+ if (!isSafeTimestamp(timestamp)) {
65
+ return "date0+";
66
+ }
67
+ const isNegative = timestamp < 0;
68
+ return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
69
+ }
70
+ return left("date-created-error", null);
71
+ }
72
+
73
+ export { create };
@@ -0,0 +1,52 @@
1
+ 'use strict';
2
+
3
+ var kind = require('../common/kind.cjs');
4
+ require('../common/stringToBytes.cjs');
5
+ require('../common/stringToMillisecond.cjs');
6
+ var unwrap = require('../common/unwrap.cjs');
7
+ require('../common/globalStore.cjs');
8
+ require('../common/builder.cjs');
9
+ require('../either/bool/falsy.cjs');
10
+ require('../either/bool/truthy.cjs');
11
+ require('../either/bool/base.cjs');
12
+ require('../either/left/create.cjs');
13
+ require('../either/left/error.cjs');
14
+ require('../either/left/fail.cjs');
15
+ var is = require('../either/left/is.cjs');
16
+ require('../either/right/success.cjs');
17
+ require('../either/kind.cjs');
18
+ require('../either/right/create.cjs');
19
+ require('../either/right/ok.cjs');
20
+ require('../either/future/success.cjs');
21
+ require('../either/future/error.cjs');
22
+ require('../either/future/base.cjs');
23
+ require('../either/nullable/empty.cjs');
24
+ require('../either/nullable/filled.cjs');
25
+ require('../either/nullable/base.cjs');
26
+ require('../either/nullish/empty.cjs');
27
+ require('../either/nullish/filled.cjs');
28
+ require('../either/nullish/base.cjs');
29
+ require('../either/optional/empty.cjs');
30
+ require('../either/optional/filled.cjs');
31
+ require('../either/optional/base.cjs');
32
+ require('../common/override.cjs');
33
+ var errorKindNamespace = require('../common/errorKindNamespace.cjs');
34
+ var create = require('./create.cjs');
35
+
36
+ class CreateTheDateError extends kind.kindHeritage("create-the-date-error", errorKindNamespace.createErrorKind("create-the-date-error"), Error) {
37
+ input;
38
+ constructor(input) {
39
+ super({}, [`Invalid input: ${input.toString()}`]);
40
+ this.input = input;
41
+ }
42
+ }
43
+ function createOrThrow(input) {
44
+ const result = create.create(input);
45
+ if (is.isLeft(result)) {
46
+ throw new CreateTheDateError(input);
47
+ }
48
+ return unwrap.unwrap(result);
49
+ }
50
+
51
+ exports.CreateTheDateError = CreateTheDateError;
52
+ exports.createOrThrow = createOrThrow;
@@ -0,0 +1,10 @@
1
+ import type { TheDate } from "./types";
2
+ declare const CreateTheDateError_base: new (params: {
3
+ "@DuplojsUtilsError/create-the-date-error"?: unknown;
4
+ }, parentParams: [message?: string | undefined, options?: ErrorOptions | undefined]) => Error & import("../common").Kind<import("../common").KindDefinition<"create-the-date-error", unknown>, unknown> & import("../common").Kind<import("../common").KindDefinition<"@DuplojsUtilsError/create-the-date-error", unknown>, unknown>;
5
+ export declare class CreateTheDateError extends CreateTheDateError_base {
6
+ input: TheDate | Date | number;
7
+ constructor(input: TheDate | Date | number);
8
+ }
9
+ export declare function createOrThrow<GenericInput extends TheDate | Date | number>(input: GenericInput): `date${number}-` | `date${number}+`;
10
+ export {};