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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-data-forge",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -77,24 +77,23 @@
|
|
|
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": "^6.0.0"
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
92
|
"@emotion/react": "11.14.0",
|
|
93
93
|
"@emotion/styled": "11.14.1",
|
|
94
|
-
"@mui/material": "9.
|
|
94
|
+
"@mui/material": "9.2.0",
|
|
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",
|
|
@@ -105,15 +104,16 @@
|
|
|
105
104
|
"@types/node": "26.1.0",
|
|
106
105
|
"@types/react": "19.2.17",
|
|
107
106
|
"@vitest/browser-playwright": "4.1.9",
|
|
108
|
-
"@vitest/coverage-v8": "4.1.
|
|
107
|
+
"@vitest/coverage-v8": "4.1.10",
|
|
109
108
|
"@vitest/ui": "4.1.9",
|
|
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.11",
|
|
117
117
|
"jiti": "2.7.0",
|
|
118
118
|
"markdownlint": "0.41.0",
|
|
119
119
|
"markdownlint-cli2": "0.23.0",
|
|
@@ -124,21 +124,22 @@
|
|
|
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": "
|
|
134
|
+
"typescript": "6.0.3",
|
|
135
|
+
"typescript-native": "npm:typescript@7.0.1-rc",
|
|
135
136
|
"vite": "8.1.3",
|
|
136
|
-
"vitest": "4.1.
|
|
137
|
+
"vitest": "4.1.10"
|
|
137
138
|
},
|
|
138
139
|
"peerDependencies": {
|
|
139
140
|
"typescript": ">=4.8"
|
|
140
141
|
},
|
|
141
|
-
"packageManager": "pnpm@11.10.0",
|
|
142
|
+
"packageManager": "pnpm@11.10.0+sha512.0b7f8b98060031904c017e3a41eb187a16d40eeb829b95c4f8cb03681761fc4ab53dd219115b9b447f4dce1a05a214764461e7d3703392a9f32f9511ce8c86c8",
|
|
142
143
|
"engines": {
|
|
143
144
|
"node": ">=22.22.2",
|
|
144
145
|
"pnpm": ">=9.0.0"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
-
type ArrayOfLength,
|
|
3
2
|
type BoolOr,
|
|
3
|
+
type FixedLengthTuple,
|
|
4
4
|
type Index,
|
|
5
5
|
type IsUnion,
|
|
6
6
|
type List,
|
|
@@ -38,7 +38,7 @@ import { type SizeType } from '../../types.mjs';
|
|
|
38
38
|
export const zeros = <N extends SizeType.ArgArr>(
|
|
39
39
|
len: N,
|
|
40
40
|
): N extends SmallUint
|
|
41
|
-
?
|
|
41
|
+
? FixedLengthTuple<N, 0>
|
|
42
42
|
: N extends SizeType.ArgArrPositive
|
|
43
43
|
? NonEmptyArray<0>
|
|
44
44
|
: readonly 0[] =>
|
|
@@ -89,7 +89,7 @@ export const create = <N extends SizeType.ArgArr, const V>(
|
|
|
89
89
|
len: N,
|
|
90
90
|
init: V,
|
|
91
91
|
): N extends SmallUint
|
|
92
|
-
?
|
|
92
|
+
? FixedLengthTuple<N, V>
|
|
93
93
|
: N extends SizeType.ArgArrPositive
|
|
94
94
|
? NonEmptyArray<V>
|
|
95
95
|
: readonly V[] =>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
type
|
|
2
|
+
type FixedLengthTuple,
|
|
3
3
|
type Increment,
|
|
4
4
|
type IsFixedLengthList,
|
|
5
5
|
type NonEmptyArray,
|
|
@@ -163,7 +163,7 @@ export function toInserted<
|
|
|
163
163
|
index: ArgArrayIndexWithNegative<Ar>,
|
|
164
164
|
newValue: V,
|
|
165
165
|
): IsFixedLengthList<Ar> extends true
|
|
166
|
-
?
|
|
166
|
+
? FixedLengthTuple<CastToNumber<Increment<Ar['length']>>, Ar[number] | V>
|
|
167
167
|
: NonEmptyArray<Ar[number] | V>;
|
|
168
168
|
|
|
169
169
|
// curried version
|
|
@@ -173,7 +173,7 @@ export function toInserted<const V>(
|
|
|
173
173
|
): <const Ar extends readonly unknown[]>(
|
|
174
174
|
array: Ar,
|
|
175
175
|
) => IsFixedLengthList<Ar> extends true
|
|
176
|
-
?
|
|
176
|
+
? FixedLengthTuple<CastToNumber<Increment<Ar['length']>>, Ar[number] | V>
|
|
177
177
|
: NonEmptyArray<Ar[number] | V>;
|
|
178
178
|
|
|
179
179
|
export function toInserted<E, const V = E>(
|
|
@@ -367,7 +367,7 @@ export function toFilled<const Ar extends readonly unknown[], const V>(
|
|
|
367
367
|
array: Ar,
|
|
368
368
|
value: V,
|
|
369
369
|
): IsFixedLengthList<Ar> extends true
|
|
370
|
-
?
|
|
370
|
+
? FixedLengthTuple<Ar['length'], V>
|
|
371
371
|
: Ar extends NonEmptyArray<unknown>
|
|
372
372
|
? NonEmptyArray<V>
|
|
373
373
|
: readonly V[];
|
|
@@ -378,7 +378,7 @@ export function toFilled<const V>(
|
|
|
378
378
|
): <const Ar extends readonly unknown[]>(
|
|
379
379
|
array: Ar,
|
|
380
380
|
) => IsFixedLengthList<Ar> extends true
|
|
381
|
-
?
|
|
381
|
+
? FixedLengthTuple<Ar['length'], V>
|
|
382
382
|
: Ar extends NonEmptyArray<unknown>
|
|
383
383
|
? NonEmptyArray<V>
|
|
384
384
|
: readonly V[];
|
|
@@ -426,7 +426,7 @@ export function toRangeFilled<const Ar extends readonly unknown[], const V>(
|
|
|
426
426
|
end: ArgArrayIndexWithNegative<Ar>,
|
|
427
427
|
],
|
|
428
428
|
): IsFixedLengthList<Ar> extends true
|
|
429
|
-
?
|
|
429
|
+
? FixedLengthTuple<Ar['length'], V | Ar[number]>
|
|
430
430
|
: Ar extends NonEmptyArray<unknown>
|
|
431
431
|
? NonEmptyArray<V | Ar[number]>
|
|
432
432
|
: readonly (V | Ar[number])[];
|
|
@@ -441,7 +441,7 @@ export function toRangeFilled<const V>(
|
|
|
441
441
|
): <const Ar extends readonly unknown[]>(
|
|
442
442
|
array: Ar,
|
|
443
443
|
) => IsFixedLengthList<Ar> extends true
|
|
444
|
-
?
|
|
444
|
+
? FixedLengthTuple<Ar['length'], V | Ar[number]>
|
|
445
445
|
: Ar extends NonEmptyArray<unknown>
|
|
446
446
|
? NonEmptyArray<V | Ar[number]>
|
|
447
447
|
: readonly (V | Ar[number])[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type FixedLengthTuple, type NonEmptyArray } from 'ts-type-forge';
|
|
2
2
|
import { expectType } from '../../expect-type.mjs';
|
|
3
3
|
import { asUint32 } from '../../number/index.mjs';
|
|
4
4
|
import {
|
|
@@ -18,7 +18,7 @@ describe('Arr modifications', () => {
|
|
|
18
18
|
|
|
19
19
|
const result = toUpdated(xs, 1, (x) => x + 2);
|
|
20
20
|
|
|
21
|
-
expectType<typeof result,
|
|
21
|
+
expectType<typeof result, FixedLengthTuple<3, number>>('=');
|
|
22
22
|
|
|
23
23
|
test('case 1', () => {
|
|
24
24
|
assert.deepStrictEqual(result, [1, 4, 3]);
|
|
@@ -39,7 +39,7 @@ describe('Arr modifications', () => {
|
|
|
39
39
|
test('case 1', () => {
|
|
40
40
|
const result = toInserted(xs, 1, 5);
|
|
41
41
|
|
|
42
|
-
expectType<typeof result,
|
|
42
|
+
expectType<typeof result, FixedLengthTuple<4, 1 | 2 | 3 | 5>>('=');
|
|
43
43
|
|
|
44
44
|
assert.deepStrictEqual(result, [1, 5, 2, 3]);
|
|
45
45
|
});
|
|
@@ -47,7 +47,7 @@ describe('Arr modifications', () => {
|
|
|
47
47
|
test('case 2 (insert head)', () => {
|
|
48
48
|
const result = toInserted(xs, 0, 5);
|
|
49
49
|
|
|
50
|
-
expectType<typeof result,
|
|
50
|
+
expectType<typeof result, FixedLengthTuple<4, 1 | 2 | 3 | 5>>('=');
|
|
51
51
|
|
|
52
52
|
assert.deepStrictEqual(result, [5, 1, 2, 3]);
|
|
53
53
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
type
|
|
2
|
+
type FixedLengthTuple,
|
|
3
3
|
type IsFixedLengthList,
|
|
4
4
|
type List,
|
|
5
5
|
type MutableNonEmptyArray,
|
|
@@ -220,7 +220,7 @@ export const toSorted = <const Ar extends readonly unknown[]>(
|
|
|
220
220
|
]
|
|
221
221
|
: readonly [array: Ar, comparator: (x: Ar[number], y: Ar[number]) => number]
|
|
222
222
|
): IsFixedLengthList<Ar> extends true
|
|
223
|
-
?
|
|
223
|
+
? FixedLengthTuple<Ar['length'], Ar[number]>
|
|
224
224
|
: Ar extends NonEmptyArray<unknown>
|
|
225
225
|
? NonEmptyArray<Ar[number]>
|
|
226
226
|
: readonly Ar[number][] =>
|
|
@@ -278,7 +278,7 @@ export function toSortedBy<const Ar extends readonly unknown[]>(
|
|
|
278
278
|
// If the array elements are mapped to numbers, comparator is optional.
|
|
279
279
|
comparator?: (x: number, y: number) => number,
|
|
280
280
|
): IsFixedLengthList<Ar> extends true
|
|
281
|
-
?
|
|
281
|
+
? FixedLengthTuple<Ar['length'], Ar[number]>
|
|
282
282
|
: Ar extends NonEmptyArray<unknown>
|
|
283
283
|
? NonEmptyArray<Ar[number]>
|
|
284
284
|
: readonly Ar[number][];
|
|
@@ -288,7 +288,7 @@ export function toSortedBy<const Ar extends readonly unknown[], const V>(
|
|
|
288
288
|
comparatorValueMapper: (value: Ar[number]) => V,
|
|
289
289
|
comparator: (x: V, y: V) => number,
|
|
290
290
|
): IsFixedLengthList<Ar> extends true
|
|
291
|
-
?
|
|
291
|
+
? FixedLengthTuple<Ar['length'], Ar[number]>
|
|
292
292
|
: Ar extends NonEmptyArray<unknown>
|
|
293
293
|
? NonEmptyArray<Ar[number]>
|
|
294
294
|
: readonly Ar[number][];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type FixedLengthTuple } from 'ts-type-forge';
|
|
2
2
|
import { IMap } from '../../collections/index.mjs';
|
|
3
3
|
import { expectType } from '../../expect-type.mjs';
|
|
4
4
|
import { Optional } from '../../functional/index.mjs';
|
|
@@ -26,7 +26,7 @@ describe('Arr transformations', () => {
|
|
|
26
26
|
describe(map, () => {
|
|
27
27
|
const mapped = map([1, 2, 3], (x, i): number => x ** 2 * i);
|
|
28
28
|
|
|
29
|
-
expectType<typeof mapped,
|
|
29
|
+
expectType<typeof mapped, FixedLengthTuple<3, number>>('=');
|
|
30
30
|
|
|
31
31
|
test('case 1', () => {
|
|
32
32
|
assert.deepStrictEqual(mapped, [0, 4, 18]);
|
|
@@ -215,7 +215,7 @@ describe('Arr transformations', () => {
|
|
|
215
215
|
|
|
216
216
|
const result = toSorted(xs);
|
|
217
217
|
|
|
218
|
-
expectType<typeof result,
|
|
218
|
+
expectType<typeof result, FixedLengthTuple<3, 1 | 2 | 3>>('=');
|
|
219
219
|
|
|
220
220
|
test('case 1', () => {
|
|
221
221
|
assert.deepStrictEqual(result, [1, 2, 3]);
|
|
@@ -227,7 +227,7 @@ describe('Arr transformations', () => {
|
|
|
227
227
|
|
|
228
228
|
const result = toSorted(xs, (a, b) => a - b);
|
|
229
229
|
|
|
230
|
-
expectType<typeof result,
|
|
230
|
+
expectType<typeof result, FixedLengthTuple<3, 1 | 2 | 3>>('=');
|
|
231
231
|
|
|
232
232
|
test('case 2', () => {
|
|
233
233
|
assert.deepStrictEqual(result, [1, 2, 3]);
|
|
@@ -239,7 +239,7 @@ describe('Arr transformations', () => {
|
|
|
239
239
|
|
|
240
240
|
const result = toSorted(xs, (a, b) => b - a);
|
|
241
241
|
|
|
242
|
-
expectType<typeof result,
|
|
242
|
+
expectType<typeof result, FixedLengthTuple<3, 1 | 2 | 3>>('=');
|
|
243
243
|
|
|
244
244
|
test('case 3', () => {
|
|
245
245
|
assert.deepStrictEqual(result, [3, 2, 1]);
|
|
@@ -255,7 +255,7 @@ describe('Arr transformations', () => {
|
|
|
255
255
|
|
|
256
256
|
expectType<
|
|
257
257
|
typeof sorted,
|
|
258
|
-
|
|
258
|
+
FixedLengthTuple<3, Readonly<{ v: 1 } | { v: 2 } | { v: 3 }>>
|
|
259
259
|
>('=');
|
|
260
260
|
|
|
261
261
|
test('case 1', () => {
|
|
@@ -274,7 +274,7 @@ describe('Arr transformations', () => {
|
|
|
274
274
|
|
|
275
275
|
expectType<
|
|
276
276
|
typeof sorted,
|
|
277
|
-
|
|
277
|
+
FixedLengthTuple<3, Readonly<{ v: 1 } | { v: 2 } | { v: 3 }>>
|
|
278
278
|
>('=');
|
|
279
279
|
|
|
280
280
|
test('case 2', () => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
type ArrayAtLeastLen,
|
|
3
|
-
type ArrayAtMostLen,
|
|
4
|
-
type ArrayBoundedLen,
|
|
5
|
-
type ArrayOfLength,
|
|
6
2
|
type BoolOr,
|
|
3
|
+
type BoundedLengthTuple,
|
|
4
|
+
type FixedLengthTuple,
|
|
5
|
+
type MaxLengthTuple,
|
|
6
|
+
type MinLengthTuple,
|
|
7
7
|
type NonEmptyArray,
|
|
8
8
|
type TypeEq,
|
|
9
9
|
} from 'ts-type-forge';
|
|
@@ -100,19 +100,19 @@ export const isNonEmpty = <E,>(
|
|
|
100
100
|
*
|
|
101
101
|
* const triple: readonly number[] = [1, 2, 3] as const;
|
|
102
102
|
*
|
|
103
|
-
* assert.isTrue(Arr.
|
|
103
|
+
* assert.isTrue(Arr.isFixedLengthTuple(pair, 2));
|
|
104
104
|
*
|
|
105
|
-
* assert.isFalse(Arr.
|
|
105
|
+
* assert.isFalse(Arr.isFixedLengthTuple(triple, 2));
|
|
106
106
|
*
|
|
107
|
-
* if (Arr.
|
|
107
|
+
* if (Arr.isFixedLengthTuple(pair, 2)) {
|
|
108
108
|
* assert.deepStrictEqual(pair, [1, 2]);
|
|
109
109
|
* }
|
|
110
110
|
* ```
|
|
111
111
|
*/
|
|
112
|
-
export const
|
|
112
|
+
export const isFixedLengthTuple = <E, N extends SizeType.ArgArr>(
|
|
113
113
|
array: readonly E[],
|
|
114
114
|
len: N,
|
|
115
|
-
): array is
|
|
115
|
+
): array is FixedLengthTuple<N, E> => array.length === len;
|
|
116
116
|
|
|
117
117
|
/**
|
|
118
118
|
* Checks if an array has at least a specific length.
|
|
@@ -124,19 +124,19 @@ export const isArrayOfLength = <E, N extends SizeType.ArgArr>(
|
|
|
124
124
|
*
|
|
125
125
|
* const emptyQueue: readonly string[] = [] as const;
|
|
126
126
|
*
|
|
127
|
-
* assert.isTrue(Arr.
|
|
127
|
+
* assert.isTrue(Arr.isMinLengthTuple(queue, 1));
|
|
128
128
|
*
|
|
129
|
-
* assert.isFalse(Arr.
|
|
129
|
+
* assert.isFalse(Arr.isMinLengthTuple(emptyQueue, 1));
|
|
130
130
|
*
|
|
131
|
-
* if (Arr.
|
|
131
|
+
* if (Arr.isMinLengthTuple(queue, 1)) {
|
|
132
132
|
* assert.isTrue(queue[0] === 'task-1');
|
|
133
133
|
* }
|
|
134
134
|
* ```
|
|
135
135
|
*/
|
|
136
|
-
export const
|
|
136
|
+
export const isMinLengthTuple = <E, N extends SizeType.ArgArr>(
|
|
137
137
|
array: readonly E[],
|
|
138
138
|
len: N,
|
|
139
|
-
): array is
|
|
139
|
+
): array is MinLengthTuple<N, E> => array.length >= len;
|
|
140
140
|
|
|
141
141
|
/**
|
|
142
142
|
* Checks if an array has at most a specific length.
|
|
@@ -148,19 +148,19 @@ export const isArrayAtLeastLength = <E, N extends SizeType.ArgArr>(
|
|
|
148
148
|
*
|
|
149
149
|
* const triple: readonly number[] = [1, 2, 3] as const;
|
|
150
150
|
*
|
|
151
|
-
* assert.isTrue(Arr.
|
|
151
|
+
* assert.isTrue(Arr.isMaxLengthTuple(pair, 2));
|
|
152
152
|
*
|
|
153
|
-
* assert.isFalse(Arr.
|
|
153
|
+
* assert.isFalse(Arr.isMaxLengthTuple(triple, 2));
|
|
154
154
|
*
|
|
155
|
-
* if (Arr.
|
|
155
|
+
* if (Arr.isMaxLengthTuple(pair, 2)) {
|
|
156
156
|
* assert.isTrue(pair.length <= 2);
|
|
157
157
|
* }
|
|
158
158
|
* ```
|
|
159
159
|
*/
|
|
160
|
-
export const
|
|
160
|
+
export const isMaxLengthTuple = <E, N extends SizeType.ArgArr>(
|
|
161
161
|
array: readonly E[],
|
|
162
162
|
len: N,
|
|
163
|
-
): array is
|
|
163
|
+
): array is MaxLengthTuple<N, E> => array.length <= len;
|
|
164
164
|
|
|
165
165
|
/**
|
|
166
166
|
* Checks if an array's length is within a specific inclusive range.
|
|
@@ -172,16 +172,16 @@ export const isArrayAtMostLength = <E, N extends SizeType.ArgArr>(
|
|
|
172
172
|
*
|
|
173
173
|
* const quad: readonly number[] = [1, 2, 3, 4] as const;
|
|
174
174
|
*
|
|
175
|
-
* assert.isTrue(Arr.
|
|
175
|
+
* assert.isTrue(Arr.isBoundedLengthTuple(pair, 1, 3));
|
|
176
176
|
*
|
|
177
|
-
* assert.isFalse(Arr.
|
|
177
|
+
* assert.isFalse(Arr.isBoundedLengthTuple(quad, 1, 3));
|
|
178
178
|
*
|
|
179
|
-
* if (Arr.
|
|
179
|
+
* if (Arr.isBoundedLengthTuple(pair, 1, 3)) {
|
|
180
180
|
* assert.isTrue(pair.length >= 1 && pair.length <= 3);
|
|
181
181
|
* }
|
|
182
182
|
* ```
|
|
183
183
|
*/
|
|
184
|
-
export const
|
|
184
|
+
export const isBoundedLengthTuple = <
|
|
185
185
|
E,
|
|
186
186
|
Min extends SizeType.ArgArr,
|
|
187
187
|
Max extends SizeType.ArgArr,
|
|
@@ -189,7 +189,7 @@ export const isArrayBoundedLength = <
|
|
|
189
189
|
array: readonly E[],
|
|
190
190
|
min: Min,
|
|
191
191
|
max: Max,
|
|
192
|
-
): array is
|
|
192
|
+
): array is BoundedLengthTuple<Min, Max, E> =>
|
|
193
193
|
array.length >= min && array.length <= max;
|
|
194
194
|
|
|
195
195
|
/**
|