@duplojs/utils 1.4.56 → 1.4.58

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 (297) hide show
  1. package/dist/clean/constraint/base.d.ts +6 -4
  2. package/dist/clean/constraint/defaultConstraint/index.d.ts +1 -0
  3. package/dist/clean/constraint/defaultConstraint/number.d.ts +6 -6
  4. package/dist/clean/constraint/defaultConstraint/string.d.ts +4 -4
  5. package/dist/clean/constraint/defaultConstraint/time.cjs +19 -0
  6. package/dist/clean/constraint/defaultConstraint/time.d.ts +61 -0
  7. package/dist/clean/constraint/defaultConstraint/time.mjs +16 -0
  8. package/dist/clean/constraint/set.d.ts +6 -4
  9. package/dist/clean/entity.cjs +9 -8
  10. package/dist/clean/entity.d.ts +16 -13
  11. package/dist/clean/entity.mjs +9 -8
  12. package/dist/clean/index.cjs +3 -0
  13. package/dist/clean/index.mjs +1 -0
  14. package/dist/clean/newType.d.ts +7 -5
  15. package/dist/clean/primitive/base.d.ts +25 -34
  16. package/dist/clean/primitive/operations/date/dateAddTime.d.ts +7 -11
  17. package/dist/clean/primitive/operations/date/dateGreaterThan.d.ts +9 -7
  18. package/dist/clean/primitive/operations/date/dateLessThan.d.ts +9 -7
  19. package/dist/clean/primitive/operations/date/dateMax.d.ts +3 -10
  20. package/dist/clean/primitive/operations/date/dateMin.d.ts +3 -10
  21. package/dist/clean/primitive/operations/date/dateSubtractTime.d.ts +7 -11
  22. package/dist/clean/primitive/operations/equal.cjs +1 -1
  23. package/dist/clean/primitive/operations/equal.d.ts +3 -3
  24. package/dist/clean/primitive/operations/equal.mjs +1 -1
  25. package/dist/clean/primitive/operations/sort.d.ts +8 -10
  26. package/dist/clean/primitive/operations/time/timeGreaterThan.d.ts +11 -9
  27. package/dist/clean/primitive/operations/time/timeLessThan.d.ts +11 -9
  28. package/dist/clean/primitive/operations/time/timeMax.cjs +2 -2
  29. package/dist/clean/primitive/operations/time/timeMax.d.ts +10 -17
  30. package/dist/clean/primitive/operations/time/timeMax.mjs +2 -2
  31. package/dist/clean/primitive/operations/time/timeMin.cjs +3 -3
  32. package/dist/clean/primitive/operations/time/timeMin.d.ts +10 -17
  33. package/dist/clean/primitive/operations/time/timeMin.mjs +3 -3
  34. package/dist/clean/unwrapEntity.cjs +13 -3
  35. package/dist/clean/unwrapEntity.d.ts +57 -5
  36. package/dist/clean/unwrapEntity.mjs +13 -3
  37. package/dist/common/index.d.ts +2 -4
  38. package/dist/common/kind.d.ts +1 -0
  39. package/dist/common/transformer.cjs +45 -0
  40. package/dist/common/transformer.d.ts +61 -0
  41. package/dist/common/transformer.mjs +40 -0
  42. package/dist/common/types/DeepReadonly.d.ts +1 -1
  43. package/dist/common/types/toLargeEnsemble.d.ts +2 -2
  44. package/dist/dataParser/base.d.ts +1 -1
  45. package/dist/dataParser/baseExtended.d.ts +1 -1
  46. package/dist/dataParser/extended/date.d.ts +9 -4
  47. package/dist/dataParser/extended/time.d.ts +28 -12
  48. package/dist/dataParser/identifier.d.ts +20 -8
  49. package/dist/dataParser/parsers/date.cjs +16 -12
  50. package/dist/dataParser/parsers/date.d.ts +15 -9
  51. package/dist/dataParser/parsers/date.mjs +16 -12
  52. package/dist/dataParser/parsers/time/checkers/max.cjs +3 -0
  53. package/dist/dataParser/parsers/time/checkers/max.d.ts +28 -0
  54. package/dist/dataParser/parsers/time/checkers/max.mjs +3 -0
  55. package/dist/dataParser/parsers/time/checkers/min.cjs +3 -0
  56. package/dist/dataParser/parsers/time/checkers/min.d.ts +28 -0
  57. package/dist/dataParser/parsers/time/checkers/min.mjs +3 -0
  58. package/dist/dataParser/parsers/time/index.cjs +14 -10
  59. package/dist/dataParser/parsers/time/index.d.ts +15 -9
  60. package/dist/dataParser/parsers/time/index.mjs +14 -10
  61. package/dist/date/applyTimezone.cjs +4 -4
  62. package/dist/date/applyTimezone.d.ts +18 -16
  63. package/dist/date/applyTimezone.mjs +2 -2
  64. package/dist/date/closestTo.cjs +6 -2
  65. package/dist/date/closestTo.d.ts +15 -15
  66. package/dist/date/closestTo.mjs +6 -2
  67. package/dist/date/constants.cjs +4 -4
  68. package/dist/date/constants.d.ts +2 -2
  69. package/dist/date/constants.mjs +3 -3
  70. package/dist/date/create.cjs +20 -10
  71. package/dist/date/create.d.ts +24 -38
  72. package/dist/date/create.mjs +21 -11
  73. package/dist/date/createOrThrow.d.ts +18 -20
  74. package/dist/date/createTime.cjs +16 -7
  75. package/dist/date/createTime.d.ts +19 -18
  76. package/dist/date/createTime.mjs +17 -8
  77. package/dist/date/createTimeOrThrow.d.ts +17 -20
  78. package/dist/date/each.cjs +6 -4
  79. package/dist/date/each.d.ts +21 -19
  80. package/dist/date/each.mjs +6 -4
  81. package/dist/date/format.d.ts +17 -15
  82. package/dist/date/formatTime.d.ts +17 -16
  83. package/dist/date/getTimezoneOffset.cjs +6 -3
  84. package/dist/date/getTimezoneOffset.d.ts +17 -18
  85. package/dist/date/getTimezoneOffset.mjs +6 -3
  86. package/dist/date/getters/getDayOfMonth.cjs +3 -3
  87. package/dist/date/getters/getDayOfMonth.d.ts +20 -14
  88. package/dist/date/getters/getDayOfMonth.mjs +3 -3
  89. package/dist/date/getters/getDayOfWeek.cjs +3 -3
  90. package/dist/date/getters/getDayOfWeek.d.ts +15 -12
  91. package/dist/date/getters/getDayOfWeek.mjs +3 -3
  92. package/dist/date/getters/getDayOfYear.cjs +6 -6
  93. package/dist/date/getters/getDayOfYear.d.ts +21 -13
  94. package/dist/date/getters/getDayOfYear.mjs +6 -6
  95. package/dist/date/getters/getFirstDayOfMonth.cjs +2 -3
  96. package/dist/date/getters/getFirstDayOfMonth.d.ts +16 -10
  97. package/dist/date/getters/getFirstDayOfMonth.mjs +2 -3
  98. package/dist/date/getters/getFirstDayOfWeek.cjs +2 -3
  99. package/dist/date/getters/getFirstDayOfWeek.d.ts +17 -10
  100. package/dist/date/getters/getFirstDayOfWeek.mjs +2 -3
  101. package/dist/date/getters/getHour.cjs +3 -3
  102. package/dist/date/getters/getHour.d.ts +16 -14
  103. package/dist/date/getters/getHour.mjs +3 -3
  104. package/dist/date/getters/getLastDayOfMonth.cjs +2 -3
  105. package/dist/date/getters/getLastDayOfMonth.d.ts +16 -10
  106. package/dist/date/getters/getLastDayOfMonth.mjs +2 -3
  107. package/dist/date/getters/getLastDayOfWeek.cjs +2 -3
  108. package/dist/date/getters/getLastDayOfWeek.d.ts +17 -10
  109. package/dist/date/getters/getLastDayOfWeek.mjs +2 -3
  110. package/dist/date/getters/getMilliseconds.cjs +2 -2
  111. package/dist/date/getters/getMilliseconds.d.ts +11 -9
  112. package/dist/date/getters/getMilliseconds.mjs +2 -2
  113. package/dist/date/getters/getMinute.cjs +3 -3
  114. package/dist/date/getters/getMinute.d.ts +17 -15
  115. package/dist/date/getters/getMinute.mjs +3 -3
  116. package/dist/date/getters/getMonth.cjs +3 -3
  117. package/dist/date/getters/getMonth.d.ts +20 -15
  118. package/dist/date/getters/getMonth.mjs +3 -3
  119. package/dist/date/getters/getSecond.cjs +3 -3
  120. package/dist/date/getters/getSecond.d.ts +17 -15
  121. package/dist/date/getters/getSecond.mjs +3 -3
  122. package/dist/date/getters/getWeekOfYear.cjs +12 -11
  123. package/dist/date/getters/getWeekOfYear.d.ts +17 -11
  124. package/dist/date/getters/getWeekOfYear.mjs +12 -11
  125. package/dist/date/getters/getYear.cjs +3 -3
  126. package/dist/date/getters/getYear.d.ts +16 -15
  127. package/dist/date/getters/getYear.mjs +3 -3
  128. package/dist/date/index.cjs +12 -6
  129. package/dist/date/index.d.ts +5 -2
  130. package/dist/date/index.mjs +6 -3
  131. package/dist/date/is.cjs +3 -8
  132. package/dist/date/is.d.ts +9 -14
  133. package/dist/date/is.mjs +3 -8
  134. package/dist/date/isSafeTimeValue.d.ts +9 -13
  135. package/dist/date/isSafeTimestamp.d.ts +7 -16
  136. package/dist/date/isSerializedTheDate.cjs +20 -0
  137. package/dist/date/isSerializedTheDate.d.ts +31 -0
  138. package/dist/date/isSerializedTheDate.mjs +18 -0
  139. package/dist/date/isSerializedTheTime.cjs +20 -0
  140. package/dist/date/isSerializedTheTime.d.ts +31 -0
  141. package/dist/date/isSerializedTheTime.mjs +18 -0
  142. package/dist/date/isTime.cjs +3 -8
  143. package/dist/date/isTime.d.ts +7 -14
  144. package/dist/date/isTime.mjs +3 -8
  145. package/dist/date/kind.cjs +9 -0
  146. package/dist/date/kind.d.ts +1 -0
  147. package/dist/date/kind.mjs +7 -0
  148. package/dist/date/makeSafeTimeValue.d.ts +12 -11
  149. package/dist/date/makeSafeTimestamp.d.ts +12 -11
  150. package/dist/date/max.cjs +2 -2
  151. package/dist/date/max.d.ts +13 -13
  152. package/dist/date/max.mjs +2 -2
  153. package/dist/date/maxTime.cjs +2 -2
  154. package/dist/date/maxTime.d.ts +13 -21
  155. package/dist/date/maxTime.mjs +2 -2
  156. package/dist/date/min.cjs +2 -2
  157. package/dist/date/min.d.ts +13 -13
  158. package/dist/date/min.mjs +2 -2
  159. package/dist/date/minTime.cjs +2 -2
  160. package/dist/date/minTime.d.ts +13 -21
  161. package/dist/date/minTime.mjs +2 -2
  162. package/dist/date/now.cjs +3 -1
  163. package/dist/date/now.d.ts +9 -7
  164. package/dist/date/now.mjs +3 -1
  165. package/dist/date/operators/addDays.cjs +3 -5
  166. package/dist/date/operators/addDays.d.ts +14 -11
  167. package/dist/date/operators/addDays.mjs +3 -5
  168. package/dist/date/operators/addHours.cjs +3 -5
  169. package/dist/date/operators/addHours.d.ts +14 -11
  170. package/dist/date/operators/addHours.mjs +3 -5
  171. package/dist/date/operators/addMilliseconds.cjs +3 -5
  172. package/dist/date/operators/addMilliseconds.d.ts +14 -11
  173. package/dist/date/operators/addMilliseconds.mjs +3 -5
  174. package/dist/date/operators/addMinutes.cjs +3 -5
  175. package/dist/date/operators/addMinutes.d.ts +14 -11
  176. package/dist/date/operators/addMinutes.mjs +3 -5
  177. package/dist/date/operators/addMonths.cjs +2 -2
  178. package/dist/date/operators/addMonths.d.ts +13 -13
  179. package/dist/date/operators/addMonths.mjs +2 -2
  180. package/dist/date/operators/addSeconds.cjs +3 -5
  181. package/dist/date/operators/addSeconds.d.ts +14 -11
  182. package/dist/date/operators/addSeconds.mjs +3 -5
  183. package/dist/date/operators/addTime.cjs +13 -6
  184. package/dist/date/operators/addTime.d.ts +20 -18
  185. package/dist/date/operators/addTime.mjs +13 -6
  186. package/dist/date/operators/addWeeks.cjs +6 -5
  187. package/dist/date/operators/addWeeks.d.ts +14 -11
  188. package/dist/date/operators/addWeeks.mjs +6 -5
  189. package/dist/date/operators/addYears.cjs +2 -2
  190. package/dist/date/operators/addYears.d.ts +13 -13
  191. package/dist/date/operators/addYears.mjs +2 -2
  192. package/dist/date/operators/between.d.ts +11 -11
  193. package/dist/date/operators/betweenThan.d.ts +11 -11
  194. package/dist/date/operators/betweenThanTime.d.ts +18 -22
  195. package/dist/date/operators/betweenTime.d.ts +17 -21
  196. package/dist/date/operators/greater.d.ts +12 -9
  197. package/dist/date/operators/greaterThan.d.ts +14 -11
  198. package/dist/date/operators/greaterThanTime.d.ts +17 -21
  199. package/dist/date/operators/greaterTime.d.ts +16 -20
  200. package/dist/date/operators/less.d.ts +12 -9
  201. package/dist/date/operators/lessThan.d.ts +13 -10
  202. package/dist/date/operators/lessThanTime.d.ts +17 -21
  203. package/dist/date/operators/lessTime.d.ts +16 -20
  204. package/dist/date/operators/subtractDays.cjs +3 -5
  205. package/dist/date/operators/subtractDays.d.ts +14 -11
  206. package/dist/date/operators/subtractDays.mjs +3 -5
  207. package/dist/date/operators/subtractHours.cjs +3 -5
  208. package/dist/date/operators/subtractHours.d.ts +14 -11
  209. package/dist/date/operators/subtractHours.mjs +3 -5
  210. package/dist/date/operators/subtractMilliseconds.cjs +3 -5
  211. package/dist/date/operators/subtractMilliseconds.d.ts +14 -11
  212. package/dist/date/operators/subtractMilliseconds.mjs +3 -5
  213. package/dist/date/operators/subtractMinutes.cjs +3 -5
  214. package/dist/date/operators/subtractMinutes.d.ts +14 -11
  215. package/dist/date/operators/subtractMinutes.mjs +3 -5
  216. package/dist/date/operators/subtractMonths.cjs +2 -2
  217. package/dist/date/operators/subtractMonths.d.ts +17 -11
  218. package/dist/date/operators/subtractMonths.mjs +2 -2
  219. package/dist/date/operators/subtractSeconds.cjs +3 -5
  220. package/dist/date/operators/subtractSeconds.d.ts +14 -11
  221. package/dist/date/operators/subtractSeconds.mjs +3 -5
  222. package/dist/date/operators/subtractTime.cjs +13 -6
  223. package/dist/date/operators/subtractTime.d.ts +20 -18
  224. package/dist/date/operators/subtractTime.mjs +13 -6
  225. package/dist/date/operators/subtractWeeks.cjs +3 -5
  226. package/dist/date/operators/subtractWeeks.d.ts +14 -11
  227. package/dist/date/operators/subtractWeeks.mjs +3 -5
  228. package/dist/date/operators/subtractYears.cjs +2 -2
  229. package/dist/date/operators/subtractYears.d.ts +17 -11
  230. package/dist/date/operators/subtractYears.mjs +2 -2
  231. package/dist/date/round.cjs +2 -2
  232. package/dist/date/round.d.ts +11 -14
  233. package/dist/date/round.mjs +2 -2
  234. package/dist/date/serialize.cjs +14 -0
  235. package/dist/date/serialize.d.ts +41 -0
  236. package/dist/date/serialize.mjs +12 -0
  237. package/dist/date/sort.cjs +2 -2
  238. package/dist/date/sort.d.ts +16 -15
  239. package/dist/date/sort.mjs +2 -2
  240. package/dist/date/sortTimes.cjs +2 -2
  241. package/dist/date/sortTimes.d.ts +15 -21
  242. package/dist/date/sortTimes.mjs +2 -2
  243. package/dist/date/theDate.cjs +124 -0
  244. package/dist/date/theDate.d.ts +114 -0
  245. package/dist/date/theDate.mjs +122 -0
  246. package/dist/date/theTime.cjs +36 -0
  247. package/dist/date/theTime.d.ts +53 -0
  248. package/dist/date/theTime.mjs +34 -0
  249. package/dist/date/timezone.cjs +3 -0
  250. package/dist/date/timezone.d.ts +27 -0
  251. package/dist/date/timezone.mjs +3 -0
  252. package/dist/date/toISOString.cjs +5 -2
  253. package/dist/date/toISOString.d.ts +12 -10
  254. package/dist/date/toISOString.mjs +5 -2
  255. package/dist/date/toNative.cjs +4 -0
  256. package/dist/date/toNative.d.ts +12 -10
  257. package/dist/date/toNative.mjs +4 -0
  258. package/dist/date/toTimeValue.cjs +6 -2
  259. package/dist/date/toTimeValue.d.ts +14 -12
  260. package/dist/date/toTimeValue.mjs +6 -2
  261. package/dist/date/toTimestamp.cjs +5 -3
  262. package/dist/date/toTimestamp.d.ts +11 -9
  263. package/dist/date/toTimestamp.mjs +6 -4
  264. package/dist/date/today.cjs +3 -1
  265. package/dist/date/today.d.ts +14 -7
  266. package/dist/date/today.mjs +3 -1
  267. package/dist/date/tomorrow.cjs +2 -1
  268. package/dist/date/tomorrow.d.ts +12 -7
  269. package/dist/date/tomorrow.mjs +2 -1
  270. package/dist/date/types/index.d.ts +2 -2
  271. package/dist/date/types/serializedTheDate.d.ts +1 -0
  272. package/dist/date/types/serializedTheTime.d.ts +42 -0
  273. package/dist/date/types/spoolingDate.d.ts +2 -1
  274. package/dist/date/yesterday.cjs +2 -1
  275. package/dist/date/yesterday.d.ts +12 -7
  276. package/dist/date/yesterday.mjs +2 -1
  277. package/dist/index.cjs +5 -6
  278. package/dist/index.mjs +1 -3
  279. package/dist/metadata.json +73 -46
  280. package/package.json +1 -1
  281. package/dist/common/toJSON.cjs +0 -37
  282. package/dist/common/toJSON.d.ts +0 -44
  283. package/dist/common/toJSON.mjs +0 -35
  284. package/dist/common/toString.cjs +0 -10
  285. package/dist/common/toString.d.ts +0 -17
  286. package/dist/common/toString.mjs +0 -8
  287. package/dist/common/toTransform.cjs +0 -37
  288. package/dist/common/toTransform.d.ts +0 -50
  289. package/dist/common/toTransform.mjs +0 -35
  290. package/dist/date/createTheDate.cjs +0 -13
  291. package/dist/date/createTheDate.d.ts +0 -28
  292. package/dist/date/createTheDate.mjs +0 -11
  293. package/dist/date/createTheTime.cjs +0 -13
  294. package/dist/date/createTheTime.d.ts +0 -25
  295. package/dist/date/createTheTime.mjs +0 -11
  296. package/dist/date/types/theDate.d.ts +0 -11
  297. package/dist/date/types/theTime.d.ts +0 -10
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ var constants = require('./constants.cjs');
4
+ var isSafeTimestamp = require('./isSafeTimestamp.cjs');
5
+
6
+ /**
7
+ * {@include date/isSerializedTheDate/index.md}
8
+ */
9
+ function isSerializedTheDate(input) {
10
+ const serializeTheDateMatch = input.match(constants.serializeTheDateRegex);
11
+ if (serializeTheDateMatch) {
12
+ const { value, sign } = serializeTheDateMatch.groups;
13
+ return isSafeTimestamp.isSafeTimestamp(Number(sign === "-"
14
+ ? `-${value}`
15
+ : value));
16
+ }
17
+ return false;
18
+ }
19
+
20
+ exports.isSerializedTheDate = isSerializedTheDate;
@@ -0,0 +1,31 @@
1
+ import type { SerializedTheDate } from "./types";
2
+ /**
3
+ * Checks whether a string is a valid `SerializedTheDate`.
4
+ *
5
+ * Signature: `isSerializedTheDate(input)` → returns a value
6
+ *
7
+ * The input value is not mutated.
8
+ *
9
+ * ```ts
10
+ * const input = "date1718841600000+";
11
+ *
12
+ * if (D.isSerializedTheDate(input)) {
13
+ * // input: SerializedTheDate
14
+ * }
15
+ *
16
+ * const result = D.isSerializedTheDate("date42-");
17
+ * // result: true
18
+ *
19
+ * const result2 = D.isSerializedTheDate("2024-06-20");
20
+ * // result2: false
21
+ * ```
22
+ *
23
+ * @remarks
24
+ * - A valid serialized date follows the pattern `date${number}${"+" | "-"}` and must contain a safe timestamp value.
25
+ *
26
+ * @see https://utils.duplojs.dev/en/v1/api/date/isSerializedTheDate
27
+ *
28
+ * @namespace D
29
+ *
30
+ */
31
+ export declare function isSerializedTheDate(input: string): input is SerializedTheDate;
@@ -0,0 +1,18 @@
1
+ import { serializeTheDateRegex } from './constants.mjs';
2
+ import { isSafeTimestamp } from './isSafeTimestamp.mjs';
3
+
4
+ /**
5
+ * {@include date/isSerializedTheDate/index.md}
6
+ */
7
+ function isSerializedTheDate(input) {
8
+ const serializeTheDateMatch = input.match(serializeTheDateRegex);
9
+ if (serializeTheDateMatch) {
10
+ const { value, sign } = serializeTheDateMatch.groups;
11
+ return isSafeTimestamp(Number(sign === "-"
12
+ ? `-${value}`
13
+ : value));
14
+ }
15
+ return false;
16
+ }
17
+
18
+ export { isSerializedTheDate };
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ var constants = require('./constants.cjs');
4
+ var isSafeTimeValue = require('./isSafeTimeValue.cjs');
5
+
6
+ /**
7
+ * {@include date/isSerializedTheTime/index.md}
8
+ */
9
+ function isSerializedTheTime(input) {
10
+ const serializeTheTimeMatch = input.match(constants.serializeTheTimeRegex);
11
+ if (serializeTheTimeMatch) {
12
+ const { value, sign } = serializeTheTimeMatch.groups;
13
+ return isSafeTimeValue.isSafeTimeValue(Number(sign === "-"
14
+ ? `-${value}`
15
+ : value));
16
+ }
17
+ return false;
18
+ }
19
+
20
+ exports.isSerializedTheTime = isSerializedTheTime;
@@ -0,0 +1,31 @@
1
+ import type { SerializedTheTime } from "./types";
2
+ /**
3
+ * Checks whether a string is a valid `SerializedTheTime`.
4
+ *
5
+ * Signature: `isSerializedTheTime(input)` → returns a value
6
+ *
7
+ * The input value is not mutated.
8
+ *
9
+ * ```ts
10
+ * const input = "time5400000+";
11
+ *
12
+ * if (D.isSerializedTheTime(input)) {
13
+ * // input: SerializedTheTime
14
+ * }
15
+ *
16
+ * const result = D.isSerializedTheTime("time1-");
17
+ * // result: true
18
+ *
19
+ * const result2 = D.isSerializedTheTime("01:30:00");
20
+ * // result2: false
21
+ * ```
22
+ *
23
+ * @remarks
24
+ * - A valid serialized time follows the pattern `time${number}${"+" | "-"}` and must contain a safe time value.
25
+ *
26
+ * @see https://utils.duplojs.dev/en/v1/api/date/isSerializedTheTime
27
+ *
28
+ * @namespace D
29
+ *
30
+ */
31
+ export declare function isSerializedTheTime(input: string): input is SerializedTheTime;
@@ -0,0 +1,18 @@
1
+ import { serializeTheTimeRegex } from './constants.mjs';
2
+ import { isSafeTimeValue } from './isSafeTimeValue.mjs';
3
+
4
+ /**
5
+ * {@include date/isSerializedTheTime/index.md}
6
+ */
7
+ function isSerializedTheTime(input) {
8
+ const serializeTheTimeMatch = input.match(serializeTheTimeRegex);
9
+ if (serializeTheTimeMatch) {
10
+ const { value, sign } = serializeTheTimeMatch.groups;
11
+ return isSafeTimeValue(Number(sign === "-"
12
+ ? `-${value}`
13
+ : value));
14
+ }
15
+ return false;
16
+ }
17
+
18
+ export { isSerializedTheTime };
@@ -1,18 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var constants = require('./constants.cjs');
4
- var isSafeTimestamp = require('./isSafeTimestamp.cjs');
3
+ var theTime = require('./theTime.cjs');
5
4
 
6
5
  /**
7
6
  * {@include date/isTime/index.md}
8
7
  */
9
8
  function isTime(input) {
10
- const theTimeMatch = input.match(constants.theTimeRegex);
11
- if (theTimeMatch) {
12
- const { value, sign } = theTimeMatch.groups;
13
- return isSafeTimestamp.isSafeTimestamp(Number(sign === "-"
14
- ? `-${value}`
15
- : value));
9
+ if (input instanceof theTime.TheTime) {
10
+ return true;
16
11
  }
17
12
  return false;
18
13
  }
@@ -1,31 +1,24 @@
1
- import { type TheTime } from "./types";
1
+ import { TheTime } from "./theTime";
2
2
  /**
3
- * Checks whether a string is a TheTime.
3
+ * Checks whether a value is an instance of `TheTime`.
4
4
  *
5
- * Signature: `isTime(input)` → returns a value
6
- *
7
- * The input value is not mutated.
5
+ * Signature: `isTime(input)` → `input is TheTime`
8
6
  *
9
7
  * ```ts
10
- * const input = "time3600000+";
8
+ * const input = D.createTime(1, "hour") as unknown;
11
9
  *
12
10
  * if (D.isTime(input)) {
13
11
  * // input: TheTime
14
12
  * }
15
13
  *
16
- * const result = D.isTime("time3600000-");
17
- * // result: true
14
+ * const result = D.isTime(D.create("2024-06-20"));
15
+ * // result: false
18
16
  *
19
- * const result2 = D.isTime("time99999999999999999+");
20
- * // result2: false
21
17
  * ```
22
18
  *
23
- * @remarks
24
- * - Validates the string format and the safe time range.
25
- *
26
19
  * @see https://utils.duplojs.dev/en/v1/api/date/isTime
27
20
  *
28
21
  * @namespace D
29
22
  *
30
23
  */
31
- export declare function isTime(input: string): input is TheTime;
24
+ export declare function isTime(input: unknown): input is TheTime;
@@ -1,16 +1,11 @@
1
- import { theTimeRegex } from './constants.mjs';
2
- import { isSafeTimestamp } from './isSafeTimestamp.mjs';
1
+ import { TheTime } from './theTime.mjs';
3
2
 
4
3
  /**
5
4
  * {@include date/isTime/index.md}
6
5
  */
7
6
  function isTime(input) {
8
- const theTimeMatch = input.match(theTimeRegex);
9
- if (theTimeMatch) {
10
- const { value, sign } = theTimeMatch.groups;
11
- return isSafeTimestamp(Number(sign === "-"
12
- ? `-${value}`
13
- : value));
7
+ if (input instanceof TheTime) {
8
+ return true;
14
9
  }
15
10
  return false;
16
11
  }
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ var kind = require('../common/kind.cjs');
4
+
5
+ const createDateKind = kind.createKindNamespace(
6
+ // @ts-expect-error - reserved kind namespace
7
+ "DuplojsUtilsDate");
8
+
9
+ exports.createDateKind = createDateKind;
@@ -0,0 +1 @@
1
+ export declare const createDateKind: <GenericName extends string, GenericKindValue extends unknown = unknown>(name: GenericName & import("../string").ForbiddenString<GenericName, "@" | "/">) => import("../common").KindHandler<import("../common").KindDefinition<`@DuplojsUtilsDate/${GenericName}`, GenericKindValue>>;
@@ -0,0 +1,7 @@
1
+ import { createKindNamespace } from '../common/kind.mjs';
2
+
3
+ const createDateKind = createKindNamespace(
4
+ // @ts-expect-error - reserved kind namespace
5
+ "DuplojsUtilsDate");
6
+
7
+ export { createDateKind };
@@ -1,23 +1,24 @@
1
1
  /**
2
- * Clamps a time value to the supported safe range.
2
+ * Normalizes a time value into the supported safe range.
3
3
  *
4
- * Signature: `makeSafeTimeValue(input)` → returns a value
5
- *
6
- * The input value is not mutated.
4
+ * Signature: `makeSafeTimeValue(timeValue)` → `number`
7
5
  *
8
6
  * ```ts
9
- * const result = D.makeSafeTimeValue(1.2);
10
- * // result: 1
7
+ * const rounded = D.makeSafeTimeValue(1.2);
8
+ * // rounded: 1
9
+ *
10
+ * const fromNaN = D.makeSafeTimeValue(Number.NaN);
11
+ * // fromNaN: 0
11
12
  *
12
- * const result2 = D.makeSafeTimeValue(Number.NaN);
13
- * // result2: 0
13
+ * const clamped = D.makeSafeTimeValue(Infinity);
14
+ * // clamped: 9007199254740991
14
15
  *
15
- * const result3 = D.makeSafeTimeValue(Infinity);
16
- * // result3: 9007199254740991
17
16
  * ```
18
17
  *
19
18
  * @remarks
20
- * - Rounds non-integers, replaces NaN with 0, and clamps to min/max bounds.
19
+ * - `NaN` becomes `0`.
20
+ * - Floating values are rounded.
21
+ * - Values outside bounds are clamped.
21
22
  *
22
23
  * @see https://utils.duplojs.dev/en/v1/api/date/makeSafeTimeValue
23
24
  *
@@ -1,23 +1,24 @@
1
1
  /**
2
- * Clamps a timestamp to the supported safe range.
2
+ * Normalizes a timestamp into the supported safe range.
3
3
  *
4
- * Signature: `makeSafeTimestamp(input)` → returns a value
5
- *
6
- * The input value is not mutated.
4
+ * Signature: `makeSafeTimestamp(timestamp)` → `number`
7
5
  *
8
6
  * ```ts
9
- * const result = D.makeSafeTimestamp(1_700_000_000_000.4);
10
- * // result: 1700000000000
7
+ * const rounded = D.makeSafeTimestamp(1_700_000_000_000.4);
8
+ * // rounded: 1700000000000
9
+ *
10
+ * const fromNaN = D.makeSafeTimestamp(Number.NaN);
11
+ * // fromNaN: 0
11
12
  *
12
- * const result2 = D.makeSafeTimestamp(Number.NaN);
13
- * // result2: 0
13
+ * const clamped = D.makeSafeTimestamp(8_640_000_000_000_500);
14
+ * // clamped: 8640000000000000
14
15
  *
15
- * const result3 = D.makeSafeTimestamp(8_640_000_000_000_500);
16
- * // result3: 8640000000000000
17
16
  * ```
18
17
  *
19
18
  * @remarks
20
- * - Rounds non-integers, replaces NaN with 0, and clamps to min/max bounds.
19
+ * - `NaN` becomes `0`.
20
+ * - Floating values are rounded.
21
+ * - Values outside bounds are clamped.
21
22
  *
22
23
  * @see https://utils.duplojs.dev/en/v1/api/date/makeSafeTimestamp
23
24
  *
package/dist/date/max.cjs CHANGED
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var createOrThrow = require('./createOrThrow.cjs');
3
+ var theDate = require('./theDate.cjs');
4
4
  var toTimestamp = require('./toTimestamp.cjs');
5
5
 
6
6
  /**
7
7
  * {@include date/max/index.md}
8
8
  */
9
9
  function max(input) {
10
- return createOrThrow.createOrThrow(Math.max(...input.map(toTimestamp.toTimestamp)));
10
+ return theDate.TheDate.new(Math.max(...input.map(toTimestamp.toTimestamp)));
11
11
  }
12
12
 
13
13
  exports.max = max;
@@ -1,22 +1,22 @@
1
- import { type AnyTuple } from "../common";
2
- import { type TheDate } from "./types";
1
+ import type { AnyTuple } from "../common/types/anyTuple";
2
+ import { TheDate } from "./theDate";
3
+ import type { SerializedTheDate } from "./types";
3
4
  /**
4
- * Returns the latest date from an iterable.
5
+ * Returns the greatest date from a tuple of date values.
5
6
  *
6
- * Signature: `max(input)` → returns a value
7
- *
8
- * The input value is not mutated.
7
+ * Signature: `max(input)` → `TheDate`
9
8
  *
10
9
  * ```ts
11
- * const input = [D.yesterday(), D.today(), D.tomorrow()] as const;
10
+ * const input = [
11
+ * D.create("2024-06-20"),
12
+ * "date1718668800000+",
13
+ * D.create("2024-06-25"),
14
+ * ] as const;
12
15
  *
13
- * const result = D.max(input);
16
+ * const value = D.max(input);
17
+ * // value: TheDate
14
18
  *
15
19
  * pipe(
16
- * input,
17
- * D.max,
18
- * );
19
- *
20
20
  * ```
21
21
  *
22
22
  * @see https://utils.duplojs.dev/en/v1/api/date/max
@@ -24,4 +24,4 @@ import { type TheDate } from "./types";
24
24
  * @namespace D
25
25
  *
26
26
  */
27
- export declare function max<GenericInput extends AnyTuple<TheDate>>(input: GenericInput): `date${number}-` | `date${number}+`;
27
+ export declare function max<GenericInput extends AnyTuple<TheDate | SerializedTheDate>>(input: GenericInput): TheDate;
package/dist/date/max.mjs CHANGED
@@ -1,11 +1,11 @@
1
- import { createOrThrow } from './createOrThrow.mjs';
1
+ import { TheDate } from './theDate.mjs';
2
2
  import { toTimestamp } from './toTimestamp.mjs';
3
3
 
4
4
  /**
5
5
  * {@include date/max/index.md}
6
6
  */
7
7
  function max(input) {
8
- return createOrThrow(Math.max(...input.map(toTimestamp)));
8
+ return TheDate.new(Math.max(...input.map(toTimestamp)));
9
9
  }
10
10
 
11
11
  export { max };
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var createTheTime = require('./createTheTime.cjs');
3
+ var theTime = require('./theTime.cjs');
4
4
  var toTimeValue = require('./toTimeValue.cjs');
5
5
 
6
6
  /**
7
7
  * {@include date/maxTime/index.md}
8
8
  */
9
9
  function maxTime(input) {
10
- return createTheTime.createTheTime(Math.max(...input.map(toTimeValue.toTimeValue)));
10
+ return theTime.TheTime.new(Math.max(...input.map(toTimeValue.toTimeValue)));
11
11
  }
12
12
 
13
13
  exports.maxTime = maxTime;
@@ -1,31 +1,23 @@
1
- import { type AnyTuple } from "../common";
2
- import { type TheTime } from "./types";
1
+ import type { AnyTuple } from "../common/types/anyTuple";
2
+ import { TheTime } from "./theTime";
3
+ import type { SerializedTheTime } from "./types";
3
4
  /**
4
- * Returns the largest time from an iterable.
5
+ * Returns the greatest duration from a tuple of time values.
5
6
  *
6
- * Signature: `maxTime(input)` → returns a value
7
- *
8
- * The input value is not mutated.
7
+ * Signature: `maxTime(input)` → `TheTime`
9
8
  *
10
9
  * ```ts
11
- * const result = D.maxTime([
12
- * D.createTheTime(3_000),
13
- * D.createTheTime(1_000),
14
- * D.createTheTime(2_000),
15
- * ]);
16
- * // result: "time3000+"
10
+ * const value = D.maxTime([
11
+ * D.createTime(3_000, "millisecond"),
12
+ * D.createTime(1_000, "millisecond"),
13
+ * "time2000+",
14
+ * ] as const);
15
+ * // value: TheTime
17
16
  *
18
- * const result2 = D.maxTime([
17
+ * const value2 = D.maxTime([
19
18
  * "time3000-",
20
19
  * "time1000-",
21
20
  * ] as const);
22
- * // result2: "time1000-"
23
- *
24
- * const result3 = D.maxTime([
25
- * "time500+",
26
- * "time100+",
27
- * ] as const);
28
- * // result3: "time500+"
29
21
  * ```
30
22
  *
31
23
  * @see https://utils.duplojs.dev/en/v1/api/date/maxTime
@@ -33,4 +25,4 @@ import { type TheTime } from "./types";
33
25
  * @namespace D
34
26
  *
35
27
  */
36
- export declare function maxTime<GenericInput extends AnyTuple<TheTime>>(input: GenericInput): `time${number}-` | `time${number}+`;
28
+ export declare function maxTime<GenericInput extends AnyTuple<TheTime | SerializedTheTime>>(input: GenericInput): TheTime;
@@ -1,11 +1,11 @@
1
- import { createTheTime } from './createTheTime.mjs';
1
+ import { TheTime } from './theTime.mjs';
2
2
  import { toTimeValue } from './toTimeValue.mjs';
3
3
 
4
4
  /**
5
5
  * {@include date/maxTime/index.md}
6
6
  */
7
7
  function maxTime(input) {
8
- return createTheTime(Math.max(...input.map(toTimeValue)));
8
+ return TheTime.new(Math.max(...input.map(toTimeValue)));
9
9
  }
10
10
 
11
11
  export { maxTime };
package/dist/date/min.cjs CHANGED
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var createOrThrow = require('./createOrThrow.cjs');
4
3
  var toTimestamp = require('./toTimestamp.cjs');
4
+ var theDate = require('./theDate.cjs');
5
5
 
6
6
  /**
7
7
  * {@include date/min/index.md}
8
8
  */
9
9
  function min(input) {
10
- return createOrThrow.createOrThrow(Math.min(...input.map(toTimestamp.toTimestamp)));
10
+ return theDate.TheDate.new(Math.min(...input.map(toTimestamp.toTimestamp)));
11
11
  }
12
12
 
13
13
  exports.min = min;
@@ -1,22 +1,22 @@
1
- import { type AnyTuple } from "../common";
2
- import { type TheDate } from "./types";
1
+ import type { AnyTuple } from "../common/types/anyTuple";
2
+ import { TheDate } from "./theDate";
3
+ import type { SerializedTheDate } from "./types";
3
4
  /**
4
- * Returns the earliest date from an iterable.
5
+ * Returns the smallest date from a tuple of date values.
5
6
  *
6
- * Signature: `min(input)` → returns a value
7
- *
8
- * The input value is not mutated.
7
+ * Signature: `min(input)` → `TheDate`
9
8
  *
10
9
  * ```ts
11
- * const input = [D.yesterday(), D.today(), D.tomorrow()] as const;
10
+ * const input = [
11
+ * D.create("2024-06-20"),
12
+ * "date1718668800000+",
13
+ * D.create("2024-06-25"),
14
+ * ] as const;
12
15
  *
13
- * const result = D.min(input);
16
+ * const value = D.min(input);
17
+ * // value: TheDate
14
18
  *
15
19
  * pipe(
16
- * input,
17
- * D.min,
18
- * );
19
- *
20
20
  * ```
21
21
  *
22
22
  * @see https://utils.duplojs.dev/en/v1/api/date/min
@@ -24,4 +24,4 @@ import { type TheDate } from "./types";
24
24
  * @namespace D
25
25
  *
26
26
  */
27
- export declare function min<GenericInput extends AnyTuple<TheDate>>(input: GenericInput): `date${number}-` | `date${number}+`;
27
+ export declare function min<GenericInput extends AnyTuple<TheDate | SerializedTheDate>>(input: GenericInput): TheDate;
package/dist/date/min.mjs CHANGED
@@ -1,11 +1,11 @@
1
- import { createOrThrow } from './createOrThrow.mjs';
2
1
  import { toTimestamp } from './toTimestamp.mjs';
2
+ import { TheDate } from './theDate.mjs';
3
3
 
4
4
  /**
5
5
  * {@include date/min/index.md}
6
6
  */
7
7
  function min(input) {
8
- return createOrThrow(Math.min(...input.map(toTimestamp)));
8
+ return TheDate.new(Math.min(...input.map(toTimestamp)));
9
9
  }
10
10
 
11
11
  export { min };
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var createTheTime = require('./createTheTime.cjs');
3
+ var theTime = require('./theTime.cjs');
4
4
  var toTimeValue = require('./toTimeValue.cjs');
5
5
 
6
6
  /**
7
7
  * {@include date/minTime/index.md}
8
8
  */
9
9
  function minTime(input) {
10
- return createTheTime.createTheTime(Math.min(...input.map(toTimeValue.toTimeValue)));
10
+ return theTime.TheTime.new(Math.min(...input.map(toTimeValue.toTimeValue)));
11
11
  }
12
12
 
13
13
  exports.minTime = minTime;
@@ -1,31 +1,23 @@
1
- import { type AnyTuple } from "../common";
2
- import { type TheTime } from "./types";
1
+ import type { AnyTuple } from "../common/types/anyTuple";
2
+ import { TheTime } from "./theTime";
3
+ import type { SerializedTheTime } from "./types";
3
4
  /**
4
- * Returns the smallest time from an iterable.
5
+ * Returns the smallest duration from a tuple of time values.
5
6
  *
6
- * Signature: `minTime(input)` → returns a value
7
- *
8
- * The input value is not mutated.
7
+ * Signature: `minTime(input)` → `TheTime`
9
8
  *
10
9
  * ```ts
11
- * const result = D.minTime([
12
- * D.createTheTime(3_000),
13
- * D.createTheTime(1_000),
14
- * D.createTheTime(2_000),
15
- * ]);
16
- * // result: "time1000+"
10
+ * const value = D.minTime([
11
+ * D.createTime(3_000, "millisecond"),
12
+ * D.createTime(1_000, "millisecond"),
13
+ * "time2000+",
14
+ * ] as const);
15
+ * // value: TheTime
17
16
  *
18
- * const result2 = D.minTime([
17
+ * const value2 = D.minTime([
19
18
  * "time3000-",
20
19
  * "time1000-",
21
20
  * ] as const);
22
- * // result2: "time3000-"
23
- *
24
- * const result3 = D.minTime([
25
- * "time500+",
26
- * "time100+",
27
- * ] as const);
28
- * // result3: "time100+"
29
21
  * ```
30
22
  *
31
23
  * @see https://utils.duplojs.dev/en/v1/api/date/minTime
@@ -33,4 +25,4 @@ import { type TheTime } from "./types";
33
25
  * @namespace D
34
26
  *
35
27
  */
36
- export declare function minTime<GenericInput extends AnyTuple<TheTime>>(input: GenericInput): `time${number}-` | `time${number}+`;
28
+ export declare function minTime<GenericInput extends AnyTuple<TheTime | SerializedTheTime>>(input: GenericInput): TheTime;
@@ -1,11 +1,11 @@
1
- import { createTheTime } from './createTheTime.mjs';
1
+ import { TheTime } from './theTime.mjs';
2
2
  import { toTimeValue } from './toTimeValue.mjs';
3
3
 
4
4
  /**
5
5
  * {@include date/minTime/index.md}
6
6
  */
7
7
  function minTime(input) {
8
- return createTheTime(Math.min(...input.map(toTimeValue)));
8
+ return TheTime.new(Math.min(...input.map(toTimeValue)));
9
9
  }
10
10
 
11
11
  export { minTime };
package/dist/date/now.cjs CHANGED
@@ -1,11 +1,13 @@
1
1
  'use strict';
2
2
 
3
+ var theDate = require('./theDate.cjs');
4
+
3
5
  /**
4
6
  * {@include date/now/index.md}
5
7
  */
6
8
  function now() {
7
9
  const timestamp = Date.now();
8
- return `date${timestamp}+`;
10
+ return theDate.TheDate.new(timestamp);
9
11
  }
10
12
 
11
13
  exports.now = now;