@evolu/common 8.8.0 → 8.10.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.
- package/dist/src/Assert.d.ts +21 -1
- package/dist/src/Assert.d.ts.map +1 -1
- package/dist/src/Assert.js +31 -27
- package/dist/src/Bytes.d.ts +647 -0
- package/dist/src/Bytes.d.ts.map +1 -0
- package/dist/src/{Binary.js → Bytes.js} +266 -16
- package/dist/src/Config.d.ts +142 -0
- package/dist/src/Config.d.ts.map +1 -0
- package/dist/src/Config.js +181 -0
- package/dist/src/Fs.d.ts +302 -0
- package/dist/src/Fs.d.ts.map +1 -0
- package/dist/src/Fs.js +111 -0
- package/dist/src/Number.d.ts +50 -7
- package/dist/src/Number.d.ts.map +1 -1
- package/dist/src/Number.js +47 -8
- package/dist/src/Object.d.ts +32 -0
- package/dist/src/Object.d.ts.map +1 -1
- package/dist/src/Object.js +41 -0
- package/dist/src/Polyfills.d.ts +6 -0
- package/dist/src/Polyfills.d.ts.map +1 -1
- package/dist/src/Polyfills.js +6 -0
- package/dist/src/Sqlite.js +1 -1
- package/dist/src/Time.d.ts +74 -12
- package/dist/src/Time.d.ts.map +1 -1
- package/dist/src/Time.js +40 -2
- package/dist/src/Type.d.ts +1451 -79
- package/dist/src/Type.d.ts.map +1 -1
- package/dist/src/Type.js +1303 -96
- package/dist/src/index.d.ts +3 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +3 -1
- package/dist/src/intl/_en.d.ts +24 -1
- package/dist/src/intl/_en.d.ts.map +1 -1
- package/dist/src/intl/_en.js +20 -0
- package/dist/src/intl/ar.d.ts +24 -1
- package/dist/src/intl/ar.d.ts.map +1 -1
- package/dist/src/intl/ar.js +20 -0
- package/dist/src/intl/bn.d.ts +24 -1
- package/dist/src/intl/bn.d.ts.map +1 -1
- package/dist/src/intl/bn.js +20 -0
- package/dist/src/intl/ca.d.ts +24 -1
- package/dist/src/intl/ca.d.ts.map +1 -1
- package/dist/src/intl/ca.js +20 -0
- package/dist/src/intl/cs.d.ts +24 -1
- package/dist/src/intl/cs.d.ts.map +1 -1
- package/dist/src/intl/cs.js +20 -0
- package/dist/src/intl/da.d.ts +24 -1
- package/dist/src/intl/da.d.ts.map +1 -1
- package/dist/src/intl/da.js +20 -0
- package/dist/src/intl/de.d.ts +24 -1
- package/dist/src/intl/de.d.ts.map +1 -1
- package/dist/src/intl/de.js +20 -0
- package/dist/src/intl/el.d.ts +24 -1
- package/dist/src/intl/el.d.ts.map +1 -1
- package/dist/src/intl/el.js +20 -0
- package/dist/src/intl/es.d.ts +24 -1
- package/dist/src/intl/es.d.ts.map +1 -1
- package/dist/src/intl/es.js +20 -0
- package/dist/src/intl/fa.d.ts +24 -1
- package/dist/src/intl/fa.d.ts.map +1 -1
- package/dist/src/intl/fa.js +20 -0
- package/dist/src/intl/fi.d.ts +24 -1
- package/dist/src/intl/fi.d.ts.map +1 -1
- package/dist/src/intl/fi.js +20 -0
- package/dist/src/intl/fil.d.ts +24 -1
- package/dist/src/intl/fil.d.ts.map +1 -1
- package/dist/src/intl/fil.js +20 -0
- package/dist/src/intl/fr.d.ts +24 -1
- package/dist/src/intl/fr.d.ts.map +1 -1
- package/dist/src/intl/fr.js +20 -0
- package/dist/src/intl/he.d.ts +24 -1
- package/dist/src/intl/he.d.ts.map +1 -1
- package/dist/src/intl/he.js +20 -0
- package/dist/src/intl/hi.d.ts +24 -1
- package/dist/src/intl/hi.d.ts.map +1 -1
- package/dist/src/intl/hi.js +20 -0
- package/dist/src/intl/hr.d.ts +24 -1
- package/dist/src/intl/hr.d.ts.map +1 -1
- package/dist/src/intl/hr.js +20 -0
- package/dist/src/intl/hu.d.ts +22 -1
- package/dist/src/intl/hu.d.ts.map +1 -1
- package/dist/src/intl/hu.js +18 -0
- package/dist/src/intl/id.d.ts +24 -1
- package/dist/src/intl/id.d.ts.map +1 -1
- package/dist/src/intl/id.js +20 -0
- package/dist/src/intl/it.d.ts +24 -1
- package/dist/src/intl/it.d.ts.map +1 -1
- package/dist/src/intl/it.js +20 -0
- package/dist/src/intl/ja.d.ts +24 -1
- package/dist/src/intl/ja.d.ts.map +1 -1
- package/dist/src/intl/ja.js +20 -0
- package/dist/src/intl/ko.d.ts +24 -1
- package/dist/src/intl/ko.d.ts.map +1 -1
- package/dist/src/intl/ko.js +20 -0
- package/dist/src/intl/ml.d.ts +24 -1
- package/dist/src/intl/ml.d.ts.map +1 -1
- package/dist/src/intl/ml.js +20 -0
- package/dist/src/intl/mr.d.ts +24 -1
- package/dist/src/intl/mr.d.ts.map +1 -1
- package/dist/src/intl/mr.js +20 -0
- package/dist/src/intl/ms.d.ts +24 -1
- package/dist/src/intl/ms.d.ts.map +1 -1
- package/dist/src/intl/ms.js +20 -0
- package/dist/src/intl/nb.d.ts +22 -1
- package/dist/src/intl/nb.d.ts.map +1 -1
- package/dist/src/intl/nb.js +18 -0
- package/dist/src/intl/nl.d.ts +24 -1
- package/dist/src/intl/nl.d.ts.map +1 -1
- package/dist/src/intl/nl.js +20 -0
- package/dist/src/intl/pa.d.ts +24 -1
- package/dist/src/intl/pa.d.ts.map +1 -1
- package/dist/src/intl/pa.js +20 -0
- package/dist/src/intl/pl.d.ts +23 -0
- package/dist/src/intl/pl.d.ts.map +1 -1
- package/dist/src/intl/pl.js +20 -0
- package/dist/src/intl/pt-BR.d.ts +24 -1
- package/dist/src/intl/pt-BR.d.ts.map +1 -1
- package/dist/src/intl/pt-BR.js +20 -0
- package/dist/src/intl/pt.d.ts +24 -1
- package/dist/src/intl/pt.d.ts.map +1 -1
- package/dist/src/intl/pt.js +20 -0
- package/dist/src/intl/ro.d.ts +24 -1
- package/dist/src/intl/ro.d.ts.map +1 -1
- package/dist/src/intl/ro.js +20 -0
- package/dist/src/intl/sk.d.ts +24 -1
- package/dist/src/intl/sk.d.ts.map +1 -1
- package/dist/src/intl/sk.js +20 -0
- package/dist/src/intl/sl.d.ts +24 -1
- package/dist/src/intl/sl.d.ts.map +1 -1
- package/dist/src/intl/sl.js +20 -0
- package/dist/src/intl/sv.d.ts +24 -1
- package/dist/src/intl/sv.d.ts.map +1 -1
- package/dist/src/intl/sv.js +20 -0
- package/dist/src/intl/sw.d.ts +21 -0
- package/dist/src/intl/sw.d.ts.map +1 -1
- package/dist/src/intl/sw.js +18 -0
- package/dist/src/intl/ta.d.ts +24 -1
- package/dist/src/intl/ta.d.ts.map +1 -1
- package/dist/src/intl/ta.js +20 -0
- package/dist/src/intl/te.d.ts +24 -1
- package/dist/src/intl/te.d.ts.map +1 -1
- package/dist/src/intl/te.js +20 -0
- package/dist/src/intl/th.d.ts +24 -1
- package/dist/src/intl/th.d.ts.map +1 -1
- package/dist/src/intl/th.js +20 -0
- package/dist/src/intl/tr.d.ts +24 -1
- package/dist/src/intl/tr.d.ts.map +1 -1
- package/dist/src/intl/tr.js +20 -0
- package/dist/src/intl/uk.d.ts +80 -57
- package/dist/src/intl/uk.d.ts.map +1 -1
- package/dist/src/intl/uk.js +174 -149
- package/dist/src/intl/ur.d.ts +24 -1
- package/dist/src/intl/ur.d.ts.map +1 -1
- package/dist/src/intl/ur.js +20 -0
- package/dist/src/intl/vi.d.ts +24 -1
- package/dist/src/intl/vi.d.ts.map +1 -1
- package/dist/src/intl/vi.js +20 -0
- package/dist/src/intl/zh-CN.d.ts +24 -1
- package/dist/src/intl/zh-CN.d.ts.map +1 -1
- package/dist/src/intl/zh-CN.js +20 -0
- package/dist/src/intl/zh-TW.d.ts +24 -1
- package/dist/src/intl/zh-TW.d.ts.map +1 -1
- package/dist/src/intl/zh-TW.js +20 -0
- package/dist/src/local-first/Protocol.d.ts +1 -1
- package/dist/src/local-first/Protocol.d.ts.map +1 -1
- package/dist/src/local-first/Protocol.js +1 -1
- package/dist/src/local-first/Schema.d.ts +10 -0
- package/dist/src/local-first/Schema.d.ts.map +1 -1
- package/dist/src/local-first/Storage.js +1 -1
- package/dist/src/local-first/Timestamp.js +1 -1
- package/package.json +1 -1
- package/src/Assert.test.ts +51 -0
- package/src/Assert.ts +56 -4
- package/src/{Binary.test.ts → Bytes.test.ts} +286 -1
- package/src/{Binary.ts → Bytes.ts} +652 -21
- package/src/Config.test.ts +672 -0
- package/src/Config.ts +410 -0
- package/src/Fs.test.ts +105 -0
- package/src/Fs.ts +414 -0
- package/src/Number.test.ts +82 -18
- package/src/Number.ts +76 -8
- package/src/Object.test.ts +115 -1
- package/src/Object.ts +44 -0
- package/src/Polyfills.ts +6 -0
- package/src/Sqlite.ts +1 -1
- package/src/Time.test.ts +82 -11
- package/src/Time.ts +141 -16
- package/src/Type.test.ts +3114 -157
- package/src/Type.ts +2553 -196
- package/src/index.ts +3 -1
- package/src/intl/_en.ts +70 -0
- package/src/intl/ar.ts +71 -0
- package/src/intl/bn.ts +70 -0
- package/src/intl/ca.ts +70 -0
- package/src/intl/cs.ts +70 -0
- package/src/intl/da.ts +70 -0
- package/src/intl/de.ts +70 -0
- package/src/intl/el.ts +70 -0
- package/src/intl/es.ts +70 -0
- package/src/intl/fa.ts +70 -0
- package/src/intl/fi.ts +70 -0
- package/src/intl/fil.ts +70 -0
- package/src/intl/fr.ts +70 -0
- package/src/intl/he.ts +70 -0
- package/src/intl/hi.ts +70 -0
- package/src/intl/hr.ts +70 -0
- package/src/intl/hu.ts +69 -0
- package/src/intl/id.ts +70 -0
- package/src/intl/intl.test.ts +819 -1
- package/src/intl/it.ts +70 -0
- package/src/intl/ja.ts +70 -0
- package/src/intl/ko.ts +68 -0
- package/src/intl/ml.ts +70 -0
- package/src/intl/mr.ts +70 -0
- package/src/intl/ms.ts +71 -0
- package/src/intl/nb.ts +69 -0
- package/src/intl/nl.ts +70 -0
- package/src/intl/pa.ts +70 -0
- package/src/intl/pl.ts +63 -0
- package/src/intl/pt-BR.ts +70 -0
- package/src/intl/pt.ts +71 -0
- package/src/intl/ro.ts +70 -0
- package/src/intl/sk.ts +71 -0
- package/src/intl/sl.ts +70 -0
- package/src/intl/sv.ts +70 -0
- package/src/intl/sw.ts +62 -0
- package/src/intl/ta.ts +70 -0
- package/src/intl/te.ts +70 -0
- package/src/intl/th.ts +68 -0
- package/src/intl/tr.ts +70 -0
- package/src/intl/uk.ts +228 -155
- package/src/intl/ur.ts +70 -0
- package/src/intl/vi.ts +70 -0
- package/src/intl/zh-CN.ts +68 -0
- package/src/intl/zh-TW.ts +68 -0
- package/src/local-first/Protocol.test.ts +1 -1
- package/src/local-first/Protocol.ts +1 -1
- package/src/local-first/Schema.ts +11 -0
- package/src/local-first/Storage.ts +1 -1
- package/src/local-first/Timestamp.ts +1 -1
- package/dist/src/Binary.d.ts +0 -254
- package/dist/src/Binary.d.ts.map +0 -1
package/dist/src/Number.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import type { NonEmptyReadonlyArray } from "./Array.ts";
|
|
7
7
|
import type { IsBranded } from "./Brand.ts";
|
|
8
8
|
import type { Result } from "./Result.ts";
|
|
9
|
-
import { Digit1To99, NonNegativeInt, PositiveInt, Ratio } from "./Type.ts";
|
|
9
|
+
import { type Type, type TypeError, type UnionError, Digit1To9, Digit1To99, NonNegativeInt, PositiveInt, Ratio } from "./Type.ts";
|
|
10
10
|
import type { Predicate, WidenLiteral } from "./Types.ts";
|
|
11
11
|
/** Integer literal from `1` to `99`. */
|
|
12
12
|
export type Int1To99 = Digit1To99 extends `${infer Value extends number}` ? Value : never;
|
|
@@ -76,14 +76,57 @@ export type Int1To100OrPositiveInt = Int1To100 | PositiveInt;
|
|
|
76
76
|
* ```
|
|
77
77
|
*/
|
|
78
78
|
export type Percentage = PercentageLiteral | Ratio;
|
|
79
|
+
export type PercentageLiteral = "0%" | "100%" | `${Digit1To99}%` | `${"0" | Digit1To99}.${Digit1To9}%`;
|
|
79
80
|
/**
|
|
80
|
-
* Percentage literal
|
|
81
|
+
* Percentage literal Type with compile-time and runtime validation.
|
|
81
82
|
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
83
|
+
* Supported formats:
|
|
84
|
+
*
|
|
85
|
+
* - Integers: `0%`, `50%`, `100%` (0-100)
|
|
86
|
+
* - One decimal place: `0.1%`, `12.5%`, `99.9%` (0.1-99.9)
|
|
87
|
+
*
|
|
88
|
+
* The decimal digit is never zero, so `12.0%` must be written as `"12%"`, and
|
|
89
|
+
* `100%` has no decimal form. For computed values or more precision, use
|
|
90
|
+
* {@link Ratio} directly.
|
|
91
|
+
*
|
|
92
|
+
* See {@link Percentage} for a type that also accepts {@link Ratio}. Use
|
|
93
|
+
* {@link percentageToRatio} to convert.
|
|
94
|
+
*
|
|
95
|
+
* Invalid values produce a {@link PercentageLiteralError}.
|
|
96
|
+
*
|
|
97
|
+
* ### Example
|
|
98
|
+
*
|
|
99
|
+
* ```ts
|
|
100
|
+
* import {
|
|
101
|
+
* assertFalse,
|
|
102
|
+
* assertOk,
|
|
103
|
+
* assertType,
|
|
104
|
+
* PercentageLiteral,
|
|
105
|
+
* } from "@evolu/common";
|
|
106
|
+
*
|
|
107
|
+
* // The TypeScript type accepts valid spellings and rejects the rest.
|
|
108
|
+
* const literal: PercentageLiteral = "12.5%";
|
|
109
|
+
* assertType<
|
|
110
|
+
* Extract<PercentageLiteral, "101%" | "12.0%" | "12.55%">,
|
|
111
|
+
* never
|
|
112
|
+
* >();
|
|
113
|
+
*
|
|
114
|
+
* // The runtime Type validates the same grammar.
|
|
115
|
+
* assertOk(PercentageLiteral.fromUnknown(literal), "12.5%");
|
|
116
|
+
* assertFalse(PercentageLiteral.is("101%"));
|
|
117
|
+
* ```
|
|
84
118
|
*/
|
|
85
|
-
export declare const PercentageLiteral:
|
|
86
|
-
|
|
119
|
+
export declare const PercentageLiteral: Type<"PercentageLiteral", PercentageLiteral, PercentageLiteral, PercentageLiteralError>;
|
|
120
|
+
/** Error returned when {@link PercentageLiteral} rejects a value. */
|
|
121
|
+
export interface PercentageLiteralError extends TypeError<"PercentageLiteral"> {
|
|
122
|
+
readonly value: unknown;
|
|
123
|
+
/**
|
|
124
|
+
* The underlying union failure, retained for diagnostics.
|
|
125
|
+
*
|
|
126
|
+
* With `{ errors: "all" }`, includes every failed alternative.
|
|
127
|
+
*/
|
|
128
|
+
readonly cause: UnionError;
|
|
129
|
+
}
|
|
87
130
|
/** Converts a {@link Percentage} to its numeric {@link Ratio}. */
|
|
88
131
|
export declare const percentageToRatio: (percentage: Percentage) => Ratio;
|
|
89
132
|
export declare const increment: (n: number) => number;
|
|
@@ -150,7 +193,7 @@ minNumberOfItemsPerBucket?: number & import("./Brand.ts").Brand<"NonNaN"> & impo
|
|
|
150
193
|
*
|
|
151
194
|
* Limited to 78 because F(79) exceeds JavaScript's `MAX_SAFE_INTEGER`.
|
|
152
195
|
*/
|
|
153
|
-
export declare const FibonacciIndex: import("./Type.ts").BrandType<import("./Type.ts").BrandType<import("./Type.ts").BrandType<import("./Type.ts").BrandType<import("./Type.ts").BrandType<import("./Type.ts").BrandType<import("./Type.ts").BrandType<
|
|
196
|
+
export declare const FibonacciIndex: import("./Type.ts").BrandType<import("./Type.ts").BrandType<import("./Type.ts").BrandType<import("./Type.ts").BrandType<import("./Type.ts").BrandType<import("./Type.ts").BrandType<import("./Type.ts").BrandType<Type<"Number", number, number, import("./Type.ts").TypeOfError<"Number">, null, import("./Type.ts").TypeOfError<"Number">, never, number, true>, "NonNaN", import("./Type.ts").NonNaNError>, "Finite", import("./Type.ts").FiniteError>, "Int", import("./Type.ts").IntError>, "NonNegative", import("./Type.ts").NonNegativeError>, "Positive", import("./Type.ts").PositiveError>, "LessThanOrEqualTo78", import("./Type.ts").LessThanOrEqualToError<78>>, "FibonacciIndex", never>;
|
|
154
197
|
export type FibonacciIndex = typeof FibonacciIndex.Output;
|
|
155
198
|
/** Returns the Fibonacci number at the given index (1-indexed: 1,1,2,3,5,8,...). */
|
|
156
199
|
export declare const fibonacciAt: (index: FibonacciIndex) => PositiveInt;
|
package/dist/src/Number.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Number.d.ts","sourceRoot":"","sources":["../../src/Number.ts"],"names":[],"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AE7B,kBAAkB;;AAGlB,iBAAiB;8OAEhB,MAAM,CAAC,qBAAqB,CAAC,WAAW,CAAC,EAAE,WAAW,CAoBxD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,yqBAG1B,CAAC;AACF,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC,MAAM,CAAC;AAE1D,oFAAoF;AACpF,eAAO,MAAM,WAAW,UAAW,cAAc,KAAG,WAMnD,CAAC"}
|
package/dist/src/Number.js
CHANGED
|
@@ -4,18 +4,57 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
import { assertNonEmptyReadonlyArray } from "./Assert.js";
|
|
7
|
+
import { safelyStringifyUnknownValue } from "./String.js";
|
|
7
8
|
import { err, ok } from "./Result.js";
|
|
8
|
-
import { brand, Digit1To9, Digit1To99, lessThanOrEqualTo, onePositiveInt, NonNegativeInt, PositiveInt, Ratio, templateLiteral, union, } from "./Type.js";
|
|
9
|
-
|
|
10
|
-
* Percentage literal from `"0%"` to `"100%"`.
|
|
11
|
-
*
|
|
12
|
-
* Decimal literals support one decimal place. Use {@link Ratio} for computed
|
|
13
|
-
* values or greater precision.
|
|
14
|
-
*/
|
|
15
|
-
export const PercentageLiteral = /*#__PURE__*/ union("0%", "100%",
|
|
9
|
+
import { brand, createTypeWithError, Digit1To9, Digit1To99, lessThanOrEqualTo, onePositiveInt, NonNegativeInt, PositiveInt, Ratio, templateLiteral, union, } from "./Type.js";
|
|
10
|
+
const percentageLiteralSyntax = /*#__PURE__*/ union("0%", "100%",
|
|
16
11
|
/*#__PURE__*/ templateLiteral(Digit1To99, "%"),
|
|
17
12
|
/*#__PURE__*/ templateLiteral(
|
|
18
13
|
/*#__PURE__*/ union("0", Digit1To99), ".", Digit1To9, "%"));
|
|
14
|
+
/**
|
|
15
|
+
* Percentage literal Type with compile-time and runtime validation.
|
|
16
|
+
*
|
|
17
|
+
* Supported formats:
|
|
18
|
+
*
|
|
19
|
+
* - Integers: `0%`, `50%`, `100%` (0-100)
|
|
20
|
+
* - One decimal place: `0.1%`, `12.5%`, `99.9%` (0.1-99.9)
|
|
21
|
+
*
|
|
22
|
+
* The decimal digit is never zero, so `12.0%` must be written as `"12%"`, and
|
|
23
|
+
* `100%` has no decimal form. For computed values or more precision, use
|
|
24
|
+
* {@link Ratio} directly.
|
|
25
|
+
*
|
|
26
|
+
* See {@link Percentage} for a type that also accepts {@link Ratio}. Use
|
|
27
|
+
* {@link percentageToRatio} to convert.
|
|
28
|
+
*
|
|
29
|
+
* Invalid values produce a {@link PercentageLiteralError}.
|
|
30
|
+
*
|
|
31
|
+
* ### Example
|
|
32
|
+
*
|
|
33
|
+
* ```ts
|
|
34
|
+
* import {
|
|
35
|
+
* assertFalse,
|
|
36
|
+
* assertOk,
|
|
37
|
+
* assertType,
|
|
38
|
+
* PercentageLiteral,
|
|
39
|
+
* } from "@evolu/common";
|
|
40
|
+
*
|
|
41
|
+
* // The TypeScript type accepts valid spellings and rejects the rest.
|
|
42
|
+
* const literal: PercentageLiteral = "12.5%";
|
|
43
|
+
* assertType<
|
|
44
|
+
* Extract<PercentageLiteral, "101%" | "12.0%" | "12.55%">,
|
|
45
|
+
* never
|
|
46
|
+
* >();
|
|
47
|
+
*
|
|
48
|
+
* // The runtime Type validates the same grammar.
|
|
49
|
+
* assertOk(PercentageLiteral.fromUnknown(literal), "12.5%");
|
|
50
|
+
* assertFalse(PercentageLiteral.is("101%"));
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export const PercentageLiteral = /*#__PURE__*/ createTypeWithError("PercentageLiteral", percentageLiteralSyntax, (cause, value) => ({
|
|
54
|
+
type: "PercentageLiteral",
|
|
55
|
+
value,
|
|
56
|
+
cause,
|
|
57
|
+
}), (error) => `The value ${safelyStringifyUnknownValue(error.value)} is not a percentage literal. Use a value such as "50%" or "12.5%".`);
|
|
19
58
|
/** Converts a {@link Percentage} to its numeric {@link Ratio}. */
|
|
20
59
|
export const percentageToRatio = (percentage) => typeof percentage === "number"
|
|
21
60
|
? percentage
|
package/dist/src/Object.d.ts
CHANGED
|
@@ -175,6 +175,38 @@ export declare const objectFrom: <K extends string, V>(keys: ReadonlyArray<K>, g
|
|
|
175
175
|
* Uses `K extends string` for precision.
|
|
176
176
|
*/
|
|
177
177
|
export declare const mapObject: <K extends string, V, U>(record: ReadonlyRecord<K, V>, fn: (value: V, key: K) => U) => ReadonlyRecord<K, U>;
|
|
178
|
+
/**
|
|
179
|
+
* Selects own string-keyed properties while preserving their descriptors.
|
|
180
|
+
*
|
|
181
|
+
* Visits enumerable and non-enumerable properties, ignoring inherited and
|
|
182
|
+
* symbol properties. The predicate receives only the key; property values and
|
|
183
|
+
* getters are never read. The result is a new ordinary object with matching
|
|
184
|
+
* descriptors, including accessor functions and property flags. Declared
|
|
185
|
+
* properties are optional because the predicate may exclude any of them.
|
|
186
|
+
* Numeric property names are visited as strings.
|
|
187
|
+
*
|
|
188
|
+
* ### Example
|
|
189
|
+
*
|
|
190
|
+
* ```ts
|
|
191
|
+
* import {
|
|
192
|
+
* assertEqual,
|
|
193
|
+
* assertType,
|
|
194
|
+
* filterObjectKeys,
|
|
195
|
+
* } from "@evolu/common";
|
|
196
|
+
*
|
|
197
|
+
* const source = { APP_PORT: "4000", HOME: "/home/evolu" };
|
|
198
|
+
* const selected = filterObjectKeys(source, (key) =>
|
|
199
|
+
* key.startsWith("APP_"),
|
|
200
|
+
* );
|
|
201
|
+
*
|
|
202
|
+
* assertEqual(selected, { APP_PORT: "4000" });
|
|
203
|
+
* assertType<
|
|
204
|
+
* typeof selected,
|
|
205
|
+
* { readonly APP_PORT?: string; readonly HOME?: string }
|
|
206
|
+
* >();
|
|
207
|
+
* ```
|
|
208
|
+
*/
|
|
209
|
+
export declare const filterObjectKeys: <T extends object>(source: T, predicate: (key: string) => boolean) => Readonly<Partial<Pick<T, Exclude<keyof T, symbol>>>>;
|
|
178
210
|
/** Conditionally excludes a property from an object. */
|
|
179
211
|
export declare const excludeProp: <T extends object, K extends keyof T>(obj: T, prop: K, condition?: boolean) => typeof condition extends true ? T : Omit<T, K>;
|
|
180
212
|
/**
|
package/dist/src/Object.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Object.d.ts","sourceRoot":"","sources":["../../src/Object.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;GAGG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,MAAM,GAAG,EAAE,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAE5E,oEAAoE;AACpE,MAAM,MAAM,UAAU,GACpB,OAAO,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,KAAK,GAAG,YAAY,GAAG,aAAa,CAAC;AAE7E;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,aAAa,UAAW,MAAM,KAAG,UAgB7C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,aAAa,UACjB,OAAO,KACb,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAYjC,CAAC;AAEF;;;;;;;;;;;;GAYG;AAEH,eAAO,MAAM,UAAU,UAAW,OAAO,KAAG,KAAK,IAAI,UAAU,CAAC,QACnC,CAAC;AAE9B;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,UAAU,UAAW,OAAO,KAAG,KAAK,IAAI,QAAQ,CAAC,OAAO,CAEA,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,UACnD,CAAC,KACR,aAAa,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CACkB,CAAC;AAGvE,KAAK,WAAW,CAAC,CAAC,IAAI,OAAO,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CAAC,KACd,CAAC,GAAG,SAAmE,CAAC;AAE3E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,SAAU,SAAQ,UAAU;IAC3C,8DAA8D;IAC9D,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,iEAAiE;AACjE,eAAO,MAAM,eAAe,SAAU,IAAI,KAAG,SAQ5C,CAAC"}
|
package/dist/src/Object.js
CHANGED
|
@@ -202,6 +202,47 @@ export const mapObject = (record, fn) => {
|
|
|
202
202
|
}
|
|
203
203
|
return out;
|
|
204
204
|
};
|
|
205
|
+
/**
|
|
206
|
+
* Selects own string-keyed properties while preserving their descriptors.
|
|
207
|
+
*
|
|
208
|
+
* Visits enumerable and non-enumerable properties, ignoring inherited and
|
|
209
|
+
* symbol properties. The predicate receives only the key; property values and
|
|
210
|
+
* getters are never read. The result is a new ordinary object with matching
|
|
211
|
+
* descriptors, including accessor functions and property flags. Declared
|
|
212
|
+
* properties are optional because the predicate may exclude any of them.
|
|
213
|
+
* Numeric property names are visited as strings.
|
|
214
|
+
*
|
|
215
|
+
* ### Example
|
|
216
|
+
*
|
|
217
|
+
* ```ts
|
|
218
|
+
* import {
|
|
219
|
+
* assertEqual,
|
|
220
|
+
* assertType,
|
|
221
|
+
* filterObjectKeys,
|
|
222
|
+
* } from "@evolu/common";
|
|
223
|
+
*
|
|
224
|
+
* const source = { APP_PORT: "4000", HOME: "/home/evolu" };
|
|
225
|
+
* const selected = filterObjectKeys(source, (key) =>
|
|
226
|
+
* key.startsWith("APP_"),
|
|
227
|
+
* );
|
|
228
|
+
*
|
|
229
|
+
* assertEqual(selected, { APP_PORT: "4000" });
|
|
230
|
+
* assertType<
|
|
231
|
+
* typeof selected,
|
|
232
|
+
* { readonly APP_PORT?: string; readonly HOME?: string }
|
|
233
|
+
* >();
|
|
234
|
+
* ```
|
|
235
|
+
*/
|
|
236
|
+
export const filterObjectKeys = (source, predicate) => {
|
|
237
|
+
const selected = {};
|
|
238
|
+
for (const key of Object.getOwnPropertyNames(source)) {
|
|
239
|
+
if (!predicate(key))
|
|
240
|
+
continue;
|
|
241
|
+
const descriptor = Object.getOwnPropertyDescriptor(source, key);
|
|
242
|
+
Object.defineProperty(selected, key, descriptor);
|
|
243
|
+
}
|
|
244
|
+
return selected;
|
|
245
|
+
};
|
|
205
246
|
/** Conditionally excludes a property from an object. */
|
|
206
247
|
export const excludeProp = (obj, prop, condition) => {
|
|
207
248
|
if (condition) {
|
package/dist/src/Polyfills.d.ts
CHANGED
|
@@ -15,6 +15,12 @@
|
|
|
15
15
|
* `Map.prototype.getOrInsertComputed`, `WeakMap.prototype.getOrInsert`, and
|
|
16
16
|
* `WeakMap.prototype.getOrInsertComputed`) for Node 24 and React Native
|
|
17
17
|
*
|
|
18
|
+
* The polyfills are implemented directly in the Evolu Library instead of being
|
|
19
|
+
* third-party runtime dependencies. We audit their behavior against
|
|
20
|
+
* specifications, conformance tests, and native implementations, and fix issues
|
|
21
|
+
* when necessary. This lets Evolu understand and control every line of this
|
|
22
|
+
* runtime code.
|
|
23
|
+
*
|
|
18
24
|
* `@evolu/react-native` has its own `Polyfills` module and its
|
|
19
25
|
* `installPolyfills` calls this function first, then installs React Native
|
|
20
26
|
* specific polyfills.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Polyfills.d.ts","sourceRoot":"","sources":["../../src/Polyfills.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH
|
|
1
|
+
{"version":3,"file":"Polyfills.d.ts","sourceRoot":"","sources":["../../src/Polyfills.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,gBAAgB,QAAO,IAiBnC,CAAC"}
|
package/dist/src/Polyfills.js
CHANGED
|
@@ -15,6 +15,12 @@
|
|
|
15
15
|
* `Map.prototype.getOrInsertComputed`, `WeakMap.prototype.getOrInsert`, and
|
|
16
16
|
* `WeakMap.prototype.getOrInsertComputed`) for Node 24 and React Native
|
|
17
17
|
*
|
|
18
|
+
* The polyfills are implemented directly in the Evolu Library instead of being
|
|
19
|
+
* third-party runtime dependencies. We audit their behavior against
|
|
20
|
+
* specifications, conformance tests, and native implementations, and fix issues
|
|
21
|
+
* when necessary. This lets Evolu understand and control every line of this
|
|
22
|
+
* runtime code.
|
|
23
|
+
*
|
|
18
24
|
* `@evolu/react-native` has its own `Polyfills` module and its
|
|
19
25
|
* `installPolyfills` calls this function first, then installs React Native
|
|
20
26
|
* specific polyfills.
|
package/dist/src/Sqlite.js
CHANGED
|
@@ -55,7 +55,7 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
|
|
|
55
55
|
var e = new Error(message);
|
|
56
56
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
57
57
|
});
|
|
58
|
-
import { bytesToHex, hexToBytes } from "./
|
|
58
|
+
import { bytesToHex, hexToBytes } from "./Bytes.js";
|
|
59
59
|
import { createEqObject, eqString, eqUint8Array } from "./Eq.js";
|
|
60
60
|
import { disposable } from "./Function.js";
|
|
61
61
|
import { createMutableRecord, objectToEntries } from "./Object.js";
|
package/dist/src/Time.d.ts
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Time representations, durations, and scheduling utilities.
|
|
3
3
|
*
|
|
4
|
+
* Durations follow a pattern that other quantities in Evolu repeat, such as
|
|
5
|
+
* sizes in Bytes.ts:
|
|
6
|
+
*
|
|
7
|
+
* - {@link Millis} is the canonical unit, a validated number of milliseconds.
|
|
8
|
+
* - {@link DurationLiteral} is the human-readable form, such as `"1.5s"`,
|
|
9
|
+
* validated at compile time and runtime.
|
|
10
|
+
* - {@link Duration} is what APIs accept: `DurationLiteral | Millis`.
|
|
11
|
+
* - {@link durationToMillis} normalizes a `Duration` to `Millis`.
|
|
12
|
+
*
|
|
4
13
|
* @module
|
|
5
14
|
*/
|
|
6
15
|
import type { Brand } from "./Brand.ts";
|
|
7
|
-
import { type DateIso, type NonNaNNumber } from "./Type.ts";
|
|
16
|
+
import { type Type, type TypeError, type UnionError, type UnionType, type TemplateLiteralType, type DateIso, Digit, Digit1To23, Digit1To51, Digit1To59, Digit1To6, Digit1To9, Digit1To99, type NonNaNNumber } from "./Type.ts";
|
|
8
17
|
/** Time and timer operations. */
|
|
9
18
|
export interface Time {
|
|
10
19
|
readonly now: {
|
|
@@ -104,10 +113,10 @@ export declare const testCreateTime: (options?: {
|
|
|
104
113
|
* If a system clock exceeds this range, operations will throw. This is
|
|
105
114
|
* intentional — there's no reasonable fallback for a misconfigured clock.
|
|
106
115
|
*/
|
|
107
|
-
export declare const Millis: import("./Type.ts").BrandType<import("./Type.ts").BrandType<import("./Type.ts").BrandType<import("./Type.ts").BrandType<import("./Type.ts").BrandType<import("./Type.ts").BrandType<
|
|
116
|
+
export declare const Millis: import("./Type.ts").BrandType<import("./Type.ts").BrandType<import("./Type.ts").BrandType<import("./Type.ts").BrandType<import("./Type.ts").BrandType<import("./Type.ts").BrandType<Type<"Number", number, number, import("./Type.ts").TypeOfError<"Number">, null, import("./Type.ts").TypeOfError<"Number">, never, number, true>, "NonNaN", import("./Type.ts").NonNaNError>, "Finite", import("./Type.ts").FiniteError>, "Int", import("./Type.ts").IntError>, "NonNegative", import("./Type.ts").NonNegativeError>, "LessThan281474976710655", import("./Type.ts").LessThanError<281474976710655>>, "Millis", never>;
|
|
108
117
|
export type Millis = typeof Millis.Output;
|
|
109
118
|
/** Positive {@link Millis} value. */
|
|
110
|
-
export declare const PositiveMillis: import("./Type.ts").BrandType<import("./Type.ts").BrandType<import("./Type.ts").BrandType<import("./Type.ts").BrandType<import("./Type.ts").BrandType<import("./Type.ts").BrandType<import("./Type.ts").BrandType<
|
|
119
|
+
export declare const PositiveMillis: import("./Type.ts").BrandType<import("./Type.ts").BrandType<import("./Type.ts").BrandType<import("./Type.ts").BrandType<import("./Type.ts").BrandType<import("./Type.ts").BrandType<import("./Type.ts").BrandType<Type<"Number", number, number, import("./Type.ts").TypeOfError<"Number">, null, import("./Type.ts").TypeOfError<"Number">, never, number, true>, "NonNaN", import("./Type.ts").NonNaNError>, "Finite", import("./Type.ts").FiniteError>, "Int", import("./Type.ts").IntError>, "NonNegative", import("./Type.ts").NonNegativeError>, "LessThan281474976710655", import("./Type.ts").LessThanError<281474976710655>>, "Millis", never>, "Positive", import("./Type.ts").PositiveError>;
|
|
111
120
|
export type PositiveMillis = typeof PositiveMillis.Output;
|
|
112
121
|
/** Minimum {@link Millis} value. */
|
|
113
122
|
export declare const minMillis: Millis;
|
|
@@ -174,44 +183,67 @@ export type Duration = DurationLiteral | Millis;
|
|
|
174
183
|
*/
|
|
175
184
|
export type PositiveDuration = DurationLiteral | PositiveMillis;
|
|
176
185
|
/** Milliseconds duration: `"1ms"` to `"999ms"`. See {@link DurationLiteral}. */
|
|
177
|
-
export declare const DurationLiteralMilliseconds:
|
|
186
|
+
export declare const DurationLiteralMilliseconds: UnionType<readonly [
|
|
187
|
+
TemplateLiteralType<readonly [typeof Digit1To9, "ms"]>,
|
|
188
|
+
TemplateLiteralType<readonly [typeof Digit1To9, typeof Digit, "ms"]>,
|
|
189
|
+
TemplateLiteralType<readonly [typeof Digit1To9, typeof Digit, typeof Digit, "ms"]>
|
|
190
|
+
]>;
|
|
178
191
|
export type DurationLiteralMilliseconds = typeof DurationLiteralMilliseconds.Output;
|
|
179
192
|
/**
|
|
180
193
|
* Seconds duration: `"1s"` to `"59s"` or `"1.1s"` to `"59.9s"`. See
|
|
181
194
|
* {@link DurationLiteral}.
|
|
182
195
|
*/
|
|
183
|
-
export declare const DurationLiteralSeconds:
|
|
196
|
+
export declare const DurationLiteralSeconds: UnionType<readonly [
|
|
197
|
+
TemplateLiteralType<readonly [typeof Digit1To59, "s"]>,
|
|
198
|
+
TemplateLiteralType<readonly [typeof Digit1To59, ".", typeof Digit1To9, "s"]>
|
|
199
|
+
]>;
|
|
184
200
|
export type DurationLiteralSeconds = typeof DurationLiteralSeconds.Output;
|
|
185
201
|
/**
|
|
186
202
|
* Minutes duration: `"1m"` to `"59m"` or `"1.1m"` to `"59.9m"`. See
|
|
187
203
|
* {@link DurationLiteral}.
|
|
188
204
|
*/
|
|
189
|
-
export declare const DurationLiteralMinutes:
|
|
205
|
+
export declare const DurationLiteralMinutes: UnionType<readonly [
|
|
206
|
+
TemplateLiteralType<readonly [typeof Digit1To59, "m"]>,
|
|
207
|
+
TemplateLiteralType<readonly [typeof Digit1To59, ".", typeof Digit1To9, "m"]>
|
|
208
|
+
]>;
|
|
190
209
|
export type DurationLiteralMinutes = typeof DurationLiteralMinutes.Output;
|
|
191
210
|
/**
|
|
192
211
|
* Hours duration: `"1h"` to `"23h"` or `"1.1h"` to `"23.9h"`. See
|
|
193
212
|
* {@link DurationLiteral}.
|
|
194
213
|
*/
|
|
195
|
-
export declare const DurationLiteralHours:
|
|
214
|
+
export declare const DurationLiteralHours: UnionType<readonly [
|
|
215
|
+
TemplateLiteralType<readonly [typeof Digit1To23, "h"]>,
|
|
216
|
+
TemplateLiteralType<readonly [typeof Digit1To23, ".", typeof Digit1To9, "h"]>
|
|
217
|
+
]>;
|
|
196
218
|
export type DurationLiteralHours = typeof DurationLiteralHours.Output;
|
|
197
219
|
/**
|
|
198
220
|
* Days duration: `"1d"` to `"6d"` or `"1.1d"` to `"6.9d"`. See
|
|
199
221
|
* {@link DurationLiteral}.
|
|
200
222
|
*/
|
|
201
|
-
export declare const DurationLiteralDays:
|
|
223
|
+
export declare const DurationLiteralDays: UnionType<readonly [
|
|
224
|
+
TemplateLiteralType<readonly [typeof Digit1To6, "d"]>,
|
|
225
|
+
TemplateLiteralType<readonly [typeof Digit1To6, ".", typeof Digit1To9, "d"]>
|
|
226
|
+
]>;
|
|
202
227
|
export type DurationLiteralDays = typeof DurationLiteralDays.Output;
|
|
203
228
|
/**
|
|
204
229
|
* Weeks duration: `"1w"` to `"51w"` or `"1.1w"` to `"51.9w"`. See
|
|
205
230
|
* {@link DurationLiteral}.
|
|
206
231
|
*/
|
|
207
|
-
export declare const DurationLiteralWeeks:
|
|
232
|
+
export declare const DurationLiteralWeeks: UnionType<readonly [
|
|
233
|
+
TemplateLiteralType<readonly [typeof Digit1To51, "w"]>,
|
|
234
|
+
TemplateLiteralType<readonly [typeof Digit1To51, ".", typeof Digit1To9, "w"]>
|
|
235
|
+
]>;
|
|
208
236
|
export type DurationLiteralWeeks = typeof DurationLiteralWeeks.Output;
|
|
209
237
|
/**
|
|
210
238
|
* Years duration: `"1y"` to `"99y"` or `"1.1y"` to `"99.9y"`. See
|
|
211
239
|
* {@link DurationLiteral}.
|
|
212
240
|
*/
|
|
213
|
-
export declare const DurationLiteralYears:
|
|
241
|
+
export declare const DurationLiteralYears: UnionType<readonly [
|
|
242
|
+
TemplateLiteralType<readonly [typeof Digit1To99, "y"]>,
|
|
243
|
+
TemplateLiteralType<readonly [typeof Digit1To99, ".", typeof Digit1To9, "y"]>
|
|
244
|
+
]>;
|
|
214
245
|
export type DurationLiteralYears = typeof DurationLiteralYears.Output;
|
|
246
|
+
export type DurationLiteral = DurationLiteralMilliseconds | DurationLiteralSeconds | DurationLiteralMinutes | DurationLiteralHours | DurationLiteralDays | DurationLiteralWeeks | DurationLiteralYears;
|
|
215
247
|
/**
|
|
216
248
|
* Duration literal Type with compile-time and runtime validation.
|
|
217
249
|
*
|
|
@@ -239,9 +271,39 @@ export type DurationLiteralYears = typeof DurationLiteralYears.Output;
|
|
|
239
271
|
*
|
|
240
272
|
* See {@link Duration} for a type that also accepts {@link Millis}. Use
|
|
241
273
|
* {@link durationToMillis} to convert to milliseconds.
|
|
274
|
+
*
|
|
275
|
+
* Invalid values produce a {@link DurationLiteralError}.
|
|
276
|
+
*
|
|
277
|
+
* ### Example
|
|
278
|
+
*
|
|
279
|
+
* ```ts
|
|
280
|
+
* import {
|
|
281
|
+
* assertFalse,
|
|
282
|
+
* assertOk,
|
|
283
|
+
* assertType,
|
|
284
|
+
* DurationLiteral,
|
|
285
|
+
* } from "@evolu/common";
|
|
286
|
+
*
|
|
287
|
+
* // The TypeScript type accepts valid spellings and rejects the rest.
|
|
288
|
+
* const literal: DurationLiteral = "1.5s";
|
|
289
|
+
* assertType<Extract<DurationLiteral, "1000ms" | "60s" | "0s">, never>();
|
|
290
|
+
*
|
|
291
|
+
* // The runtime Type validates the same grammar.
|
|
292
|
+
* assertOk(DurationLiteral.fromUnknown(literal), "1.5s");
|
|
293
|
+
* assertFalse(DurationLiteral.is("1000ms"));
|
|
294
|
+
* ```
|
|
242
295
|
*/
|
|
243
|
-
export declare const DurationLiteral: import("./Type.ts").UnionType<readonly [import("./Type.ts").UnionType<readonly [import("./Type.ts").TemplateLiteralType<readonly [import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">, import("./Type.ts").LiteralType<"5">, import("./Type.ts").LiteralType<"6">, import("./Type.ts").LiteralType<"7">, import("./Type.ts").LiteralType<"8">, import("./Type.ts").LiteralType<"9">]>, "ms"]>, import("./Type.ts").TemplateLiteralType<readonly [import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">, import("./Type.ts").LiteralType<"5">, import("./Type.ts").LiteralType<"6">, import("./Type.ts").LiteralType<"7">, import("./Type.ts").LiteralType<"8">, import("./Type.ts").LiteralType<"9">]>, import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"0">, import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">, import("./Type.ts").LiteralType<"5">, import("./Type.ts").LiteralType<"6">, import("./Type.ts").LiteralType<"7">, import("./Type.ts").LiteralType<"8">, import("./Type.ts").LiteralType<"9">]>, "ms"]>, import("./Type.ts").TemplateLiteralType<readonly [import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">, import("./Type.ts").LiteralType<"5">, import("./Type.ts").LiteralType<"6">, import("./Type.ts").LiteralType<"7">, import("./Type.ts").LiteralType<"8">, import("./Type.ts").LiteralType<"9">]>, import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"0">, import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">, import("./Type.ts").LiteralType<"5">, import("./Type.ts").LiteralType<"6">, import("./Type.ts").LiteralType<"7">, import("./Type.ts").LiteralType<"8">, import("./Type.ts").LiteralType<"9">]>, import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"0">, import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">, import("./Type.ts").LiteralType<"5">, import("./Type.ts").LiteralType<"6">, import("./Type.ts").LiteralType<"7">, import("./Type.ts").LiteralType<"8">, import("./Type.ts").LiteralType<"9">]>, "ms"]>]>, import("./Type.ts").UnionType<readonly [import("./Type.ts").TemplateLiteralType<readonly [import("./Type.ts").UnionType<readonly [import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">, import("./Type.ts").LiteralType<"5">, import("./Type.ts").LiteralType<"6">, import("./Type.ts").LiteralType<"7">, import("./Type.ts").LiteralType<"8">, import("./Type.ts").LiteralType<"9">]>, import("./Type.ts").TemplateLiteralType<readonly [import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">, import("./Type.ts").LiteralType<"5">]>, import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"0">, import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">, import("./Type.ts").LiteralType<"5">, import("./Type.ts").LiteralType<"6">, import("./Type.ts").LiteralType<"7">, import("./Type.ts").LiteralType<"8">, import("./Type.ts").LiteralType<"9">]>]>]>, "s"]>, import("./Type.ts").TemplateLiteralType<readonly [import("./Type.ts").UnionType<readonly [import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">, import("./Type.ts").LiteralType<"5">, import("./Type.ts").LiteralType<"6">, import("./Type.ts").LiteralType<"7">, import("./Type.ts").LiteralType<"8">, import("./Type.ts").LiteralType<"9">]>, import("./Type.ts").TemplateLiteralType<readonly [import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">, import("./Type.ts").LiteralType<"5">]>, import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"0">, import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">, import("./Type.ts").LiteralType<"5">, import("./Type.ts").LiteralType<"6">, import("./Type.ts").LiteralType<"7">, import("./Type.ts").LiteralType<"8">, import("./Type.ts").LiteralType<"9">]>]>]>, ".", import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">, import("./Type.ts").LiteralType<"5">, import("./Type.ts").LiteralType<"6">, import("./Type.ts").LiteralType<"7">, import("./Type.ts").LiteralType<"8">, import("./Type.ts").LiteralType<"9">]>, "s"]>]>, import("./Type.ts").UnionType<readonly [import("./Type.ts").TemplateLiteralType<readonly [import("./Type.ts").UnionType<readonly [import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">, import("./Type.ts").LiteralType<"5">, import("./Type.ts").LiteralType<"6">, import("./Type.ts").LiteralType<"7">, import("./Type.ts").LiteralType<"8">, import("./Type.ts").LiteralType<"9">]>, import("./Type.ts").TemplateLiteralType<readonly [import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">, import("./Type.ts").LiteralType<"5">]>, import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"0">, import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">, import("./Type.ts").LiteralType<"5">, import("./Type.ts").LiteralType<"6">, import("./Type.ts").LiteralType<"7">, import("./Type.ts").LiteralType<"8">, import("./Type.ts").LiteralType<"9">]>]>]>, "m"]>, import("./Type.ts").TemplateLiteralType<readonly [import("./Type.ts").UnionType<readonly [import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">, import("./Type.ts").LiteralType<"5">, import("./Type.ts").LiteralType<"6">, import("./Type.ts").LiteralType<"7">, import("./Type.ts").LiteralType<"8">, import("./Type.ts").LiteralType<"9">]>, import("./Type.ts").TemplateLiteralType<readonly [import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">, import("./Type.ts").LiteralType<"5">]>, import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"0">, import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">, import("./Type.ts").LiteralType<"5">, import("./Type.ts").LiteralType<"6">, import("./Type.ts").LiteralType<"7">, import("./Type.ts").LiteralType<"8">, import("./Type.ts").LiteralType<"9">]>]>]>, ".", import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">, import("./Type.ts").LiteralType<"5">, import("./Type.ts").LiteralType<"6">, import("./Type.ts").LiteralType<"7">, import("./Type.ts").LiteralType<"8">, import("./Type.ts").LiteralType<"9">]>, "m"]>]>, import("./Type.ts").UnionType<readonly [import("./Type.ts").TemplateLiteralType<readonly [import("./Type.ts").UnionType<readonly [import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">, import("./Type.ts").LiteralType<"5">, import("./Type.ts").LiteralType<"6">, import("./Type.ts").LiteralType<"7">, import("./Type.ts").LiteralType<"8">, import("./Type.ts").LiteralType<"9">]>, import("./Type.ts").TemplateLiteralType<readonly ["1", import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"0">, import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">, import("./Type.ts").LiteralType<"5">, import("./Type.ts").LiteralType<"6">, import("./Type.ts").LiteralType<"7">, import("./Type.ts").LiteralType<"8">, import("./Type.ts").LiteralType<"9">]>]>, import("./Type.ts").TemplateLiteralType<readonly ["2", import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"0">, import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">]>]>]>, "h"]>, import("./Type.ts").TemplateLiteralType<readonly [import("./Type.ts").UnionType<readonly [import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">, import("./Type.ts").LiteralType<"5">, import("./Type.ts").LiteralType<"6">, import("./Type.ts").LiteralType<"7">, import("./Type.ts").LiteralType<"8">, import("./Type.ts").LiteralType<"9">]>, import("./Type.ts").TemplateLiteralType<readonly ["1", import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"0">, import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">, import("./Type.ts").LiteralType<"5">, import("./Type.ts").LiteralType<"6">, import("./Type.ts").LiteralType<"7">, import("./Type.ts").LiteralType<"8">, import("./Type.ts").LiteralType<"9">]>]>, import("./Type.ts").TemplateLiteralType<readonly ["2", import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"0">, import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">]>]>]>, ".", import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">, import("./Type.ts").LiteralType<"5">, import("./Type.ts").LiteralType<"6">, import("./Type.ts").LiteralType<"7">, import("./Type.ts").LiteralType<"8">, import("./Type.ts").LiteralType<"9">]>, "h"]>]>, import("./Type.ts").UnionType<readonly [import("./Type.ts").TemplateLiteralType<readonly [import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">, import("./Type.ts").LiteralType<"5">, import("./Type.ts").LiteralType<"6">]>, "d"]>, import("./Type.ts").TemplateLiteralType<readonly [import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">, import("./Type.ts").LiteralType<"5">, import("./Type.ts").LiteralType<"6">]>, ".", import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">, import("./Type.ts").LiteralType<"5">, import("./Type.ts").LiteralType<"6">, import("./Type.ts").LiteralType<"7">, import("./Type.ts").LiteralType<"8">, import("./Type.ts").LiteralType<"9">]>, "d"]>]>, import("./Type.ts").UnionType<readonly [import("./Type.ts").TemplateLiteralType<readonly [import("./Type.ts").UnionType<readonly [import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">, import("./Type.ts").LiteralType<"5">, import("./Type.ts").LiteralType<"6">, import("./Type.ts").LiteralType<"7">, import("./Type.ts").LiteralType<"8">, import("./Type.ts").LiteralType<"9">]>, import("./Type.ts").TemplateLiteralType<readonly [import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">]>, import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"0">, import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">, import("./Type.ts").LiteralType<"5">, import("./Type.ts").LiteralType<"6">, import("./Type.ts").LiteralType<"7">, import("./Type.ts").LiteralType<"8">, import("./Type.ts").LiteralType<"9">]>]>, import("./Type.ts").TemplateLiteralType<readonly ["5", import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"0">, import("./Type.ts").LiteralType<"1">]>]>]>, "w"]>, import("./Type.ts").TemplateLiteralType<readonly [import("./Type.ts").UnionType<readonly [import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">, import("./Type.ts").LiteralType<"5">, import("./Type.ts").LiteralType<"6">, import("./Type.ts").LiteralType<"7">, import("./Type.ts").LiteralType<"8">, import("./Type.ts").LiteralType<"9">]>, import("./Type.ts").TemplateLiteralType<readonly [import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">]>, import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"0">, import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">, import("./Type.ts").LiteralType<"5">, import("./Type.ts").LiteralType<"6">, import("./Type.ts").LiteralType<"7">, import("./Type.ts").LiteralType<"8">, import("./Type.ts").LiteralType<"9">]>]>, import("./Type.ts").TemplateLiteralType<readonly ["5", import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"0">, import("./Type.ts").LiteralType<"1">]>]>]>, ".", import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">, import("./Type.ts").LiteralType<"5">, import("./Type.ts").LiteralType<"6">, import("./Type.ts").LiteralType<"7">, import("./Type.ts").LiteralType<"8">, import("./Type.ts").LiteralType<"9">]>, "w"]>]>, import("./Type.ts").UnionType<readonly [import("./Type.ts").TemplateLiteralType<readonly [import("./Type.ts").UnionType<readonly [import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">, import("./Type.ts").LiteralType<"5">, import("./Type.ts").LiteralType<"6">, import("./Type.ts").LiteralType<"7">, import("./Type.ts").LiteralType<"8">, import("./Type.ts").LiteralType<"9">]>, import("./Type.ts").TemplateLiteralType<readonly [import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">, import("./Type.ts").LiteralType<"5">, import("./Type.ts").LiteralType<"6">, import("./Type.ts").LiteralType<"7">, import("./Type.ts").LiteralType<"8">, import("./Type.ts").LiteralType<"9">]>, import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"0">, import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">, import("./Type.ts").LiteralType<"5">, import("./Type.ts").LiteralType<"6">, import("./Type.ts").LiteralType<"7">, import("./Type.ts").LiteralType<"8">, import("./Type.ts").LiteralType<"9">]>]>]>, "y"]>, import("./Type.ts").TemplateLiteralType<readonly [import("./Type.ts").UnionType<readonly [import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">, import("./Type.ts").LiteralType<"5">, import("./Type.ts").LiteralType<"6">, import("./Type.ts").LiteralType<"7">, import("./Type.ts").LiteralType<"8">, import("./Type.ts").LiteralType<"9">]>, import("./Type.ts").TemplateLiteralType<readonly [import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">, import("./Type.ts").LiteralType<"5">, import("./Type.ts").LiteralType<"6">, import("./Type.ts").LiteralType<"7">, import("./Type.ts").LiteralType<"8">, import("./Type.ts").LiteralType<"9">]>, import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"0">, import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">, import("./Type.ts").LiteralType<"5">, import("./Type.ts").LiteralType<"6">, import("./Type.ts").LiteralType<"7">, import("./Type.ts").LiteralType<"8">, import("./Type.ts").LiteralType<"9">]>]>]>, ".", import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<"1">, import("./Type.ts").LiteralType<"2">, import("./Type.ts").LiteralType<"3">, import("./Type.ts").LiteralType<"4">, import("./Type.ts").LiteralType<"5">, import("./Type.ts").LiteralType<"6">, import("./Type.ts").LiteralType<"7">, import("./Type.ts").LiteralType<"8">, import("./Type.ts").LiteralType<"9">]>, "y"]>]>]>;
|
|
244
|
-
|
|
296
|
+
export declare const DurationLiteral: Type<"DurationLiteral", DurationLiteral, DurationLiteral, DurationLiteralError>;
|
|
297
|
+
/** Error returned when {@link DurationLiteral} rejects a value. */
|
|
298
|
+
export interface DurationLiteralError extends TypeError<"DurationLiteral"> {
|
|
299
|
+
readonly value: unknown;
|
|
300
|
+
/**
|
|
301
|
+
* The underlying union failure, retained for diagnostics.
|
|
302
|
+
*
|
|
303
|
+
* With `{ errors: "all" }`, includes every failed alternative.
|
|
304
|
+
*/
|
|
305
|
+
readonly cause: UnionError;
|
|
306
|
+
}
|
|
245
307
|
/**
|
|
246
308
|
* Converts a duration to milliseconds.
|
|
247
309
|
*
|