metano-runtime 3.0.1 → 3.1.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/system/char-members.d.ts +51 -0
- package/dist/system/char-members.js +108 -0
- package/dist/system/collections/array-helpers.d.ts +28 -0
- package/dist/system/collections/array-helpers.js +105 -0
- package/dist/system/collections/hash-core.d.ts +5 -0
- package/dist/system/collections/hash-core.js +24 -0
- package/dist/system/collections/helpers.d.ts +16 -3
- package/dist/system/collections/helpers.js +28 -2
- package/dist/system/collections/immutable-list-builder-core.d.ts +7 -2
- package/dist/system/collections/immutable-list-builder-core.js +11 -0
- package/dist/system/collections/immutable-list-core.d.ts +8 -0
- package/dist/system/collections/immutable-list-core.js +19 -1
- package/dist/system/collections/immutable-storage.d.ts +2 -0
- package/dist/system/collections/immutable-storage.js +6 -1
- package/dist/system/collections/index.d.ts +2 -0
- package/dist/system/collections/index.js +2 -0
- package/dist/system/collections/interfaces.d.ts +13 -0
- package/dist/system/collections/list.d.ts +3 -0
- package/dist/system/collections/list.js +8 -11
- package/dist/system/collections/read-only-list.d.ts +11 -0
- package/dist/system/collections/read-only-list.js +26 -1
- package/dist/system/collections/sorted-list.d.ts +5 -0
- package/dist/system/collections/sorted-list.js +12 -1
- package/dist/system/collections/string-comparer.d.ts +14 -0
- package/dist/system/collections/string-comparer.js +45 -0
- package/dist/system/decimal-parsing.d.ts +12 -0
- package/dist/system/decimal-parsing.js +86 -0
- package/dist/system/exceptions/index.d.ts +1 -0
- package/dist/system/exceptions/index.js +1 -0
- package/dist/system/exceptions/throw-error.d.ts +7 -0
- package/dist/system/exceptions/throw-error.js +9 -0
- package/dist/system/index.d.ts +5 -0
- package/dist/system/index.js +5 -0
- package/dist/system/int64.d.ts +6 -0
- package/dist/system/int64.js +18 -9
- package/dist/system/integer-division.d.ts +12 -4
- package/dist/system/integer-division.js +19 -2
- package/dist/system/json/contract-name.d.ts +2 -1
- package/dist/system/json/contract-name.js +3 -2
- package/dist/system/json/converters.d.ts +15 -52
- package/dist/system/json/converters.js +33 -317
- package/dist/system/json/dictionary-keys.js +1 -3
- package/dist/system/json/index.d.ts +1 -1
- package/dist/system/json/index.js +1 -1
- package/dist/system/json/json-serializer.d.ts +12 -1
- package/dist/system/json/json-serializer.js +29 -1
- package/dist/system/json/json-text-writer.d.ts +17 -0
- package/dist/system/json/json-text-writer.js +175 -0
- package/dist/system/json/null-reads.d.ts +2 -1
- package/dist/system/json/null-reads.js +3 -1
- package/dist/system/json/number-from-string.d.ts +2 -0
- package/dist/system/json/number-from-string.js +24 -6
- package/dist/system/json/numeric-converters.d.ts +4 -4
- package/dist/system/json/numeric-converters.js +46 -8
- package/dist/system/json/numeric-enum-members.d.ts +3 -3
- package/dist/system/json/numeric-enum-members.js +2 -4
- package/dist/system/json/spec-plans.d.ts +102 -0
- package/dist/system/json/spec-plans.js +312 -0
- package/dist/system/json/types.d.ts +15 -9
- package/dist/system/lazy.d.ts +15 -0
- package/dist/system/lazy.js +43 -0
- package/dist/system/linq/grouping.d.ts +12 -0
- package/dist/system/linq/grouping.js +42 -0
- package/dist/system/linq/index.d.ts +4 -3
- package/dist/system/linq/index.js +3 -2
- package/dist/system/linq/linq.js +20 -1
- package/dist/system/linq/lookup.d.ts +17 -0
- package/dist/system/linq/lookup.js +20 -0
- package/dist/system/linq/operators.d.ts +35 -5
- package/dist/system/linq/operators.js +82 -31
- package/dist/system/linq/terminals.d.ts +41 -2
- package/dist/system/linq/terminals.js +122 -2
- package/dist/system/linq/types.d.ts +48 -4
- package/dist/system/math.d.ts +7 -0
- package/dist/system/math.js +14 -0
- package/dist/system/number-members.d.ts +10 -0
- package/dist/system/number-members.js +25 -0
- package/dist/system/number-parsing.d.ts +16 -4
- package/dist/system/number-parsing.js +21 -4
- package/dist/system/string-builder.d.ts +30 -0
- package/dist/system/string-builder.js +86 -0
- package/dist/system/task-completion-source.d.ts +37 -0
- package/dist/system/task-completion-source.js +81 -0
- package/dist-unchecked/system/char-members.d.ts +51 -0
- package/dist-unchecked/system/char-members.js +108 -0
- package/dist-unchecked/system/collections/array-helpers.d.ts +28 -0
- package/dist-unchecked/system/collections/array-helpers.js +105 -0
- package/dist-unchecked/system/collections/hash-core.d.ts +5 -0
- package/dist-unchecked/system/collections/hash-core.js +24 -0
- package/dist-unchecked/system/collections/helpers.d.ts +16 -3
- package/dist-unchecked/system/collections/helpers.js +28 -2
- package/dist-unchecked/system/collections/immutable-list-builder-core.d.ts +7 -2
- package/dist-unchecked/system/collections/immutable-list-builder-core.js +11 -0
- package/dist-unchecked/system/collections/immutable-list-core.d.ts +8 -0
- package/dist-unchecked/system/collections/immutable-list-core.js +19 -1
- package/dist-unchecked/system/collections/immutable-storage.d.ts +2 -0
- package/dist-unchecked/system/collections/immutable-storage.js +6 -1
- package/dist-unchecked/system/collections/index.d.ts +2 -0
- package/dist-unchecked/system/collections/index.js +2 -0
- package/dist-unchecked/system/collections/interfaces.d.ts +13 -0
- package/dist-unchecked/system/collections/list.d.ts +3 -0
- package/dist-unchecked/system/collections/list.js +8 -11
- package/dist-unchecked/system/collections/read-only-list.d.ts +11 -0
- package/dist-unchecked/system/collections/read-only-list.js +26 -1
- package/dist-unchecked/system/collections/sorted-list.d.ts +5 -0
- package/dist-unchecked/system/collections/sorted-list.js +12 -1
- package/dist-unchecked/system/collections/string-comparer.d.ts +14 -0
- package/dist-unchecked/system/collections/string-comparer.js +45 -0
- package/dist-unchecked/system/decimal-parsing.d.ts +12 -0
- package/dist-unchecked/system/decimal-parsing.js +86 -0
- package/dist-unchecked/system/exceptions/index.d.ts +1 -0
- package/dist-unchecked/system/exceptions/index.js +1 -0
- package/dist-unchecked/system/exceptions/throw-error.d.ts +7 -0
- package/dist-unchecked/system/exceptions/throw-error.js +9 -0
- package/dist-unchecked/system/index.d.ts +5 -0
- package/dist-unchecked/system/index.js +5 -0
- package/dist-unchecked/system/int64.d.ts +6 -0
- package/dist-unchecked/system/int64.js +18 -9
- package/dist-unchecked/system/integer-division.d.ts +12 -4
- package/dist-unchecked/system/integer-division.js +19 -2
- package/dist-unchecked/system/json/contract-name.d.ts +2 -1
- package/dist-unchecked/system/json/contract-name.js +3 -2
- package/dist-unchecked/system/json/converters.d.ts +15 -52
- package/dist-unchecked/system/json/converters.js +33 -317
- package/dist-unchecked/system/json/dictionary-keys.js +1 -3
- package/dist-unchecked/system/json/index.d.ts +1 -1
- package/dist-unchecked/system/json/index.js +1 -1
- package/dist-unchecked/system/json/json-serializer.d.ts +12 -1
- package/dist-unchecked/system/json/json-serializer.js +29 -1
- package/dist-unchecked/system/json/json-text-writer.d.ts +17 -0
- package/dist-unchecked/system/json/json-text-writer.js +175 -0
- package/dist-unchecked/system/json/null-reads.d.ts +2 -1
- package/dist-unchecked/system/json/null-reads.js +3 -1
- package/dist-unchecked/system/json/number-from-string.d.ts +2 -0
- package/dist-unchecked/system/json/number-from-string.js +24 -6
- package/dist-unchecked/system/json/numeric-converters.d.ts +4 -4
- package/dist-unchecked/system/json/numeric-converters.js +46 -8
- package/dist-unchecked/system/json/numeric-enum-members.d.ts +3 -3
- package/dist-unchecked/system/json/numeric-enum-members.js +2 -4
- package/dist-unchecked/system/json/spec-plans.d.ts +102 -0
- package/dist-unchecked/system/json/spec-plans.js +312 -0
- package/dist-unchecked/system/json/types.d.ts +15 -9
- package/dist-unchecked/system/lazy.d.ts +15 -0
- package/dist-unchecked/system/lazy.js +43 -0
- package/dist-unchecked/system/linq/grouping.d.ts +12 -0
- package/dist-unchecked/system/linq/grouping.js +42 -0
- package/dist-unchecked/system/linq/index.d.ts +4 -3
- package/dist-unchecked/system/linq/index.js +3 -2
- package/dist-unchecked/system/linq/linq.js +20 -1
- package/dist-unchecked/system/linq/lookup.d.ts +17 -0
- package/dist-unchecked/system/linq/lookup.js +20 -0
- package/dist-unchecked/system/linq/operators.d.ts +35 -5
- package/dist-unchecked/system/linq/operators.js +82 -31
- package/dist-unchecked/system/linq/terminals.d.ts +41 -2
- package/dist-unchecked/system/linq/terminals.js +122 -2
- package/dist-unchecked/system/linq/types.d.ts +48 -4
- package/dist-unchecked/system/math.d.ts +7 -0
- package/dist-unchecked/system/math.js +14 -0
- package/dist-unchecked/system/number-members.d.ts +10 -0
- package/dist-unchecked/system/number-members.js +25 -0
- package/dist-unchecked/system/number-parsing.d.ts +16 -4
- package/dist-unchecked/system/number-parsing.js +21 -4
- package/dist-unchecked/system/string-builder.d.ts +30 -0
- package/dist-unchecked/system/string-builder.js +86 -0
- package/dist-unchecked/system/task-completion-source.d.ts +37 -0
- package/dist-unchecked/system/task-completion-source.js +81 -0
- package/package.json +1 -1
- package/src/system/char-members.ts +131 -0
- package/src/system/collections/array-helpers.ts +139 -0
- package/src/system/collections/hash-core.ts +31 -0
- package/src/system/collections/helpers.ts +39 -4
- package/src/system/collections/immutable-list-builder-core.ts +16 -2
- package/src/system/collections/immutable-list-core.ts +23 -1
- package/src/system/collections/immutable-storage.ts +8 -1
- package/src/system/collections/index.ts +2 -0
- package/src/system/collections/interfaces.ts +16 -0
- package/src/system/collections/list.ts +10 -15
- package/src/system/collections/read-only-list.ts +35 -1
- package/src/system/collections/sorted-list.ts +15 -1
- package/src/system/collections/string-comparer.ts +57 -0
- package/src/system/decimal-parsing.ts +109 -0
- package/src/system/exceptions/index.ts +1 -0
- package/src/system/exceptions/throw-error.ts +9 -0
- package/src/system/index.ts +5 -0
- package/src/system/int64.ts +27 -10
- package/src/system/integer-division.ts +43 -6
- package/src/system/json/contract-name.ts +3 -2
- package/src/system/json/converters.ts +38 -526
- package/src/system/json/dictionary-keys.ts +6 -4
- package/src/system/json/index.ts +1 -1
- package/src/system/json/json-serializer.ts +42 -1
- package/src/system/json/json-text-writer.ts +224 -0
- package/src/system/json/null-reads.ts +3 -1
- package/src/system/json/number-from-string.ts +31 -6
- package/src/system/json/numeric-converters.ts +60 -8
- package/src/system/json/numeric-enum-members.ts +4 -6
- package/src/system/json/spec-plans.ts +524 -0
- package/src/system/json/types.ts +15 -9
- package/src/system/lazy.ts +62 -0
- package/src/system/linq/grouping.ts +77 -0
- package/src/system/linq/index.ts +14 -0
- package/src/system/linq/linq.ts +23 -1
- package/src/system/linq/lookup.ts +34 -0
- package/src/system/linq/operators.ts +109 -17
- package/src/system/linq/terminals.ts +161 -2
- package/src/system/linq/types.ts +66 -3
- package/src/system/math.ts +19 -0
- package/src/system/number-members.ts +29 -0
- package/src/system/number-parsing.ts +24 -4
- package/src/system/string-builder.ts +117 -0
- package/src/system/task-completion-source.ts +106 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { closeCollectionFor } from "./close-collection.js";
|
|
2
2
|
import { collectionTypeName } from "./collection-type-name.js";
|
|
3
3
|
import { copyInto } from "./copy-to.js";
|
|
4
|
+
import { isIdentityComparable, sortInPlace } from "./array-helpers.js";
|
|
4
5
|
import { comparisonOf, elementEquals } from "./default-comparer.js";
|
|
5
6
|
import { binarySearch } from "./sorted-array.js";
|
|
6
7
|
import { throwArgumentNull, throwCompareFailed, throwFixedSize, throwIndexAtMostCount, throwInsertOOR, throwInvalidRange, throwModified, throwNegative, throwOOR, throwReadOnly } from "./throw-helpers.js";
|
|
@@ -55,6 +56,9 @@ class List {
|
|
|
55
56
|
get count() {
|
|
56
57
|
return this._items.length;
|
|
57
58
|
}
|
|
59
|
+
get length() {
|
|
60
|
+
return this._items.length;
|
|
61
|
+
}
|
|
58
62
|
get isReadOnly() {
|
|
59
63
|
return !1;
|
|
60
64
|
}
|
|
@@ -221,6 +225,10 @@ class List {
|
|
|
221
225
|
asJsArray() {
|
|
222
226
|
return this._items;
|
|
223
227
|
}
|
|
228
|
+
/** The backing array itself, typed read-only (FR-056). */
|
|
229
|
+
asReadOnlyJsArray() {
|
|
230
|
+
return this._items;
|
|
231
|
+
}
|
|
224
232
|
/** The backing array itself, typed as a length-keeping view (FR-056). */
|
|
225
233
|
asSpan() {
|
|
226
234
|
return this._items;
|
|
@@ -306,9 +314,6 @@ class ListIterator {
|
|
|
306
314
|
return this;
|
|
307
315
|
}
|
|
308
316
|
}
|
|
309
|
-
function isIdentityComparable(value) {
|
|
310
|
-
return typeof value != "object" && !Number.isNaN(value);
|
|
311
|
-
}
|
|
312
317
|
function requireDelegate(delegate, paramName) {
|
|
313
318
|
delegate == null && throwArgumentNull(paramName);
|
|
314
319
|
}
|
|
@@ -322,14 +327,6 @@ function insertAll(storage, index, added) {
|
|
|
322
327
|
for (const item of tail)
|
|
323
328
|
storage.push(item);
|
|
324
329
|
}
|
|
325
|
-
function sortInPlace(items, comparison) {
|
|
326
|
-
const compare = comparisonOf(comparison);
|
|
327
|
-
try {
|
|
328
|
-
items.sort(compare);
|
|
329
|
-
} catch (error) {
|
|
330
|
-
throwCompareFailed(error);
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
330
|
export {
|
|
334
331
|
List
|
|
335
332
|
};
|
|
@@ -20,6 +20,7 @@ export declare class ReadOnlyList<T> implements IList<T>, IReadOnlyList<T> {
|
|
|
20
20
|
static empty<T>(typeArguments?: readonly RuntimeType[] | null): ReadOnlyList<T>;
|
|
21
21
|
static get $runtimeType(): CollectionType<ReadOnlyList<unknown>>;
|
|
22
22
|
get count(): number;
|
|
23
|
+
get length(): number;
|
|
23
24
|
get isReadOnly(): boolean;
|
|
24
25
|
/** The source's element; an array source is bounds-checked as .NET's array `IList<T>` indexer. */
|
|
25
26
|
get(index: number): T;
|
|
@@ -36,6 +37,16 @@ export declare class ReadOnlyList<T> implements IList<T>, IReadOnlyList<T> {
|
|
|
36
37
|
remove(_item: T): never;
|
|
37
38
|
removeAt(_index: number): never;
|
|
38
39
|
clear(): never;
|
|
40
|
+
/** Detached shallow copy of the source's elements (FR-055). */
|
|
41
|
+
toArray(): T[];
|
|
42
|
+
/**
|
|
43
|
+
* Read-only view over the source's backing array (spec 011 FR-056):
|
|
44
|
+
* zero-copy and live ONLY for runtime array-backed sources (a native array,
|
|
45
|
+
* a `List`, or a source exposing `asReadOnlyJsArray()`). For a custom `IList`
|
|
46
|
+
* source without `asReadOnlyJsArray()`, returns a **shallow snapshot copy**
|
|
47
|
+
* (not live; allocates a new array on each call).
|
|
48
|
+
*/
|
|
49
|
+
asReadOnlyJsArray(): readonly T[];
|
|
39
50
|
toJSON(): T[];
|
|
40
51
|
/** .NET's ``System.Collections.ObjectModel.ReadOnlyCollection`1[T]`` text. */
|
|
41
52
|
toString(): string;
|
|
@@ -66,6 +66,9 @@ export class ReadOnlyList {
|
|
|
66
66
|
const source = this._source;
|
|
67
67
|
return isArraySource(source) ? source.length : source.count;
|
|
68
68
|
}
|
|
69
|
+
get length() {
|
|
70
|
+
return this.count;
|
|
71
|
+
}
|
|
69
72
|
get isReadOnly() {
|
|
70
73
|
return true;
|
|
71
74
|
}
|
|
@@ -129,8 +132,27 @@ export class ReadOnlyList {
|
|
|
129
132
|
clear() {
|
|
130
133
|
return throwReadOnly();
|
|
131
134
|
}
|
|
135
|
+
/** Detached shallow copy of the source's elements (FR-055). */
|
|
136
|
+
toArray() {
|
|
137
|
+
const source = this._source;
|
|
138
|
+
return isArraySource(source) ? source.slice() : Array.from(source);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Read-only view over the source's backing array (spec 011 FR-056):
|
|
142
|
+
* zero-copy and live ONLY for runtime array-backed sources (a native array,
|
|
143
|
+
* a `List`, or a source exposing `asReadOnlyJsArray()`). For a custom `IList`
|
|
144
|
+
* source without `asReadOnlyJsArray()`, returns a **shallow snapshot copy**
|
|
145
|
+
* (not live; allocates a new array on each call).
|
|
146
|
+
*/
|
|
147
|
+
asReadOnlyJsArray() {
|
|
148
|
+
const source = this._source;
|
|
149
|
+
if (isArraySource(source)) {
|
|
150
|
+
return source;
|
|
151
|
+
}
|
|
152
|
+
return hasAsReadOnlyJsArray(source) ? source.asReadOnlyJsArray() : Array.from(source);
|
|
153
|
+
}
|
|
132
154
|
toJSON() {
|
|
133
|
-
return
|
|
155
|
+
return this.toArray();
|
|
134
156
|
}
|
|
135
157
|
/** .NET's ``System.Collections.ObjectModel.ReadOnlyCollection`1[T]`` text. */
|
|
136
158
|
toString() {
|
|
@@ -150,3 +172,6 @@ export function asReadOnly(list, typeArguments) {
|
|
|
150
172
|
function isArraySource(source) {
|
|
151
173
|
return Array.isArray(source);
|
|
152
174
|
}
|
|
175
|
+
function hasAsReadOnlyJsArray(source) {
|
|
176
|
+
return typeof source.asReadOnlyJsArray === "function";
|
|
177
|
+
}
|
|
@@ -109,6 +109,7 @@ export declare class SortedListView<T> implements IList<T>, IReadOnlyList<T> {
|
|
|
109
109
|
/** .NET's `KeyList` / `ValueList`: `IList<T>` and `ICollection<T>`, no read-only interface. */
|
|
110
110
|
static get $runtimeType(): CollectionType<SortedListView<unknown>>;
|
|
111
111
|
get count(): number;
|
|
112
|
+
get length(): number;
|
|
112
113
|
get isReadOnly(): true;
|
|
113
114
|
get(index: number): T;
|
|
114
115
|
/** `view[^n]`. */
|
|
@@ -124,6 +125,10 @@ export declare class SortedListView<T> implements IList<T>, IReadOnlyList<T> {
|
|
|
124
125
|
remove(_item: T): never;
|
|
125
126
|
removeAt(_index: number): never;
|
|
126
127
|
clear(): never;
|
|
128
|
+
/** Detached shallow copy (FR-055). */
|
|
129
|
+
toArray(): T[];
|
|
130
|
+
/** Zero-copy live read-only view over the list's backing key/value array (FR-056). */
|
|
131
|
+
asReadOnlyJsArray(): readonly T[];
|
|
127
132
|
toJSON(): T[];
|
|
128
133
|
[Symbol.iterator](): Iterator<T>;
|
|
129
134
|
private items;
|
|
@@ -231,6 +231,9 @@ class SortedListView {
|
|
|
231
231
|
get count() {
|
|
232
232
|
return this._list.count;
|
|
233
233
|
}
|
|
234
|
+
get length() {
|
|
235
|
+
return this._list.count;
|
|
236
|
+
}
|
|
234
237
|
get isReadOnly() {
|
|
235
238
|
return !0;
|
|
236
239
|
}
|
|
@@ -270,8 +273,16 @@ class SortedListView {
|
|
|
270
273
|
clear() {
|
|
271
274
|
return throwSortedListNested();
|
|
272
275
|
}
|
|
276
|
+
/** Detached shallow copy (FR-055). */
|
|
277
|
+
toArray() {
|
|
278
|
+
return this.items().slice();
|
|
279
|
+
}
|
|
280
|
+
/** Zero-copy live read-only view over the list's backing key/value array (FR-056). */
|
|
281
|
+
asReadOnlyJsArray() {
|
|
282
|
+
return this.items();
|
|
283
|
+
}
|
|
273
284
|
toJSON() {
|
|
274
|
-
return
|
|
285
|
+
return this.toArray();
|
|
275
286
|
}
|
|
276
287
|
[Symbol.iterator]() {
|
|
277
288
|
return new SortedListIterator(this._list, (index) => at(this.items(), index));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type IComparer, type IEqualityComparer } from "./default-comparer.ts";
|
|
2
|
+
export declare class StringComparer implements IEqualityComparer<string | null>, IComparer<string | null> {
|
|
3
|
+
private readonly ignoreCase;
|
|
4
|
+
private constructor();
|
|
5
|
+
/** Every code unit compared as is. */
|
|
6
|
+
static get ordinal(): StringComparer;
|
|
7
|
+
/** Strings that differ only by the simple uppercase mapping of their code points are equal. */
|
|
8
|
+
static get ordinalIgnoreCase(): StringComparer;
|
|
9
|
+
equals(a: string | null, b: string | null): boolean;
|
|
10
|
+
getHashCode(value: string | null): number;
|
|
11
|
+
/** `null` sorts first; the rest by UTF-16 code unit order (of the uppercased text when ignoring case). */
|
|
12
|
+
compare(a: string | null, b: string | null): number;
|
|
13
|
+
private keyOf;
|
|
14
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `System.StringComparer.Ordinal` and `OrdinalIgnoreCase` as the runtime's comparers
|
|
3
|
+
* (#687): the argument a `Dictionary<string, V>`, a `HashSet<string>` or a sort takes. The
|
|
4
|
+
* culture-sensitive comparers have no counterpart and stay unmapped.
|
|
5
|
+
*/
|
|
6
|
+
import { ordinalIgnoreCaseKeyOf } from "../json/ordinal-ignore-case.js";
|
|
7
|
+
import { elementHashCode } from "./default-comparer.js";
|
|
8
|
+
/* The singletons are built on first read, so importing the module runs no code (tree shaking). */
|
|
9
|
+
let ordinal;
|
|
10
|
+
let ordinalIgnoreCase;
|
|
11
|
+
export class StringComparer {
|
|
12
|
+
ignoreCase;
|
|
13
|
+
constructor(ignoreCase) {
|
|
14
|
+
this.ignoreCase = ignoreCase;
|
|
15
|
+
}
|
|
16
|
+
/** Every code unit compared as is. */
|
|
17
|
+
static get ordinal() {
|
|
18
|
+
return (ordinal ??= new StringComparer(false));
|
|
19
|
+
}
|
|
20
|
+
/** Strings that differ only by the simple uppercase mapping of their code points are equal. */
|
|
21
|
+
static get ordinalIgnoreCase() {
|
|
22
|
+
return (ordinalIgnoreCase ??= new StringComparer(true));
|
|
23
|
+
}
|
|
24
|
+
equals(a, b) {
|
|
25
|
+
return this.keyOf(a) === this.keyOf(b);
|
|
26
|
+
}
|
|
27
|
+
getHashCode(value) {
|
|
28
|
+
return elementHashCode(this.keyOf(value));
|
|
29
|
+
}
|
|
30
|
+
/** `null` sorts first; the rest by UTF-16 code unit order (of the uppercased text when ignoring case). */
|
|
31
|
+
compare(a, b) {
|
|
32
|
+
const left = this.keyOf(a);
|
|
33
|
+
const right = this.keyOf(b);
|
|
34
|
+
if (left === right) {
|
|
35
|
+
return 0;
|
|
36
|
+
}
|
|
37
|
+
if (left === null) {
|
|
38
|
+
return -1;
|
|
39
|
+
}
|
|
40
|
+
return right === null || left > right ? 1 : -1;
|
|
41
|
+
}
|
|
42
|
+
keyOf(value) {
|
|
43
|
+
return this.ignoreCase && value !== null ? ordinalIgnoreCaseKeyOf(value) : value;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -6,6 +6,18 @@
|
|
|
6
6
|
* @throws OverflowException for a value beyond `decimal.MaxValue` in magnitude.
|
|
7
7
|
*/
|
|
8
8
|
export declare function parseDecimalText(text: string | null | undefined): string;
|
|
9
|
+
/**
|
|
10
|
+
* The digits of `(decimal)d` (`digits` 15) or `(decimal)f` (`digits` 7), for
|
|
11
|
+
* `new Decimal(…)`, ported from .NET's `VarDecFromR8` / `VarDecFromR4`
|
|
12
|
+
* (#695): the value is scaled by a power of ten to `digits` significant
|
|
13
|
+
* digits, the scale capped at 28, rounded half to even, and trailing zeros
|
|
14
|
+
* are dropped from the scale. So `(decimal)(0.1 + 0.2)` is `0.3`,
|
|
15
|
+
* `(decimal)1000000000000005.0` is `1000000000000000` and `(decimal)1e-30`
|
|
16
|
+
* is `0`. The scaling is done in double arithmetic, as .NET does.
|
|
17
|
+
*
|
|
18
|
+
* @throws OverflowException for NaN, ±Infinity and a magnitude of 2^96 or more.
|
|
19
|
+
*/
|
|
20
|
+
export declare function decimalTextFromDouble(value: number, digits: 7 | 15): string;
|
|
9
21
|
/** Parses once and records scale without decorating the constructed numeric value. */
|
|
10
22
|
export declare function parseDecimal<TDecimal extends object>(text: string | null | undefined, create: new (value: string) => TDecimal): TDecimal;
|
|
11
23
|
/**
|
|
@@ -44,6 +44,92 @@ export function parseDecimalText(text) {
|
|
|
44
44
|
const sign = leadingSign === "-" || trailingSign === "-" ? "-" : "";
|
|
45
45
|
return `${sign}${integer || "0"}${fraction ? `.${fraction}` : ""}`;
|
|
46
46
|
}
|
|
47
|
+
/** The largest scale of a `decimal`. */
|
|
48
|
+
const DECIMAL_SCALE_MAX = 28;
|
|
49
|
+
/** `1e0` … `1e28`, parsed so each is the exact double .NET's table holds. */
|
|
50
|
+
const DOUBLE_POWERS_OF_TEN = /* @__PURE__ */ lazyValue(() => Array.from({ length: DECIMAL_SCALE_MAX + 1 }, (_, power) => Number(`1e${power}`)));
|
|
51
|
+
/** A scratch view that reads the biased binary exponent of a `number`. */
|
|
52
|
+
const EXPONENT_VIEW = /* @__PURE__ */ lazyValue(() => new DataView(new ArrayBuffer(8)));
|
|
53
|
+
/**
|
|
54
|
+
* The digits of `(decimal)d` (`digits` 15) or `(decimal)f` (`digits` 7), for
|
|
55
|
+
* `new Decimal(…)`, ported from .NET's `VarDecFromR8` / `VarDecFromR4`
|
|
56
|
+
* (#695): the value is scaled by a power of ten to `digits` significant
|
|
57
|
+
* digits, the scale capped at 28, rounded half to even, and trailing zeros
|
|
58
|
+
* are dropped from the scale. So `(decimal)(0.1 + 0.2)` is `0.3`,
|
|
59
|
+
* `(decimal)1000000000000005.0` is `1000000000000000` and `(decimal)1e-30`
|
|
60
|
+
* is `0`. The scaling is done in double arithmetic, as .NET does.
|
|
61
|
+
*
|
|
62
|
+
* @throws OverflowException for NaN, ±Infinity and a magnitude of 2^96 or more.
|
|
63
|
+
*/
|
|
64
|
+
export function decimalTextFromDouble(value, digits) {
|
|
65
|
+
const exponent = binaryExponentOf(value);
|
|
66
|
+
if (exponent < -94) {
|
|
67
|
+
return "0";
|
|
68
|
+
}
|
|
69
|
+
if (exponent > 96) {
|
|
70
|
+
throw new OverflowException(DECIMAL_RANGE_MESSAGE);
|
|
71
|
+
}
|
|
72
|
+
const lowest = DOUBLE_POWERS_OF_TEN()[digits - 1];
|
|
73
|
+
let power = digits - 1 - ((exponent * 19728) >> 16);
|
|
74
|
+
let scaled = Math.abs(value);
|
|
75
|
+
if (power >= 0) {
|
|
76
|
+
power = Math.min(power, DECIMAL_SCALE_MAX);
|
|
77
|
+
scaled *= DOUBLE_POWERS_OF_TEN()[power];
|
|
78
|
+
}
|
|
79
|
+
else if (power !== -1 || scaled >= lowest * 10) {
|
|
80
|
+
scaled /= DOUBLE_POWERS_OF_TEN()[-power];
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
power = 0;
|
|
84
|
+
}
|
|
85
|
+
if (scaled < lowest && power < DECIMAL_SCALE_MAX) {
|
|
86
|
+
scaled *= 10;
|
|
87
|
+
power++;
|
|
88
|
+
}
|
|
89
|
+
const mantissa = roundHalfToEven(scaled);
|
|
90
|
+
if (mantissa === 0) {
|
|
91
|
+
return "0";
|
|
92
|
+
}
|
|
93
|
+
const sign = value < 0 ? "-" : "";
|
|
94
|
+
return power < 0
|
|
95
|
+
? `${sign}${mantissa}${"0".repeat(-power)}`
|
|
96
|
+
: `${sign}${scaledText(String(mantissa), power, digits - 1)}`;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* The exponent .NET reads from a binary floating-point value: the biased
|
|
100
|
+
* exponent of the double minus 1022, so `2^e ≤ |value| < 2^(e+1)` gives
|
|
101
|
+
* `e + 1`. A `float` held as a double reads the same exponent.
|
|
102
|
+
*/
|
|
103
|
+
function binaryExponentOf(value) {
|
|
104
|
+
const view = EXPONENT_VIEW();
|
|
105
|
+
view.setFloat64(0, value);
|
|
106
|
+
return ((view.getUint16(0) >> 4) & 0x7ff) - 1022;
|
|
107
|
+
}
|
|
108
|
+
/** `value` (below 2^53) rounded to an integer, a tie to the even one. */
|
|
109
|
+
function roundHalfToEven(value) {
|
|
110
|
+
const floor = Math.floor(value);
|
|
111
|
+
const rest = value - floor;
|
|
112
|
+
return rest > 0.5 || (rest === 0.5 && floor % 2 === 1) ? floor + 1 : floor;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* `digitsText` divided by `10^scale`, written out after up to `maxStrip`
|
|
116
|
+
* trailing zeros are dropped from the scale.
|
|
117
|
+
*/
|
|
118
|
+
function scaledText(digitsText, scale, maxStrip) {
|
|
119
|
+
let text = digitsText;
|
|
120
|
+
let remaining = scale;
|
|
121
|
+
let strippable = Math.min(scale, maxStrip);
|
|
122
|
+
while (strippable > 0 && text.endsWith("0")) {
|
|
123
|
+
text = text.slice(0, -1);
|
|
124
|
+
remaining--;
|
|
125
|
+
strippable--;
|
|
126
|
+
}
|
|
127
|
+
if (remaining === 0) {
|
|
128
|
+
return text;
|
|
129
|
+
}
|
|
130
|
+
const padded = text.padStart(remaining + 1, "0");
|
|
131
|
+
return `${padded.slice(0, -remaining)}.${padded.slice(-remaining)}`;
|
|
132
|
+
}
|
|
47
133
|
function formatException(text) {
|
|
48
134
|
return new FormatException(`The input string '${text}' was not in a correct format.`);
|
|
49
135
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Throws `error` from an expression position: the tail of a lowered C#
|
|
3
|
+
* `switch` expression no arm matched, or an arm whose result is a throw
|
|
4
|
+
* expression (`_ => throw new X()`). Returning `never` lets the conditional
|
|
5
|
+
* chain keep the type of its other arms, with no closure allocated.
|
|
6
|
+
*/
|
|
7
|
+
export declare function throwError(error: unknown): never;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Throws `error` from an expression position: the tail of a lowered C#
|
|
3
|
+
* `switch` expression no arm matched, or an arm whose result is a throw
|
|
4
|
+
* expression (`_ => throw new X()`). Returning `never` lets the conditional
|
|
5
|
+
* chain keep the type of its other arms, with no closure allocated.
|
|
6
|
+
*/
|
|
7
|
+
export function throwError(error) {
|
|
8
|
+
throw error;
|
|
9
|
+
}
|
package/dist/system/index.d.ts
CHANGED
|
@@ -33,3 +33,8 @@ export * from "./array-length.ts";
|
|
|
33
33
|
export * from "./argument-guards.ts";
|
|
34
34
|
export * from "./reflection/index.ts";
|
|
35
35
|
export * from "./dynamic-conversion.ts";
|
|
36
|
+
export * from "./number-members.ts";
|
|
37
|
+
export * from "./char-members.ts";
|
|
38
|
+
export * from "./string-builder.ts";
|
|
39
|
+
export * from "./lazy.ts";
|
|
40
|
+
export * from "./task-completion-source.ts";
|
package/dist/system/index.js
CHANGED
|
@@ -33,3 +33,8 @@ export * from "./array-length.js";
|
|
|
33
33
|
export * from "./argument-guards.js";
|
|
34
34
|
export * from "./reflection/index.js";
|
|
35
35
|
export * from "./dynamic-conversion.js";
|
|
36
|
+
export * from "./number-members.js";
|
|
37
|
+
export * from "./char-members.js";
|
|
38
|
+
export * from "./string-builder.js";
|
|
39
|
+
export * from "./lazy.js";
|
|
40
|
+
export * from "./task-completion-source.js";
|
package/dist/system/int64.d.ts
CHANGED
|
@@ -82,6 +82,12 @@ export declare function int64FromDecimal(value: DecimalLike): bigint;
|
|
|
82
82
|
export declare function uint64FromDecimal(value: DecimalLike): bigint;
|
|
83
83
|
/** Decimal to an integer of 32 bits or fewer: truncate exactly, then check even when unchecked. */
|
|
84
84
|
export declare function narrowFromDecimal(value: DecimalLike, bits: 8 | 16 | 32, signed: boolean): number;
|
|
85
|
+
/**
|
|
86
|
+
* `(char)m`: the UTF-16 code of the truncated `decimal` (#695).
|
|
87
|
+
*
|
|
88
|
+
* @throws OverflowException("Value was either too large or too small for a character.") outside 0–65535.
|
|
89
|
+
*/
|
|
90
|
+
export declare function charCodeFromDecimal(value: DecimalLike): number;
|
|
85
91
|
/** `(long)b`: throws OverflowException outside the range, in every context. */
|
|
86
92
|
export declare function int64FromBigInteger(value: bigint): bigint;
|
|
87
93
|
/**
|
package/dist/system/int64.js
CHANGED
|
@@ -162,18 +162,27 @@ export function uint64FromDecimal(value) {
|
|
|
162
162
|
}
|
|
163
163
|
/** Decimal to an integer of 32 bits or fewer: truncate exactly, then check even when unchecked. */
|
|
164
164
|
export function narrowFromDecimal(value, bits, signed) {
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
? signed
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
: `${signed ? "an Int" : "a UInt"}${bits}`;
|
|
171
|
-
return `Value was either too large or too small for ${type}.`;
|
|
172
|
-
};
|
|
173
|
-
const integer = truncatedDecimal(value, message);
|
|
165
|
+
const type = bits === 8
|
|
166
|
+
? signed
|
|
167
|
+
? "a signed byte"
|
|
168
|
+
: "an unsigned byte"
|
|
169
|
+
: `${signed ? "an Int" : "a UInt"}${bits}`;
|
|
174
170
|
const width = BigInt(bits);
|
|
175
171
|
const min = signed ? -(1n << (width - 1n)) : 0n;
|
|
176
172
|
const max = signed ? (1n << (width - 1n)) - 1n : (1n << width) - 1n;
|
|
173
|
+
return truncatedDecimalInRange(value, min, max, type);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* `(char)m`: the UTF-16 code of the truncated `decimal` (#695).
|
|
177
|
+
*
|
|
178
|
+
* @throws OverflowException("Value was either too large or too small for a character.") outside 0–65535.
|
|
179
|
+
*/
|
|
180
|
+
export function charCodeFromDecimal(value) {
|
|
181
|
+
return truncatedDecimalInRange(value, 0n, 0xffffn, "a character");
|
|
182
|
+
}
|
|
183
|
+
function truncatedDecimalInRange(value, min, max, type) {
|
|
184
|
+
const message = () => `Value was either too large or too small for ${type}.`;
|
|
185
|
+
const integer = truncatedDecimal(value, message);
|
|
177
186
|
return Number(requireRange(integer, min, max, message));
|
|
178
187
|
}
|
|
179
188
|
/** `(long)b`: throws OverflowException outside the range, in every context. */
|
|
@@ -9,12 +9,20 @@
|
|
|
9
9
|
* for integral operands (`-7 / 2` is `-3`). A `null` (or `undefined`) operand yields
|
|
10
10
|
* `null`, matching C#'s lifted `int?` division.
|
|
11
11
|
*
|
|
12
|
-
* Overflow is not modelled: `int.MinValue / -1` returns `2147483648` instead of
|
|
13
|
-
* throwing `OverflowException`, and a `long` quotient beyond `Number.MAX_SAFE_INTEGER`
|
|
14
|
-
* loses precision, like every other `long` value mapped to `number`.
|
|
15
|
-
*
|
|
16
12
|
* @throws DivideByZeroException, with .NET's message, when `divisor` is zero,
|
|
17
13
|
* where a bare `Math.trunc(dividend / divisor)` would yield `Infinity` or `NaN`.
|
|
14
|
+
* @throws OverflowException for `int.MinValue / -1`, whose quotient does not fit `int`.
|
|
18
15
|
*/
|
|
19
16
|
export declare function intDiv(dividend: number, divisor: number): number;
|
|
20
17
|
export declare function intDiv(dividend: number | null | undefined, divisor: number | null | undefined): number | null;
|
|
18
|
+
/**
|
|
19
|
+
* `a % b` over `int` or `uint` operands with a divisor that is not a constant:
|
|
20
|
+
* the remainder with the dividend's sign, as JavaScript's `%` computes it, but
|
|
21
|
+
* throwing where .NET throws instead of yielding `NaN` or `0` (#695). A `null`
|
|
22
|
+
* (or `undefined`) operand yields `null`, matching C#'s lifted `int?` remainder.
|
|
23
|
+
*
|
|
24
|
+
* @throws DivideByZeroException, with .NET's message, when `divisor` is zero.
|
|
25
|
+
* @throws OverflowException for `int.MinValue % -1`, as .NET does.
|
|
26
|
+
*/
|
|
27
|
+
export declare function intRem(dividend: number, divisor: number): number;
|
|
28
|
+
export declare function intRem(dividend: number | null | undefined, divisor: number | null | undefined): number | null;
|
|
@@ -5,13 +5,30 @@
|
|
|
5
5
|
* where C# gives `3`.
|
|
6
6
|
*/
|
|
7
7
|
import { DivideByZeroException } from "./exceptions/divide-by-zero-exception.js";
|
|
8
|
+
import { OverflowException } from "./exceptions/overflow-exception.js";
|
|
9
|
+
const INT32_MIN = -2147483648;
|
|
8
10
|
export function intDiv(dividend, divisor) {
|
|
9
11
|
if (dividend == null || divisor == null) {
|
|
10
12
|
return null;
|
|
11
13
|
}
|
|
14
|
+
requireInt32Division(dividend, divisor);
|
|
15
|
+
// C# integers have no negative zero: `+ 0` turns the `-0` of `-1 / 3` into `0`.
|
|
16
|
+
return Math.trunc(dividend / divisor) + 0;
|
|
17
|
+
}
|
|
18
|
+
export function intRem(dividend, divisor) {
|
|
19
|
+
if (dividend == null || divisor == null) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
requireInt32Division(dividend, divisor);
|
|
23
|
+
// `+ 0` turns the `-0` of `-4 % 2` into `0`.
|
|
24
|
+
return (dividend % divisor) + 0;
|
|
25
|
+
}
|
|
26
|
+
/** Throws what .NET throws for an `int` `/` or `%`: a zero divisor, or `int.MinValue` by `-1`. */
|
|
27
|
+
function requireInt32Division(dividend, divisor) {
|
|
12
28
|
if (divisor === 0) {
|
|
13
29
|
throw new DivideByZeroException();
|
|
14
30
|
}
|
|
15
|
-
|
|
16
|
-
|
|
31
|
+
if (dividend === INT32_MIN && divisor === -1) {
|
|
32
|
+
throw new OverflowException();
|
|
33
|
+
}
|
|
17
34
|
}
|
|
@@ -3,7 +3,8 @@ import { JsonException } from "./errors.ts";
|
|
|
3
3
|
/**
|
|
4
4
|
* The C# type name a contract reports in errors: its constructor's name, the
|
|
5
5
|
* `typeName` of a polymorphic base without a constructor (an interface or a
|
|
6
|
-
* `[PlainObject]` base),
|
|
6
|
+
* `[PlainObject]` base), the CLR `typeName` of any other `[PlainObject]`
|
|
7
|
+
* contract (#512), and `Object` for a hand-written spec with none of them.
|
|
7
8
|
*/
|
|
8
9
|
export declare function contractNameOf(spec: TypeSpec): string;
|
|
9
10
|
/** System.Text.Json's error for a JSON value that does not fit the spec. */
|
|
@@ -3,10 +3,11 @@ import { isValueSpec } from "./spec-kind.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* The C# type name a contract reports in errors: its constructor's name, the
|
|
5
5
|
* `typeName` of a polymorphic base without a constructor (an interface or a
|
|
6
|
-
* `[PlainObject]` base),
|
|
6
|
+
* `[PlainObject]` base), the CLR `typeName` of any other `[PlainObject]`
|
|
7
|
+
* contract (#512), and `Object` for a hand-written spec with none of them.
|
|
7
8
|
*/
|
|
8
9
|
export function contractNameOf(spec) {
|
|
9
|
-
return spec.type?.name ?? spec.polymorphism?.typeName ?? "Object";
|
|
10
|
+
return spec.type?.name ?? spec.polymorphism?.typeName ?? spec.typeName ?? "Object";
|
|
10
11
|
}
|
|
11
12
|
/**
|
|
12
13
|
* The type a conversion error names: the CLR name a value-type spec carries
|
|
@@ -1,52 +1,15 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
* it, stably, across the whole chain (measured: `{"Der2":20,"Base3":3,"Der1":10,
|
|
17
|
-
* "Base1":1,"Der3":30,"Base2":2}` for orders -5, -5, 0, 0, 1, 5).
|
|
18
|
-
*/
|
|
19
|
-
export declare function collectWireProperties(spec: TypeSpec): readonly PropertySpec[];
|
|
20
|
-
/**
|
|
21
|
-
* How the tree being read holds its numbers: `parsed`, each a `number`, as
|
|
22
|
-
* `JSON.parse` builds it; `exact`, some as leaves, as `readJsonText` builds
|
|
23
|
-
* it (#457): a `JsonNumberText` for those with more significant digits than
|
|
24
|
-
* a double holds and, for a spec that reads a 64-bit integer, a
|
|
25
|
-
* `JsonNonIntegerNumber` for the other ones with a fraction or an exponent
|
|
26
|
-
* (`NumberTextLeaves`).
|
|
27
|
-
*/
|
|
28
|
-
export type TreeNumbers = "parsed" | "exact";
|
|
29
|
-
/**
|
|
30
|
-
* Serialize a TS object to a JSON-safe plain object using the given spec. A
|
|
31
|
-
* polymorphic spec first chooses the derived contract and writes its tag
|
|
32
|
-
* before every property (FR-005); the chosen contract is never dispatched
|
|
33
|
-
* again (FR-006).
|
|
34
|
-
*/
|
|
35
|
-
export declare function serializeWithSpec(value: unknown, spec: TypeSpec, customConverters?: readonly JsonConverter[]): Record<string, unknown>;
|
|
36
|
-
/**
|
|
37
|
-
* Deserialize unknown data (from JSON.parse) into a typed instance using the
|
|
38
|
-
* spec. A polymorphic spec reads the derived contract its tag selects
|
|
39
|
-
* (FR-007). `treeNumbers` says how `data` holds its numbers; a root number
|
|
40
|
-
* leaf reads as the number it is, which no contract accepts.
|
|
41
|
-
*/
|
|
42
|
-
export declare function deserializeWithSpec<T>(data: unknown, spec: TypeSpec<T>, customConverters?: readonly JsonConverter[], treeNumbers?: TreeNumbers): T;
|
|
43
|
-
/**
|
|
44
|
-
* Serializes a non-object root through its descriptor, exactly as a property
|
|
45
|
-
* of that type would be (custom converters still match by kind).
|
|
46
|
-
*/
|
|
47
|
-
export declare function serializeWithValueSpec(value: unknown, spec: ValueSpec, customConverters?: readonly JsonConverter[]): unknown;
|
|
48
|
-
/**
|
|
49
|
-
* Deserializes a non-object root through its descriptor, under the spec's
|
|
50
|
-
* read options. `treeNumbers` says how `data` holds its numbers.
|
|
51
|
-
*/
|
|
52
|
-
export declare function deserializeWithValueSpec(data: unknown, spec: ValueSpec, customConverters?: readonly JsonConverter[], treeNumbers?: TreeNumbers): unknown;
|
|
1
|
+
import type { TypeDescriptor, JsonReadOptions } from "./types.ts";
|
|
2
|
+
import type { ValueConverter } from "./value-converter.ts";
|
|
3
|
+
import { type ErrorTypeName } from "./numeric-converters.ts";
|
|
4
|
+
import type { SpecPlans } from "./spec-plans.ts";
|
|
5
|
+
/**
|
|
6
|
+
* Resolves the serialize/deserialize pair for a given type descriptor, checking
|
|
7
|
+
* the custom converters of `plans` first (user overrides), then falling back to
|
|
8
|
+
* built-in ones. `readOptions` are the read options of the spec being read
|
|
9
|
+
* (FR-048); a `ref` reads with its target spec's own options. `errorTypeName`
|
|
10
|
+
* names the type a built-in conversion error reports: a property names the
|
|
11
|
+
* declaring contract, every other position names the value's own CLR type
|
|
12
|
+
* (#485). Under exact tree numbers, only the built-in converters that read a
|
|
13
|
+
* number's exact text see a number leaf (`withNumberTextsAsDoubles`).
|
|
14
|
+
*/
|
|
15
|
+
export declare function resolveConverter(descriptor: TypeDescriptor, plans: SpecPlans, readOptions?: JsonReadOptions, errorTypeName?: ErrorTypeName): ValueConverter;
|