@evolu/common 8.1.0 → 8.3.0

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 (232) hide show
  1. package/dist/src/Function.d.ts +1 -0
  2. package/dist/src/Function.d.ts.map +1 -1
  3. package/dist/src/Http.d.ts +9 -0
  4. package/dist/src/Http.d.ts.map +1 -1
  5. package/dist/src/Number.d.ts +66 -6
  6. package/dist/src/Number.d.ts.map +1 -1
  7. package/dist/src/Number.js +11 -3
  8. package/dist/src/Object.d.ts +1 -0
  9. package/dist/src/Object.d.ts.map +1 -1
  10. package/dist/src/RefCount.d.ts +1 -0
  11. package/dist/src/RefCount.d.ts.map +1 -1
  12. package/dist/src/Relation.d.ts +2 -0
  13. package/dist/src/Relation.d.ts.map +1 -1
  14. package/dist/src/Resource.d.ts +1 -0
  15. package/dist/src/Resource.d.ts.map +1 -1
  16. package/dist/src/Result.d.ts +383 -548
  17. package/dist/src/Result.d.ts.map +1 -1
  18. package/dist/src/Result.js +296 -46
  19. package/dist/src/Schedule.d.ts +2 -2
  20. package/dist/src/Schedule.d.ts.map +1 -1
  21. package/dist/src/StackTrace.d.ts +1 -0
  22. package/dist/src/StackTrace.d.ts.map +1 -1
  23. package/dist/src/Task.d.ts +978 -1061
  24. package/dist/src/Task.d.ts.map +1 -1
  25. package/dist/src/Task.js +1010 -159
  26. package/dist/src/Time.d.ts +71 -34
  27. package/dist/src/Time.d.ts.map +1 -1
  28. package/dist/src/Time.js +77 -1
  29. package/dist/src/Type.d.ts +1740 -795
  30. package/dist/src/Type.d.ts.map +1 -1
  31. package/dist/src/Type.js +1634 -211
  32. package/dist/src/Types.d.ts +0 -24
  33. package/dist/src/Types.d.ts.map +1 -1
  34. package/dist/src/intl/_en.d.ts +126 -0
  35. package/dist/src/intl/_en.d.ts.map +1 -0
  36. package/dist/src/intl/_en.js +267 -0
  37. package/dist/src/intl/ar.d.ts +117 -0
  38. package/dist/src/intl/ar.d.ts.map +1 -0
  39. package/dist/src/intl/ar.js +245 -0
  40. package/dist/src/intl/bn.d.ts +117 -0
  41. package/dist/src/intl/bn.d.ts.map +1 -0
  42. package/dist/src/intl/bn.js +258 -0
  43. package/dist/src/intl/ca.d.ts +117 -0
  44. package/dist/src/intl/ca.d.ts.map +1 -0
  45. package/dist/src/intl/ca.js +258 -0
  46. package/dist/src/intl/cs.d.ts +30 -7
  47. package/dist/src/intl/cs.d.ts.map +1 -1
  48. package/dist/src/intl/cs.js +65 -28
  49. package/dist/src/intl/da.d.ts +117 -0
  50. package/dist/src/intl/da.d.ts.map +1 -0
  51. package/dist/src/intl/da.js +258 -0
  52. package/dist/src/intl/de.d.ts +117 -0
  53. package/dist/src/intl/de.d.ts.map +1 -0
  54. package/dist/src/intl/de.js +258 -0
  55. package/dist/src/intl/el.d.ts +117 -0
  56. package/dist/src/intl/el.d.ts.map +1 -0
  57. package/dist/src/intl/el.js +265 -0
  58. package/dist/src/intl/es.d.ts +117 -0
  59. package/dist/src/intl/es.d.ts.map +1 -0
  60. package/dist/src/intl/es.js +258 -0
  61. package/dist/src/intl/fa.d.ts +117 -0
  62. package/dist/src/intl/fa.d.ts.map +1 -0
  63. package/dist/src/intl/fa.js +258 -0
  64. package/dist/src/intl/fi.d.ts +117 -0
  65. package/dist/src/intl/fi.d.ts.map +1 -0
  66. package/dist/src/intl/fi.js +258 -0
  67. package/dist/src/intl/fil.d.ts +117 -0
  68. package/dist/src/intl/fil.d.ts.map +1 -0
  69. package/dist/src/intl/fil.js +258 -0
  70. package/dist/src/intl/fr.d.ts +117 -0
  71. package/dist/src/intl/fr.d.ts.map +1 -0
  72. package/dist/src/intl/fr.js +258 -0
  73. package/dist/src/intl/he.d.ts +117 -0
  74. package/dist/src/intl/he.d.ts.map +1 -0
  75. package/dist/src/intl/he.js +258 -0
  76. package/dist/src/intl/hi.d.ts +117 -0
  77. package/dist/src/intl/hi.d.ts.map +1 -0
  78. package/dist/src/intl/hi.js +258 -0
  79. package/dist/src/intl/hr.d.ts +117 -0
  80. package/dist/src/intl/hr.d.ts.map +1 -0
  81. package/dist/src/intl/hr.js +265 -0
  82. package/dist/src/intl/hu.d.ts +63 -0
  83. package/dist/src/intl/hu.d.ts.map +1 -0
  84. package/dist/src/intl/hu.js +204 -0
  85. package/dist/src/intl/id.d.ts +117 -0
  86. package/dist/src/intl/id.d.ts.map +1 -0
  87. package/dist/src/intl/id.js +258 -0
  88. package/dist/src/intl/index.d.ts +42 -0
  89. package/dist/src/intl/index.d.ts.map +1 -1
  90. package/dist/src/intl/index.js +42 -0
  91. package/dist/src/intl/it.d.ts +117 -0
  92. package/dist/src/intl/it.d.ts.map +1 -0
  93. package/dist/src/intl/it.js +258 -0
  94. package/dist/src/intl/ja.d.ts +117 -0
  95. package/dist/src/intl/ja.d.ts.map +1 -0
  96. package/dist/src/intl/ja.js +258 -0
  97. package/dist/src/intl/ko.d.ts +117 -0
  98. package/dist/src/intl/ko.d.ts.map +1 -0
  99. package/dist/src/intl/ko.js +258 -0
  100. package/dist/src/intl/ml.d.ts +117 -0
  101. package/dist/src/intl/ml.d.ts.map +1 -0
  102. package/dist/src/intl/ml.js +258 -0
  103. package/dist/src/intl/mr.d.ts +117 -0
  104. package/dist/src/intl/mr.d.ts.map +1 -0
  105. package/dist/src/intl/mr.js +258 -0
  106. package/dist/src/intl/ms.d.ts +117 -0
  107. package/dist/src/intl/ms.d.ts.map +1 -0
  108. package/dist/src/intl/ms.js +245 -0
  109. package/dist/src/intl/nb.d.ts +63 -0
  110. package/dist/src/intl/nb.d.ts.map +1 -0
  111. package/dist/src/intl/nb.js +191 -0
  112. package/dist/src/intl/nl.d.ts +117 -0
  113. package/dist/src/intl/nl.d.ts.map +1 -0
  114. package/dist/src/intl/nl.js +258 -0
  115. package/dist/src/intl/pa.d.ts +117 -0
  116. package/dist/src/intl/pa.d.ts.map +1 -0
  117. package/dist/src/intl/pa.js +258 -0
  118. package/dist/src/intl/pl.d.ts +117 -0
  119. package/dist/src/intl/pl.d.ts.map +1 -0
  120. package/dist/src/intl/pl.js +242 -0
  121. package/dist/src/intl/pt-BR.d.ts +117 -0
  122. package/dist/src/intl/pt-BR.d.ts.map +1 -0
  123. package/dist/src/intl/pt-BR.js +258 -0
  124. package/dist/src/intl/pt.d.ts +117 -0
  125. package/dist/src/intl/pt.d.ts.map +1 -0
  126. package/dist/src/intl/pt.js +246 -0
  127. package/dist/src/intl/ro.d.ts +117 -0
  128. package/dist/src/intl/ro.d.ts.map +1 -0
  129. package/dist/src/intl/ro.js +258 -0
  130. package/dist/src/intl/sk.d.ts +117 -0
  131. package/dist/src/intl/sk.d.ts.map +1 -0
  132. package/dist/src/intl/sk.js +244 -0
  133. package/dist/src/intl/sl.d.ts +117 -0
  134. package/dist/src/intl/sl.d.ts.map +1 -0
  135. package/dist/src/intl/sl.js +258 -0
  136. package/dist/src/intl/sv.d.ts +117 -0
  137. package/dist/src/intl/sv.d.ts.map +1 -0
  138. package/dist/src/intl/sv.js +258 -0
  139. package/dist/src/intl/sw.d.ts +63 -0
  140. package/dist/src/intl/sw.d.ts.map +1 -0
  141. package/dist/src/intl/sw.js +191 -0
  142. package/dist/src/intl/ta.d.ts +117 -0
  143. package/dist/src/intl/ta.d.ts.map +1 -0
  144. package/dist/src/intl/ta.js +258 -0
  145. package/dist/src/intl/te.d.ts +117 -0
  146. package/dist/src/intl/te.d.ts.map +1 -0
  147. package/dist/src/intl/te.js +258 -0
  148. package/dist/src/intl/th.d.ts +117 -0
  149. package/dist/src/intl/th.d.ts.map +1 -0
  150. package/dist/src/intl/th.js +258 -0
  151. package/dist/src/intl/tr.d.ts +117 -0
  152. package/dist/src/intl/tr.d.ts.map +1 -0
  153. package/dist/src/intl/tr.js +255 -0
  154. package/dist/src/intl/uk.d.ts +117 -0
  155. package/dist/src/intl/uk.d.ts.map +1 -0
  156. package/dist/src/intl/uk.js +258 -0
  157. package/dist/src/intl/ur.d.ts +117 -0
  158. package/dist/src/intl/ur.d.ts.map +1 -0
  159. package/dist/src/intl/ur.js +245 -0
  160. package/dist/src/intl/vi.d.ts +117 -0
  161. package/dist/src/intl/vi.d.ts.map +1 -0
  162. package/dist/src/intl/vi.js +255 -0
  163. package/dist/src/intl/zh-CN.d.ts +117 -0
  164. package/dist/src/intl/zh-CN.d.ts.map +1 -0
  165. package/dist/src/intl/zh-CN.js +258 -0
  166. package/dist/src/intl/zh-TW.d.ts +117 -0
  167. package/dist/src/intl/zh-TW.d.ts.map +1 -0
  168. package/dist/src/intl/zh-TW.js +258 -0
  169. package/dist/src/local-first/Owner.d.ts +156 -62
  170. package/dist/src/local-first/Owner.d.ts.map +1 -1
  171. package/dist/src/local-first/Owner.js +119 -20
  172. package/package.json +1 -1
  173. package/src/Function.ts +2 -0
  174. package/src/Http.ts +9 -0
  175. package/src/Number.ts +85 -14
  176. package/src/Object.ts +2 -0
  177. package/src/RefCount.ts +2 -0
  178. package/src/Relation.ts +4 -0
  179. package/src/Resource.ts +2 -0
  180. package/src/Result.ts +397 -560
  181. package/src/Schedule.ts +1 -1
  182. package/src/StackTrace.ts +2 -0
  183. package/src/Task.ts +1145 -1225
  184. package/src/Time.ts +110 -62
  185. package/src/Type.ts +2842 -835
  186. package/src/Types.ts +0 -49
  187. package/src/intl/_en.ts +497 -0
  188. package/src/intl/ar.ts +417 -0
  189. package/src/intl/bn.ts +486 -0
  190. package/src/intl/ca.ts +488 -0
  191. package/src/intl/cs.ts +131 -32
  192. package/src/intl/da.ts +488 -0
  193. package/src/intl/de.ts +488 -0
  194. package/src/intl/el.ts +494 -0
  195. package/src/intl/es.ts +488 -0
  196. package/src/intl/fa.ts +487 -0
  197. package/src/intl/fi.ts +487 -0
  198. package/src/intl/fil.ts +488 -0
  199. package/src/intl/fr.ts +488 -0
  200. package/src/intl/he.ts +486 -0
  201. package/src/intl/hi.ts +487 -0
  202. package/src/intl/hr.ts +494 -0
  203. package/src/intl/hu.ts +387 -0
  204. package/src/intl/id.ts +487 -0
  205. package/src/intl/index.ts +42 -0
  206. package/src/intl/it.ts +488 -0
  207. package/src/intl/ja.ts +488 -0
  208. package/src/intl/ko.ts +487 -0
  209. package/src/intl/ml.ts +487 -0
  210. package/src/intl/mr.ts +487 -0
  211. package/src/intl/ms.ts +410 -0
  212. package/src/intl/nb.ts +364 -0
  213. package/src/intl/nl.ts +488 -0
  214. package/src/intl/pa.ts +487 -0
  215. package/src/intl/pl.ts +450 -0
  216. package/src/intl/pt-BR.ts +487 -0
  217. package/src/intl/pt.ts +424 -0
  218. package/src/intl/ro.ts +488 -0
  219. package/src/intl/sk.ts +412 -0
  220. package/src/intl/sl.ts +487 -0
  221. package/src/intl/sv.ts +488 -0
  222. package/src/intl/sw.ts +324 -0
  223. package/src/intl/ta.ts +487 -0
  224. package/src/intl/te.ts +487 -0
  225. package/src/intl/th.ts +484 -0
  226. package/src/intl/tr.ts +487 -0
  227. package/src/intl/uk.ts +488 -0
  228. package/src/intl/ur.ts +410 -0
  229. package/src/intl/vi.ts +435 -0
  230. package/src/intl/zh-CN.ts +482 -0
  231. package/src/intl/zh-TW.ts +482 -0
  232. package/src/local-first/Owner.ts +156 -62
package/src/Time.ts CHANGED
@@ -10,12 +10,6 @@ import type { yieldNow } from "./Task.ts";
10
10
  import {
11
11
  brand,
12
12
  type DateIso,
13
- lessThan,
14
- type NonNaNNumber,
15
- NonNegativeInt,
16
- positive,
17
- } from "./Type.ts";
18
- import type {
19
13
  Digit,
20
14
  Digit1To23,
21
15
  Digit1To51,
@@ -23,7 +17,13 @@ import type {
23
17
  Digit1To6,
24
18
  Digit1To9,
25
19
  Digit1To99,
26
- } from "./Types.ts";
20
+ lessThan,
21
+ type NonNaNNumber,
22
+ NonNegativeInt,
23
+ positive,
24
+ templateLiteral,
25
+ union,
26
+ } from "./Type.ts";
27
27
 
28
28
  /** Time and timer operations. */
29
29
  export interface Time {
@@ -376,104 +376,150 @@ export const performanceDurationBetween = (
376
376
  };
377
377
 
378
378
  /**
379
- * Duration can be either a {@link DurationLiteral} or milliseconds as
380
- * {@link Millis}.
379
+ * {@link DurationLiteral} or {@link Millis}.
380
+ *
381
+ * Convenience input accepting a human-readable {@link DurationLiteral} or
382
+ * validated milliseconds as {@link Millis}. APIs normalize it to `Millis`.
383
+ *
384
+ * ### Example
385
+ *
386
+ * ```ts
387
+ * import { Millis, spaced } from "@evolu/common";
388
+ *
389
+ * const readableSchedule = spaced("1s");
390
+ * const validatedSchedule = spaced(Millis.orThrow(1000));
391
+ *
392
+ * expectTypeOf(readableSchedule).toEqualTypeOf(validatedSchedule);
393
+ * ```
381
394
  */
382
395
  export type Duration = DurationLiteral | Millis;
383
396
 
384
- /** Positive duration accepted by timer-based APIs. */
385
- export type PositiveDuration = DurationLiteral | PositiveMillis;
386
-
387
397
  /**
388
- * Duration literal with compile-time validation.
398
+ * {@link DurationLiteral} or {@link PositiveMillis}.
389
399
  *
390
- * Supported formats:
391
- *
392
- * - Milliseconds: `1ms`, `500ms`, `999ms` (1-999)
393
- * - Seconds: `1s`, `59s`, `12.5s` (1-59, 1.1-59.9)
394
- * - Minutes: `1m`, `59m`, `12.5m` (1-59, 1.1-59.9)
395
- * - Hours: `1h`, `23h`, `12.5h` (1-23, 1.1-23.9)
396
- * - Days: `1d`, `6d`, `1.5d` (1-6, 1.1-6.9)
397
- * - Weeks: `1w`, `51w`, `1.5w` (1-51, 1.1-51.9)
398
- * - Months: not supported (variable length)
399
- * - Years: `1y`, `99y`, `1.5y` (1-99, 1.1-99.9)
400
+ * Convenience input accepting a human-readable {@link DurationLiteral} or
401
+ * validated milliseconds as {@link PositiveMillis} for timer-based APIs.
400
402
  *
401
- * Each unit uses a bounded range. Where units convert exactly, this avoids
402
- * equivalent representations (e.g., 1000ms must be written as `"1s"`, not
403
- * `"1000ms"`).
403
+ * ### Example
404
404
  *
405
- * Decimal values cover cases like 1.5s (1500ms) or 1.5h (90 minutes) without
406
- * allowing redundant forms. For precise values that don't fit (e.g., 1050ms),
407
- * use {@link Millis} directly.
405
+ * ```ts
406
+ * import { PositiveMillis, sleep } from "@evolu/common";
408
407
  *
409
- * Zero duration (0ms) is not supported. For yielding without delay, use `await
410
- * Promise.resolve()` for microtasks or the {@link yieldNow} for macrotasks.
408
+ * const readableSleep = sleep("1s");
409
+ * const validatedSleep = sleep(PositiveMillis.orThrow(1000));
411
410
  *
412
- * See {@link Duration} for a type that also accepts {@link Millis}. Use
413
- * {@link durationToMillis} to convert to milliseconds.
411
+ * expectTypeOf(readableSleep).toEqualTypeOf(validatedSleep);
412
+ * ```
414
413
  */
415
- export type DurationLiteral =
416
- | DurationLiteralMilliseconds
417
- | DurationLiteralSeconds
418
- | DurationLiteralMinutes
419
- | DurationLiteralHours
420
- | DurationLiteralDays
421
- | DurationLiteralWeeks
422
- | DurationLiteralYears;
414
+ export type PositiveDuration = DurationLiteral | PositiveMillis;
423
415
 
424
416
  /** Milliseconds duration: `"1ms"` to `"999ms"`. See {@link DurationLiteral}. */
417
+ export const DurationLiteralMilliseconds = /*#__PURE__*/ union(
418
+ /*#__PURE__*/ templateLiteral(Digit1To9, "ms"),
419
+ /*#__PURE__*/ templateLiteral(Digit1To9, Digit, "ms"),
420
+ /*#__PURE__*/ templateLiteral(Digit1To9, Digit, Digit, "ms"),
421
+ );
425
422
  export type DurationLiteralMilliseconds =
426
- | `${Digit1To9}ms` // 1-9
427
- | `${Digit1To9}${Digit}ms` // 10-99
428
- | `${Digit1To9}${Digit}${Digit}ms`; // 100-999
423
+ typeof DurationLiteralMilliseconds.Output;
429
424
 
430
425
  /**
431
426
  * Seconds duration: `"1s"` to `"59s"` or `"1.1s"` to `"59.9s"`. See
432
427
  * {@link DurationLiteral}.
433
428
  */
434
- export type DurationLiteralSeconds =
435
- | `${Digit1To59}s` // 1-59
436
- | `${Digit1To59}.${Digit1To9}s`; // 1.1-59.9
429
+ export const DurationLiteralSeconds = /*#__PURE__*/ union(
430
+ /*#__PURE__*/ templateLiteral(Digit1To59, "s"),
431
+ /*#__PURE__*/ templateLiteral(Digit1To59, ".", Digit1To9, "s"),
432
+ );
433
+ export type DurationLiteralSeconds = typeof DurationLiteralSeconds.Output;
437
434
 
438
435
  /**
439
436
  * Minutes duration: `"1m"` to `"59m"` or `"1.1m"` to `"59.9m"`. See
440
437
  * {@link DurationLiteral}.
441
438
  */
442
- export type DurationLiteralMinutes =
443
- | `${Digit1To59}m` // 1-59
444
- | `${Digit1To59}.${Digit1To9}m`; // 1.1-59.9
439
+ export const DurationLiteralMinutes = /*#__PURE__*/ union(
440
+ /*#__PURE__*/ templateLiteral(Digit1To59, "m"),
441
+ /*#__PURE__*/ templateLiteral(Digit1To59, ".", Digit1To9, "m"),
442
+ );
443
+ export type DurationLiteralMinutes = typeof DurationLiteralMinutes.Output;
445
444
 
446
445
  /**
447
446
  * Hours duration: `"1h"` to `"23h"` or `"1.1h"` to `"23.9h"`. See
448
447
  * {@link DurationLiteral}.
449
448
  */
450
- export type DurationLiteralHours =
451
- | `${Digit1To23}h` // 1-23
452
- | `${Digit1To23}.${Digit1To9}h`; // 1.1-23.9
449
+ export const DurationLiteralHours = /*#__PURE__*/ union(
450
+ /*#__PURE__*/ templateLiteral(Digit1To23, "h"),
451
+ /*#__PURE__*/ templateLiteral(Digit1To23, ".", Digit1To9, "h"),
452
+ );
453
+ export type DurationLiteralHours = typeof DurationLiteralHours.Output;
453
454
 
454
455
  /**
455
456
  * Days duration: `"1d"` to `"6d"` or `"1.1d"` to `"6.9d"`. See
456
457
  * {@link DurationLiteral}.
457
458
  */
458
- export type DurationLiteralDays =
459
- | `${Digit1To6}d` // 1-6
460
- | `${Digit1To6}.${Digit1To9}d`; // 1.1-6.9
459
+ export const DurationLiteralDays = /*#__PURE__*/ union(
460
+ /*#__PURE__*/ templateLiteral(Digit1To6, "d"),
461
+ /*#__PURE__*/ templateLiteral(Digit1To6, ".", Digit1To9, "d"),
462
+ );
463
+ export type DurationLiteralDays = typeof DurationLiteralDays.Output;
461
464
 
462
465
  /**
463
466
  * Weeks duration: `"1w"` to `"51w"` or `"1.1w"` to `"51.9w"`. See
464
467
  * {@link DurationLiteral}.
465
468
  */
466
- export type DurationLiteralWeeks =
467
- | `${Digit1To51}w` // 1-51
468
- | `${Digit1To51}.${Digit1To9}w`; // 1.1-51.9
469
+ export const DurationLiteralWeeks = /*#__PURE__*/ union(
470
+ /*#__PURE__*/ templateLiteral(Digit1To51, "w"),
471
+ /*#__PURE__*/ templateLiteral(Digit1To51, ".", Digit1To9, "w"),
472
+ );
473
+ export type DurationLiteralWeeks = typeof DurationLiteralWeeks.Output;
469
474
 
470
475
  /**
471
476
  * Years duration: `"1y"` to `"99y"` or `"1.1y"` to `"99.9y"`. See
472
477
  * {@link DurationLiteral}.
473
478
  */
474
- export type DurationLiteralYears =
475
- | `${Digit1To99}y` // 1-99
476
- | `${Digit1To99}.${Digit1To9}y`; // 1.1-99.9
479
+ export const DurationLiteralYears = /*#__PURE__*/ union(
480
+ /*#__PURE__*/ templateLiteral(Digit1To99, "y"),
481
+ /*#__PURE__*/ templateLiteral(Digit1To99, ".", Digit1To9, "y"),
482
+ );
483
+ export type DurationLiteralYears = typeof DurationLiteralYears.Output;
484
+
485
+ /**
486
+ * Duration literal Type with compile-time and runtime validation.
487
+ *
488
+ * Supported formats:
489
+ *
490
+ * - Milliseconds: `1ms`, `500ms`, `999ms` (1-999)
491
+ * - Seconds: `1s`, `59s`, `12.5s` (1-59, 1.1-59.9)
492
+ * - Minutes: `1m`, `59m`, `12.5m` (1-59, 1.1-59.9)
493
+ * - Hours: `1h`, `23h`, `12.5h` (1-23, 1.1-23.9)
494
+ * - Days: `1d`, `6d`, `1.5d` (1-6, 1.1-6.9)
495
+ * - Weeks: `1w`, `51w`, `1.5w` (1-51, 1.1-51.9)
496
+ * - Months: not supported (variable length)
497
+ * - Years: `1y`, `99y`, `1.5y` (1-99, 1.1-99.9)
498
+ *
499
+ * Each unit uses a bounded range. Where units convert exactly, this avoids
500
+ * equivalent representations (e.g., 1000ms must be written as `"1s"`, not
501
+ * `"1000ms"`).
502
+ *
503
+ * Decimal values cover cases like 1.5s (1500ms) or 1.5h (90 minutes) without
504
+ * allowing redundant forms. For precise values that don't fit (e.g., 1050ms),
505
+ * use {@link Millis} directly.
506
+ *
507
+ * Zero duration (0ms) is not supported. For yielding without delay, use `await
508
+ * Promise.resolve()` for microtasks or the {@link yieldNow} for macrotasks.
509
+ *
510
+ * See {@link Duration} for a type that also accepts {@link Millis}. Use
511
+ * {@link durationToMillis} to convert to milliseconds.
512
+ */
513
+ export const DurationLiteral = /*#__PURE__*/ union(
514
+ DurationLiteralMilliseconds,
515
+ DurationLiteralSeconds,
516
+ DurationLiteralMinutes,
517
+ DurationLiteralHours,
518
+ DurationLiteralDays,
519
+ DurationLiteralWeeks,
520
+ DurationLiteralYears,
521
+ );
522
+ export type DurationLiteral = typeof DurationLiteral.Output;
477
523
 
478
524
  /**
479
525
  * Converts a duration to milliseconds.
@@ -496,6 +542,8 @@ export type DurationLiteralYears =
496
542
  export function durationToMillis(
497
543
  duration: DurationLiteral | PositiveMillis,
498
544
  ): PositiveMillis;
545
+
546
+ /** Converts a general {@link Duration}, including zero, to milliseconds. */
499
547
  export function durationToMillis(duration: Duration): Millis;
500
548
  export function durationToMillis(duration: Duration): Millis {
501
549
  if (typeof duration === "number") return duration;