metano-runtime 2.10.1 → 3.0.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/README.md +11 -1
- package/dist/system/argument-guards.d.ts +63 -0
- package/dist/system/argument-guards.js +155 -0
- package/dist/system/array-length.d.ts +6 -0
- package/dist/system/array-length.js +17 -0
- package/dist/system/big-integer.d.ts +50 -0
- package/dist/system/big-integer.js +108 -0
- package/dist/system/boolean-format.d.ts +6 -0
- package/dist/system/boolean-format.js +11 -0
- package/dist/system/collections/builder-iterator.d.ts +14 -0
- package/dist/system/collections/builder-iterator.js +15 -0
- package/dist/system/collections/checks.d.ts +17 -0
- package/dist/system/collections/checks.js +0 -0
- package/dist/system/collections/close-collection.d.ts +33 -0
- package/dist/system/collections/close-collection.js +68 -0
- package/dist/system/collections/collection-type-name.d.ts +11 -0
- package/dist/system/collections/collection-type-name.js +19 -0
- package/dist/system/collections/concurrent-dictionary.d.ts +80 -0
- package/dist/system/collections/concurrent-dictionary.js +261 -0
- package/dist/system/collections/copy-to.d.ts +8 -0
- package/dist/system/collections/copy-to.js +37 -0
- package/dist/system/collections/default-comparer.d.ts +64 -0
- package/dist/system/collections/default-comparer.js +231 -0
- package/dist/system/collections/descriptors.d.ts +58 -0
- package/dist/system/collections/descriptors.js +181 -0
- package/dist/system/collections/dictionary-helpers.d.ts +3 -28
- package/dist/system/collections/dictionary-helpers.js +3 -38
- package/dist/system/collections/dictionary-views.d.ts +39 -0
- package/dist/system/collections/dictionary-views.js +153 -0
- package/dist/system/collections/dictionary.d.ts +68 -0
- package/dist/system/collections/dictionary.js +165 -0
- package/dist/system/collections/hash-core.d.ts +51 -0
- package/dist/system/collections/hash-core.js +160 -0
- package/dist/system/collections/hash-set.d.ts +51 -24
- package/dist/system/collections/hash-set.js +165 -137
- package/dist/system/collections/helpers.d.ts +29 -0
- package/dist/system/collections/helpers.js +73 -0
- package/dist/system/collections/immutable-array-builder.d.ts +37 -0
- package/dist/system/collections/immutable-array-builder.js +117 -0
- package/dist/system/collections/immutable-array.d.ts +74 -0
- package/dist/system/collections/immutable-array.js +243 -0
- package/dist/system/collections/immutable-dictionary-builder.d.ts +58 -0
- package/dist/system/collections/immutable-dictionary-builder.js +126 -0
- package/dist/system/collections/immutable-dictionary.d.ts +80 -0
- package/dist/system/collections/immutable-dictionary.js +284 -0
- package/dist/system/collections/immutable-hash-set-builder.d.ts +58 -0
- package/dist/system/collections/immutable-hash-set-builder.js +125 -0
- package/dist/system/collections/immutable-hash-set.d.ts +71 -0
- package/dist/system/collections/immutable-hash-set.js +242 -0
- package/dist/system/collections/immutable-interfaces.d.ts +51 -0
- package/dist/system/collections/immutable-interfaces.js +0 -0
- package/dist/system/collections/immutable-list-builder-core.d.ts +58 -0
- package/dist/system/collections/immutable-list-builder-core.js +136 -0
- package/dist/system/collections/immutable-list-builder.d.ts +35 -0
- package/dist/system/collections/immutable-list-builder.js +73 -0
- package/dist/system/collections/immutable-list-core.d.ts +98 -0
- package/dist/system/collections/immutable-list-core.js +268 -0
- package/dist/system/collections/immutable-list.d.ts +49 -0
- package/dist/system/collections/immutable-list.js +176 -0
- package/dist/system/collections/immutable-storage.d.ts +50 -0
- package/dist/system/collections/immutable-storage.js +83 -0
- package/dist/system/collections/index.d.ts +25 -2
- package/dist/system/collections/index.js +22 -2
- package/dist/system/collections/interfaces.d.ts +76 -0
- package/dist/system/collections/interfaces.js +0 -0
- package/dist/system/collections/list.d.ts +96 -0
- package/dist/system/collections/list.js +335 -0
- package/dist/system/collections/queue.d.ts +44 -0
- package/dist/system/collections/queue.js +115 -0
- package/dist/system/collections/read-only-list.d.ts +45 -0
- package/dist/system/collections/read-only-list.js +152 -0
- package/dist/system/collections/red-black-tree.d.ts +64 -0
- package/dist/system/collections/red-black-tree.js +361 -0
- package/dist/system/collections/set-algebra.d.ts +15 -0
- package/dist/system/collections/set-algebra.js +58 -0
- package/dist/system/collections/sorted-array.d.ts +14 -0
- package/dist/system/collections/sorted-array.js +31 -0
- package/dist/system/collections/sorted-dictionary.d.ts +64 -0
- package/dist/system/collections/sorted-dictionary.js +163 -0
- package/dist/system/collections/sorted-list.d.ts +131 -0
- package/dist/system/collections/sorted-list.js +301 -0
- package/dist/system/collections/sorted-set.d.ts +98 -0
- package/dist/system/collections/sorted-set.js +255 -0
- package/dist/system/collections/stack.d.ts +39 -0
- package/dist/system/collections/stack.js +106 -0
- package/dist/system/collections/throw-helpers.d.ts +77 -0
- package/dist/system/collections/throw-helpers.js +158 -0
- package/dist/system/date-time-offset.d.ts +23 -0
- package/dist/system/date-time-offset.js +61 -0
- package/dist/system/decimal-parsing.d.ts +18 -0
- package/dist/system/decimal-parsing.js +74 -0
- package/dist/system/decimal.d.ts +20 -0
- package/dist/system/decimal.js +30 -0
- package/dist/system/default-text.d.ts +11 -0
- package/dist/system/default-text.js +52 -0
- package/dist/system/delegates.js +1 -1
- package/dist/system/double-format.d.ts +20 -0
- package/dist/system/double-format.js +171 -0
- package/dist/system/dynamic-conversion.d.ts +37 -0
- package/dist/system/dynamic-conversion.js +229 -0
- package/dist/system/equality.d.ts +23 -3
- package/dist/system/equality.js +135 -3
- package/dist/system/exceptions/argument-exception.d.ts +17 -0
- package/dist/system/exceptions/argument-exception.js +44 -0
- package/dist/system/exceptions/argument-null-exception.d.ts +16 -0
- package/dist/system/exceptions/argument-null-exception.js +35 -0
- package/dist/system/exceptions/argument-out-of-range-exception.d.ts +18 -0
- package/dist/system/exceptions/argument-out-of-range-exception.js +51 -0
- package/dist/system/exceptions/arithmetic-exception.d.ts +12 -0
- package/dist/system/exceptions/arithmetic-exception.js +31 -0
- package/dist/system/exceptions/divide-by-zero-exception.d.ts +12 -0
- package/dist/system/exceptions/divide-by-zero-exception.js +31 -0
- package/dist/system/exceptions/exception.d.ts +38 -0
- package/dist/system/exceptions/exception.js +77 -0
- package/dist/system/exceptions/format-exception.d.ts +12 -0
- package/dist/system/exceptions/format-exception.js +31 -0
- package/dist/system/exceptions/index-out-of-range-exception.d.ts +12 -0
- package/dist/system/exceptions/index-out-of-range-exception.js +31 -0
- package/dist/system/exceptions/index.d.ts +26 -0
- package/dist/system/exceptions/index.js +26 -0
- package/dist/system/exceptions/invalid-cast-exception.d.ts +12 -0
- package/dist/system/exceptions/invalid-cast-exception.js +31 -0
- package/dist/system/exceptions/invalid-operation-exception.d.ts +12 -0
- package/dist/system/exceptions/invalid-operation-exception.js +31 -0
- package/dist/system/exceptions/json-exception.d.ts +18 -0
- package/dist/system/exceptions/json-exception.js +39 -0
- package/dist/system/exceptions/key-not-found-exception.d.ts +13 -0
- package/dist/system/exceptions/key-not-found-exception.js +34 -0
- package/dist/system/exceptions/message-value.d.ts +7 -0
- package/dist/system/exceptions/message-value.js +9 -0
- package/dist/system/exceptions/missing-method-exception.d.ts +19 -0
- package/dist/system/exceptions/missing-method-exception.js +38 -0
- package/dist/system/exceptions/named-exception.d.ts +7 -0
- package/dist/system/exceptions/named-exception.js +29 -0
- package/dist/system/exceptions/not-implemented-exception.d.ts +12 -0
- package/dist/system/exceptions/not-implemented-exception.js +31 -0
- package/dist/system/exceptions/not-supported-exception.d.ts +12 -0
- package/dist/system/exceptions/not-supported-exception.js +31 -0
- package/dist/system/exceptions/null-reference-exception.d.ts +12 -0
- package/dist/system/exceptions/null-reference-exception.js +31 -0
- package/dist/system/exceptions/object-disposed-exception.d.ts +18 -0
- package/dist/system/exceptions/object-disposed-exception.js +41 -0
- package/dist/system/exceptions/operation-canceled-exception.d.ts +12 -0
- package/dist/system/exceptions/operation-canceled-exception.js +31 -0
- package/dist/system/exceptions/overflow-exception.d.ts +15 -0
- package/dist/system/exceptions/overflow-exception.js +34 -0
- package/dist/system/exceptions/switch-expression-exception.d.ts +21 -0
- package/dist/system/exceptions/switch-expression-exception.js +49 -0
- package/dist/system/exceptions/system-exception.d.ts +12 -0
- package/dist/system/exceptions/system-exception.js +31 -0
- package/dist/system/exceptions/task-canceled-exception.d.ts +13 -0
- package/dist/system/exceptions/task-canceled-exception.js +34 -0
- package/dist/system/exceptions/timeout-exception.d.ts +12 -0
- package/dist/system/exceptions/timeout-exception.js +31 -0
- package/dist/system/exceptions/to-exception.d.ts +25 -0
- package/dist/system/exceptions/to-exception.js +53 -0
- package/dist/system/exceptions/type-initialization-exception.d.ts +19 -0
- package/dist/system/exceptions/type-initialization-exception.js +36 -0
- package/dist/system/hash-code.d.ts +0 -7
- package/dist/system/hash-code.js +3 -1
- package/dist/system/identity-memo.d.ts +7 -0
- package/dist/system/identity-memo.js +14 -0
- package/dist/system/index.d.ts +21 -0
- package/dist/system/index.js +21 -0
- package/dist/system/int64-convert.d.ts +59 -0
- package/dist/system/int64-convert.js +226 -0
- package/dist/system/int64-format.d.ts +13 -0
- package/dist/system/int64-format.js +28 -0
- package/dist/system/int64-math.d.ts +56 -0
- package/dist/system/int64-math.js +109 -0
- package/dist/system/int64-parsing.d.ts +45 -0
- package/dist/system/int64-parsing.js +153 -0
- package/dist/system/int64.d.ts +134 -0
- package/dist/system/int64.js +298 -0
- package/dist/system/integer-division.d.ts +1 -1
- package/dist/system/integer-division.js +2 -3
- package/dist/system/integer-format.d.ts +12 -0
- package/dist/system/integer-format.js +22 -0
- package/dist/system/integer-standard-format.d.ts +9 -0
- package/dist/system/integer-standard-format.js +66 -0
- package/dist/system/json/byte-array-converter.d.ts +19 -0
- package/dist/system/json/byte-array-converter.js +106 -0
- package/dist/system/json/container-depth.d.ts +10 -0
- package/dist/system/json/container-depth.js +43 -16
- package/dist/system/json/contract-name.d.ts +8 -3
- package/dist/system/json/contract-name.js +22 -2
- package/dist/system/json/converter-set-cache.d.ts +17 -0
- package/dist/system/json/converter-set-cache.js +26 -0
- package/dist/system/json/converters.d.ts +27 -12
- package/dist/system/json/converters.js +498 -169
- package/dist/system/json/decimal-text.d.ts +9 -0
- package/dist/system/json/decimal-text.js +125 -0
- package/dist/system/json/dictionary-keys.d.ts +31 -0
- package/dist/system/json/dictionary-keys.js +195 -0
- package/dist/system/json/errors.d.ts +9 -11
- package/dist/system/json/errors.js +9 -11
- package/dist/system/json/exact-json-number.d.ts +103 -0
- package/dist/system/json/exact-json-number.js +155 -0
- package/dist/system/json/exact-number-reads.d.ts +21 -0
- package/dist/system/json/exact-number-reads.js +104 -0
- package/dist/system/json/index.d.ts +1 -2
- package/dist/system/json/index.js +0 -1
- package/dist/system/json/json-serializer.d.ts +64 -9
- package/dist/system/json/json-serializer.js +52 -12
- package/dist/system/json/json-text-reader.d.ts +33 -0
- package/dist/system/json/json-text-reader.js +608 -0
- package/dist/system/json/null-reads.d.ts +22 -0
- package/dist/system/json/null-reads.js +43 -0
- package/dist/system/json/number-from-string.d.ts +44 -0
- package/dist/system/json/number-from-string.js +248 -0
- package/dist/system/json/numeric-converters.d.ts +65 -0
- package/dist/system/json/numeric-converters.js +361 -0
- package/dist/system/json/numeric-enum-members.d.ts +18 -0
- package/dist/system/json/numeric-enum-members.js +18 -0
- package/dist/system/json/ordinal-ignore-case.d.ts +14 -0
- package/dist/system/json/ordinal-ignore-case.js +60 -0
- package/dist/system/json/polymorphism.d.ts +2 -0
- package/dist/system/json/polymorphism.js +101 -20
- package/dist/system/json/property-lookup.d.ts +17 -0
- package/dist/system/json/property-lookup.js +32 -0
- package/dist/system/json/property-naming-policy.d.ts +5 -5
- package/dist/system/json/property-naming-policy.js +163 -73
- package/dist/system/json/serializer-context.d.ts +19 -4
- package/dist/system/json/serializer-context.js +33 -7
- package/dist/system/json/spec-kind.d.ts +3 -0
- package/dist/system/json/spec-kind.js +4 -0
- package/dist/system/json/temporal-reads.d.ts +15 -0
- package/dist/system/json/temporal-reads.js +423 -0
- package/dist/system/json/temporal-text.d.ts +16 -0
- package/dist/system/json/temporal-text.js +32 -0
- package/dist/system/json/types.d.ts +190 -24
- package/dist/system/json/types.js +0 -1
- package/dist/system/json/value-converter.d.ts +5 -0
- package/dist/system/json/value-converter.js +0 -0
- package/dist/system/lazy-value.d.ts +9 -0
- package/dist/system/lazy-value.js +19 -0
- package/dist/system/linq/compare-keys.js +4 -0
- package/dist/system/linq/decimal-terminals.d.ts +24 -0
- package/dist/system/linq/decimal-terminals.js +67 -0
- package/dist/system/linq/expr-tree-visitor.d.ts +2 -27
- package/dist/system/linq/expr-tree-visitor.js +62 -0
- package/dist/system/linq/expr-tree.d.ts +11 -1
- package/dist/system/linq/index.d.ts +7 -4
- package/dist/system/linq/index.js +4 -2
- package/dist/system/linq/int64-terminals.d.ts +33 -0
- package/dist/system/linq/int64-terminals.js +131 -0
- package/dist/system/linq/operators.d.ts +7 -1
- package/dist/system/linq/operators.js +60 -2
- package/dist/system/linq/terminals.d.ts +85 -7
- package/dist/system/linq/terminals.js +220 -67
- package/dist/system/linq/types.d.ts +101 -20
- package/dist/system/math.d.ts +6 -5
- package/dist/system/math.js +26 -14
- package/dist/system/number-parsing.d.ts +43 -17
- package/dist/system/number-parsing.js +121 -37
- package/dist/system/record-copy.js +11 -0
- package/dist/system/reflection/box.d.ts +19 -0
- package/dist/system/reflection/box.js +32 -0
- package/dist/system/reflection/boxed-text.d.ts +8 -0
- package/dist/system/reflection/boxed-text.js +31 -0
- package/dist/system/reflection/cast-to.d.ts +15 -0
- package/dist/system/reflection/cast-to.js +32 -0
- package/dist/system/reflection/constructor-descriptor.d.ts +11 -0
- package/dist/system/reflection/constructor-descriptor.js +22 -0
- package/dist/system/reflection/create-instance.d.ts +6 -0
- package/dist/system/reflection/create-instance.js +11 -0
- package/dist/system/reflection/decimal-type-defaults.d.ts +7 -0
- package/dist/system/reflection/decimal-type-defaults.js +17 -0
- package/dist/system/reflection/enum-from-raw.d.ts +14 -0
- package/dist/system/reflection/enum-from-raw.js +89 -0
- package/dist/system/reflection/enum-is-defined.d.ts +7 -0
- package/dist/system/reflection/enum-is-defined.js +14 -0
- package/dist/system/reflection/get-number-type.d.ts +7 -0
- package/dist/system/reflection/get-number-type.js +10 -0
- package/dist/system/reflection/get-runtime-type-from-type.d.ts +6 -0
- package/dist/system/reflection/get-runtime-type-from-type.js +22 -0
- package/dist/system/reflection/get-runtime-type.d.ts +3 -0
- package/dist/system/reflection/get-runtime-type.js +105 -0
- package/dist/system/reflection/implements-interface.d.ts +10 -0
- package/dist/system/reflection/implements-interface.js +26 -0
- package/dist/system/reflection/index.d.ts +27 -0
- package/dist/system/reflection/index.js +26 -0
- package/dist/system/reflection/invalid-cast.d.ts +8 -0
- package/dist/system/reflection/invalid-cast.js +33 -0
- package/dist/system/reflection/is-assignable-from.d.ts +13 -0
- package/dist/system/reflection/is-assignable-from.js +121 -0
- package/dist/system/reflection/is-box-of.d.ts +3 -0
- package/dist/system/reflection/is-box-of.js +5 -0
- package/dist/system/reflection/is-boxed.d.ts +7 -0
- package/dist/system/reflection/is-boxed.js +9 -0
- package/dist/system/reflection/is-type.d.ts +12 -0
- package/dist/system/reflection/is-type.js +20 -0
- package/dist/system/reflection/nullable-type.d.ts +3 -0
- package/dist/system/reflection/nullable-type.js +19 -0
- package/dist/system/reflection/opaque-type.d.ts +6 -0
- package/dist/system/reflection/opaque-type.js +22 -0
- package/dist/system/reflection/primitive-types.d.ts +20 -0
- package/dist/system/reflection/primitive-types.js +160 -0
- package/dist/system/reflection/runtime-type.d.ts +131 -0
- package/dist/system/reflection/runtime-type.js +5 -0
- package/dist/system/reflection/specialize-collection.d.ts +11 -0
- package/dist/system/reflection/specialize-collection.js +93 -0
- package/dist/system/reflection/specialize.d.ts +7 -0
- package/dist/system/reflection/specialize.js +33 -0
- package/dist/system/reflection/temporal-type-defaults.d.ts +11 -0
- package/dist/system/reflection/temporal-type-defaults.js +61 -0
- package/dist/system/reflection/temporal-types.d.ts +7 -0
- package/dist/system/reflection/temporal-types.js +44 -0
- package/dist/system/reflection/to-string-tag.d.ts +6 -0
- package/dist/system/reflection/to-string-tag.js +8 -0
- package/dist/system/reflection/tuple-type.d.ts +6 -0
- package/dist/system/reflection/tuple-type.js +23 -0
- package/dist/system/reflection/unbox-for-cast.d.ts +10 -0
- package/dist/system/reflection/unbox-for-cast.js +28 -0
- package/dist/system/reflection/unbox-for.d.ts +9 -0
- package/dist/system/reflection/unbox-for.js +15 -0
- package/dist/system/reflection/unbox.d.ts +5 -0
- package/dist/system/reflection/unbox.js +8 -0
- package/dist/system/reflection/unsupported-type.d.ts +7 -0
- package/dist/system/reflection/unsupported-type.js +27 -0
- package/dist/system/reflection/well-known-types.d.ts +13 -0
- package/dist/system/reflection/well-known-types.js +32 -0
- package/dist/system/reflection/with-implementers.d.ts +8 -0
- package/dist/system/reflection/with-implementers.js +23 -0
- package/dist/system/standard-numeric-format.d.ts +67 -0
- package/dist/system/standard-numeric-format.js +213 -0
- package/dist/system/string-members.d.ts +170 -0
- package/dist/system/string-members.js +445 -0
- package/dist/system/strings.d.ts +13 -9
- package/dist/system/strings.js +17 -18
- package/dist/system/temporal-helpers.d.ts +33 -0
- package/dist/system/temporal-helpers.js +117 -2
- package/dist/system/time-span-format.d.ts +3 -0
- package/dist/system/time-span-format.js +17 -0
- package/dist/system/time-span.d.ts +33 -0
- package/dist/system/time-span.js +90 -0
- package/dist/system/type-initializer.d.ts +14 -0
- package/dist/system/type-initializer.js +36 -0
- package/dist/system/uuid.d.ts +54 -38
- package/dist/system/uuid.js +120 -79
- package/dist/type-checking/primitive-type-checks.d.ts +17 -5
- package/dist/type-checking/primitive-type-checks.js +22 -15
- package/dist-unchecked/index.d.ts +2 -0
- package/dist-unchecked/index.js +2 -0
- package/dist-unchecked/system/argument-guards.d.ts +63 -0
- package/dist-unchecked/system/argument-guards.js +155 -0
- package/dist-unchecked/system/array-length.d.ts +6 -0
- package/dist-unchecked/system/array-length.js +17 -0
- package/dist-unchecked/system/big-integer.d.ts +50 -0
- package/dist-unchecked/system/big-integer.js +108 -0
- package/dist-unchecked/system/bind-receiver.d.ts +26 -0
- package/dist-unchecked/system/bind-receiver.js +30 -0
- package/dist-unchecked/system/boolean-format.d.ts +6 -0
- package/dist-unchecked/system/boolean-format.js +11 -0
- package/dist-unchecked/system/collections/builder-iterator.d.ts +14 -0
- package/dist-unchecked/system/collections/builder-iterator.js +15 -0
- package/dist-unchecked/system/collections/checks.d.ts +17 -0
- package/dist-unchecked/system/collections/checks.js +0 -0
- package/dist-unchecked/system/collections/close-collection.d.ts +33 -0
- package/dist-unchecked/system/collections/close-collection.js +68 -0
- package/dist-unchecked/system/collections/collection-type-name.d.ts +11 -0
- package/dist-unchecked/system/collections/collection-type-name.js +19 -0
- package/dist-unchecked/system/collections/concurrent-dictionary.d.ts +80 -0
- package/dist-unchecked/system/collections/concurrent-dictionary.js +261 -0
- package/dist-unchecked/system/collections/copy-to.d.ts +8 -0
- package/dist-unchecked/system/collections/copy-to.js +37 -0
- package/dist-unchecked/system/collections/default-comparer.d.ts +64 -0
- package/dist-unchecked/system/collections/default-comparer.js +231 -0
- package/dist-unchecked/system/collections/descriptors.d.ts +58 -0
- package/dist-unchecked/system/collections/descriptors.js +181 -0
- package/dist-unchecked/system/collections/dictionary-helpers.d.ts +15 -0
- package/dist-unchecked/system/collections/dictionary-helpers.js +17 -0
- package/dist-unchecked/system/collections/dictionary-views.d.ts +39 -0
- package/dist-unchecked/system/collections/dictionary-views.js +153 -0
- package/dist-unchecked/system/collections/dictionary.d.ts +68 -0
- package/dist-unchecked/system/collections/dictionary.js +164 -0
- package/dist-unchecked/system/collections/hash-core.d.ts +51 -0
- package/dist-unchecked/system/collections/hash-core.js +160 -0
- package/dist-unchecked/system/collections/hash-set.d.ts +56 -0
- package/dist-unchecked/system/collections/hash-set.js +165 -0
- package/dist-unchecked/system/collections/helpers.d.ts +29 -0
- package/dist-unchecked/system/collections/helpers.js +73 -0
- package/dist-unchecked/system/collections/immutable-array-builder.d.ts +37 -0
- package/dist-unchecked/system/collections/immutable-array-builder.js +117 -0
- package/dist-unchecked/system/collections/immutable-array.d.ts +74 -0
- package/dist-unchecked/system/collections/immutable-array.js +243 -0
- package/dist-unchecked/system/collections/immutable-dictionary-builder.d.ts +58 -0
- package/dist-unchecked/system/collections/immutable-dictionary-builder.js +125 -0
- package/dist-unchecked/system/collections/immutable-dictionary.d.ts +80 -0
- package/dist-unchecked/system/collections/immutable-dictionary.js +284 -0
- package/dist-unchecked/system/collections/immutable-hash-set-builder.d.ts +58 -0
- package/dist-unchecked/system/collections/immutable-hash-set-builder.js +124 -0
- package/dist-unchecked/system/collections/immutable-hash-set.d.ts +71 -0
- package/dist-unchecked/system/collections/immutable-hash-set.js +242 -0
- package/dist-unchecked/system/collections/immutable-interfaces.d.ts +51 -0
- package/dist-unchecked/system/collections/immutable-interfaces.js +0 -0
- package/dist-unchecked/system/collections/immutable-list-builder-core.d.ts +58 -0
- package/dist-unchecked/system/collections/immutable-list-builder-core.js +136 -0
- package/dist-unchecked/system/collections/immutable-list-builder.d.ts +35 -0
- package/dist-unchecked/system/collections/immutable-list-builder.js +72 -0
- package/dist-unchecked/system/collections/immutable-list-core.d.ts +98 -0
- package/dist-unchecked/system/collections/immutable-list-core.js +268 -0
- package/dist-unchecked/system/collections/immutable-list.d.ts +49 -0
- package/dist-unchecked/system/collections/immutable-list.js +176 -0
- package/dist-unchecked/system/collections/immutable-storage.d.ts +50 -0
- package/dist-unchecked/system/collections/immutable-storage.js +83 -0
- package/dist-unchecked/system/collections/index.d.ts +27 -0
- package/dist-unchecked/system/collections/index.js +24 -0
- package/dist-unchecked/system/collections/interfaces.d.ts +76 -0
- package/dist-unchecked/system/collections/interfaces.js +0 -0
- package/dist-unchecked/system/collections/list.d.ts +96 -0
- package/dist-unchecked/system/collections/list.js +332 -0
- package/dist-unchecked/system/collections/queue.d.ts +44 -0
- package/dist-unchecked/system/collections/queue.js +114 -0
- package/dist-unchecked/system/collections/read-only-list.d.ts +45 -0
- package/dist-unchecked/system/collections/read-only-list.js +152 -0
- package/dist-unchecked/system/collections/red-black-tree.d.ts +64 -0
- package/dist-unchecked/system/collections/red-black-tree.js +361 -0
- package/dist-unchecked/system/collections/set-algebra.d.ts +15 -0
- package/dist-unchecked/system/collections/set-algebra.js +58 -0
- package/dist-unchecked/system/collections/sorted-array.d.ts +14 -0
- package/dist-unchecked/system/collections/sorted-array.js +31 -0
- package/dist-unchecked/system/collections/sorted-dictionary.d.ts +64 -0
- package/dist-unchecked/system/collections/sorted-dictionary.js +161 -0
- package/dist-unchecked/system/collections/sorted-list.d.ts +131 -0
- package/dist-unchecked/system/collections/sorted-list.js +300 -0
- package/dist-unchecked/system/collections/sorted-set.d.ts +98 -0
- package/dist-unchecked/system/collections/sorted-set.js +253 -0
- package/dist-unchecked/system/collections/stack.d.ts +39 -0
- package/dist-unchecked/system/collections/stack.js +105 -0
- package/dist-unchecked/system/collections/throw-helpers.d.ts +77 -0
- package/dist-unchecked/system/collections/throw-helpers.js +158 -0
- package/dist-unchecked/system/date-time-offset.d.ts +23 -0
- package/dist-unchecked/system/date-time-offset.js +61 -0
- package/dist-unchecked/system/decimal-parsing.d.ts +18 -0
- package/dist-unchecked/system/decimal-parsing.js +74 -0
- package/dist-unchecked/system/decimal.d.ts +20 -0
- package/dist-unchecked/system/decimal.js +30 -0
- package/dist-unchecked/system/default-text.d.ts +11 -0
- package/dist-unchecked/system/default-text.js +52 -0
- package/dist-unchecked/system/delegates.d.ts +40 -0
- package/dist-unchecked/system/delegates.js +74 -0
- package/dist-unchecked/system/double-format.d.ts +20 -0
- package/dist-unchecked/system/double-format.js +171 -0
- package/dist-unchecked/system/dynamic-conversion.d.ts +37 -0
- package/dist-unchecked/system/dynamic-conversion.js +229 -0
- package/dist-unchecked/system/equality.d.ts +111 -0
- package/dist-unchecked/system/equality.js +392 -0
- package/dist-unchecked/system/exceptions/argument-exception.d.ts +17 -0
- package/dist-unchecked/system/exceptions/argument-exception.js +44 -0
- package/dist-unchecked/system/exceptions/argument-null-exception.d.ts +16 -0
- package/dist-unchecked/system/exceptions/argument-null-exception.js +35 -0
- package/dist-unchecked/system/exceptions/argument-out-of-range-exception.d.ts +18 -0
- package/dist-unchecked/system/exceptions/argument-out-of-range-exception.js +51 -0
- package/dist-unchecked/system/exceptions/arithmetic-exception.d.ts +12 -0
- package/dist-unchecked/system/exceptions/arithmetic-exception.js +31 -0
- package/dist-unchecked/system/exceptions/divide-by-zero-exception.d.ts +12 -0
- package/dist-unchecked/system/exceptions/divide-by-zero-exception.js +31 -0
- package/dist-unchecked/system/exceptions/exception.d.ts +38 -0
- package/dist-unchecked/system/exceptions/exception.js +77 -0
- package/dist-unchecked/system/exceptions/format-exception.d.ts +12 -0
- package/dist-unchecked/system/exceptions/format-exception.js +31 -0
- package/dist-unchecked/system/exceptions/index-out-of-range-exception.d.ts +12 -0
- package/dist-unchecked/system/exceptions/index-out-of-range-exception.js +31 -0
- package/dist-unchecked/system/exceptions/index.d.ts +26 -0
- package/dist-unchecked/system/exceptions/index.js +26 -0
- package/dist-unchecked/system/exceptions/invalid-cast-exception.d.ts +12 -0
- package/dist-unchecked/system/exceptions/invalid-cast-exception.js +31 -0
- package/dist-unchecked/system/exceptions/invalid-operation-exception.d.ts +12 -0
- package/dist-unchecked/system/exceptions/invalid-operation-exception.js +31 -0
- package/dist-unchecked/system/exceptions/json-exception.d.ts +18 -0
- package/dist-unchecked/system/exceptions/json-exception.js +39 -0
- package/dist-unchecked/system/exceptions/key-not-found-exception.d.ts +13 -0
- package/dist-unchecked/system/exceptions/key-not-found-exception.js +34 -0
- package/dist-unchecked/system/exceptions/message-value.d.ts +7 -0
- package/dist-unchecked/system/exceptions/message-value.js +9 -0
- package/dist-unchecked/system/exceptions/missing-method-exception.d.ts +19 -0
- package/dist-unchecked/system/exceptions/missing-method-exception.js +38 -0
- package/dist-unchecked/system/exceptions/named-exception.d.ts +7 -0
- package/dist-unchecked/system/exceptions/named-exception.js +29 -0
- package/dist-unchecked/system/exceptions/not-implemented-exception.d.ts +12 -0
- package/dist-unchecked/system/exceptions/not-implemented-exception.js +31 -0
- package/dist-unchecked/system/exceptions/not-supported-exception.d.ts +12 -0
- package/dist-unchecked/system/exceptions/not-supported-exception.js +31 -0
- package/dist-unchecked/system/exceptions/null-reference-exception.d.ts +12 -0
- package/dist-unchecked/system/exceptions/null-reference-exception.js +31 -0
- package/dist-unchecked/system/exceptions/object-disposed-exception.d.ts +18 -0
- package/dist-unchecked/system/exceptions/object-disposed-exception.js +41 -0
- package/dist-unchecked/system/exceptions/operation-canceled-exception.d.ts +12 -0
- package/dist-unchecked/system/exceptions/operation-canceled-exception.js +31 -0
- package/dist-unchecked/system/exceptions/overflow-exception.d.ts +15 -0
- package/dist-unchecked/system/exceptions/overflow-exception.js +34 -0
- package/dist-unchecked/system/exceptions/switch-expression-exception.d.ts +21 -0
- package/dist-unchecked/system/exceptions/switch-expression-exception.js +49 -0
- package/dist-unchecked/system/exceptions/system-exception.d.ts +12 -0
- package/dist-unchecked/system/exceptions/system-exception.js +31 -0
- package/dist-unchecked/system/exceptions/task-canceled-exception.d.ts +13 -0
- package/dist-unchecked/system/exceptions/task-canceled-exception.js +34 -0
- package/dist-unchecked/system/exceptions/timeout-exception.d.ts +12 -0
- package/dist-unchecked/system/exceptions/timeout-exception.js +31 -0
- package/dist-unchecked/system/exceptions/to-exception.d.ts +25 -0
- package/dist-unchecked/system/exceptions/to-exception.js +53 -0
- package/dist-unchecked/system/exceptions/type-initialization-exception.d.ts +19 -0
- package/dist-unchecked/system/exceptions/type-initialization-exception.js +36 -0
- package/dist-unchecked/system/hash-code.d.ts +28 -0
- package/dist-unchecked/system/hash-code.js +179 -0
- package/dist-unchecked/system/identity-memo.d.ts +7 -0
- package/dist-unchecked/system/identity-memo.js +14 -0
- package/dist-unchecked/system/index.d.ts +35 -0
- package/dist-unchecked/system/index.js +35 -0
- package/dist-unchecked/system/int64-convert.d.ts +59 -0
- package/dist-unchecked/system/int64-convert.js +226 -0
- package/dist-unchecked/system/int64-format.d.ts +13 -0
- package/dist-unchecked/system/int64-format.js +28 -0
- package/dist-unchecked/system/int64-math.d.ts +56 -0
- package/dist-unchecked/system/int64-math.js +109 -0
- package/dist-unchecked/system/int64-parsing.d.ts +45 -0
- package/dist-unchecked/system/int64-parsing.js +153 -0
- package/dist-unchecked/system/int64.d.ts +134 -0
- package/dist-unchecked/system/int64.js +298 -0
- package/dist-unchecked/system/integer-division.d.ts +20 -0
- package/dist-unchecked/system/integer-division.js +17 -0
- package/dist-unchecked/system/integer-format.d.ts +12 -0
- package/dist-unchecked/system/integer-format.js +22 -0
- package/dist-unchecked/system/integer-standard-format.d.ts +9 -0
- package/dist-unchecked/system/integer-standard-format.js +66 -0
- package/dist-unchecked/system/json/byte-array-converter.d.ts +19 -0
- package/dist-unchecked/system/json/byte-array-converter.js +106 -0
- package/dist-unchecked/system/json/container-depth.d.ts +30 -0
- package/dist-unchecked/system/json/container-depth.js +84 -0
- package/dist-unchecked/system/json/contract-name.d.ts +15 -0
- package/dist-unchecked/system/json/contract-name.js +33 -0
- package/dist-unchecked/system/json/converter-set-cache.d.ts +17 -0
- package/dist-unchecked/system/json/converter-set-cache.js +26 -0
- package/dist-unchecked/system/json/converters.d.ts +52 -0
- package/dist-unchecked/system/json/converters.js +677 -0
- package/dist-unchecked/system/json/decimal-text.d.ts +9 -0
- package/dist-unchecked/system/json/decimal-text.js +125 -0
- package/dist-unchecked/system/json/dictionary-keys.d.ts +31 -0
- package/dist-unchecked/system/json/dictionary-keys.js +195 -0
- package/dist-unchecked/system/json/errors.d.ts +18 -0
- package/dist-unchecked/system/json/errors.js +18 -0
- package/dist-unchecked/system/json/exact-json-number.d.ts +103 -0
- package/dist-unchecked/system/json/exact-json-number.js +155 -0
- package/dist-unchecked/system/json/exact-number-reads.d.ts +21 -0
- package/dist-unchecked/system/json/exact-number-reads.js +104 -0
- package/dist-unchecked/system/json/index.d.ts +7 -0
- package/dist-unchecked/system/json/index.js +6 -0
- package/dist-unchecked/system/json/json-serializer.d.ts +102 -0
- package/dist-unchecked/system/json/json-serializer.js +114 -0
- package/dist-unchecked/system/json/json-text-reader.d.ts +33 -0
- package/dist-unchecked/system/json/json-text-reader.js +608 -0
- package/dist-unchecked/system/json/null-reads.d.ts +22 -0
- package/dist-unchecked/system/json/null-reads.js +43 -0
- package/dist-unchecked/system/json/number-from-string.d.ts +44 -0
- package/dist-unchecked/system/json/number-from-string.js +248 -0
- package/dist-unchecked/system/json/numeric-converters.d.ts +65 -0
- package/dist-unchecked/system/json/numeric-converters.js +361 -0
- package/dist-unchecked/system/json/numeric-enum-members.d.ts +18 -0
- package/dist-unchecked/system/json/numeric-enum-members.js +18 -0
- package/dist-unchecked/system/json/ordinal-ignore-case.d.ts +14 -0
- package/dist-unchecked/system/json/ordinal-ignore-case.js +60 -0
- package/dist-unchecked/system/json/polymorphism.d.ts +26 -0
- package/dist-unchecked/system/json/polymorphism.js +430 -0
- package/dist-unchecked/system/json/property-lookup.d.ts +17 -0
- package/dist-unchecked/system/json/property-lookup.js +32 -0
- package/dist-unchecked/system/json/property-naming-policy.d.ts +14 -0
- package/dist-unchecked/system/json/property-naming-policy.js +206 -0
- package/dist-unchecked/system/json/public-json-shape.d.ts +13 -0
- package/dist-unchecked/system/json/public-json-shape.js +38 -0
- package/dist-unchecked/system/json/serializer-context.d.ts +59 -0
- package/dist-unchecked/system/json/serializer-context.js +85 -0
- package/dist-unchecked/system/json/spec-kind.d.ts +3 -0
- package/dist-unchecked/system/json/spec-kind.js +4 -0
- package/dist-unchecked/system/json/temporal-reads.d.ts +15 -0
- package/dist-unchecked/system/json/temporal-reads.js +423 -0
- package/dist-unchecked/system/json/temporal-text.d.ts +16 -0
- package/dist-unchecked/system/json/temporal-text.js +32 -0
- package/dist-unchecked/system/json/types.d.ts +347 -0
- package/dist-unchecked/system/json/types.js +0 -0
- package/dist-unchecked/system/json/value-converter.d.ts +5 -0
- package/dist-unchecked/system/json/value-converter.js +0 -0
- package/dist-unchecked/system/lazy-value.d.ts +9 -0
- package/dist-unchecked/system/lazy-value.js +19 -0
- package/dist-unchecked/system/linq/compare-keys.d.ts +8 -0
- package/dist-unchecked/system/linq/compare-keys.js +37 -0
- package/dist-unchecked/system/linq/decimal-terminals.d.ts +24 -0
- package/dist-unchecked/system/linq/decimal-terminals.js +67 -0
- package/dist-unchecked/system/linq/expr-tree-visitor.d.ts +148 -0
- package/dist-unchecked/system/linq/expr-tree-visitor.js +479 -0
- package/dist-unchecked/system/linq/expr-tree.d.ts +166 -0
- package/dist-unchecked/system/linq/expr-tree.js +18 -0
- package/dist-unchecked/system/linq/index.d.ts +32 -0
- package/dist-unchecked/system/linq/index.js +27 -0
- package/dist-unchecked/system/linq/int64-terminals.d.ts +33 -0
- package/dist-unchecked/system/linq/int64-terminals.js +131 -0
- package/dist-unchecked/system/linq/linq.d.ts +107 -0
- package/dist-unchecked/system/linq/linq.js +46 -0
- package/dist-unchecked/system/linq/operators.d.ts +40 -0
- package/dist-unchecked/system/linq/operators.js +410 -0
- package/dist-unchecked/system/linq/terminals.d.ts +100 -0
- package/dist-unchecked/system/linq/terminals.js +467 -0
- package/dist-unchecked/system/linq/types.d.ts +330 -0
- package/dist-unchecked/system/linq/types.js +0 -0
- package/dist-unchecked/system/math.d.ts +55 -0
- package/dist-unchecked/system/math.js +141 -0
- package/dist-unchecked/system/number-parsing.d.ts +58 -0
- package/dist-unchecked/system/number-parsing.js +174 -0
- package/dist-unchecked/system/record-copy.d.ts +26 -0
- package/dist-unchecked/system/record-copy.js +72 -0
- package/dist-unchecked/system/reflection/box.d.ts +19 -0
- package/dist-unchecked/system/reflection/box.js +32 -0
- package/dist-unchecked/system/reflection/boxed-text.d.ts +8 -0
- package/dist-unchecked/system/reflection/boxed-text.js +31 -0
- package/dist-unchecked/system/reflection/cast-to.d.ts +15 -0
- package/dist-unchecked/system/reflection/cast-to.js +32 -0
- package/dist-unchecked/system/reflection/constructor-descriptor.d.ts +11 -0
- package/dist-unchecked/system/reflection/constructor-descriptor.js +22 -0
- package/dist-unchecked/system/reflection/create-instance.d.ts +6 -0
- package/dist-unchecked/system/reflection/create-instance.js +11 -0
- package/dist-unchecked/system/reflection/decimal-type-defaults.d.ts +7 -0
- package/dist-unchecked/system/reflection/decimal-type-defaults.js +17 -0
- package/dist-unchecked/system/reflection/enum-from-raw.d.ts +14 -0
- package/dist-unchecked/system/reflection/enum-from-raw.js +89 -0
- package/dist-unchecked/system/reflection/enum-is-defined.d.ts +7 -0
- package/dist-unchecked/system/reflection/enum-is-defined.js +14 -0
- package/dist-unchecked/system/reflection/get-number-type.d.ts +7 -0
- package/dist-unchecked/system/reflection/get-number-type.js +10 -0
- package/dist-unchecked/system/reflection/get-runtime-type-from-type.d.ts +6 -0
- package/dist-unchecked/system/reflection/get-runtime-type-from-type.js +22 -0
- package/dist-unchecked/system/reflection/get-runtime-type.d.ts +3 -0
- package/dist-unchecked/system/reflection/get-runtime-type.js +105 -0
- package/dist-unchecked/system/reflection/implements-interface.d.ts +10 -0
- package/dist-unchecked/system/reflection/implements-interface.js +26 -0
- package/dist-unchecked/system/reflection/index.d.ts +27 -0
- package/dist-unchecked/system/reflection/index.js +26 -0
- package/dist-unchecked/system/reflection/invalid-cast.d.ts +8 -0
- package/dist-unchecked/system/reflection/invalid-cast.js +33 -0
- package/dist-unchecked/system/reflection/is-assignable-from.d.ts +13 -0
- package/dist-unchecked/system/reflection/is-assignable-from.js +121 -0
- package/dist-unchecked/system/reflection/is-box-of.d.ts +3 -0
- package/dist-unchecked/system/reflection/is-box-of.js +5 -0
- package/dist-unchecked/system/reflection/is-boxed.d.ts +7 -0
- package/dist-unchecked/system/reflection/is-boxed.js +9 -0
- package/dist-unchecked/system/reflection/is-type.d.ts +12 -0
- package/dist-unchecked/system/reflection/is-type.js +20 -0
- package/dist-unchecked/system/reflection/nullable-type.d.ts +3 -0
- package/dist-unchecked/system/reflection/nullable-type.js +19 -0
- package/dist-unchecked/system/reflection/opaque-type.d.ts +6 -0
- package/dist-unchecked/system/reflection/opaque-type.js +22 -0
- package/dist-unchecked/system/reflection/primitive-types.d.ts +20 -0
- package/dist-unchecked/system/reflection/primitive-types.js +160 -0
- package/dist-unchecked/system/reflection/runtime-type.d.ts +131 -0
- package/dist-unchecked/system/reflection/runtime-type.js +5 -0
- package/dist-unchecked/system/reflection/specialize-collection.d.ts +11 -0
- package/dist-unchecked/system/reflection/specialize-collection.js +93 -0
- package/dist-unchecked/system/reflection/specialize.d.ts +7 -0
- package/dist-unchecked/system/reflection/specialize.js +33 -0
- package/dist-unchecked/system/reflection/temporal-type-defaults.d.ts +11 -0
- package/dist-unchecked/system/reflection/temporal-type-defaults.js +61 -0
- package/dist-unchecked/system/reflection/temporal-types.d.ts +7 -0
- package/dist-unchecked/system/reflection/temporal-types.js +44 -0
- package/dist-unchecked/system/reflection/to-string-tag.d.ts +6 -0
- package/dist-unchecked/system/reflection/to-string-tag.js +8 -0
- package/dist-unchecked/system/reflection/tuple-type.d.ts +6 -0
- package/dist-unchecked/system/reflection/tuple-type.js +23 -0
- package/dist-unchecked/system/reflection/unbox-for-cast.d.ts +10 -0
- package/dist-unchecked/system/reflection/unbox-for-cast.js +28 -0
- package/dist-unchecked/system/reflection/unbox-for.d.ts +9 -0
- package/dist-unchecked/system/reflection/unbox-for.js +15 -0
- package/dist-unchecked/system/reflection/unbox.d.ts +5 -0
- package/dist-unchecked/system/reflection/unbox.js +8 -0
- package/dist-unchecked/system/reflection/unsupported-type.d.ts +7 -0
- package/dist-unchecked/system/reflection/unsupported-type.js +27 -0
- package/dist-unchecked/system/reflection/well-known-types.d.ts +13 -0
- package/dist-unchecked/system/reflection/well-known-types.js +32 -0
- package/dist-unchecked/system/reflection/with-implementers.d.ts +8 -0
- package/dist-unchecked/system/reflection/with-implementers.js +23 -0
- package/dist-unchecked/system/standard-numeric-format.d.ts +67 -0
- package/dist-unchecked/system/standard-numeric-format.js +213 -0
- package/dist-unchecked/system/string-members.d.ts +170 -0
- package/dist-unchecked/system/string-members.js +445 -0
- package/dist-unchecked/system/strings.d.ts +42 -0
- package/dist-unchecked/system/strings.js +66 -0
- package/dist-unchecked/system/temporal-helpers.d.ts +43 -0
- package/dist-unchecked/system/temporal-helpers.js +127 -0
- package/dist-unchecked/system/time-span-format.d.ts +3 -0
- package/dist-unchecked/system/time-span-format.js +17 -0
- package/dist-unchecked/system/time-span.d.ts +33 -0
- package/dist-unchecked/system/time-span.js +90 -0
- package/dist-unchecked/system/type-initializer.d.ts +14 -0
- package/dist-unchecked/system/type-initializer.js +36 -0
- package/dist-unchecked/system/uuid.d.ts +68 -0
- package/dist-unchecked/system/uuid.js +124 -0
- package/dist-unchecked/type-checking/index.d.ts +1 -0
- package/dist-unchecked/type-checking/index.js +1 -0
- package/dist-unchecked/type-checking/primitive-type-checks.d.ts +45 -0
- package/dist-unchecked/type-checking/primitive-type-checks.js +81 -0
- package/package.json +88 -10
- package/src/index.ts +2 -0
- package/src/system/argument-guards.ts +253 -0
- package/src/system/array-length.ts +19 -0
- package/src/system/big-integer.ts +135 -0
- package/src/system/bind-receiver.ts +32 -0
- package/src/system/boolean-format.ts +13 -0
- package/src/system/collections/builder-iterator.ts +30 -0
- package/src/system/collections/checks.ts +18 -0
- package/src/system/collections/close-collection.ts +127 -0
- package/src/system/collections/collection-type-name.ts +37 -0
- package/src/system/collections/concurrent-dictionary.ts +396 -0
- package/src/system/collections/copy-to.ts +52 -0
- package/src/system/collections/default-comparer.ts +334 -0
- package/src/system/collections/descriptors.ts +310 -0
- package/src/system/collections/dictionary-helpers.ts +18 -0
- package/src/system/collections/dictionary-views.ts +231 -0
- package/src/system/collections/dictionary.ts +325 -0
- package/src/system/collections/hash-core.ts +232 -0
- package/src/system/collections/hash-set.ts +302 -0
- package/src/system/collections/helpers.ts +92 -0
- package/src/system/collections/immutable-array-builder.ts +160 -0
- package/src/system/collections/immutable-array.ts +352 -0
- package/src/system/collections/immutable-dictionary-builder.ts +238 -0
- package/src/system/collections/immutable-dictionary.ts +493 -0
- package/src/system/collections/immutable-hash-set-builder.ts +218 -0
- package/src/system/collections/immutable-hash-set.ts +362 -0
- package/src/system/collections/immutable-interfaces.ts +58 -0
- package/src/system/collections/immutable-list-builder-core.ts +204 -0
- package/src/system/collections/immutable-list-builder.ts +146 -0
- package/src/system/collections/immutable-list-core.ts +419 -0
- package/src/system/collections/immutable-list.ts +257 -0
- package/src/system/collections/immutable-storage.ts +107 -0
- package/src/system/collections/index.ts +27 -0
- package/src/system/collections/interfaces.ts +84 -0
- package/src/system/collections/list.ts +680 -0
- package/src/system/collections/queue.ts +240 -0
- package/src/system/collections/read-only-list.ts +210 -0
- package/src/system/collections/red-black-tree.ts +485 -0
- package/src/system/collections/set-algebra.ts +89 -0
- package/src/system/collections/sorted-array.ts +43 -0
- package/src/system/collections/sorted-dictionary.ts +322 -0
- package/src/system/collections/sorted-list.ts +566 -0
- package/src/system/collections/sorted-set.ts +483 -0
- package/src/system/collections/stack.ts +201 -0
- package/src/system/collections/throw-helpers.ts +240 -0
- package/src/system/date-time-offset.ts +102 -0
- package/src/system/decimal-parsing.ts +102 -0
- package/src/system/decimal.ts +36 -0
- package/src/system/default-text.ts +73 -0
- package/src/system/delegates.ts +83 -0
- package/src/system/double-format.ts +234 -0
- package/src/system/dynamic-conversion.ts +337 -0
- package/src/system/equality.ts +448 -0
- package/src/system/exceptions/argument-exception.ts +51 -0
- package/src/system/exceptions/argument-null-exception.ts +42 -0
- package/src/system/exceptions/argument-out-of-range-exception.ts +65 -0
- package/src/system/exceptions/arithmetic-exception.ts +37 -0
- package/src/system/exceptions/divide-by-zero-exception.ts +38 -0
- package/src/system/exceptions/exception.ts +91 -0
- package/src/system/exceptions/format-exception.ts +37 -0
- package/src/system/exceptions/index-out-of-range-exception.ts +38 -0
- package/src/system/exceptions/index.ts +26 -0
- package/src/system/exceptions/invalid-cast-exception.ts +38 -0
- package/src/system/exceptions/invalid-operation-exception.ts +39 -0
- package/src/system/exceptions/json-exception.ts +46 -0
- package/src/system/exceptions/key-not-found-exception.ts +42 -0
- package/src/system/exceptions/message-value.ts +9 -0
- package/src/system/exceptions/missing-method-exception.ts +45 -0
- package/src/system/exceptions/named-exception.ts +43 -0
- package/src/system/exceptions/not-implemented-exception.ts +38 -0
- package/src/system/exceptions/not-supported-exception.ts +38 -0
- package/src/system/exceptions/null-reference-exception.ts +38 -0
- package/src/system/exceptions/object-disposed-exception.ts +49 -0
- package/src/system/exceptions/operation-canceled-exception.ts +38 -0
- package/src/system/exceptions/overflow-exception.ts +40 -0
- package/src/system/exceptions/switch-expression-exception.ts +62 -0
- package/src/system/exceptions/system-exception.ts +37 -0
- package/src/system/exceptions/task-canceled-exception.ts +42 -0
- package/src/system/exceptions/timeout-exception.ts +37 -0
- package/src/system/exceptions/to-exception.ts +70 -0
- package/src/system/exceptions/type-initialization-exception.ts +42 -0
- package/src/system/hash-code.ts +202 -0
- package/src/system/identity-memo.ts +25 -0
- package/src/system/index.ts +35 -0
- package/src/system/int64-convert.ts +326 -0
- package/src/system/int64-format.ts +37 -0
- package/src/system/int64-math.ts +137 -0
- package/src/system/int64-parsing.ts +243 -0
- package/src/system/int64.ts +446 -0
- package/src/system/integer-division.ts +41 -0
- package/src/system/integer-format.ts +34 -0
- package/src/system/integer-standard-format.ts +103 -0
- package/src/system/json/byte-array-converter.ts +148 -0
- package/src/system/json/container-depth.ts +101 -0
- package/src/system/json/contract-name.ts +39 -0
- package/src/system/json/converter-set-cache.ts +55 -0
- package/src/system/json/converters.ts +1040 -0
- package/src/system/json/decimal-text.ts +174 -0
- package/src/system/json/dictionary-keys.ts +293 -0
- package/src/system/json/errors.ts +19 -0
- package/src/system/json/exact-json-number.ts +196 -0
- package/src/system/json/exact-number-reads.ts +136 -0
- package/src/system/json/index.ts +35 -0
- package/src/system/json/json-serializer.ts +259 -0
- package/src/system/json/json-text-reader.ts +799 -0
- package/src/system/json/null-reads.ts +47 -0
- package/src/system/json/number-from-string.ts +372 -0
- package/src/system/json/numeric-converters.ts +495 -0
- package/src/system/json/numeric-enum-members.ts +35 -0
- package/src/system/json/ordinal-ignore-case.ts +74 -0
- package/src/system/json/polymorphism.ts +650 -0
- package/src/system/json/property-lookup.ts +63 -0
- package/src/system/json/property-naming-policy.ts +258 -0
- package/src/system/json/public-json-shape.ts +43 -0
- package/src/system/json/serializer-context.ts +105 -0
- package/src/system/json/spec-kind.ts +6 -0
- package/src/system/json/temporal-reads.ts +606 -0
- package/src/system/json/temporal-text.ts +48 -0
- package/src/system/json/types.ts +433 -0
- package/src/system/json/value-converter.ts +5 -0
- package/src/system/lazy-value.ts +21 -0
- package/src/system/linq/compare-keys.ts +38 -0
- package/src/system/linq/decimal-terminals.ts +122 -0
- package/src/system/linq/expr-tree-visitor.ts +568 -0
- package/src/system/linq/expr-tree.ts +213 -0
- package/src/system/linq/index.ts +181 -0
- package/src/system/linq/int64-terminals.ts +199 -0
- package/src/system/linq/linq.ts +1816 -0
- package/src/system/linq/operators.ts +491 -0
- package/src/system/linq/terminals.ts +672 -0
- package/src/system/linq/types.ts +484 -0
- package/src/system/math.ts +182 -0
- package/src/system/number-parsing.ts +242 -0
- package/src/system/record-copy.ts +89 -0
- package/src/system/reflection/box.ts +38 -0
- package/src/system/reflection/boxed-text.ts +42 -0
- package/src/system/reflection/cast-to.ts +43 -0
- package/src/system/reflection/constructor-descriptor.ts +28 -0
- package/src/system/reflection/create-instance.ts +14 -0
- package/src/system/reflection/decimal-type-defaults.ts +20 -0
- package/src/system/reflection/enum-from-raw.ts +131 -0
- package/src/system/reflection/enum-is-defined.ts +18 -0
- package/src/system/reflection/get-number-type.ts +12 -0
- package/src/system/reflection/get-runtime-type-from-type.ts +33 -0
- package/src/system/reflection/get-runtime-type.ts +145 -0
- package/src/system/reflection/implements-interface.ts +40 -0
- package/src/system/reflection/index.ts +44 -0
- package/src/system/reflection/invalid-cast.ts +46 -0
- package/src/system/reflection/is-assignable-from.ts +161 -0
- package/src/system/reflection/is-box-of.ts +7 -0
- package/src/system/reflection/is-boxed.ts +17 -0
- package/src/system/reflection/is-type.ts +25 -0
- package/src/system/reflection/nullable-type.ts +27 -0
- package/src/system/reflection/opaque-type.ts +30 -0
- package/src/system/reflection/primitive-types.ts +197 -0
- package/src/system/reflection/runtime-type.ts +220 -0
- package/src/system/reflection/specialize-collection.ts +161 -0
- package/src/system/reflection/specialize.ts +52 -0
- package/src/system/reflection/temporal-type-defaults.ts +78 -0
- package/src/system/reflection/temporal-types.ts +57 -0
- package/src/system/reflection/to-string-tag.ts +8 -0
- package/src/system/reflection/tuple-type.ts +32 -0
- package/src/system/reflection/unbox-for-cast.ts +31 -0
- package/src/system/reflection/unbox-for.ts +19 -0
- package/src/system/reflection/unbox.ts +9 -0
- package/src/system/reflection/unsupported-type.ts +35 -0
- package/src/system/reflection/well-known-types.ts +50 -0
- package/src/system/reflection/with-implementers.ts +33 -0
- package/src/system/standard-numeric-format.ts +334 -0
- package/src/system/string-members.ts +641 -0
- package/src/system/strings.ts +83 -0
- package/src/system/temporal-helpers.ts +183 -0
- package/src/system/time-span-format.ts +21 -0
- package/src/system/time-span.ts +126 -0
- package/src/system/type-initializer.ts +41 -0
- package/src/system/uuid.ts +163 -0
- package/src/type-checking/index.ts +1 -0
- package/src/type-checking/primitive-type-checks.ts +113 -0
- package/dist/system/collections/immutable-collection.d.ts +0 -31
- package/dist/system/collections/immutable-collection.js +0 -58
- package/dist/system/collections/list-helpers.d.ts +0 -43
- package/dist/system/collections/list-helpers.js +0 -58
- package/dist/system/json/union-guard-registry.d.ts +0 -30
- package/dist/system/json/union-guard-registry.js +0 -34
|
@@ -0,0 +1,799 @@
|
|
|
1
|
+
import type { JsonContainer } from "./container-depth.ts";
|
|
2
|
+
import { JsonException } from "./errors.ts";
|
|
3
|
+
import {
|
|
4
|
+
JsonNonIntegerNumber,
|
|
5
|
+
JsonNumberText,
|
|
6
|
+
type NumberTextLeaves,
|
|
7
|
+
} from "./exact-json-number.ts";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Reads JSON text into the tree `JSON.parse` builds (#457), for
|
|
11
|
+
* `JsonSerializer.deserializeText`:
|
|
12
|
+
*
|
|
13
|
+
* - `parseJsonText` is `JSON.parse`, throwing System.Text.Json's
|
|
14
|
+
* `JsonException` for invalid text instead of the engine's `SyntaxError`;
|
|
15
|
+
* - `readJsonText` tokenizes the text itself and keeps every number with more
|
|
16
|
+
* significant digits than a double holds as a `JsonNumberText` leaf, so a
|
|
17
|
+
* `decimal` is built from its source digits — and, asked for
|
|
18
|
+
* `inexactOrNonInteger` leaves, marks every other number with a fraction
|
|
19
|
+
* or an exponent as a `JsonNonIntegerNumber`, so a `long` / `ulong` sees
|
|
20
|
+
* the token shape a double erases (spec 012 FR-053).
|
|
21
|
+
*
|
|
22
|
+
* Both accept exactly what `JSON.parse` accepts (lone surrogates included,
|
|
23
|
+
* which STJ rejects) and build the same tree: the last of duplicate keys
|
|
24
|
+
* wins at the first key's position, and `__proto__` is an own property. The
|
|
25
|
+
* tokenizer rejects what STJ's reader rejects with its message (measured on
|
|
26
|
+
* .NET 10.0.12, without the `Path` suffix, DECIDED-5), in document order.
|
|
27
|
+
* FR-016's limit of 64 is left to the contract walk, which counts the
|
|
28
|
+
* containers it reads, as for a tree `JSON.parse` built; the tokenizer only
|
|
29
|
+
* bounds its own recursion (`MAX_TEXT_DEPTH`).
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The deepest nesting the recursive tokenizer reads: a third of what Node's
|
|
34
|
+
* default stack held in a measurement (about 3 200 containers; Bun about
|
|
35
|
+
* 20 000), far past FR-016's 64. `JSON.parse` reads deeper documents, so a
|
|
36
|
+
* text nested past it is the one case where the two paths differ. A caller
|
|
37
|
+
* already deep in the stack can run out of it sooner; `readJsonText` then
|
|
38
|
+
* throws the same `JsonException` instead of the `RangeError`. That path has
|
|
39
|
+
* no test: how many frames remain at a given depth differs between engines
|
|
40
|
+
* and JIT tiers (a probe that backed off a measured edge read 1000 levels on
|
|
41
|
+
* Bun at every distance and overflowed in the probe itself on Node).
|
|
42
|
+
*/
|
|
43
|
+
const MAX_TEXT_DEPTH = 1000;
|
|
44
|
+
|
|
45
|
+
/** The message for a text deeper than {@link MAX_TEXT_DEPTH} (1000) levels. */
|
|
46
|
+
const TOO_DEEP =
|
|
47
|
+
// 1000: keep in sync with MAX_TEXT_DEPTH (a substitution would keep the message at load).
|
|
48
|
+
"The JSON text nests containers deeper than 1000 levels, which " +
|
|
49
|
+
"deserializeText does not read.";
|
|
50
|
+
|
|
51
|
+
/** A number text with at most this many significant digits is exact as a double. */
|
|
52
|
+
const DOUBLE_EXACT_DIGITS = 15;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The shortest run of `[0-9.]` that can hold a mantissa of more than 15 digits:
|
|
56
|
+
* {@link DOUBLE_EXACT_DIGITS} + 1, written as its value; keep the two in sync.
|
|
57
|
+
*/
|
|
58
|
+
const INEXACT_RUN_LENGTH = 16;
|
|
59
|
+
|
|
60
|
+
const TAB = 0x09;
|
|
61
|
+
const LINE_FEED = 0x0a;
|
|
62
|
+
const CARRIAGE_RETURN = 0x0d;
|
|
63
|
+
const SPACE = 0x20;
|
|
64
|
+
const QUOTE = 0x22;
|
|
65
|
+
const PLUS = 0x2b;
|
|
66
|
+
const COMMA = 0x2c;
|
|
67
|
+
const MINUS = 0x2d;
|
|
68
|
+
const DOT = 0x2e;
|
|
69
|
+
const SLASH = 0x2f;
|
|
70
|
+
const ZERO = 0x30;
|
|
71
|
+
const NINE = 0x39;
|
|
72
|
+
const COLON = 0x3a;
|
|
73
|
+
const UPPER_E = 0x45;
|
|
74
|
+
const OPEN_BRACKET = 0x5b;
|
|
75
|
+
const BACKSLASH = 0x5c;
|
|
76
|
+
const CLOSE_BRACKET = 0x5d;
|
|
77
|
+
const LOWER_E = 0x65;
|
|
78
|
+
const LOWER_F = 0x66;
|
|
79
|
+
const LOWER_N = 0x6e;
|
|
80
|
+
const LOWER_T = 0x74;
|
|
81
|
+
const LOWER_U = 0x75;
|
|
82
|
+
const OPEN_BRACE = 0x7b;
|
|
83
|
+
const CLOSE_BRACE = 0x7d;
|
|
84
|
+
const LAST_PRINTABLE = 0x7e;
|
|
85
|
+
|
|
86
|
+
/** The characters `\` may escape besides `u`: `"`, `\`, `/`, `b`, `f`, `n`, `r`, `t`. */
|
|
87
|
+
const SIMPLE_ESCAPES = /* @__PURE__ */ new Set([0x22, 0x5c, 0x2f, 0x62, 0x66, 0x6e, 0x72, 0x74]);
|
|
88
|
+
|
|
89
|
+
const UNICODE_ESCAPE_DIGITS = 4;
|
|
90
|
+
|
|
91
|
+
const NO_TOKENS =
|
|
92
|
+
"The input does not contain any JSON tokens. Expected the input to start with a valid JSON " +
|
|
93
|
+
"token, when isFinalBlock is true.";
|
|
94
|
+
|
|
95
|
+
const OPEN_CONTAINER =
|
|
96
|
+
"Expected depth to be zero at the end of the JSON payload. There is an open JSON object or " +
|
|
97
|
+
"array that should be closed.";
|
|
98
|
+
|
|
99
|
+
const NOTHING_AFTER_COMMA =
|
|
100
|
+
"Expected start of a property name or value, but instead reached end of data.";
|
|
101
|
+
|
|
102
|
+
const NOTHING_AFTER_PROPERTY_NAME = "Expected a value, but instead reached end of data.";
|
|
103
|
+
|
|
104
|
+
const UNTERMINATED_STRING = "Expected end of string, but instead reached end of data.";
|
|
105
|
+
|
|
106
|
+
const UNTERMINATED_NUMBER = "Expected a digit ('0'-'9'), but instead reached end of data.";
|
|
107
|
+
|
|
108
|
+
const SHOULD_BE_ESCAPED = "The string should be correctly escaped.";
|
|
109
|
+
|
|
110
|
+
const EXPECTED_DIGIT = "Expected a digit ('0'-'9').";
|
|
111
|
+
|
|
112
|
+
const AFTER_VALUE = "is invalid after a value. Expected either ',', '}', or ']'.";
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Whether a number of `text` can have a mantissa of more than 15 digits. Such
|
|
116
|
+
* a mantissa is a run of 16 `[0-9.]` characters or more, and every such run
|
|
117
|
+
* covers an index that is 15 modulo 16, so only those indexes are probed. A
|
|
118
|
+
* digit run inside a string (`"card 4111111111111111"`) can answer `true`
|
|
119
|
+
* for a text without such a number; the tokenizer then reads the same tree
|
|
120
|
+
* `JSON.parse` would, only more slowly.
|
|
121
|
+
*/
|
|
122
|
+
export function mayHoldInexactNumber(text: string): boolean {
|
|
123
|
+
const { length } = text;
|
|
124
|
+
|
|
125
|
+
for (let probe = INEXACT_RUN_LENGTH - 1; probe < length; probe += INEXACT_RUN_LENGTH) {
|
|
126
|
+
if (isNumberRunCode(text.charCodeAt(probe)) && hasInexactRunAt(text, probe)) {
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** Whether the `[0-9.]` run through `index` is long enough to hold an inexact number. */
|
|
135
|
+
function hasInexactRunAt(text: string, index: number): boolean {
|
|
136
|
+
let start = index;
|
|
137
|
+
let end = index + 1;
|
|
138
|
+
|
|
139
|
+
while (start > 0 && isNumberRunCode(text.charCodeAt(start - 1))) {
|
|
140
|
+
start--;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
while (end < text.length && isNumberRunCode(text.charCodeAt(end))) {
|
|
144
|
+
end++;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return end - start >= INEXACT_RUN_LENGTH;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function isNumberRunCode(code: number): boolean {
|
|
151
|
+
return isDigit(code) || code === DOT;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* A digit followed by `.`, `e` or `E`: every number with a fraction or an
|
|
156
|
+
* exponent holds one. Inside a string (`"v1.0"`, a GUID's `"3e4f…"`) it
|
|
157
|
+
* answers `true` for a text without such a number; the tokenizer then reads
|
|
158
|
+
* the same tree `JSON.parse` would, only more slowly.
|
|
159
|
+
*/
|
|
160
|
+
const NON_INTEGER_NUMBER_PATTERN = /[0-9][.eE]/;
|
|
161
|
+
|
|
162
|
+
/** Whether a number of `text` can have a fraction or an exponent. */
|
|
163
|
+
export function mayHoldNonIntegerNumber(text: string): boolean {
|
|
164
|
+
return NON_INTEGER_NUMBER_PATTERN.test(text);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Whether `readJsonText(text, leaves)` can build a number leaf (a
|
|
169
|
+
* `JsonNumberText` or a `JsonNonIntegerNumber`); when it cannot,
|
|
170
|
+
* `JSON.parse` builds the same tree, faster.
|
|
171
|
+
*/
|
|
172
|
+
export function mayHoldNumberTextLeaf(text: string, leaves: NumberTextLeaves): boolean {
|
|
173
|
+
if (mayHoldInexactNumber(text)) {
|
|
174
|
+
return true;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return leaves === "inexactOrNonInteger" && mayHoldNonIntegerNumber(text);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** `JSON.parse(text)`, throwing System.Text.Json's `JsonException` for invalid text. */
|
|
181
|
+
export function parseJsonText(text: string): unknown {
|
|
182
|
+
try {
|
|
183
|
+
return JSON.parse(text);
|
|
184
|
+
} catch (error) {
|
|
185
|
+
if (error instanceof SyntaxError) {
|
|
186
|
+
// Throws the JsonException; should it accept the text, the engine's error stands.
|
|
187
|
+
readJsonText(text);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
throw error;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* The tree `JSON.parse(text)` builds, except that a number whose mantissa has
|
|
196
|
+
* more than 15 digits past a zero integer part is a `JsonNumberText` leaf —
|
|
197
|
+
* and, for `inexactOrNonInteger` leaves, every other number with a fraction
|
|
198
|
+
* or an exponent is a `JsonNonIntegerNumber` holding its double. `leaves`
|
|
199
|
+
* defaults to `inexact` for `parseJsonText`, which reads the text only for
|
|
200
|
+
* its syntax error, and the leaves do not change the errors. Strings are
|
|
201
|
+
* copied, so the tree never keeps `text` alive (a slice would, on
|
|
202
|
+
* JavaScriptCore). A caller already deep in the stack can run out of it
|
|
203
|
+
* before `MAX_TEXT_DEPTH`; the stack overflow then throws the same
|
|
204
|
+
* `JsonException` as the bound.
|
|
205
|
+
*/
|
|
206
|
+
export function readJsonText(text: string, leaves: NumberTextLeaves = "inexact"): unknown {
|
|
207
|
+
try {
|
|
208
|
+
return new JsonTextReader(text, leaves === "inexactOrNonInteger").readDocument();
|
|
209
|
+
} catch (error) {
|
|
210
|
+
if (isStackOverflow(error)) {
|
|
211
|
+
throw new JsonException(TOO_DEEP);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
throw error;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** V8 and JavaScriptCore both say "Maximum call stack size exceeded". */
|
|
219
|
+
function isStackOverflow(error: unknown): boolean {
|
|
220
|
+
return error instanceof RangeError && /call stack/i.test(error.message);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/** A recursive-descent reader over the UTF-16 code units of one JSON document. */
|
|
224
|
+
class JsonTextReader {
|
|
225
|
+
private position = 0;
|
|
226
|
+
private depth = 0;
|
|
227
|
+
|
|
228
|
+
constructor(
|
|
229
|
+
private readonly text: string,
|
|
230
|
+
private readonly marksNonIntegers: boolean,
|
|
231
|
+
) {}
|
|
232
|
+
|
|
233
|
+
readDocument(): unknown {
|
|
234
|
+
const first = this.skipWhitespace();
|
|
235
|
+
|
|
236
|
+
if (isEnd(first)) {
|
|
237
|
+
throw new JsonException(NO_TOKENS);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const value = this.readValue(first);
|
|
241
|
+
|
|
242
|
+
if (!isEnd(this.skipWhitespace())) {
|
|
243
|
+
throw this.unexpected("is invalid after a single JSON value. Expected end of data.");
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
return value;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/** Reads the value whose first code, `code`, is at the current position. */
|
|
250
|
+
private readValue(code: number): unknown {
|
|
251
|
+
switch (code) {
|
|
252
|
+
case QUOTE:
|
|
253
|
+
return this.readString();
|
|
254
|
+
case OPEN_BRACE:
|
|
255
|
+
return this.readObject();
|
|
256
|
+
case OPEN_BRACKET:
|
|
257
|
+
return this.readArray();
|
|
258
|
+
case LOWER_T:
|
|
259
|
+
return this.readLiteral("true", true);
|
|
260
|
+
case LOWER_F:
|
|
261
|
+
return this.readLiteral("false", false);
|
|
262
|
+
case LOWER_N:
|
|
263
|
+
return this.readLiteral("null", null);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
if (code === MINUS || isDigit(code)) {
|
|
267
|
+
return this.readNumber();
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
throw this.unexpected("is an invalid start of a value.");
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// ─── Containers ────────────────────────────────────────────────────────────
|
|
274
|
+
|
|
275
|
+
private readObject(): Record<string, unknown> {
|
|
276
|
+
const result: Record<string, unknown> = {};
|
|
277
|
+
|
|
278
|
+
this.enterContainer("object");
|
|
279
|
+
|
|
280
|
+
let code = this.codeWhereItemStarts();
|
|
281
|
+
|
|
282
|
+
if (code === CLOSE_BRACE) {
|
|
283
|
+
return this.exitContainer(result);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
for (;;) {
|
|
287
|
+
this.readMember(code, result);
|
|
288
|
+
code = this.codeInContainer();
|
|
289
|
+
|
|
290
|
+
if (code === CLOSE_BRACE) {
|
|
291
|
+
return this.exitContainer(result);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
if (code !== COMMA) {
|
|
295
|
+
throw this.unexpectedAfterValue(CLOSE_BRACKET);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
this.position++;
|
|
299
|
+
code = this.codeAfterComma(CLOSE_BRACE, "object");
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/** Reads `"name": value` into `result`; `code`, the current one, is not the end. */
|
|
304
|
+
private readMember(code: number, result: Record<string, unknown>): void {
|
|
305
|
+
if (code !== QUOTE) {
|
|
306
|
+
throw this.unexpected("is an invalid start of a property name. Expected a '\"'.");
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
const name = this.readString();
|
|
310
|
+
const separator = this.skipWhitespace();
|
|
311
|
+
|
|
312
|
+
if (isEnd(separator)) {
|
|
313
|
+
throw new JsonException(NOTHING_AFTER_PROPERTY_NAME);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
if (separator !== COLON) {
|
|
317
|
+
throw this.unexpected("is invalid after a property name. Expected a ':'.");
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
this.position++;
|
|
321
|
+
setMember(result, name, this.readValue(this.codeWhereItemStarts()));
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
private readArray(): unknown[] {
|
|
325
|
+
const result: unknown[] = [];
|
|
326
|
+
|
|
327
|
+
this.enterContainer("array");
|
|
328
|
+
|
|
329
|
+
let code = this.codeWhereItemStarts();
|
|
330
|
+
|
|
331
|
+
if (code === CLOSE_BRACKET) {
|
|
332
|
+
return this.exitContainer(result);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
for (;;) {
|
|
336
|
+
result.push(this.readValue(code));
|
|
337
|
+
code = this.codeInContainer();
|
|
338
|
+
|
|
339
|
+
if (code === CLOSE_BRACKET) {
|
|
340
|
+
return this.exitContainer(result);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
if (code !== COMMA) {
|
|
344
|
+
throw this.unexpectedAfterValue(CLOSE_BRACE);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
this.position++;
|
|
348
|
+
code = this.codeAfterComma(CLOSE_BRACKET, "array");
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* The next code after `[`, `{` or `:`. STJ's reader takes a `/` there for
|
|
354
|
+
* the start of a comment after a value, and reports it as such.
|
|
355
|
+
*/
|
|
356
|
+
private codeWhereItemStarts(): number {
|
|
357
|
+
const code = this.codeInContainer();
|
|
358
|
+
|
|
359
|
+
if (code === SLASH) {
|
|
360
|
+
throw this.unexpected(AFTER_VALUE);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
return code;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/** The next code inside an open container, which the end of the text leaves open. */
|
|
367
|
+
private codeInContainer(): number {
|
|
368
|
+
const code = this.skipWhitespace();
|
|
369
|
+
|
|
370
|
+
if (isEnd(code)) {
|
|
371
|
+
throw new JsonException(OPEN_CONTAINER);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
return code;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/** The next code after a comma: neither the end nor the container's `closer`. */
|
|
378
|
+
private codeAfterComma(closer: number, container: JsonContainer): number {
|
|
379
|
+
const code = this.skipWhitespace();
|
|
380
|
+
|
|
381
|
+
if (isEnd(code)) {
|
|
382
|
+
throw new JsonException(NOTHING_AFTER_COMMA);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
if (code === closer) {
|
|
386
|
+
throw new JsonException(trailingCommaMessage(container));
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
return code;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/** Steps over the opening `{` or `[`, within the tokenizer's own depth bound. */
|
|
393
|
+
private enterContainer(container: JsonContainer): void {
|
|
394
|
+
if (this.depth >= MAX_TEXT_DEPTH) {
|
|
395
|
+
throw new JsonException(`${TOO_DEEP} Cannot read next JSON ${container}.`);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
this.depth++;
|
|
399
|
+
this.position++;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/** Steps over the closing `}` or `]` and returns the container read. */
|
|
403
|
+
private exitContainer<T>(container: T): T {
|
|
404
|
+
this.depth--;
|
|
405
|
+
this.position++;
|
|
406
|
+
|
|
407
|
+
return container;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/** The error for the code after a value: the other container's closer has no matching open. */
|
|
411
|
+
private unexpectedAfterValue(otherCloser: number): JsonException {
|
|
412
|
+
if (this.text.charCodeAt(this.position) === otherCloser) {
|
|
413
|
+
return this.unexpected("is invalid without a matching open.");
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
return this.unexpected(AFTER_VALUE);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
// ─── Scalars ───────────────────────────────────────────────────────────────
|
|
420
|
+
|
|
421
|
+
private readLiteral<T>(literal: string, value: T): T {
|
|
422
|
+
const { text } = this;
|
|
423
|
+
|
|
424
|
+
if (!text.startsWith(literal, this.position)) {
|
|
425
|
+
throw new JsonException(
|
|
426
|
+
`'${text.slice(this.position)}' is an invalid JSON literal. Expected the literal '${literal}'.`,
|
|
427
|
+
);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
this.position += literal.length;
|
|
431
|
+
|
|
432
|
+
return value;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/** Reads the string at the opening quote, copied out of the text. */
|
|
436
|
+
private readString(): string {
|
|
437
|
+
const { text } = this;
|
|
438
|
+
const start = this.position;
|
|
439
|
+
let index = start + 1;
|
|
440
|
+
let escaped = false;
|
|
441
|
+
|
|
442
|
+
for (;;) {
|
|
443
|
+
const code = text.charCodeAt(index);
|
|
444
|
+
|
|
445
|
+
if (code === QUOTE) {
|
|
446
|
+
break;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
if (code === BACKSLASH) {
|
|
450
|
+
index = this.escapeEnd(index);
|
|
451
|
+
escaped = true;
|
|
452
|
+
continue;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
// NaN, past the end, fails the comparison too.
|
|
456
|
+
if (!(code >= SPACE)) {
|
|
457
|
+
throw this.invalidInString(index);
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
index++;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
this.position = index + 1;
|
|
464
|
+
|
|
465
|
+
return copiedString(text, start, this.position, escaped);
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/** The index after the escape sequence whose backslash is at `index`. */
|
|
469
|
+
private escapeEnd(index: number): number {
|
|
470
|
+
const { text } = this;
|
|
471
|
+
const code = text.charCodeAt(index + 1);
|
|
472
|
+
|
|
473
|
+
if (SIMPLE_ESCAPES.has(code)) {
|
|
474
|
+
return index + 2;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
if (code !== LOWER_U) {
|
|
478
|
+
throw this.unexpectedInString(
|
|
479
|
+
index + 1,
|
|
480
|
+
`is an invalid escapable character within a JSON string. ${SHOULD_BE_ESCAPED}`,
|
|
481
|
+
);
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
for (let digit = index + 2; digit < index + 2 + UNICODE_ESCAPE_DIGITS; digit++) {
|
|
485
|
+
if (!isHexDigit(text.charCodeAt(digit))) {
|
|
486
|
+
throw this.unexpectedInString(
|
|
487
|
+
digit,
|
|
488
|
+
`is not a hex digit following '\\u' within a JSON string. ${SHOULD_BE_ESCAPED}`,
|
|
489
|
+
);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
return index + 2 + UNICODE_ESCAPE_DIGITS;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/** A control character inside a string, or its end before the closing quote. */
|
|
497
|
+
private invalidInString(index: number): JsonException {
|
|
498
|
+
return this.unexpectedInString(index, `is invalid within a JSON string. ${SHOULD_BE_ESCAPED}`);
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
/** `message` about the code at `index`, or the unterminated string past the end. */
|
|
502
|
+
private unexpectedInString(index: number, message: string): JsonException {
|
|
503
|
+
if (index >= this.text.length) {
|
|
504
|
+
return new JsonException(UNTERMINATED_STRING);
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
return new JsonException(`${printableCodeAt(this.text, index)} ${message}`);
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* Reads the number at its first character with STJ's grammar: an optional
|
|
512
|
+
* `-`, `0` or digits without a leading zero, an optional fraction and an
|
|
513
|
+
* optional exponent, then a delimiter or the end.
|
|
514
|
+
*/
|
|
515
|
+
private readNumber(): number | JsonNumberText | JsonNonIntegerNumber {
|
|
516
|
+
const { text } = this;
|
|
517
|
+
const start = this.position;
|
|
518
|
+
const signLength = text.charCodeAt(start) === MINUS ? 1 : 0;
|
|
519
|
+
const integerEnd = this.integerEnd(start + signLength);
|
|
520
|
+
const mantissaEnd = this.fractionEnd(integerEnd);
|
|
521
|
+
const end = this.exponentEnd(mantissaEnd);
|
|
522
|
+
const hasFraction = mantissaEnd > integerEnd;
|
|
523
|
+
const endsAfterFraction = hasFraction && end === mantissaEnd;
|
|
524
|
+
|
|
525
|
+
this.throwIfNoDelimiterAt(end, endsAfterFraction);
|
|
526
|
+
this.position = end;
|
|
527
|
+
|
|
528
|
+
// A text no longer than 15 characters past its sign has at most 15 digits.
|
|
529
|
+
const fitsInDouble = end - start - signLength <= DOUBLE_EXACT_DIGITS;
|
|
530
|
+
|
|
531
|
+
const read = fitsInDouble
|
|
532
|
+
? Number(text.slice(start, end))
|
|
533
|
+
: numberOrNumberText(text, start, start + signLength, mantissaEnd, end, hasFraction);
|
|
534
|
+
|
|
535
|
+
const marksNonInteger = this.marksNonIntegers && end !== integerEnd;
|
|
536
|
+
|
|
537
|
+
return marksNonInteger && typeof read === "number" ? new JsonNonIntegerNumber(read) : read;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
/** The end of the integer digits at `index`: `0`, or digits without a leading zero. */
|
|
541
|
+
private integerEnd(index: number): number {
|
|
542
|
+
const { text } = this;
|
|
543
|
+
const code = text.charCodeAt(index);
|
|
544
|
+
|
|
545
|
+
if (!isDigit(code)) {
|
|
546
|
+
throw this.unexpectedInNumber(index, "immediately after a sign character ('+' or '-')");
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
if (code === ZERO) {
|
|
550
|
+
if (isDigit(text.charCodeAt(index + 1))) {
|
|
551
|
+
throw new JsonException(`Invalid leading zero before ${printableCodeAt(text, index + 1)}.`);
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
return index + 1;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
return digitsEnd(text, index + 1);
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/** The end of the fraction at `index`, if one starts there. */
|
|
561
|
+
private fractionEnd(index: number): number {
|
|
562
|
+
if (this.text.charCodeAt(index) !== DOT) {
|
|
563
|
+
return index;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
if (!isDigit(this.text.charCodeAt(index + 1))) {
|
|
567
|
+
throw this.unexpectedInNumber(index + 1, "immediately after a decimal point ('.')");
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
return digitsEnd(this.text, index + 2);
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/** The end of the exponent at `index`, if one starts there; STJ names its sign for a missing digit. */
|
|
574
|
+
private exponentEnd(index: number): number {
|
|
575
|
+
const { text } = this;
|
|
576
|
+
const code = text.charCodeAt(index);
|
|
577
|
+
|
|
578
|
+
if (code !== LOWER_E && code !== UPPER_E) {
|
|
579
|
+
return index;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
const sign = text.charCodeAt(index + 1);
|
|
583
|
+
const firstDigit = sign === PLUS || sign === MINUS ? index + 2 : index + 1;
|
|
584
|
+
|
|
585
|
+
if (!isDigit(text.charCodeAt(firstDigit))) {
|
|
586
|
+
throw this.unexpectedInNumber(firstDigit, "immediately after a sign character ('+' or '-')");
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
return digitsEnd(text, firstDigit + 1);
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* A number ends at a delimiter, or at the end of a root value; inside a
|
|
594
|
+
* container STJ reports its last character at the end of the text.
|
|
595
|
+
*/
|
|
596
|
+
private throwIfNoDelimiterAt(end: number, afterFraction: boolean): void {
|
|
597
|
+
const { text } = this;
|
|
598
|
+
|
|
599
|
+
if (end >= text.length) {
|
|
600
|
+
if (this.depth > 0) {
|
|
601
|
+
throw this.unexpectedEndOfNumber(end - 1, "Expected a delimiter.");
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
if (!isDelimiter(text.charCodeAt(end))) {
|
|
608
|
+
throw this.unexpectedEndOfNumber(
|
|
609
|
+
end,
|
|
610
|
+
afterFraction ? "Expected 'E' or 'e'." : "Expected a delimiter.",
|
|
611
|
+
);
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
private unexpectedEndOfNumber(index: number, expected: string): JsonException {
|
|
616
|
+
return new JsonException(
|
|
617
|
+
`${printableCodeAt(this.text, index)} is an invalid end of a number. ${expected}`,
|
|
618
|
+
);
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
/** A missing digit at `index`, `where` in the number. */
|
|
622
|
+
private unexpectedInNumber(index: number, where: string): JsonException {
|
|
623
|
+
if (index >= this.text.length) {
|
|
624
|
+
return new JsonException(UNTERMINATED_NUMBER);
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
return new JsonException(
|
|
628
|
+
`${printableCodeAt(this.text, index)} is invalid within a number, ${where}. ${EXPECTED_DIGIT}`,
|
|
629
|
+
);
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
// ─── Position ──────────────────────────────────────────────────────────────
|
|
633
|
+
|
|
634
|
+
/** Skips JSON whitespace and returns the code there, `NaN` at the end. */
|
|
635
|
+
private skipWhitespace(): number {
|
|
636
|
+
const { text } = this;
|
|
637
|
+
let index = this.position;
|
|
638
|
+
let code = text.charCodeAt(index);
|
|
639
|
+
|
|
640
|
+
while (isWhitespace(code)) {
|
|
641
|
+
code = text.charCodeAt(++index);
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
this.position = index;
|
|
645
|
+
|
|
646
|
+
return code;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
/** `message` about the code at the current position. */
|
|
650
|
+
private unexpected(message: string): JsonException {
|
|
651
|
+
return new JsonException(`${printableCodeAt(this.text, this.position)} ${message}`);
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
/** `charCodeAt` past the end of the text is `NaN`. */
|
|
656
|
+
function isEnd(code: number): boolean {
|
|
657
|
+
return Number.isNaN(code);
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
function trailingCommaMessage(container: JsonContainer): string {
|
|
661
|
+
return (
|
|
662
|
+
`The JSON ${container} contains a trailing comma at the end which is not supported in this ` +
|
|
663
|
+
"mode. Change the reader options."
|
|
664
|
+
);
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
/** Sets a member as `JSON.parse` does: `__proto__` is an own property, not the prototype. */
|
|
668
|
+
function setMember(target: Record<string, unknown>, name: string, value: unknown): void {
|
|
669
|
+
if (name === "__proto__") {
|
|
670
|
+
Object.defineProperty(target, name, {
|
|
671
|
+
value,
|
|
672
|
+
writable: true,
|
|
673
|
+
enumerable: true,
|
|
674
|
+
configurable: true,
|
|
675
|
+
});
|
|
676
|
+
|
|
677
|
+
return;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
target[name] = value;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
/**
|
|
684
|
+
* The string between the quotes at `start` and `end - 1`. `JSON.parse` of the
|
|
685
|
+
* quoted slice both unescapes it and copies it out of `text`: on
|
|
686
|
+
* JavaScriptCore a slice of any length keeps the whole text alive (measured:
|
|
687
|
+
* a 10 MB payload stayed reachable through its 9-character values).
|
|
688
|
+
*/
|
|
689
|
+
function copiedString(text: string, start: number, end: number, escaped: boolean): string {
|
|
690
|
+
if (!escaped && end - start <= 3) {
|
|
691
|
+
// Empty and one-character strings are shared engine constants.
|
|
692
|
+
return text.slice(start + 1, end - 1);
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
return JSON.parse(text.slice(start, end)) as string;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* The number `text` spells from `start` to `end`: a `number` when its
|
|
700
|
+
* mantissa (from `mantissaStart` to `mantissaEnd`) has at most 15 digits
|
|
701
|
+
* past a zero integer part, a `JsonNumberText` with a copy of its text
|
|
702
|
+
* otherwise. Leading fraction zeros count: the decimal reader rounds a tie
|
|
703
|
+
* by its position in the text (`decimal-text.ts`), which a double loses.
|
|
704
|
+
*/
|
|
705
|
+
function numberOrNumberText(
|
|
706
|
+
text: string,
|
|
707
|
+
start: number,
|
|
708
|
+
mantissaStart: number,
|
|
709
|
+
mantissaEnd: number,
|
|
710
|
+
end: number,
|
|
711
|
+
hasFraction: boolean,
|
|
712
|
+
): number | JsonNumberText {
|
|
713
|
+
const source = text.slice(start, end);
|
|
714
|
+
|
|
715
|
+
if (textDigitsOf(text, mantissaStart, mantissaEnd, hasFraction) <= DOUBLE_EXACT_DIGITS) {
|
|
716
|
+
return Number(source);
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
// `source` is a slice of `text`, which a slice keeps alive on
|
|
720
|
+
// JavaScriptCore; `JSON.parse` of it quoted builds an independent copy.
|
|
721
|
+
return new JsonNumberText(JSON.parse(`"${source}"`) as string);
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
/**
|
|
725
|
+
* The digits of the mantissa, without a zero integer part (JSON spells it as
|
|
726
|
+
* a single `0`): every significant digit, and the zeros before it in the
|
|
727
|
+
* fraction.
|
|
728
|
+
*/
|
|
729
|
+
function textDigitsOf(text: string, start: number, end: number, hasFraction: boolean): number {
|
|
730
|
+
const zeroIntegerDigits = text.charCodeAt(start) === ZERO ? 1 : 0;
|
|
731
|
+
const pointLength = hasFraction ? 1 : 0;
|
|
732
|
+
|
|
733
|
+
return end - start - zeroIntegerDigits - pointLength;
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
function digitsEnd(text: string, index: number): number {
|
|
737
|
+
let end = index;
|
|
738
|
+
|
|
739
|
+
while (isDigit(text.charCodeAt(end))) {
|
|
740
|
+
end++;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
return end;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
function isDigit(code: number): boolean {
|
|
747
|
+
return code >= ZERO && code <= NINE;
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
function isHexDigit(code: number): boolean {
|
|
751
|
+
return isDigit(code) || ((code | 0x20) >= 0x61 && (code | 0x20) <= 0x66);
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
function isWhitespace(code: number): boolean {
|
|
755
|
+
return code === SPACE || code === LINE_FEED || code === CARRIAGE_RETURN || code === TAB;
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
/** What may follow a number: STJ's delimiters, `/` included. */
|
|
759
|
+
function isDelimiter(code: number): boolean {
|
|
760
|
+
return (
|
|
761
|
+
code === COMMA ||
|
|
762
|
+
code === CLOSE_BRACE ||
|
|
763
|
+
code === CLOSE_BRACKET ||
|
|
764
|
+
code === SLASH ||
|
|
765
|
+
isWhitespace(code)
|
|
766
|
+
);
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
/**
|
|
770
|
+
* The code at `index` as STJ prints the byte there: a printable ASCII
|
|
771
|
+
* character itself (`'x'`), anything else as the first byte of its UTF-8
|
|
772
|
+
* encoding (`'0x0A'`, `'0xC3'` for `é`, `'0xF0'` for an emoji).
|
|
773
|
+
*/
|
|
774
|
+
function printableCodeAt(text: string, index: number): string {
|
|
775
|
+
const code = text.charCodeAt(index);
|
|
776
|
+
|
|
777
|
+
if (code >= SPACE && code <= LAST_PRINTABLE) {
|
|
778
|
+
return `'${String.fromCharCode(code)}'`;
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
return `'0x${utf8LeadByteHex(text.codePointAt(index)!)}'`;
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
/** The first byte of the code point's UTF-8 encoding, as two uppercase hex digits. */
|
|
785
|
+
function utf8LeadByteHex(codePoint: number): string {
|
|
786
|
+
return firstUtf8ByteOf(codePoint).toString(16).toUpperCase().padStart(2, "0");
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
function firstUtf8ByteOf(codePoint: number): number {
|
|
790
|
+
if (codePoint < 0x80) {
|
|
791
|
+
return codePoint;
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
if (codePoint < 0x800) {
|
|
795
|
+
return 0xc0 | (codePoint >> 6);
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
return codePoint < 0x10000 ? 0xe0 | (codePoint >> 12) : 0xf0 | (codePoint >> 18);
|
|
799
|
+
}
|