ts-data-forge 8.0.0 → 9.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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.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 +1 -1
- 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.map +1 -1
- package/dist/array/impl/array-utils-validation.mjs +18 -169
- package/dist/array/impl/array-utils-validation.mjs.map +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 +1 -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/functional/ternary-result/ternary-result.d.mts.map +1 -1
- 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 +1 -0
- package/dist/guard/index.d.mts.map +1 -1
- package/dist/guard/index.mjs +1 -0
- package/dist/guard/index.mjs.map +1 -1
- package/dist/guard/is-length-bounded-string.d.mts +164 -0
- package/dist/guard/is-length-bounded-string.d.mts.map +1 -0
- package/dist/guard/is-length-bounded-string.mjs +7 -0
- package/dist/guard/is-length-bounded-string.mjs.map +1 -0
- 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 +1 -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 +17 -16
- package/src/array/impl/array-utils-transformation.mts +1 -2
- package/src/array/impl/array-utils-transformation.test.mts +3 -36
- package/src/array/impl/array-utils-validation.test.mts +1 -3
- package/src/expect-type.mts +4 -5
- package/src/functional/ternary-result/ternary-result.mts +2 -6
- package/src/guard/index.mts +1 -0
- package/src/guard/is-length-bounded-string.mts +199 -0
- package/src/guard/is-length-bounded-string.test.mts +170 -0
- package/src/number/refined-number-utils.mts +1 -9
- package/src/object/object.mts +25 -23
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-data-forge",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -77,16 +77,16 @@
|
|
|
77
77
|
"test:cov:ui": "vite preview --outDir ./coverage",
|
|
78
78
|
"test:ui": "pnpm run z:vitest:node --ui",
|
|
79
79
|
"testw": "pnpm run z:vitest:node watch",
|
|
80
|
-
"tsc": "tsc --noEmit",
|
|
81
|
-
"tscw": "tsc --noEmit --watch -p ./tsconfig.json",
|
|
82
|
-
"type-check": "tsc --noEmit",
|
|
80
|
+
"tsc": "node ./node_modules/typescript-native/bin/tsc --noEmit",
|
|
81
|
+
"tscw": "node ./node_modules/typescript-native/bin/tsc --noEmit --watch -p ./tsconfig.json",
|
|
82
|
+
"type-check": "node ./node_modules/typescript-native/bin/tsc --noEmit",
|
|
83
83
|
"update-packages": "pnpm update --latest",
|
|
84
84
|
"z:vitest": "vitest --config ./configs/vitest.config.mts",
|
|
85
85
|
"z:vitest:node": "pnpm run z:vitest --project='Node.js'"
|
|
86
86
|
},
|
|
87
87
|
"dependencies": {
|
|
88
88
|
"@sindresorhus/is": "^8.1.0",
|
|
89
|
-
"ts-type-forge": "^
|
|
89
|
+
"ts-type-forge": "^5.0.0"
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
92
|
"@emotion/react": "11.14.0",
|
|
@@ -94,15 +94,14 @@
|
|
|
94
94
|
"@mui/material": "9.1.2",
|
|
95
95
|
"@rollup/plugin-replace": "6.0.3",
|
|
96
96
|
"@rollup/plugin-strip": "3.0.4",
|
|
97
|
-
"@rollup/plugin-typescript": "12.3.0",
|
|
98
97
|
"@semantic-release/changelog": "6.0.3",
|
|
99
98
|
"@semantic-release/commit-analyzer": "13.0.1",
|
|
100
99
|
"@semantic-release/exec": "7.1.0",
|
|
101
100
|
"@semantic-release/git": "10.0.1",
|
|
102
|
-
"@semantic-release/github": "12.0.
|
|
101
|
+
"@semantic-release/github": "12.0.9",
|
|
103
102
|
"@semantic-release/npm": "13.1.5",
|
|
104
103
|
"@semantic-release/release-notes-generator": "14.1.1",
|
|
105
|
-
"@types/node": "26.0
|
|
104
|
+
"@types/node": "26.1.0",
|
|
106
105
|
"@types/react": "19.2.17",
|
|
107
106
|
"@vitest/browser-playwright": "4.1.9",
|
|
108
107
|
"@vitest/coverage-v8": "4.1.9",
|
|
@@ -110,35 +109,37 @@
|
|
|
110
109
|
"conventional-changelog-conventionalcommits": "10.2.0",
|
|
111
110
|
"cspell": "10.0.1",
|
|
112
111
|
"dedent": "1.7.2",
|
|
112
|
+
"esbuild": "0.28.1",
|
|
113
113
|
"eslint": "9.39.4",
|
|
114
114
|
"eslint-config-typed": "5.3.0",
|
|
115
115
|
"github-settings-as-code": "1.2.9",
|
|
116
|
-
"immer": "11.1.
|
|
116
|
+
"immer": "11.1.9",
|
|
117
117
|
"jiti": "2.7.0",
|
|
118
118
|
"markdownlint": "0.41.0",
|
|
119
|
-
"markdownlint-cli2": "0.
|
|
119
|
+
"markdownlint-cli2": "0.23.0",
|
|
120
120
|
"npm-run-all2": "9.0.2",
|
|
121
|
-
"playwright": "1.61.
|
|
122
|
-
"prettier": "3.
|
|
121
|
+
"playwright": "1.61.1",
|
|
122
|
+
"prettier": "3.9.4",
|
|
123
123
|
"prettier-plugin-organize-imports": "4.3.0",
|
|
124
124
|
"prettier-plugin-packagejson": "3.0.2",
|
|
125
125
|
"react": "19.2.7",
|
|
126
126
|
"rollup": "4.62.2",
|
|
127
|
+
"rollup-plugin-esbuild": "6.2.1",
|
|
127
128
|
"semantic-release": "25.0.5",
|
|
128
129
|
"ts-codemod-lib": "2.2.1",
|
|
129
130
|
"ts-repo-utils": "10.1.2",
|
|
130
|
-
"tslib": "2.8.1",
|
|
131
131
|
"tsx": "4.22.4",
|
|
132
132
|
"typedoc": "0.28.19",
|
|
133
133
|
"typedoc-github-theme": "0.4.0",
|
|
134
|
-
"typescript": "
|
|
135
|
-
"
|
|
134
|
+
"typescript": "6.0.3",
|
|
135
|
+
"typescript-native": "npm:typescript@7.0.1-rc",
|
|
136
|
+
"vite": "8.1.3",
|
|
136
137
|
"vitest": "4.1.9"
|
|
137
138
|
},
|
|
138
139
|
"peerDependencies": {
|
|
139
140
|
"typescript": ">=4.8"
|
|
140
141
|
},
|
|
141
|
-
"packageManager": "pnpm@10.
|
|
142
|
+
"packageManager": "pnpm@11.10.0",
|
|
142
143
|
"engines": {
|
|
143
144
|
"node": ">=22.22.2",
|
|
144
145
|
"pnpm": ">=9.0.0"
|
|
@@ -651,8 +651,7 @@ export function partition<
|
|
|
651
651
|
E,
|
|
652
652
|
>(
|
|
653
653
|
...args:
|
|
654
|
-
|
|
655
|
-
| readonly [chunkSize: N]
|
|
654
|
+
readonly [array: readonly E[], chunkSize: N] | readonly [chunkSize: N]
|
|
656
655
|
):
|
|
657
656
|
| readonly (readonly E[])[]
|
|
658
657
|
| ((array: readonly E[]) => readonly (readonly E[])[]) {
|
|
@@ -645,18 +645,7 @@ describe('Arr transformations', () => {
|
|
|
645
645
|
expectType<
|
|
646
646
|
typeof result,
|
|
647
647
|
readonly (readonly (
|
|
648
|
-
|
|
|
649
|
-
| 2
|
|
650
|
-
| 3
|
|
651
|
-
| 4
|
|
652
|
-
| 5
|
|
653
|
-
| 6
|
|
654
|
-
| 7
|
|
655
|
-
| 8
|
|
656
|
-
| 9
|
|
657
|
-
| 10
|
|
658
|
-
| 11
|
|
659
|
-
| 12
|
|
648
|
+
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12
|
|
660
649
|
)[])[]
|
|
661
650
|
>('=');
|
|
662
651
|
|
|
@@ -675,18 +664,7 @@ describe('Arr transformations', () => {
|
|
|
675
664
|
expectType<
|
|
676
665
|
typeof result,
|
|
677
666
|
readonly (readonly (
|
|
678
|
-
|
|
|
679
|
-
| 2
|
|
680
|
-
| 3
|
|
681
|
-
| 4
|
|
682
|
-
| 5
|
|
683
|
-
| 6
|
|
684
|
-
| 7
|
|
685
|
-
| 8
|
|
686
|
-
| 9
|
|
687
|
-
| 10
|
|
688
|
-
| 11
|
|
689
|
-
| 12
|
|
667
|
+
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12
|
|
690
668
|
)[])[]
|
|
691
669
|
>('=');
|
|
692
670
|
|
|
@@ -706,18 +684,7 @@ describe('Arr transformations', () => {
|
|
|
706
684
|
expectType<
|
|
707
685
|
typeof result,
|
|
708
686
|
readonly (readonly (
|
|
709
|
-
|
|
|
710
|
-
| 2
|
|
711
|
-
| 3
|
|
712
|
-
| 4
|
|
713
|
-
| 5
|
|
714
|
-
| 6
|
|
715
|
-
| 7
|
|
716
|
-
| 8
|
|
717
|
-
| 9
|
|
718
|
-
| 10
|
|
719
|
-
| 11
|
|
720
|
-
| 12
|
|
687
|
+
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12
|
|
721
688
|
)[])[]
|
|
722
689
|
>('=');
|
|
723
690
|
|
|
@@ -228,9 +228,7 @@ describe('Arr validations', () => {
|
|
|
228
228
|
|
|
229
229
|
test('should handle union of array types', () => {
|
|
230
230
|
type MixedArrayUnion =
|
|
231
|
-
| readonly
|
|
232
|
-
| readonly number[]
|
|
233
|
-
| readonly boolean[];
|
|
231
|
+
readonly string[] | readonly number[] | readonly boolean[];
|
|
234
232
|
|
|
235
233
|
const mixedArray: MixedArrayUnion = [1, 2, 3] as const;
|
|
236
234
|
|
package/src/expect-type.mts
CHANGED
|
@@ -71,9 +71,8 @@ import { type TypeEq, type TypeExtends } from 'ts-type-forge';
|
|
|
71
71
|
export const expectType = <A, B>(
|
|
72
72
|
_relation: TypeEq<A, B> extends true
|
|
73
73
|
? '<=' | '=' | '>=' | '~='
|
|
74
|
-
:
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
: '!<=' | (TypeExtends<B, A> extends true ? '>=' : '!>=')),
|
|
74
|
+
: | '!='
|
|
75
|
+
| (TypeExtends<A, B> extends true
|
|
76
|
+
? '<=' | (TypeExtends<B, A> extends true ? '>=' | '~=' : '!>=')
|
|
77
|
+
: '!<=' | (TypeExtends<B, A> extends true ? '>=' : '!>=')),
|
|
79
78
|
): void => undefined;
|
|
@@ -39,16 +39,12 @@ export type TernaryErr<E> = Readonly<{
|
|
|
39
39
|
* Represents a value that can be `Ok`, `Warn`, or `Err`.
|
|
40
40
|
*/
|
|
41
41
|
export type TernaryResult<S, E, W = E> =
|
|
42
|
-
|
|
|
43
|
-
| TernaryWarn<S, W>
|
|
44
|
-
| TernaryErr<E>;
|
|
42
|
+
TernaryOk<S> | TernaryWarn<S, W> | TernaryErr<E>;
|
|
45
43
|
|
|
46
44
|
/**
|
|
47
45
|
* Base type for any `TernaryResult`, used for generic constraints.
|
|
48
46
|
*/
|
|
49
47
|
export type UnknownTernaryResult =
|
|
50
|
-
|
|
|
51
|
-
| TernaryWarn<unknown, unknown>
|
|
52
|
-
| TernaryErr<unknown>;
|
|
48
|
+
TernaryOk<unknown> | TernaryWarn<unknown, unknown> | TernaryErr<unknown>;
|
|
53
49
|
|
|
54
50
|
export * as TernaryResult from './impl/index.mjs';
|
package/src/guard/index.mts
CHANGED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type BoundedLengthString,
|
|
3
|
+
type FixedLengthString,
|
|
4
|
+
type MaxLengthString,
|
|
5
|
+
type MinLengthString,
|
|
6
|
+
} from 'ts-type-forge';
|
|
7
|
+
import { type SizeType } from '../types.mjs';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Type guard that checks if a string has at least `minLength` characters.
|
|
11
|
+
*
|
|
12
|
+
* The length is measured in UTF-16 code units (the same unit as
|
|
13
|
+
* `String.prototype.length`), so characters outside the Basic Multilingual
|
|
14
|
+
* Plane (e.g. emoji) count as 2.
|
|
15
|
+
*
|
|
16
|
+
* **Type Narrowing Behavior:**
|
|
17
|
+
*
|
|
18
|
+
* - Narrows the input to `MinLengthString<MinLength>` while preserving the
|
|
19
|
+
* original string type (e.g. literal types) via intersection.
|
|
20
|
+
* - The result participates in the length-constraint subtyping relation: for
|
|
21
|
+
* example, a value narrowed to `MinLengthString<3>` is assignable to
|
|
22
|
+
* `MinLengthString<1>` (= `NonEmptyString`).
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
*
|
|
26
|
+
* ```ts
|
|
27
|
+
* const input: string = 'very-secret-password';
|
|
28
|
+
*
|
|
29
|
+
* assert.isTrue(isMinLengthString(input, 12));
|
|
30
|
+
*
|
|
31
|
+
* assert.isFalse(isMinLengthString('short', 12));
|
|
32
|
+
*
|
|
33
|
+
* if (isMinLengthString(input, 12)) {
|
|
34
|
+
* const password: MinLengthString<12> = input;
|
|
35
|
+
*
|
|
36
|
+
* const nonEmpty: NonEmptyString = input; // OK (12 >= 1)
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @template S - The input string type (literal types are preserved).
|
|
41
|
+
* @template MinLength - The minimum number of characters (inclusive).
|
|
42
|
+
* @param s - The string to check.
|
|
43
|
+
* @param minLength - The minimum number of characters (inclusive).
|
|
44
|
+
* @returns `true` if `s.length >= minLength`, `false` otherwise. When `true`,
|
|
45
|
+
* TypeScript narrows `s` to `MinLengthString<MinLength> & S`.
|
|
46
|
+
*/
|
|
47
|
+
export const isMinLengthString = <
|
|
48
|
+
S extends string,
|
|
49
|
+
MinLength extends SizeType.ArgStr,
|
|
50
|
+
>(
|
|
51
|
+
s: S,
|
|
52
|
+
minLength: MinLength,
|
|
53
|
+
): s is MinLengthString<MinLength> & S => s.length >= minLength;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Type guard that checks if a string has at most `maxLength` characters.
|
|
57
|
+
*
|
|
58
|
+
* The length is measured in UTF-16 code units (the same unit as
|
|
59
|
+
* `String.prototype.length`), so characters outside the Basic Multilingual
|
|
60
|
+
* Plane (e.g. emoji) count as 2.
|
|
61
|
+
*
|
|
62
|
+
* **Type Narrowing Behavior:**
|
|
63
|
+
*
|
|
64
|
+
* - Narrows the input to `MaxLengthString<MaxLength>` while preserving the
|
|
65
|
+
* original string type (e.g. literal types) via intersection.
|
|
66
|
+
* - The result participates in the length-constraint subtyping relation: for
|
|
67
|
+
* example, a value narrowed to `MaxLengthString<16>` is assignable to
|
|
68
|
+
* `MaxLengthString<32>`.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
*
|
|
72
|
+
* ```ts
|
|
73
|
+
* const input: string = 'noshiro';
|
|
74
|
+
*
|
|
75
|
+
* assert.isTrue(isMaxLengthString(input, 32));
|
|
76
|
+
*
|
|
77
|
+
* assert.isFalse(isMaxLengthString(input, 3));
|
|
78
|
+
*
|
|
79
|
+
* if (isMaxLengthString(input, 32)) {
|
|
80
|
+
* const userName: MaxLengthString<32> = input;
|
|
81
|
+
*
|
|
82
|
+
* const relaxed: MaxLengthString<64> = input; // OK (32 <= 64)
|
|
83
|
+
* }
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @template S - The input string type (literal types are preserved).
|
|
87
|
+
* @template MaxLength - The maximum number of characters (inclusive).
|
|
88
|
+
* @param s - The string to check.
|
|
89
|
+
* @param maxLength - The maximum number of characters (inclusive).
|
|
90
|
+
* @returns `true` if `s.length <= maxLength`, `false` otherwise. When `true`,
|
|
91
|
+
* TypeScript narrows `s` to `MaxLengthString<MaxLength> & S`.
|
|
92
|
+
*/
|
|
93
|
+
export const isMaxLengthString = <
|
|
94
|
+
S extends string,
|
|
95
|
+
MaxLength extends SizeType.ArgStr,
|
|
96
|
+
>(
|
|
97
|
+
s: S,
|
|
98
|
+
maxLength: MaxLength,
|
|
99
|
+
): s is MaxLengthString<MaxLength> & S => s.length <= maxLength;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Type guard that checks if a string's length is within the inclusive range
|
|
103
|
+
* `[minLength, maxLength]`.
|
|
104
|
+
*
|
|
105
|
+
* The length is measured in UTF-16 code units (the same unit as
|
|
106
|
+
* `String.prototype.length`), so characters outside the Basic Multilingual
|
|
107
|
+
* Plane (e.g. emoji) count as 2.
|
|
108
|
+
*
|
|
109
|
+
* **Type Narrowing Behavior:**
|
|
110
|
+
*
|
|
111
|
+
* - Narrows the input to `BoundedLengthString<MinLength, MaxLength>` while
|
|
112
|
+
* preserving the original string type (e.g. literal types) via intersection.
|
|
113
|
+
* - Since `BoundedLengthString` is the intersection of `MinLengthString` and
|
|
114
|
+
* `MaxLengthString`, the narrowed value is assignable to both, and both
|
|
115
|
+
* bounds can be weakened independently.
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
*
|
|
119
|
+
* ```ts
|
|
120
|
+
* const input: string = 'user-12345678';
|
|
121
|
+
*
|
|
122
|
+
* assert.isTrue(isBoundedLengthString(input, 8, 16));
|
|
123
|
+
*
|
|
124
|
+
* assert.isFalse(isBoundedLengthString('user', 8, 16));
|
|
125
|
+
*
|
|
126
|
+
* if (isBoundedLengthString(input, 8, 16)) {
|
|
127
|
+
* const userId: BoundedLengthString<8, 16> = input;
|
|
128
|
+
*
|
|
129
|
+
* const relaxed: BoundedLengthString<1, 255> = input; // OK ([8, 16] ⊆ [1, 255])
|
|
130
|
+
* }
|
|
131
|
+
* ```
|
|
132
|
+
*
|
|
133
|
+
* @template S - The input string type (literal types are preserved).
|
|
134
|
+
* @template MinLength - The minimum number of characters (inclusive).
|
|
135
|
+
* @template MaxLength - The maximum number of characters (inclusive).
|
|
136
|
+
* @param s - The string to check.
|
|
137
|
+
* @param minLength - The minimum number of characters (inclusive).
|
|
138
|
+
* @param maxLength - The maximum number of characters (inclusive).
|
|
139
|
+
* @returns `true` if `minLength <= s.length && s.length <= maxLength`, `false`
|
|
140
|
+
* otherwise. When `true`, TypeScript narrows `s` to
|
|
141
|
+
* `BoundedLengthString<MinLength, MaxLength> & S`.
|
|
142
|
+
*/
|
|
143
|
+
export const isBoundedLengthString = <
|
|
144
|
+
S extends string,
|
|
145
|
+
MinLength extends SizeType.ArgStr,
|
|
146
|
+
MaxLength extends SizeType.ArgStr,
|
|
147
|
+
>(
|
|
148
|
+
s: S,
|
|
149
|
+
minLength: MinLength,
|
|
150
|
+
maxLength: MaxLength,
|
|
151
|
+
): s is BoundedLengthString<MinLength, MaxLength> & S =>
|
|
152
|
+
s.length >= minLength && s.length <= maxLength;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Type guard that checks if a string has exactly `length` characters.
|
|
156
|
+
*
|
|
157
|
+
* The length is measured in UTF-16 code units (the same unit as
|
|
158
|
+
* `String.prototype.length`), so characters outside the Basic Multilingual
|
|
159
|
+
* Plane (e.g. emoji) count as 2.
|
|
160
|
+
*
|
|
161
|
+
* **Type Narrowing Behavior:**
|
|
162
|
+
*
|
|
163
|
+
* - Narrows the input to `FixedLengthString<Length>` while preserving the
|
|
164
|
+
* original string type (e.g. literal types) via intersection.
|
|
165
|
+
* - Since `FixedLengthString<Length>` is defined as
|
|
166
|
+
* `BoundedLengthString<Length, Length>`, the narrowed value is assignable to
|
|
167
|
+
* any `MinLengthString<N>` with `N <= Length` and any `MaxLengthString<N>`
|
|
168
|
+
* with `N >= Length`.
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
*
|
|
172
|
+
* ```ts
|
|
173
|
+
* const input: string = 'JP';
|
|
174
|
+
*
|
|
175
|
+
* assert.isTrue(isFixedLengthString(input, 2));
|
|
176
|
+
*
|
|
177
|
+
* assert.isFalse(isFixedLengthString(input, 3));
|
|
178
|
+
*
|
|
179
|
+
* if (isFixedLengthString(input, 2)) {
|
|
180
|
+
* const countryCode: FixedLengthString<2> = input;
|
|
181
|
+
*
|
|
182
|
+
* const atMost5: MaxLengthString<5> = input; // OK (2 <= 5)
|
|
183
|
+
* }
|
|
184
|
+
* ```
|
|
185
|
+
*
|
|
186
|
+
* @template S - The input string type (literal types are preserved).
|
|
187
|
+
* @template Length - The exact number of characters.
|
|
188
|
+
* @param s - The string to check.
|
|
189
|
+
* @param length - The exact number of characters.
|
|
190
|
+
* @returns `true` if `s.length === length`, `false` otherwise. When `true`,
|
|
191
|
+
* TypeScript narrows `s` to `FixedLengthString<Length> & S`.
|
|
192
|
+
*/
|
|
193
|
+
export const isFixedLengthString = <
|
|
194
|
+
S extends string,
|
|
195
|
+
Length extends SizeType.ArgStr,
|
|
196
|
+
>(
|
|
197
|
+
s: S,
|
|
198
|
+
length: Length,
|
|
199
|
+
): s is FixedLengthString<Length> & S => s.length === length;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type BoundedLengthString,
|
|
3
|
+
type FixedLengthString,
|
|
4
|
+
type MaxLengthString,
|
|
5
|
+
type MinLengthString,
|
|
6
|
+
type NonEmptyString,
|
|
7
|
+
} from 'ts-type-forge';
|
|
8
|
+
import { expectType } from '../expect-type.mjs';
|
|
9
|
+
import {
|
|
10
|
+
isBoundedLengthString,
|
|
11
|
+
isFixedLengthString,
|
|
12
|
+
isMaxLengthString,
|
|
13
|
+
isMinLengthString,
|
|
14
|
+
} from './is-length-bounded-string.mjs';
|
|
15
|
+
|
|
16
|
+
describe(isMinLengthString, () => {
|
|
17
|
+
test('should return true when the string is long enough', () => {
|
|
18
|
+
assert.isTrue(isMinLengthString('hello', 3));
|
|
19
|
+
|
|
20
|
+
assert.isTrue(isMinLengthString('hello', 5));
|
|
21
|
+
|
|
22
|
+
assert.isTrue(isMinLengthString('', 0));
|
|
23
|
+
|
|
24
|
+
assert.isTrue(isMinLengthString(' ', 1)); // Space counts
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test('should return false when the string is too short', () => {
|
|
28
|
+
assert.isFalse(isMinLengthString('hi', 3));
|
|
29
|
+
|
|
30
|
+
assert.isFalse(isMinLengthString('', 1));
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('should measure length in UTF-16 code units', () => {
|
|
34
|
+
assert.isTrue(isMinLengthString('🎉', 2)); // Surrogate pair
|
|
35
|
+
|
|
36
|
+
assert.isFalse(isMinLengthString('🎉', 3));
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test('should act as a type guard', () => {
|
|
40
|
+
const value: string = 'very-secret-password';
|
|
41
|
+
|
|
42
|
+
if (isMinLengthString(value, 12)) {
|
|
43
|
+
expectType<typeof value, MinLengthString<12>>('<=');
|
|
44
|
+
|
|
45
|
+
expectType<typeof value, NonEmptyString>('<='); // 12 >= 1
|
|
46
|
+
|
|
47
|
+
expectType<typeof value, MinLengthString<16>>('!<=');
|
|
48
|
+
|
|
49
|
+
expect(value.length).toBeGreaterThanOrEqual(12);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test('should preserve literal string types', () => {
|
|
54
|
+
const literal = 'hello';
|
|
55
|
+
|
|
56
|
+
if (isMinLengthString(literal, 3)) {
|
|
57
|
+
expectType<typeof literal, 'hello'>('<=');
|
|
58
|
+
|
|
59
|
+
expectType<typeof literal, MinLengthString<3>>('<=');
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
describe(isMaxLengthString, () => {
|
|
65
|
+
test('should return true when the string is short enough', () => {
|
|
66
|
+
assert.isTrue(isMaxLengthString('hello', 10));
|
|
67
|
+
|
|
68
|
+
assert.isTrue(isMaxLengthString('hello', 5));
|
|
69
|
+
|
|
70
|
+
assert.isTrue(isMaxLengthString('', 0));
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test('should return false when the string is too long', () => {
|
|
74
|
+
assert.isFalse(isMaxLengthString('hello', 3));
|
|
75
|
+
|
|
76
|
+
assert.isFalse(isMaxLengthString(' ', 0));
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test('should measure length in UTF-16 code units', () => {
|
|
80
|
+
assert.isFalse(isMaxLengthString('🎉', 1)); // Surrogate pair
|
|
81
|
+
|
|
82
|
+
assert.isTrue(isMaxLengthString('🎉', 2));
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test('should act as a type guard', () => {
|
|
86
|
+
const value: string = 'noshiro';
|
|
87
|
+
|
|
88
|
+
if (isMaxLengthString(value, 32)) {
|
|
89
|
+
expectType<typeof value, MaxLengthString<32>>('<=');
|
|
90
|
+
|
|
91
|
+
expectType<typeof value, MaxLengthString<64>>('<='); // 32 <= 64
|
|
92
|
+
|
|
93
|
+
expectType<typeof value, MaxLengthString<16>>('!<=');
|
|
94
|
+
|
|
95
|
+
expect(value.length).toBeLessThanOrEqual(32);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
describe(isBoundedLengthString, () => {
|
|
101
|
+
test('should return true when the length is within the range', () => {
|
|
102
|
+
assert.isTrue(isBoundedLengthString('user-12345678', 8, 16));
|
|
103
|
+
|
|
104
|
+
assert.isTrue(isBoundedLengthString('12345678', 8, 16)); // Lower bound (inclusive)
|
|
105
|
+
|
|
106
|
+
assert.isTrue(isBoundedLengthString('1234567890123456', 8, 16)); // Upper bound (inclusive)
|
|
107
|
+
|
|
108
|
+
assert.isTrue(isBoundedLengthString('', 0, 0));
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
test('should return false when the length is out of range', () => {
|
|
112
|
+
assert.isFalse(isBoundedLengthString('user', 8, 16));
|
|
113
|
+
|
|
114
|
+
assert.isFalse(isBoundedLengthString('12345678901234567', 8, 16));
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
test('should act as a type guard', () => {
|
|
118
|
+
const value: string = 'user-12345678';
|
|
119
|
+
|
|
120
|
+
if (isBoundedLengthString(value, 8, 16)) {
|
|
121
|
+
expectType<typeof value, BoundedLengthString<8, 16>>('<=');
|
|
122
|
+
|
|
123
|
+
expectType<typeof value, BoundedLengthString<1, 255>>('<='); // [8, 16] ⊆ [1, 255]
|
|
124
|
+
|
|
125
|
+
expectType<typeof value, MinLengthString<8>>('<=');
|
|
126
|
+
|
|
127
|
+
expectType<typeof value, MaxLengthString<16>>('<=');
|
|
128
|
+
|
|
129
|
+
expectType<typeof value, NonEmptyString>('<='); // 8 >= 1
|
|
130
|
+
|
|
131
|
+
expectType<typeof value, BoundedLengthString<10, 16>>('!<=');
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
describe(isFixedLengthString, () => {
|
|
137
|
+
test('should return true only for the exact length', () => {
|
|
138
|
+
assert.isTrue(isFixedLengthString('JP', 2));
|
|
139
|
+
|
|
140
|
+
assert.isTrue(isFixedLengthString('', 0));
|
|
141
|
+
|
|
142
|
+
assert.isFalse(isFixedLengthString('JPN', 2));
|
|
143
|
+
|
|
144
|
+
assert.isFalse(isFixedLengthString('J', 2));
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
test('should measure length in UTF-16 code units', () => {
|
|
148
|
+
assert.isTrue(isFixedLengthString('🎉', 2)); // Surrogate pair
|
|
149
|
+
|
|
150
|
+
assert.isFalse(isFixedLengthString('🎉', 1));
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
test('should act as a type guard', () => {
|
|
154
|
+
const value: string = 'JP';
|
|
155
|
+
|
|
156
|
+
if (isFixedLengthString(value, 2)) {
|
|
157
|
+
expectType<typeof value, FixedLengthString<2>>('<=');
|
|
158
|
+
|
|
159
|
+
expectType<typeof value, BoundedLengthString<2, 2>>('<=');
|
|
160
|
+
|
|
161
|
+
expectType<typeof value, MaxLengthString<5>>('<='); // 2 <= 5
|
|
162
|
+
|
|
163
|
+
expectType<typeof value, MinLengthString<1>>('<='); // 2 >= 1
|
|
164
|
+
|
|
165
|
+
expectType<typeof value, NonEmptyString>('<=');
|
|
166
|
+
|
|
167
|
+
expectType<typeof value, FixedLengthString<3>>('!<=');
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
});
|
|
@@ -185,15 +185,7 @@ export namespace TsDataForgeInternals {
|
|
|
185
185
|
}>;
|
|
186
186
|
|
|
187
187
|
type BaseKeys =
|
|
188
|
-
| '
|
|
189
|
-
| 'div'
|
|
190
|
-
| 'is'
|
|
191
|
-
| 'max'
|
|
192
|
-
| 'min'
|
|
193
|
-
| 'mul'
|
|
194
|
-
| 'pow'
|
|
195
|
-
| 'random'
|
|
196
|
-
| 'sub';
|
|
188
|
+
'add' | 'div' | 'is' | 'max' | 'min' | 'mul' | 'pow' | 'random' | 'sub';
|
|
197
189
|
|
|
198
190
|
type FloatMethods = 'ceil' | 'floor' | 'round';
|
|
199
191
|
|
package/src/object/object.mts
CHANGED
|
@@ -224,11 +224,9 @@ export namespace Obj {
|
|
|
224
224
|
const Keys extends readonly (keyof R)[],
|
|
225
225
|
>(
|
|
226
226
|
...args:
|
|
227
|
-
|
|
228
|
-
| readonly [keys: readonly PropertyKey[]]
|
|
227
|
+
readonly [record: R, keys: Keys] | readonly [keys: readonly PropertyKey[]]
|
|
229
228
|
):
|
|
230
|
-
| Omit<R, ArrayElement<Keys>>
|
|
231
|
-
| ((record: R) => Omit<R, ArrayElement<Keys>>) {
|
|
229
|
+
Omit<R, ArrayElement<Keys>> | ((record: R) => Omit<R, ArrayElement<Keys>>) {
|
|
232
230
|
switch (args.length) {
|
|
233
231
|
case 2: {
|
|
234
232
|
const [record, keys] = args;
|
|
@@ -644,32 +642,36 @@ declare namespace TsDataForgeInternals {
|
|
|
644
642
|
readonly [K in keyof B as {} extends Pick<B, K> ? never : K]: B[K];
|
|
645
643
|
} & {
|
|
646
644
|
// 2. Optional properties from B that are NOT in A
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
?
|
|
651
|
-
|
|
652
|
-
|
|
645
|
+
readonly [
|
|
646
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
647
|
+
K in keyof B as {} extends Pick<B, K>
|
|
648
|
+
? K extends keyof A
|
|
649
|
+
? never
|
|
650
|
+
: K
|
|
651
|
+
: never
|
|
652
|
+
]?: B[K];
|
|
653
653
|
} & {
|
|
654
654
|
// 3. Optional properties from B that ARE in A (create union)
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
? K
|
|
655
|
+
readonly [
|
|
656
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
657
|
+
K in keyof B as {} extends Pick<B, K>
|
|
658
|
+
? K extends keyof A
|
|
659
|
+
? K
|
|
660
|
+
: never
|
|
659
661
|
: never
|
|
660
|
-
|
|
662
|
+
]?: K extends keyof A ? A[K] | B[K] : never;
|
|
661
663
|
} & {
|
|
662
664
|
// 4. Required properties only in A (not overridden by B)
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
? never
|
|
666
|
-
|
|
665
|
+
readonly [
|
|
666
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
667
|
+
K in Exclude<keyof A, keyof B> as {} extends Pick<A, K> ? never : K
|
|
668
|
+
]: A[K];
|
|
667
669
|
} & {
|
|
668
670
|
// 5. Optional properties only in A (not overridden by B)
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
? K
|
|
672
|
-
|
|
671
|
+
readonly [
|
|
672
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
673
|
+
K in Exclude<keyof A, keyof B> as {} extends Pick<A, K> ? K : never
|
|
674
|
+
]?: A[K];
|
|
673
675
|
} extends infer O
|
|
674
676
|
? Readonly<
|
|
675
677
|
{
|