ts-data-forge 9.0.0 → 10.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 +1 -1
- package/dist/array/impl/array-utils-creation.d.mts +4 -4
- package/dist/array/impl/array-utils-creation.d.mts.map +1 -1
- package/dist/array/impl/array-utils-creation.mjs +17 -112
- package/dist/array/impl/array-utils-creation.mjs.map +1 -1
- package/dist/array/impl/array-utils-element-access.d.mts.map +1 -1
- package/dist/array/impl/array-utils-element-access.mjs +22 -61
- package/dist/array/impl/array-utils-element-access.mjs.map +1 -1
- package/dist/array/impl/array-utils-iterators.d.mts.map +1 -1
- package/dist/array/impl/array-utils-iterators.mjs +9 -63
- package/dist/array/impl/array-utils-iterators.mjs.map +1 -1
- package/dist/array/impl/array-utils-modification.d.mts +7 -7
- package/dist/array/impl/array-utils-modification.d.mts.map +1 -1
- package/dist/array/impl/array-utils-modification.mjs +78 -78
- package/dist/array/impl/array-utils-modification.mjs.map +1 -1
- package/dist/array/impl/array-utils-reducing-value.mjs +95 -89
- package/dist/array/impl/array-utils-reducing-value.mjs.map +1 -1
- package/dist/array/impl/array-utils-search.mjs +100 -92
- package/dist/array/impl/array-utils-search.mjs.map +1 -1
- package/dist/array/impl/array-utils-set-op.d.mts.map +1 -1
- package/dist/array/impl/array-utils-set-op.mjs +31 -141
- package/dist/array/impl/array-utils-set-op.mjs.map +1 -1
- package/dist/array/impl/array-utils-size.d.mts.map +1 -1
- package/dist/array/impl/array-utils-size.mjs +4 -8
- package/dist/array/impl/array-utils-size.mjs.map +1 -1
- package/dist/array/impl/array-utils-slice-clamped.mjs +11 -12
- package/dist/array/impl/array-utils-slice-clamped.mjs.map +1 -1
- package/dist/array/impl/array-utils-slicing.d.mts.map +1 -1
- package/dist/array/impl/array-utils-slicing.mjs +44 -96
- package/dist/array/impl/array-utils-slicing.mjs.map +1 -1
- package/dist/array/impl/array-utils-transformation.d.mts +4 -4
- package/dist/array/impl/array-utils-transformation.d.mts.map +1 -1
- package/dist/array/impl/array-utils-transformation.mjs +150 -292
- package/dist/array/impl/array-utils-transformation.mjs.map +1 -1
- package/dist/array/impl/array-utils-validation.d.mts +17 -17
- package/dist/array/impl/array-utils-validation.d.mts.map +1 -1
- package/dist/array/impl/array-utils-validation.mjs +23 -174
- package/dist/array/impl/array-utils-validation.mjs.map +1 -1
- package/dist/array/impl/index.mjs +1 -1
- package/dist/collections/imap-mapped.d.mts.map +1 -1
- package/dist/collections/imap-mapped.mjs +243 -330
- package/dist/collections/imap-mapped.mjs.map +1 -1
- package/dist/collections/imap.d.mts.map +1 -1
- package/dist/collections/imap.mjs +190 -275
- package/dist/collections/imap.mjs.map +1 -1
- package/dist/collections/iset-mapped.d.mts +1 -1
- package/dist/collections/iset-mapped.d.mts.map +1 -1
- package/dist/collections/iset-mapped.mjs +222 -444
- package/dist/collections/iset-mapped.mjs.map +1 -1
- package/dist/collections/iset.d.mts +1 -1
- package/dist/collections/iset.d.mts.map +1 -1
- package/dist/collections/iset.mjs +158 -324
- package/dist/collections/iset.mjs.map +1 -1
- package/dist/collections/queue.d.mts.map +1 -1
- package/dist/collections/queue.mjs +106 -178
- package/dist/collections/queue.mjs.map +1 -1
- package/dist/collections/stack.d.mts.map +1 -1
- package/dist/collections/stack.mjs +95 -165
- package/dist/collections/stack.mjs.map +1 -1
- package/dist/entry-point.mjs +2 -0
- package/dist/entry-point.mjs.map +1 -1
- package/dist/expect-type.d.mts +1 -1
- package/dist/expect-type.d.mts.map +1 -1
- package/dist/expect-type.mjs +1 -69
- package/dist/expect-type.mjs.map +1 -1
- package/dist/functional/match.mjs +9 -9
- package/dist/functional/match.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-expect-to-be.mjs +13 -14
- package/dist/functional/optional/impl/optional-expect-to-be.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-filter.mjs +14 -15
- package/dist/functional/optional/impl/optional-filter.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-flat-map.mjs +10 -11
- package/dist/functional/optional/impl/optional-flat-map.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-from-nullable.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-from-nullable.mjs +1 -25
- package/dist/functional/optional/impl/optional-from-nullable.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-is-none.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-is-none.mjs +0 -19
- package/dist/functional/optional/impl/optional-is-none.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-is-optional.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-is-optional.mjs +1 -23
- package/dist/functional/optional/impl/optional-is-optional.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-is-some.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-is-some.mjs +0 -20
- package/dist/functional/optional/impl/optional-is-some.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-map.mjs +13 -14
- package/dist/functional/optional/impl/optional-map.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-none.mjs +0 -16
- package/dist/functional/optional/impl/optional-none.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-or-else.mjs +10 -11
- package/dist/functional/optional/impl/optional-or-else.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-some.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-some.mjs +2 -21
- package/dist/functional/optional/impl/optional-some.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-to-nullable.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-to-nullable.mjs +1 -27
- package/dist/functional/optional/impl/optional-to-nullable.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-unwrap-or.mjs +9 -10
- package/dist/functional/optional/impl/optional-unwrap-or.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-unwrap-throw.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-unwrap-throw.mjs +4 -32
- package/dist/functional/optional/impl/optional-unwrap-throw.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-unwrap.mjs +4 -4
- package/dist/functional/optional/impl/optional-unwrap.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-zip.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-zip.mjs +1 -35
- package/dist/functional/optional/impl/optional-zip.mjs.map +1 -1
- package/dist/functional/optional/impl/tag.mjs +2 -3
- package/dist/functional/optional/impl/tag.mjs.map +1 -1
- package/dist/functional/pipe.d.mts.map +1 -1
- package/dist/functional/pipe.mjs +9 -34
- package/dist/functional/pipe.mjs.map +1 -1
- package/dist/functional/result/impl/result-err.d.mts.map +1 -1
- package/dist/functional/result/impl/result-err.mjs +2 -27
- package/dist/functional/result/impl/result-err.mjs.map +1 -1
- package/dist/functional/result/impl/result-expect-to-be.mjs +13 -15
- package/dist/functional/result/impl/result-expect-to-be.mjs.map +1 -1
- package/dist/functional/result/impl/result-flat-map.mjs +16 -16
- package/dist/functional/result/impl/result-flat-map.mjs.map +1 -1
- package/dist/functional/result/impl/result-fold.mjs +16 -16
- package/dist/functional/result/impl/result-fold.mjs.map +1 -1
- package/dist/functional/result/impl/result-from-promise.d.mts.map +1 -1
- package/dist/functional/result/impl/result-from-promise.mjs +4 -31
- package/dist/functional/result/impl/result-from-promise.mjs.map +1 -1
- package/dist/functional/result/impl/result-from-throwable.d.mts.map +1 -1
- package/dist/functional/result/impl/result-from-throwable.mjs +8 -38
- package/dist/functional/result/impl/result-from-throwable.mjs.map +1 -1
- package/dist/functional/result/impl/result-is-err.d.mts.map +1 -1
- package/dist/functional/result/impl/result-is-err.mjs +0 -19
- package/dist/functional/result/impl/result-is-err.mjs.map +1 -1
- package/dist/functional/result/impl/result-is-ok.d.mts.map +1 -1
- package/dist/functional/result/impl/result-is-ok.mjs +0 -19
- package/dist/functional/result/impl/result-is-ok.mjs.map +1 -1
- package/dist/functional/result/impl/result-is-result.d.mts.map +1 -1
- package/dist/functional/result/impl/result-is-result.mjs +1 -23
- package/dist/functional/result/impl/result-is-result.mjs.map +1 -1
- package/dist/functional/result/impl/result-map-err.mjs +16 -16
- package/dist/functional/result/impl/result-map-err.mjs.map +1 -1
- package/dist/functional/result/impl/result-map.mjs +16 -16
- package/dist/functional/result/impl/result-map.mjs.map +1 -1
- package/dist/functional/result/impl/result-ok.d.mts.map +1 -1
- package/dist/functional/result/impl/result-ok.mjs +2 -27
- package/dist/functional/result/impl/result-ok.mjs.map +1 -1
- package/dist/functional/result/impl/result-or-else.mjs +10 -12
- package/dist/functional/result/impl/result-or-else.mjs.map +1 -1
- package/dist/functional/result/impl/result-swap.d.mts.map +1 -1
- package/dist/functional/result/impl/result-swap.mjs +4 -22
- package/dist/functional/result/impl/result-swap.mjs.map +1 -1
- package/dist/functional/result/impl/result-to-optional.d.mts.map +1 -1
- package/dist/functional/result/impl/result-to-optional.mjs +0 -27
- package/dist/functional/result/impl/result-to-optional.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-err-or.mjs +9 -11
- package/dist/functional/result/impl/result-unwrap-err-or.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-err-throw.d.mts.map +1 -1
- package/dist/functional/result/impl/result-unwrap-err-throw.mjs +13 -40
- package/dist/functional/result/impl/result-unwrap-err-throw.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-err.d.mts.map +1 -1
- package/dist/functional/result/impl/result-unwrap-err.mjs +4 -32
- package/dist/functional/result/impl/result-unwrap-err.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-ok-or.mjs +9 -11
- package/dist/functional/result/impl/result-unwrap-ok-or.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-ok.mjs +4 -4
- package/dist/functional/result/impl/result-unwrap-ok.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-throw.d.mts.map +1 -1
- package/dist/functional/result/impl/result-unwrap-throw.mjs +4 -35
- package/dist/functional/result/impl/result-unwrap-throw.mjs.map +1 -1
- package/dist/functional/result/impl/result-zip.d.mts.map +1 -1
- package/dist/functional/result/impl/result-zip.mjs +1 -34
- package/dist/functional/result/impl/result-zip.mjs.map +1 -1
- package/dist/functional/result/impl/tag.mjs +2 -3
- package/dist/functional/result/impl/tag.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/tag.mjs +3 -5
- package/dist/functional/ternary-result/impl/tag.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-err.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-err.mjs +2 -15
- package/dist/functional/ternary-result/impl/ternary-result-err.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs +13 -13
- package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs +27 -26
- package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-fold.mjs +21 -22
- package/dist/functional/ternary-result/impl/ternary-result-fold.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-from-promise.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs +4 -20
- package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-from-throwable.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs +7 -25
- package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-is-err.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs +0 -17
- package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-is-ok.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs +0 -19
- package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs +1 -25
- package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-is-warn.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs +0 -18
- package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs +13 -15
- package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs +18 -18
- package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-map.mjs +21 -22
- package/dist/functional/ternary-result/impl/ternary-result-map.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-ok.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-ok.mjs +2 -16
- package/dist/functional/ternary-result/impl/ternary-result-ok.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs +9 -9
- package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-to-optional.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs +4 -22
- package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs +9 -9
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs +12 -27
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs +4 -19
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs +9 -9
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs +4 -5
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs +15 -27
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs +9 -9
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs +10 -24
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs +4 -19
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-warn.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-warn.mjs +3 -19
- package/dist/functional/ternary-result/impl/ternary-result-warn.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-zip.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-zip.mjs +14 -45
- package/dist/functional/ternary-result/impl/ternary-result-zip.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/variant-name.d.mts +1 -1
- package/dist/functional/ternary-result/impl/variant-name.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/variant-name.mjs +8 -9
- package/dist/functional/ternary-result/impl/variant-name.mjs.map +1 -1
- package/dist/guard/as-length-bounded-array.d.mts +117 -0
- package/dist/guard/as-length-bounded-array.d.mts.map +1 -0
- package/dist/guard/as-length-bounded-array.mjs +37 -0
- package/dist/guard/as-length-bounded-array.mjs.map +1 -0
- package/dist/guard/has-key.d.mts.map +1 -1
- package/dist/guard/has-key.mjs +0 -41
- package/dist/guard/has-key.mjs.map +1 -1
- package/dist/guard/index.d.mts +2 -0
- package/dist/guard/index.d.mts.map +1 -1
- package/dist/guard/index.mjs +2 -0
- package/dist/guard/index.mjs.map +1 -1
- package/dist/guard/is-length-bounded-array.d.mts +159 -0
- package/dist/guard/is-length-bounded-array.d.mts.map +1 -0
- package/dist/guard/is-length-bounded-array.mjs +7 -0
- package/dist/guard/is-length-bounded-array.mjs.map +1 -0
- package/dist/guard/is-length-bounded-string.d.mts +5 -6
- package/dist/guard/is-length-bounded-string.d.mts.map +1 -1
- package/dist/guard/is-length-bounded-string.mjs +0 -157
- package/dist/guard/is-length-bounded-string.mjs.map +1 -1
- package/dist/guard/is-non-empty-string.d.mts +1 -1
- package/dist/guard/is-non-empty-string.d.mts.map +1 -1
- package/dist/guard/is-non-empty-string.mjs +1 -38
- package/dist/guard/is-non-empty-string.mjs.map +1 -1
- package/dist/guard/is-non-null-object.d.mts.map +1 -1
- package/dist/guard/is-non-null-object.mjs +1 -35
- package/dist/guard/is-non-null-object.mjs.map +1 -1
- package/dist/guard/is-primitive.d.mts.map +1 -1
- package/dist/guard/is-primitive.mjs +12 -43
- package/dist/guard/is-primitive.mjs.map +1 -1
- package/dist/guard/is-record.d.mts.map +1 -1
- package/dist/guard/is-record.mjs +0 -86
- package/dist/guard/is-record.mjs.map +1 -1
- package/dist/guard/is-type.d.mts.map +1 -1
- package/dist/guard/is-type.mjs +12 -399
- package/dist/guard/is-type.mjs.map +1 -1
- package/dist/guard/key-is-in.d.mts.map +1 -1
- package/dist/guard/key-is-in.mjs +0 -40
- package/dist/guard/key-is-in.mjs.map +1 -1
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -1
- package/dist/iterator/range.mjs +16 -16
- package/dist/iterator/range.mjs.map +1 -1
- package/dist/json/json.d.mts.map +1 -1
- package/dist/json/json.mjs +52 -340
- package/dist/json/json.mjs.map +1 -1
- package/dist/number/branded-types/finite-number.d.mts +3 -3
- package/dist/number/branded-types/finite-number.mjs +135 -154
- package/dist/number/branded-types/finite-number.mjs.map +1 -1
- package/dist/number/branded-types/int.d.mts +4 -4
- package/dist/number/branded-types/int.mjs +205 -245
- package/dist/number/branded-types/int.mjs.map +1 -1
- package/dist/number/branded-types/int16.d.mts +15 -15
- package/dist/number/branded-types/int16.mjs +116 -123
- package/dist/number/branded-types/int16.mjs.map +1 -1
- package/dist/number/branded-types/int32.d.mts +11 -11
- package/dist/number/branded-types/int32.mjs +116 -123
- package/dist/number/branded-types/int32.mjs.map +1 -1
- package/dist/number/branded-types/negative-finite-number.d.mts +4 -4
- package/dist/number/branded-types/negative-finite-number.mjs +129 -144
- package/dist/number/branded-types/negative-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/negative-int.d.mts +5 -5
- package/dist/number/branded-types/negative-int.mjs +94 -113
- package/dist/number/branded-types/negative-int.mjs.map +1 -1
- package/dist/number/branded-types/negative-safe-int.d.mts +5 -5
- package/dist/number/branded-types/negative-safe-int.mjs +103 -124
- package/dist/number/branded-types/negative-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/non-negative-finite-number.d.mts +5 -5
- package/dist/number/branded-types/non-negative-finite-number.mjs +136 -142
- package/dist/number/branded-types/non-negative-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/non-negative-int16.d.mts +16 -16
- package/dist/number/branded-types/non-negative-int16.mjs +109 -118
- package/dist/number/branded-types/non-negative-int16.mjs.map +1 -1
- package/dist/number/branded-types/non-negative-int32.d.mts +12 -12
- package/dist/number/branded-types/non-negative-int32.mjs +110 -119
- package/dist/number/branded-types/non-negative-int32.mjs.map +1 -1
- package/dist/number/branded-types/non-positive-finite-number.d.mts +3 -3
- package/dist/number/branded-types/non-positive-finite-number.mjs +120 -124
- package/dist/number/branded-types/non-positive-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/non-positive-int.d.mts +4 -4
- package/dist/number/branded-types/non-positive-int.mjs +167 -212
- package/dist/number/branded-types/non-positive-int.mjs.map +1 -1
- package/dist/number/branded-types/non-positive-safe-int.d.mts +4 -4
- package/dist/number/branded-types/non-positive-safe-int.mjs +95 -106
- package/dist/number/branded-types/non-positive-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-finite-number.d.mts +4 -4
- package/dist/number/branded-types/non-zero-finite-number.mjs +114 -123
- package/dist/number/branded-types/non-zero-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-int.d.mts +2 -2
- package/dist/number/branded-types/non-zero-int.mjs +72 -83
- package/dist/number/branded-types/non-zero-int.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-int16.d.mts +7 -7
- package/dist/number/branded-types/non-zero-int16.mjs +96 -107
- package/dist/number/branded-types/non-zero-int16.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-int32.d.mts +5 -5
- package/dist/number/branded-types/non-zero-int32.mjs +97 -108
- package/dist/number/branded-types/non-zero-int32.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-safe-int.d.mts +2 -2
- package/dist/number/branded-types/non-zero-safe-int.mjs +100 -111
- package/dist/number/branded-types/non-zero-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-uint16.d.mts +8 -8
- package/dist/number/branded-types/non-zero-uint16.mjs +96 -107
- package/dist/number/branded-types/non-zero-uint16.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-uint32.d.mts +6 -6
- package/dist/number/branded-types/non-zero-uint32.mjs +96 -107
- package/dist/number/branded-types/non-zero-uint32.mjs.map +1 -1
- package/dist/number/branded-types/positive-finite-number.d.mts +8 -8
- package/dist/number/branded-types/positive-finite-number.mjs +139 -141
- package/dist/number/branded-types/positive-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/positive-int.d.mts +11 -11
- package/dist/number/branded-types/positive-int.mjs +228 -271
- package/dist/number/branded-types/positive-int.mjs.map +1 -1
- package/dist/number/branded-types/positive-int16.d.mts +19 -19
- package/dist/number/branded-types/positive-int16.mjs +109 -118
- package/dist/number/branded-types/positive-int16.mjs.map +1 -1
- package/dist/number/branded-types/positive-int32.d.mts +15 -15
- package/dist/number/branded-types/positive-int32.mjs +109 -118
- package/dist/number/branded-types/positive-int32.mjs.map +1 -1
- package/dist/number/branded-types/positive-safe-int.d.mts +11 -11
- package/dist/number/branded-types/positive-safe-int.mjs +244 -275
- package/dist/number/branded-types/positive-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/positive-uint16.d.mts +17 -17
- package/dist/number/branded-types/positive-uint16.mjs +109 -118
- package/dist/number/branded-types/positive-uint16.mjs.map +1 -1
- package/dist/number/branded-types/positive-uint32.d.mts +13 -13
- package/dist/number/branded-types/positive-uint32.mjs +110 -119
- package/dist/number/branded-types/positive-uint32.mjs.map +1 -1
- package/dist/number/branded-types/safe-int.d.mts +4 -4
- package/dist/number/branded-types/safe-int.mjs +251 -292
- package/dist/number/branded-types/safe-int.mjs.map +1 -1
- package/dist/number/branded-types/safe-uint.d.mts +8 -8
- package/dist/number/branded-types/safe-uint.mjs +111 -119
- package/dist/number/branded-types/safe-uint.mjs.map +1 -1
- package/dist/number/branded-types/uint.d.mts +8 -8
- package/dist/number/branded-types/uint.mjs +198 -225
- package/dist/number/branded-types/uint.mjs.map +1 -1
- package/dist/number/branded-types/uint16.d.mts +14 -14
- package/dist/number/branded-types/uint16.mjs +109 -119
- package/dist/number/branded-types/uint16.mjs.map +1 -1
- package/dist/number/branded-types/uint32.d.mts +10 -10
- package/dist/number/branded-types/uint32.mjs +110 -117
- package/dist/number/branded-types/uint32.mjs.map +1 -1
- package/dist/number/enum/int8.mjs +119 -145
- package/dist/number/enum/int8.mjs.map +1 -1
- package/dist/number/enum/uint8.mjs +107 -121
- package/dist/number/enum/uint8.mjs.map +1 -1
- package/dist/number/num.d.mts +2 -2
- package/dist/number/num.d.mts.map +1 -1
- package/dist/number/num.mjs +76 -537
- package/dist/number/num.mjs.map +1 -1
- package/dist/number/refined-number-utils.d.mts +1 -1
- package/dist/number/refined-number-utils.d.mts.map +1 -1
- package/dist/number/refined-number-utils.mjs +127 -263
- package/dist/number/refined-number-utils.mjs.map +1 -1
- package/dist/object/object.d.mts.map +1 -1
- package/dist/object/object.mjs +107 -222
- package/dist/object/object.mjs.map +1 -1
- package/dist/others/cast-mutable.d.mts.map +1 -1
- package/dist/others/cast-mutable.mjs +8 -37
- package/dist/others/cast-mutable.mjs.map +1 -1
- package/dist/others/cast-readonly.d.mts.map +1 -1
- package/dist/others/cast-readonly.mjs +8 -36
- package/dist/others/cast-readonly.mjs.map +1 -1
- package/dist/others/debounce-function.d.mts.map +1 -1
- package/dist/others/debounce-function.mjs +7 -16
- package/dist/others/debounce-function.mjs.map +1 -1
- package/dist/others/fast-deep-equal.d.mts.map +1 -1
- package/dist/others/fast-deep-equal.mjs +43 -59
- package/dist/others/fast-deep-equal.mjs.map +1 -1
- package/dist/others/if-then.d.mts.map +1 -1
- package/dist/others/if-then.mjs +0 -29
- package/dist/others/if-then.mjs.map +1 -1
- package/dist/others/map-nullable.mjs +9 -9
- package/dist/others/map-nullable.mjs.map +1 -1
- package/dist/others/memoize-function.mjs +12 -12
- package/dist/others/memoize-function.mjs.map +1 -1
- package/dist/others/tuple.d.mts.map +1 -1
- package/dist/others/tuple.mjs +0 -50
- package/dist/others/tuple.mjs.map +1 -1
- package/dist/others/unknown-to-string.d.mts.map +1 -1
- package/dist/others/unknown-to-string.mjs +41 -88
- package/dist/others/unknown-to-string.mjs.map +1 -1
- package/dist/promise/promise.d.mts.map +1 -1
- package/dist/promise/promise.mjs +4 -49
- package/dist/promise/promise.mjs.map +1 -1
- package/package.json +14 -13
- package/src/array/impl/array-utils-creation.mts +3 -3
- package/src/array/impl/array-utils-modification.mts +7 -7
- package/src/array/impl/array-utils-modification.test.mts +4 -4
- package/src/array/impl/array-utils-transformation.mts +4 -4
- package/src/array/impl/array-utils-transformation.test.mts +7 -7
- package/src/array/impl/array-utils-validation.mts +24 -24
- package/src/array/impl/array-utils-validation.test.mts +94 -92
- package/src/collections/queue.test.mts +1 -1
- package/src/guard/as-length-bounded-array.mts +190 -0
- package/src/guard/as-length-bounded-array.test.mts +118 -0
- package/src/guard/index.mts +2 -0
- package/src/guard/is-length-bounded-array.mts +195 -0
- package/src/guard/is-length-bounded-array.test.mts +169 -0
- package/src/guard/is-length-bounded-string.mts +6 -6
- package/src/object/object.test.mts +3 -3
package/dist/json/json.mjs
CHANGED
|
@@ -47,352 +47,64 @@ import '../collections/iset-mapped.mjs';
|
|
|
47
47
|
import '../collections/iset.mjs';
|
|
48
48
|
import { uniq } from '../array/impl/array-utils-transformation.mjs';
|
|
49
49
|
|
|
50
|
-
/**
|
|
51
|
-
* A collection of type-safe JSON utility functions that provide safe parsing,
|
|
52
|
-
* stringification, and manipulation of JSON data. All functions return `Result`
|
|
53
|
-
* types to handle errors without throwing exceptions.
|
|
54
|
-
*/
|
|
55
50
|
var Json;
|
|
56
|
-
(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
* });
|
|
94
|
-
*
|
|
95
|
-
* assert.isTrue(Result.isOk(withReviver));
|
|
96
|
-
* ```
|
|
97
|
-
*
|
|
98
|
-
* @param text - A valid JSON string to parse. Can contain any valid JSON data
|
|
99
|
-
* type: primitives (string, number, boolean, null), arrays, or objects.
|
|
100
|
-
* @param reviver - Optional function that transforms parsed values. Called
|
|
101
|
-
* for each key-value pair in the JSON. The function receives the key name
|
|
102
|
-
* and parsed value, and should return the transformed value. For nested
|
|
103
|
-
* objects, inner objects are processed before outer objects.
|
|
104
|
-
* @returns A `Result<JsonValue, string>` containing:
|
|
105
|
-
*
|
|
106
|
-
* - On success: `Result.ok(parsedValue)` where `parsedValue` is the parsed JSON
|
|
107
|
-
* - On failure: `Result.err(errorMessage)` where `errorMessage` describes the
|
|
108
|
-
* parsing error
|
|
109
|
-
*/
|
|
110
|
-
Json.parse = (text, reviver) => {
|
|
111
|
-
try {
|
|
112
|
-
return ok(JSON.parse(text,
|
|
113
|
-
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
114
|
-
reviver));
|
|
115
|
-
}
|
|
116
|
-
catch (error) {
|
|
117
|
-
const errStr = unknownToString(error);
|
|
118
|
-
return err(errStr);
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
/**
|
|
122
|
-
* Safely converts a JavaScript value to a JSON string without throwing
|
|
123
|
-
* exceptions.
|
|
124
|
-
*
|
|
125
|
-
* This function provides type-safe JSON stringification by wrapping the
|
|
126
|
-
* native `JSON.stringify` in a `Result` type, allowing you to handle
|
|
127
|
-
* serialization errors gracefully (such as circular references or BigInt
|
|
128
|
-
* values).
|
|
129
|
-
*
|
|
130
|
-
* @example
|
|
131
|
-
*
|
|
132
|
-
* ```ts
|
|
133
|
-
* const data = { name: 'Bob', age: 25, active: true } as const;
|
|
134
|
-
*
|
|
135
|
-
* // Basic stringify
|
|
136
|
-
* const basic = Json.stringify(data);
|
|
137
|
-
*
|
|
138
|
-
* assert.isTrue(Result.isOk(basic));
|
|
139
|
-
*
|
|
140
|
-
* if (Result.isOk(basic)) {
|
|
141
|
-
* assert.isTrue(basic.value === '{"name":"Bob","age":25,"active":true}');
|
|
142
|
-
* }
|
|
143
|
-
*
|
|
144
|
-
* // With formatting
|
|
145
|
-
* const formatted = Json.stringify(data, undefined, 2);
|
|
146
|
-
*
|
|
147
|
-
* assert.isTrue(Result.isOk(formatted));
|
|
148
|
-
*
|
|
149
|
-
* // With replacer
|
|
150
|
-
* const filtered = Json.stringify(data, (key, value) => {
|
|
151
|
-
* if (key === 'age') return undefined; // omit age field
|
|
152
|
-
*
|
|
153
|
-
* return value;
|
|
154
|
-
* });
|
|
155
|
-
*
|
|
156
|
-
* assert.isTrue(Result.isOk(filtered));
|
|
157
|
-
*
|
|
158
|
-
* if (Result.isOk(filtered)) {
|
|
159
|
-
* assert.isTrue(isString(filtered.value));
|
|
160
|
-
*
|
|
161
|
-
* assert.isFalse(filtered.value.includes('age'));
|
|
162
|
-
* }
|
|
163
|
-
* ```
|
|
164
|
-
*
|
|
165
|
-
* @param value - The JavaScript value to serialize. Can be any value that
|
|
166
|
-
* JSON.stringify accepts: primitives, objects, arrays. Non-serializable
|
|
167
|
-
* values (functions, undefined, symbols) will be omitted or converted to
|
|
168
|
-
* null according to JSON.stringify behavior.
|
|
169
|
-
* @param replacer - Optional function that transforms values during
|
|
170
|
-
* serialization. Called for each key-value pair. Should return the value to
|
|
171
|
-
* be serialized, or undefined to omit the property from the result.
|
|
172
|
-
* @param space - Optional parameter for formatting the output JSON:
|
|
173
|
-
*
|
|
174
|
-
* - Number (1-10): Number of spaces to indent each level
|
|
175
|
-
* - String: String to use for indentation (first 10 characters)
|
|
176
|
-
* - Undefined/null: No formatting (compact output)
|
|
177
|
-
*
|
|
178
|
-
* @returns A `Result<string, string>` containing:
|
|
179
|
-
*
|
|
180
|
-
* - On success: `Result.ok(jsonString)` where `jsonString` is the serialized
|
|
181
|
-
* JSON
|
|
182
|
-
* - On failure: `Result.err(errorMessage)` where `errorMessage` describes the
|
|
183
|
-
* error
|
|
184
|
-
*/
|
|
185
|
-
Json.stringify = (value, replacer, space) => {
|
|
186
|
-
try {
|
|
187
|
-
return ok(JSON.stringify(value, replacer, space));
|
|
188
|
-
}
|
|
189
|
-
catch (error) {
|
|
190
|
-
const errStr = unknownToString(error);
|
|
191
|
-
return err(errStr);
|
|
192
|
-
}
|
|
193
|
-
};
|
|
194
|
-
/**
|
|
195
|
-
* Safely converts a JavaScript value to a JSON string, including only the
|
|
196
|
-
* specified properties.
|
|
197
|
-
*
|
|
198
|
-
* This function provides selective serialization by allowing you to specify
|
|
199
|
-
* exactly which object properties should be included in the resulting JSON.
|
|
200
|
-
* It's useful for creating filtered or minimal representations of objects,
|
|
201
|
-
* such as for API responses or logging.
|
|
202
|
-
*
|
|
203
|
-
* @example
|
|
204
|
-
*
|
|
205
|
-
* ```ts
|
|
206
|
-
* const user = {
|
|
207
|
-
* id: 1,
|
|
208
|
-
* name: 'Charlie',
|
|
209
|
-
* email: 'charlie@example.com',
|
|
210
|
-
* password: 'secret123',
|
|
211
|
-
* role: 'admin',
|
|
212
|
-
* } as const;
|
|
213
|
-
*
|
|
214
|
-
* // Select only safe properties to serialize
|
|
215
|
-
* const safeJson = Json.stringifySelected(user, ['id', 'name', 'role']);
|
|
216
|
-
*
|
|
217
|
-
* assert.isTrue(Result.isOk(safeJson));
|
|
218
|
-
*
|
|
219
|
-
* if (Result.isOk(safeJson)) {
|
|
220
|
-
* assert.isTrue(isString(safeJson.value));
|
|
221
|
-
*
|
|
222
|
-
* const parsed: unknown = JSON.parse(safeJson.value);
|
|
223
|
-
*
|
|
224
|
-
* assert.deepStrictEqual(parsed, {
|
|
225
|
-
* id: 1,
|
|
226
|
-
* name: 'Charlie',
|
|
227
|
-
* role: 'admin',
|
|
228
|
-
* });
|
|
229
|
-
*
|
|
230
|
-
* assert.isFalse(safeJson.value.includes('password'));
|
|
231
|
-
*
|
|
232
|
-
* assert.isFalse(safeJson.value.includes('email'));
|
|
233
|
-
* }
|
|
234
|
-
*
|
|
235
|
-
* // With formatting
|
|
236
|
-
* const formatted = Json.stringifySelected(user, ['id', 'name'], 2);
|
|
237
|
-
*
|
|
238
|
-
* assert.isTrue(Result.isOk(formatted));
|
|
239
|
-
* ```
|
|
240
|
-
*
|
|
241
|
-
* @param value - The JavaScript value to serialize. While any value is
|
|
242
|
-
* accepted, the property filtering only applies to objects and nested
|
|
243
|
-
* objects.
|
|
244
|
-
* @param propertiesToBeSelected - Optional array of property names (strings)
|
|
245
|
-
* and array indices (numbers) to include in the serialization. If provided,
|
|
246
|
-
* only these properties will appear in the output JSON. If undefined, all
|
|
247
|
-
* properties are included.
|
|
248
|
-
* @param space - Optional formatting parameter:
|
|
249
|
-
*
|
|
250
|
-
* - Number (1-10): Number of spaces to indent each level
|
|
251
|
-
* - String: String to use for indentation (first 10 characters)
|
|
252
|
-
* - Undefined/null: No formatting (compact output)
|
|
253
|
-
*
|
|
254
|
-
* @returns A `Result<string, string>` containing:
|
|
255
|
-
*
|
|
256
|
-
* - On success: `Result.ok(jsonString)` with only selected properties
|
|
257
|
-
* - On failure: `Result.err(errorMessage)` describing the serialization error
|
|
258
|
-
*/
|
|
259
|
-
Json.stringifySelected = (value, propertiesToBeSelected, space) => {
|
|
260
|
-
try {
|
|
261
|
-
return ok(JSON.stringify(value, castMutable(propertiesToBeSelected), space));
|
|
262
|
-
}
|
|
263
|
-
catch (error) {
|
|
264
|
-
const errStr = unknownToString(error);
|
|
265
|
-
return err(errStr);
|
|
266
|
-
}
|
|
267
|
-
};
|
|
268
|
-
/**
|
|
269
|
-
* Safely converts a JavaScript record to a JSON string with keys sorted
|
|
270
|
-
* alphabetically at all levels.
|
|
271
|
-
*
|
|
272
|
-
* This function creates deterministic JSON output by ensuring that object
|
|
273
|
-
* keys appear in alphabetical order at every level of nesting. This is
|
|
274
|
-
* particularly useful for creating consistent output for comparison, hashing,
|
|
275
|
-
* caching, or when you need reproducible JSON representations across
|
|
276
|
-
* different JavaScript engines or runs.
|
|
277
|
-
*
|
|
278
|
-
* @example
|
|
279
|
-
*
|
|
280
|
-
* ```ts
|
|
281
|
-
* const unorderedData = {
|
|
282
|
-
* zebra: 1,
|
|
283
|
-
* apple: 2,
|
|
284
|
-
* mango: 3,
|
|
285
|
-
* nested: {
|
|
286
|
-
* zulu: 'z',
|
|
287
|
-
* alpha: 'a',
|
|
288
|
-
* beta: 'b',
|
|
289
|
-
* },
|
|
290
|
-
* } as const;
|
|
291
|
-
*
|
|
292
|
-
* // Keys will be sorted alphabetically at all levels
|
|
293
|
-
* const sorted = Json.stringifySortedKey(unorderedData);
|
|
294
|
-
*
|
|
295
|
-
* assert.isTrue(Result.isOk(sorted));
|
|
296
|
-
*
|
|
297
|
-
* if (Result.isOk(sorted)) {
|
|
298
|
-
* // Keys should appear in alphabetical order
|
|
299
|
-
* const expected =
|
|
300
|
-
* '{"apple":2,"mango":3,"nested":{"alpha":"a","beta":"b","zulu":"z"},"zebra":1}';
|
|
301
|
-
*
|
|
302
|
-
* assert.isTrue(sorted.value === expected);
|
|
303
|
-
* }
|
|
304
|
-
*
|
|
305
|
-
* // With formatting
|
|
306
|
-
* const formatted = Json.stringifySortedKey(unorderedData, 2);
|
|
307
|
-
*
|
|
308
|
-
* assert.isTrue(Result.isOk(formatted));
|
|
309
|
-
*
|
|
310
|
-
* if (Result.isOk(formatted)) {
|
|
311
|
-
* assert.isTrue(isString(formatted.value));
|
|
312
|
-
*
|
|
313
|
-
* // Check that keys are in order (first key should be "apple")
|
|
314
|
-
* assert.isTrue(
|
|
315
|
-
* formatted.value.indexOf('"apple"') < formatted.value.indexOf('"mango"'),
|
|
316
|
-
* );
|
|
317
|
-
*
|
|
318
|
-
* assert.isTrue(
|
|
319
|
-
* formatted.value.indexOf('"mango"') <
|
|
320
|
-
* formatted.value.indexOf('"nested"'),
|
|
321
|
-
* );
|
|
322
|
-
*
|
|
323
|
-
* assert.isTrue(
|
|
324
|
-
* formatted.value.indexOf('"nested"') <
|
|
325
|
-
* formatted.value.indexOf('"zebra"'),
|
|
326
|
-
* );
|
|
327
|
-
* }
|
|
328
|
-
* ```
|
|
329
|
-
*
|
|
330
|
-
* @param value - An object (`UnknownRecord`) to serialize. Must be a plain
|
|
331
|
-
* object (not an array, primitive, or null). Nested objects and arrays
|
|
332
|
-
* within the object will also have their keys sorted alphabetically.
|
|
333
|
-
* @param space - Optional formatting parameter:
|
|
334
|
-
*
|
|
335
|
-
* - Number (1-10): Number of spaces to indent each level
|
|
336
|
-
* - String: String to use for indentation (first 10 characters)
|
|
337
|
-
* - Undefined/null: No formatting (compact output)
|
|
338
|
-
*
|
|
339
|
-
* @returns A `Result<string, string>` containing:
|
|
340
|
-
*
|
|
341
|
-
* - On success: `Result.ok(jsonString)` with all object keys sorted
|
|
342
|
-
* alphabetically
|
|
343
|
-
* - On failure: `Result.err(errorMessage)` describing the serialization error
|
|
344
|
-
*/
|
|
345
|
-
Json.stringifySortedKey = (value, space) => {
|
|
346
|
-
const allKeys = pipe(keysDeep(value))
|
|
347
|
-
.map((keys) => uniq(keys))
|
|
348
|
-
.map((ks) => ks.toSorted()).value;
|
|
349
|
-
return Json.stringifySelected(value, allKeys, space);
|
|
350
|
-
};
|
|
51
|
+
((Json2) => {
|
|
52
|
+
Json2.parse = (text, reviver) => {
|
|
53
|
+
try {
|
|
54
|
+
return ok(
|
|
55
|
+
JSON.parse(
|
|
56
|
+
text,
|
|
57
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
58
|
+
reviver
|
|
59
|
+
)
|
|
60
|
+
);
|
|
61
|
+
} catch (error) {
|
|
62
|
+
const errStr = unknownToString(error);
|
|
63
|
+
return err(errStr);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
Json2.stringify = (value, replacer, space) => {
|
|
67
|
+
try {
|
|
68
|
+
return ok(JSON.stringify(value, replacer, space));
|
|
69
|
+
} catch (error) {
|
|
70
|
+
const errStr = unknownToString(error);
|
|
71
|
+
return err(errStr);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
Json2.stringifySelected = (value, propertiesToBeSelected, space) => {
|
|
75
|
+
try {
|
|
76
|
+
return ok(
|
|
77
|
+
JSON.stringify(value, castMutable(propertiesToBeSelected), space)
|
|
78
|
+
);
|
|
79
|
+
} catch (error) {
|
|
80
|
+
const errStr = unknownToString(error);
|
|
81
|
+
return err(errStr);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
Json2.stringifySortedKey = (value, space) => {
|
|
85
|
+
const allKeys = pipe(keysDeep(value)).map((keys) => uniq(keys)).map((ks) => ks.toSorted()).value;
|
|
86
|
+
return (0, Json2.stringifySelected)(value, allKeys, space);
|
|
87
|
+
};
|
|
351
88
|
})(Json || (Json = {}));
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
*/
|
|
363
|
-
const keysDeepImpl = (obj,
|
|
364
|
-
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
365
|
-
mut_keys) => {
|
|
366
|
-
for (const [k, v] of Object.entries(obj)) {
|
|
367
|
-
mut_keys.push(k);
|
|
368
|
-
if (isRecord(v)) {
|
|
369
|
-
keysDeepImpl(v, mut_keys);
|
|
370
|
-
}
|
|
371
|
-
if (Array.isArray(v)) {
|
|
372
|
-
for (const li of v) {
|
|
373
|
-
if (isRecord(li)) {
|
|
374
|
-
keysDeepImpl(li, mut_keys);
|
|
375
|
-
}
|
|
376
|
-
}
|
|
89
|
+
const keysDeepImpl = (obj, mut_keys) => {
|
|
90
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
91
|
+
mut_keys.push(k);
|
|
92
|
+
if (isRecord(v)) {
|
|
93
|
+
keysDeepImpl(v, mut_keys);
|
|
94
|
+
}
|
|
95
|
+
if (Array.isArray(v)) {
|
|
96
|
+
for (const li of v) {
|
|
97
|
+
if (isRecord(li)) {
|
|
98
|
+
keysDeepImpl(li, mut_keys);
|
|
377
99
|
}
|
|
100
|
+
}
|
|
378
101
|
}
|
|
102
|
+
}
|
|
379
103
|
};
|
|
380
|
-
/**
|
|
381
|
-
* @param obj - The record to extract keys from. Must be a plain object.
|
|
382
|
-
* @returns A readonly array of all string keys found in the object and its
|
|
383
|
-
* nested objects/arrays. May contain duplicates if the same key appears at
|
|
384
|
-
* multiple levels.
|
|
385
|
-
* @internal
|
|
386
|
-
* Extracts all property keys from a nested object structure into a flat array.
|
|
387
|
-
*
|
|
388
|
-
* This function serves as a safe wrapper around `keysDeepImpl`, creating a new
|
|
389
|
-
* mutable array and passing it to the recursive implementation. The result
|
|
390
|
-
* contains all keys found at any level of nesting within the input object.
|
|
391
|
-
*/
|
|
392
104
|
const keysDeep = (obj) => {
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
105
|
+
const mut_keys = [];
|
|
106
|
+
keysDeepImpl(obj, mut_keys);
|
|
107
|
+
return mut_keys;
|
|
396
108
|
};
|
|
397
109
|
|
|
398
110
|
export { Json };
|
package/dist/json/json.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.mjs","sources":["../../src/json/json.mts"],"sourcesContent":[null],"names":["Result.ok","Result.err","Arr.uniq"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA;;;;AAIG;AACG,IAAW;AAAjB,CAAA,UAAiB,IAAI,EAAA;AACnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDG;AACU,IAAA,IAAA,CAAA,KAAK,GAAG,CACnB,IAAY,EACZ,OAAmE,KACtC;AAC7B,QAAA,IAAI;YACF,OAAOA,EAAS,CACd,IAAI,CAAC,KAAK,CACR,IAAI;;YAEJ,OAAkE,CACnE,CACF;QACH;QAAE,OAAO,KAAc,EAAE;AACvB,YAAA,MAAM,MAAM,GAAG,eAAe,CAAC,KAAK,CAAC;AAErC,YAAA,OAAOC,GAAU,CAAC,MAAM,CAAC;QAC3B;AACF,IAAA,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+DG;IACU,IAAA,CAAA,SAAS,GAAG,CACvB,KAAc,EACd,QAAgE,EAChE,KAA0C,KACJ;AACtC,QAAA,IAAI;AACF,YAAA,OAAOD,EAAS,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;QAC1D;QAAE,OAAO,KAAK,EAAE;AACd,YAAA,MAAM,MAAM,GAAG,eAAe,CAAC,KAAK,CAAC;AAErC,YAAA,OAAOC,GAAU,CAAC,MAAM,CAAC;QAC3B;AACF,IAAA,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEG;IACU,IAAA,CAAA,iBAAiB,GAAG,CAC/B,KAAc,EACd,sBAAqD,EACrD,KAA0C,KACJ;AACtC,QAAA,IAAI;AACF,YAAA,OAAOD,EAAS,CACd,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,WAAW,CAAC,sBAAsB,CAAC,EAAE,KAAK,CAAC,CAClE;QACH;QAAE,OAAO,KAAK,EAAE;AACd,YAAA,MAAM,MAAM,GAAG,eAAe,CAAC,KAAK,CAAC;AAErC,YAAA,OAAOC,GAAU,CAAC,MAAM,CAAC;QAC3B;AACF,IAAA,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4EG;AACU,IAAA,IAAA,CAAA,kBAAkB,GAAG,CAChC,KAAoB,EACpB,KAA0C,KACJ;QACtC,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;AACjC,aAAA,GAAG,CAAC,CAAC,IAAI,KAAKC,IAAQ,CAAC,IAAI,CAAC;AAC5B,aAAA,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC,KAAK;QAEnC,OAAO,IAAA,CAAA,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC;AACjD,IAAA,CAAC;AACH,CAAC,EA/TgB,IAAI,KAAJ,IAAI,GAAA,EAAA,CAAA,CAAA;AAiUrB;;;;;;;;;;AAUG;AACH,MAAM,YAAY,GAAG,CACnB,GAAkB;AAClB;AACA,QAAkB,KACV;AACR,IAAA,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;AACxC,QAAA,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;AAEhB,QAAA,IAAI,QAAQ,CAAC,CAAC,CAAC,EAAE;AACf,YAAA,YAAY,CAAC,CAAC,EAAE,QAAQ,CAAC;QAC3B;AAEA,QAAA,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;AACpB,YAAA,KAAK,MAAM,EAAE,IAAI,CAAC,EAAE;AAClB,gBAAA,IAAI,QAAQ,CAAC,EAAE,CAAC,EAAE;AAChB,oBAAA,YAAY,CAAC,EAAE,EAAE,QAAQ,CAAC;gBAC5B;YACF;QACF;IACF;AACF,CAAC;AAED;;;;;;;;;;;AAWG;AACH,MAAM,QAAQ,GAAG,CAAC,GAAkB,KAAuB;IACzD,MAAM,QAAQ,GAAa,EAAE;AAE7B,IAAA,YAAY,CAAC,GAAG,EAAE,QAAQ,CAAC;AAE3B,IAAA,OAAO,QAAQ;AACjB,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"json.mjs","sources":["../../src/json/json.mts"],"sourcesContent":["import {\n type JsonValue,\n type UintRangeInclusive,\n type UnknownRecord,\n} from 'ts-type-forge';\nimport { Arr } from '../array/index.mjs';\nimport { pipe, Result } from '../functional/index.mjs';\nimport { isRecord } from '../guard/index.mjs';\nimport { castMutable, unknownToString } from '../others/index.mjs';\n\n/**\n * A collection of type-safe JSON utility functions that provide safe parsing,\n * stringification, and manipulation of JSON data. All functions return `Result`\n * types to handle errors without throwing exceptions.\n */\nexport namespace Json {\n /**\n * Safely converts a JSON string into a JavaScript value without throwing\n * exceptions.\n *\n * This function provides type-safe JSON parsing by wrapping the native\n * `JSON.parse` in a `Result` type, allowing you to handle parsing errors\n * gracefully without try-catch blocks.\n *\n * @example\n *\n * ```ts\n * const validJson = '{\"name\": \"Alice\", \"age\": 30}';\n *\n * const invalidJson = '{invalid json}';\n *\n * const parsed = Json.parse(validJson);\n *\n * const failed = Json.parse(invalidJson);\n *\n * assert.isTrue(Result.isOk(parsed));\n *\n * if (Result.isOk(parsed)) {\n * assert.deepStrictEqual(parsed.value, { name: 'Alice', age: 30 });\n * }\n *\n * assert.isTrue(Result.isErr(failed));\n *\n * // With reviver\n * const jsonWithDate = '{\"created\": \"2024-01-01T00:00:00.000Z\"}';\n *\n * const withReviver = Json.parse(jsonWithDate, (key, value) => {\n * if (key === 'created' && typeof value === 'string') {\n * return new Date(value);\n * }\n *\n * return value;\n * });\n *\n * assert.isTrue(Result.isOk(withReviver));\n * ```\n *\n * @param text - A valid JSON string to parse. Can contain any valid JSON data\n * type: primitives (string, number, boolean, null), arrays, or objects.\n * @param reviver - Optional function that transforms parsed values. Called\n * for each key-value pair in the JSON. The function receives the key name\n * and parsed value, and should return the transformed value. For nested\n * objects, inner objects are processed before outer objects.\n * @returns A `Result<JsonValue, string>` containing:\n *\n * - On success: `Result.ok(parsedValue)` where `parsedValue` is the parsed JSON\n * - On failure: `Result.err(errorMessage)` where `errorMessage` describes the\n * parsing error\n */\n export const parse = (\n text: string,\n reviver?: (this: unknown, key: string, value: JsonValue) => unknown,\n ): Result<JsonValue, string> => {\n try {\n return Result.ok(\n JSON.parse(\n text,\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n reviver as (this: unknown, key: string, value: unknown) => unknown,\n ),\n );\n } catch (error: unknown) {\n const errStr = unknownToString(error);\n\n return Result.err(errStr);\n }\n };\n\n /**\n * Safely converts a JavaScript value to a JSON string without throwing\n * exceptions.\n *\n * This function provides type-safe JSON stringification by wrapping the\n * native `JSON.stringify` in a `Result` type, allowing you to handle\n * serialization errors gracefully (such as circular references or BigInt\n * values).\n *\n * @example\n *\n * ```ts\n * const data = { name: 'Bob', age: 25, active: true } as const;\n *\n * // Basic stringify\n * const basic = Json.stringify(data);\n *\n * assert.isTrue(Result.isOk(basic));\n *\n * if (Result.isOk(basic)) {\n * assert.isTrue(basic.value === '{\"name\":\"Bob\",\"age\":25,\"active\":true}');\n * }\n *\n * // With formatting\n * const formatted = Json.stringify(data, undefined, 2);\n *\n * assert.isTrue(Result.isOk(formatted));\n *\n * // With replacer\n * const filtered = Json.stringify(data, (key, value) => {\n * if (key === 'age') return undefined; // omit age field\n *\n * return value;\n * });\n *\n * assert.isTrue(Result.isOk(filtered));\n *\n * if (Result.isOk(filtered)) {\n * assert.isTrue(isString(filtered.value));\n *\n * assert.isFalse(filtered.value.includes('age'));\n * }\n * ```\n *\n * @param value - The JavaScript value to serialize. Can be any value that\n * JSON.stringify accepts: primitives, objects, arrays. Non-serializable\n * values (functions, undefined, symbols) will be omitted or converted to\n * null according to JSON.stringify behavior.\n * @param replacer - Optional function that transforms values during\n * serialization. Called for each key-value pair. Should return the value to\n * be serialized, or undefined to omit the property from the result.\n * @param space - Optional parameter for formatting the output JSON:\n *\n * - Number (1-10): Number of spaces to indent each level\n * - String: String to use for indentation (first 10 characters)\n * - Undefined/null: No formatting (compact output)\n *\n * @returns A `Result<string, string>` containing:\n *\n * - On success: `Result.ok(jsonString)` where `jsonString` is the serialized\n * JSON\n * - On failure: `Result.err(errorMessage)` where `errorMessage` describes the\n * error\n */\n export const stringify = (\n value: unknown,\n replacer?: (this: unknown, key: string, val: unknown) => unknown,\n space?: UintRangeInclusive<1, 10> | string,\n ): Result<string | undefined, string> => {\n try {\n return Result.ok(JSON.stringify(value, replacer, space));\n } catch (error) {\n const errStr = unknownToString(error);\n\n return Result.err(errStr);\n }\n };\n\n /**\n * Safely converts a JavaScript value to a JSON string, including only the\n * specified properties.\n *\n * This function provides selective serialization by allowing you to specify\n * exactly which object properties should be included in the resulting JSON.\n * It's useful for creating filtered or minimal representations of objects,\n * such as for API responses or logging.\n *\n * @example\n *\n * ```ts\n * const user = {\n * id: 1,\n * name: 'Charlie',\n * email: 'charlie@example.com',\n * password: 'secret123',\n * role: 'admin',\n * } as const;\n *\n * // Select only safe properties to serialize\n * const safeJson = Json.stringifySelected(user, ['id', 'name', 'role']);\n *\n * assert.isTrue(Result.isOk(safeJson));\n *\n * if (Result.isOk(safeJson)) {\n * assert.isTrue(isString(safeJson.value));\n *\n * const parsed: unknown = JSON.parse(safeJson.value);\n *\n * assert.deepStrictEqual(parsed, {\n * id: 1,\n * name: 'Charlie',\n * role: 'admin',\n * });\n *\n * assert.isFalse(safeJson.value.includes('password'));\n *\n * assert.isFalse(safeJson.value.includes('email'));\n * }\n *\n * // With formatting\n * const formatted = Json.stringifySelected(user, ['id', 'name'], 2);\n *\n * assert.isTrue(Result.isOk(formatted));\n * ```\n *\n * @param value - The JavaScript value to serialize. While any value is\n * accepted, the property filtering only applies to objects and nested\n * objects.\n * @param propertiesToBeSelected - Optional array of property names (strings)\n * and array indices (numbers) to include in the serialization. If provided,\n * only these properties will appear in the output JSON. If undefined, all\n * properties are included.\n * @param space - Optional formatting parameter:\n *\n * - Number (1-10): Number of spaces to indent each level\n * - String: String to use for indentation (first 10 characters)\n * - Undefined/null: No formatting (compact output)\n *\n * @returns A `Result<string, string>` containing:\n *\n * - On success: `Result.ok(jsonString)` with only selected properties\n * - On failure: `Result.err(errorMessage)` describing the serialization error\n */\n export const stringifySelected = (\n value: unknown,\n propertiesToBeSelected?: readonly (number | string)[],\n space?: UintRangeInclusive<1, 10> | string,\n ): Result<string | undefined, string> => {\n try {\n return Result.ok(\n JSON.stringify(value, castMutable(propertiesToBeSelected), space),\n );\n } catch (error) {\n const errStr = unknownToString(error);\n\n return Result.err(errStr);\n }\n };\n\n /**\n * Safely converts a JavaScript record to a JSON string with keys sorted\n * alphabetically at all levels.\n *\n * This function creates deterministic JSON output by ensuring that object\n * keys appear in alphabetical order at every level of nesting. This is\n * particularly useful for creating consistent output for comparison, hashing,\n * caching, or when you need reproducible JSON representations across\n * different JavaScript engines or runs.\n *\n * @example\n *\n * ```ts\n * const unorderedData = {\n * zebra: 1,\n * apple: 2,\n * mango: 3,\n * nested: {\n * zulu: 'z',\n * alpha: 'a',\n * beta: 'b',\n * },\n * } as const;\n *\n * // Keys will be sorted alphabetically at all levels\n * const sorted = Json.stringifySortedKey(unorderedData);\n *\n * assert.isTrue(Result.isOk(sorted));\n *\n * if (Result.isOk(sorted)) {\n * // Keys should appear in alphabetical order\n * const expected =\n * '{\"apple\":2,\"mango\":3,\"nested\":{\"alpha\":\"a\",\"beta\":\"b\",\"zulu\":\"z\"},\"zebra\":1}';\n *\n * assert.isTrue(sorted.value === expected);\n * }\n *\n * // With formatting\n * const formatted = Json.stringifySortedKey(unorderedData, 2);\n *\n * assert.isTrue(Result.isOk(formatted));\n *\n * if (Result.isOk(formatted)) {\n * assert.isTrue(isString(formatted.value));\n *\n * // Check that keys are in order (first key should be \"apple\")\n * assert.isTrue(\n * formatted.value.indexOf('\"apple\"') < formatted.value.indexOf('\"mango\"'),\n * );\n *\n * assert.isTrue(\n * formatted.value.indexOf('\"mango\"') <\n * formatted.value.indexOf('\"nested\"'),\n * );\n *\n * assert.isTrue(\n * formatted.value.indexOf('\"nested\"') <\n * formatted.value.indexOf('\"zebra\"'),\n * );\n * }\n * ```\n *\n * @param value - An object (`UnknownRecord`) to serialize. Must be a plain\n * object (not an array, primitive, or null). Nested objects and arrays\n * within the object will also have their keys sorted alphabetically.\n * @param space - Optional formatting parameter:\n *\n * - Number (1-10): Number of spaces to indent each level\n * - String: String to use for indentation (first 10 characters)\n * - Undefined/null: No formatting (compact output)\n *\n * @returns A `Result<string, string>` containing:\n *\n * - On success: `Result.ok(jsonString)` with all object keys sorted\n * alphabetically\n * - On failure: `Result.err(errorMessage)` describing the serialization error\n */\n export const stringifySortedKey = (\n value: UnknownRecord,\n space?: UintRangeInclusive<1, 10> | string,\n ): Result<string | undefined, string> => {\n const allKeys = pipe(keysDeep(value))\n .map((keys) => Arr.uniq(keys))\n .map((ks) => ks.toSorted()).value;\n\n return stringifySelected(value, allKeys, space);\n };\n}\n\n/**\n * @param obj - The record to extract keys from. Must be a plain object.\n * @param mut_keys - A mutable array to accumulate the collected keys. This\n * array will be modified in-place by the function for performance reasons.\n * @internal\n * Recursively collects all property keys from a nested object structure.\n *\n * This helper function traverses an object and its nested objects and arrays,\n * collecting all string keys found at any level of nesting. The function mutates\n * the provided keys array for performance reasons.\n */\nconst keysDeepImpl = (\n obj: UnknownRecord,\n // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types\n mut_keys: string[],\n): void => {\n for (const [k, v] of Object.entries(obj)) {\n mut_keys.push(k);\n\n if (isRecord(v)) {\n keysDeepImpl(v, mut_keys);\n }\n\n if (Array.isArray(v)) {\n for (const li of v) {\n if (isRecord(li)) {\n keysDeepImpl(li, mut_keys);\n }\n }\n }\n }\n};\n\n/**\n * @param obj - The record to extract keys from. Must be a plain object.\n * @returns A readonly array of all string keys found in the object and its\n * nested objects/arrays. May contain duplicates if the same key appears at\n * multiple levels.\n * @internal\n * Extracts all property keys from a nested object structure into a flat array.\n *\n * This function serves as a safe wrapper around `keysDeepImpl`, creating a new\n * mutable array and passing it to the recursive implementation. The result\n * contains all keys found at any level of nesting within the input object.\n */\nconst keysDeep = (obj: UnknownRecord): readonly string[] => {\n const mut_keys: string[] = [];\n\n keysDeepImpl(obj, mut_keys);\n\n return mut_keys;\n};\n"],"names":["Json","Result.ok","Result.err","Arr.uniq"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeO,IAAU;AAAA,CAAV,CAAUA,KAAAA,KAAV;AAsDE,EAAMA,KAAAA,CAAA,KAAA,GAAQ,CACnB,IAAA,EACA,OAAA,KAC8B;AAC9B,IAAA,IAAI;AACF,MAAA,OAAOC,EAAO;AAAA,QACZ,IAAA,CAAK,KAAA;AAAA,UACH,IAAA;AAAA;AAAA,UAEA;AAAA;AACF,OACF;AAAA,IACF,SAAS,KAAA,EAAgB;AACvB,MAAA,MAAM,MAAA,GAAS,gBAAgB,KAAK,CAAA;AAEpC,MAAA,OAAOC,IAAW,MAAM,CAAA;AAAA,IAC1B;AAAA,EACF,CAAA;AAkEO,EAAMF,KAAAA,CAAA,SAAA,GAAY,CACvB,KAAA,EACA,UACA,KAAA,KACuC;AACvC,IAAA,IAAI;AACF,MAAA,OAAOC,EAAO,CAAG,IAAA,CAAK,UAAU,KAAA,EAAO,QAAA,EAAU,KAAK,CAAC,CAAA;AAAA,IACzD,SAAS,KAAA,EAAO;AACd,MAAA,MAAM,MAAA,GAAS,gBAAgB,KAAK,CAAA;AAEpC,MAAA,OAAOC,IAAW,MAAM,CAAA;AAAA,IAC1B;AAAA,EACF,CAAA;AAmEO,EAAMF,KAAAA,CAAA,iBAAA,GAAoB,CAC/B,KAAA,EACA,wBACA,KAAA,KACuC;AACvC,IAAA,IAAI;AACF,MAAA,OAAOC,EAAO;AAAA,QACZ,KAAK,SAAA,CAAU,KAAA,EAAO,WAAA,CAAY,sBAAsB,GAAG,KAAK;AAAA,OAClE;AAAA,IACF,SAAS,KAAA,EAAO;AACd,MAAA,MAAM,MAAA,GAAS,gBAAgB,KAAK,CAAA;AAEpC,MAAA,OAAOC,IAAW,MAAM,CAAA;AAAA,IAC1B;AAAA,EACF,CAAA;AA+EO,EAAMF,KAAAA,CAAA,kBAAA,GAAqB,CAChC,KAAA,EACA,KAAA,KACuC;AACvC,IAAA,MAAM,OAAA,GAAU,KAAK,QAAA,CAAS,KAAK,CAAC,CAAA,CACjC,GAAA,CAAI,CAAC,IAAA,KAASG,KAAS,IAAI,CAAC,EAC5B,GAAA,CAAI,CAAC,OAAO,EAAA,CAAG,QAAA,EAAU,CAAA,CAAE,KAAA;AAE9B,IAAA,OAAA,IAAOH,KAAAA,CAAA,iBAAA,EAAkB,KAAA,EAAO,OAAA,EAAS,KAAK,CAAA;AAAA,EAChD,CAAA;AAAA,CAAA,EA9Te,IAAA,KAAA,IAAA,GAAA,EAAA,CAAA,CAAA;AA4UjB,MAAM,YAAA,GAAe,CACnB,GAAA,EAEA,QAAA,KACS;AACT,EAAA,KAAA,MAAW,CAAC,CAAA,EAAG,CAAC,KAAK,MAAA,CAAO,OAAA,CAAQ,GAAG,CAAA,EAAG;AACxC,IAAA,QAAA,CAAS,KAAK,CAAC,CAAA;AAEf,IAAA,IAAI,QAAA,CAAS,CAAC,CAAA,EAAG;AACf,MAAA,YAAA,CAAa,GAAG,QAAQ,CAAA;AAAA,IAC1B;AAEA,IAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,CAAC,CAAA,EAAG;AACpB,MAAA,KAAA,MAAW,MAAM,CAAA,EAAG;AAClB,QAAA,IAAI,QAAA,CAAS,EAAE,CAAA,EAAG;AAChB,UAAA,YAAA,CAAa,IAAI,QAAQ,CAAA;AAAA,QAC3B;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF,CAAA;AAcA,MAAM,QAAA,GAAW,CAAC,GAAA,KAA0C;AAC1D,EAAA,MAAM,WAAqB,EAAC;AAE5B,EAAA,YAAA,CAAa,KAAK,QAAQ,CAAA;AAE1B,EAAA,OAAO,QAAA;AACT,CAAA;;;;"}
|
|
@@ -25,8 +25,8 @@ export declare const isFiniteNumber: (a: number) => a is TtfImported_FiniteNumbe
|
|
|
25
25
|
* @throws {TypeError} If the value is NaN, Infinity, or -Infinity
|
|
26
26
|
*/
|
|
27
27
|
export declare const asFiniteNumber: <N extends number>(x: N) => number & {
|
|
28
|
-
readonly NaNValue: false;
|
|
29
28
|
readonly Finite: true;
|
|
29
|
+
readonly NaNValue: false;
|
|
30
30
|
} & Readonly<{
|
|
31
31
|
'TSTypeForgeInternals--edd2f9ce-7ca5-45b0-9d1a-bd61b9b5d9c3': unknown;
|
|
32
32
|
}> & N;
|
|
@@ -150,9 +150,9 @@ export declare const FiniteNumber: {
|
|
|
150
150
|
* @returns The quotient `a / b` as a FiniteNumber
|
|
151
151
|
*/
|
|
152
152
|
readonly div: (x: TtfImported_FiniteNumber, y: number & {
|
|
153
|
-
readonly NaNValue: false;
|
|
154
|
-
readonly Finite: true;
|
|
155
153
|
readonly "!=0": true;
|
|
154
|
+
readonly Finite: true;
|
|
155
|
+
readonly NaNValue: false;
|
|
156
156
|
} & Readonly<{
|
|
157
157
|
'TSTypeForgeInternals--edd2f9ce-7ca5-45b0-9d1a-bd61b9b5d9c3': unknown;
|
|
158
158
|
}>) => TtfImported_FiniteNumber;
|