ts-data-forge 9.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/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/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/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/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 +8 -7
|
@@ -1,280 +1,237 @@
|
|
|
1
1
|
import { TsDataForgeInternals } from '../refined-number-utils.mjs';
|
|
2
2
|
|
|
3
|
-
const typeNameInMessage =
|
|
4
|
-
const {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
const typeNameInMessage = "a positive integer";
|
|
4
|
+
const {
|
|
5
|
+
MIN_VALUE,
|
|
6
|
+
add,
|
|
7
|
+
castType,
|
|
8
|
+
clamp,
|
|
9
|
+
div,
|
|
10
|
+
is,
|
|
11
|
+
max: max_,
|
|
12
|
+
min: min_,
|
|
13
|
+
mul,
|
|
14
|
+
pow,
|
|
15
|
+
random,
|
|
16
|
+
sub
|
|
17
|
+
} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger({
|
|
18
|
+
integerOrSafeInteger: "Integer",
|
|
19
|
+
MIN_VALUE: 1,
|
|
20
|
+
MAX_VALUE: Number.MAX_VALUE,
|
|
21
|
+
typeNameInMessage
|
|
9
22
|
});
|
|
10
|
-
/**
|
|
11
|
-
* Type guard that checks if a value is a positive integer.
|
|
12
|
-
*
|
|
13
|
-
* A positive integer is any integer greater than zero (>= 1). This excludes
|
|
14
|
-
* zero, negative numbers, and non-integers.
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
*
|
|
18
|
-
* ```ts
|
|
19
|
-
* assert.isTrue(isPositiveInt(5));
|
|
20
|
-
*
|
|
21
|
-
* assert.isFalse(isPositiveInt(0));
|
|
22
|
-
*
|
|
23
|
-
* assert.isTrue(PositiveInt.is(10));
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* @param value - The value to check
|
|
27
|
-
* @returns `true` if the value is a positive integer, `false` otherwise
|
|
28
|
-
*/
|
|
29
23
|
const isPositiveInt = is;
|
|
30
|
-
/**
|
|
31
|
-
* Casts a number to a PositiveInt branded type.
|
|
32
|
-
*
|
|
33
|
-
* This function validates that the input is a positive integer (>= 1) and
|
|
34
|
-
* returns it with the PositiveInt brand. This ensures type safety for
|
|
35
|
-
* operations that require strictly positive integer values.
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
*
|
|
39
|
-
* ```ts
|
|
40
|
-
* const branded = asPositiveInt(7);
|
|
41
|
-
*
|
|
42
|
-
* assert.isTrue(branded === 7);
|
|
43
|
-
*
|
|
44
|
-
* assert.isTrue(PositiveInt.is(branded));
|
|
45
|
-
* ```
|
|
46
|
-
*
|
|
47
|
-
* @param value - The value to cast
|
|
48
|
-
* @returns The value as a PositiveInt branded type
|
|
49
|
-
* @throws {TypeError} If the value is not a positive integer
|
|
50
|
-
*/
|
|
51
24
|
const asPositiveInt = castType;
|
|
52
|
-
/**
|
|
53
|
-
* Namespace providing type-safe operations for PositiveInt branded types.
|
|
54
|
-
*
|
|
55
|
-
* PositiveInt represents integers that are strictly greater than zero (>= 1).
|
|
56
|
-
* All operations automatically clamp results to maintain the positive
|
|
57
|
-
* constraint, ensuring that arithmetic operations never produce zero or
|
|
58
|
-
* negative values.
|
|
59
|
-
*
|
|
60
|
-
* This type is essential for:
|
|
61
|
-
*
|
|
62
|
-
* - Array lengths and sizes (length >= 1)
|
|
63
|
-
* - Counts and quantities that must be positive
|
|
64
|
-
* - Denominators in division operations
|
|
65
|
-
* - Loop counters and iteration counts
|
|
66
|
-
* - Database primary keys and IDs
|
|
67
|
-
*/
|
|
68
25
|
const PositiveInt = {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Type guard that checks if a value is a positive integer.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
*
|
|
31
|
+
* ```ts
|
|
32
|
+
* assert.isTrue(isPositiveInt(5));
|
|
33
|
+
*
|
|
34
|
+
* assert.isFalse(isPositiveInt(0));
|
|
35
|
+
*
|
|
36
|
+
* assert.isTrue(PositiveInt.is(10));
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @param value - The value to check
|
|
40
|
+
* @returns `true` if the value is a positive integer, `false` otherwise
|
|
41
|
+
* @see {@link isPositiveInt} for usage examples
|
|
42
|
+
*/
|
|
43
|
+
is,
|
|
44
|
+
/**
|
|
45
|
+
* The minimum value for a PositiveInt.
|
|
46
|
+
*
|
|
47
|
+
* @readonly
|
|
48
|
+
*/
|
|
49
|
+
MIN_VALUE,
|
|
50
|
+
/**
|
|
51
|
+
* Returns the minimum value from a list of positive integers.
|
|
52
|
+
*
|
|
53
|
+
* Since all inputs are guaranteed to be >= 1, the result is also guaranteed
|
|
54
|
+
* to be a positive integer.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
*
|
|
58
|
+
* ```ts
|
|
59
|
+
* const smallest = PositiveInt.min(
|
|
60
|
+
* asPositiveInt(9),
|
|
61
|
+
* asPositiveInt(3),
|
|
62
|
+
* asPositiveInt(12),
|
|
63
|
+
* );
|
|
64
|
+
*
|
|
65
|
+
* assert.isTrue(smallest === 3);
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* @param values - The positive integers to compare (at least one required)
|
|
69
|
+
* @returns The smallest value as a PositiveInt
|
|
70
|
+
*/
|
|
71
|
+
min: min_,
|
|
72
|
+
/**
|
|
73
|
+
* Returns the maximum value from a list of positive integers.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
*
|
|
77
|
+
* ```ts
|
|
78
|
+
* const largest = PositiveInt.max(
|
|
79
|
+
* asPositiveInt(9),
|
|
80
|
+
* asPositiveInt(3),
|
|
81
|
+
* asPositiveInt(12),
|
|
82
|
+
* );
|
|
83
|
+
*
|
|
84
|
+
* assert.isTrue(largest === 12);
|
|
85
|
+
* ```
|
|
86
|
+
*
|
|
87
|
+
* @param values - The positive integers to compare (at least one required)
|
|
88
|
+
* @returns The largest value as a PositiveInt
|
|
89
|
+
*/
|
|
90
|
+
max: max_,
|
|
91
|
+
/**
|
|
92
|
+
* Clamps a number to the positive integer range.
|
|
93
|
+
*
|
|
94
|
+
* Since PositiveInt has a minimum value of 1, this function ensures that any
|
|
95
|
+
* input less than 1 is clamped to 1.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
*
|
|
99
|
+
* ```ts
|
|
100
|
+
* const belowRange = PositiveInt.clamp(0);
|
|
101
|
+
*
|
|
102
|
+
* const withinRange = PositiveInt.clamp(10);
|
|
103
|
+
*
|
|
104
|
+
* assert.isTrue(belowRange === 1);
|
|
105
|
+
*
|
|
106
|
+
* assert.isTrue(withinRange === 10);
|
|
107
|
+
* ```
|
|
108
|
+
*
|
|
109
|
+
* @param value - The number to clamp
|
|
110
|
+
* @returns The value clamped to >= 1 as a PositiveInt
|
|
111
|
+
*/
|
|
112
|
+
clamp,
|
|
113
|
+
/**
|
|
114
|
+
* Generates a random positive integer within the specified range (inclusive).
|
|
115
|
+
*
|
|
116
|
+
* Both bounds are inclusive, and both min and max must be positive integers.
|
|
117
|
+
* If min > max, they are automatically swapped.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
*
|
|
121
|
+
* ```ts
|
|
122
|
+
* const min = asPositiveInt(3);
|
|
123
|
+
*
|
|
124
|
+
* const max = asPositiveInt(6);
|
|
125
|
+
*
|
|
126
|
+
* const randomValue = PositiveInt.random(min, max);
|
|
127
|
+
*
|
|
128
|
+
* assert.isTrue(PositiveInt.is(randomValue));
|
|
129
|
+
*
|
|
130
|
+
* assert.isTrue(randomValue >= 3 && randomValue <= 6);
|
|
131
|
+
* ```
|
|
132
|
+
*
|
|
133
|
+
* @param min - The minimum value (inclusive, must be >= 1)
|
|
134
|
+
* @param max - The maximum value (inclusive, must be >= min)
|
|
135
|
+
* @returns A random PositiveInt in the range [min, max]
|
|
136
|
+
*/
|
|
137
|
+
random,
|
|
138
|
+
/**
|
|
139
|
+
* Raises a positive integer to a power, ensuring the result is never less
|
|
140
|
+
* than 1.
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
*
|
|
144
|
+
* ```ts
|
|
145
|
+
* const base = asPositiveInt(2);
|
|
146
|
+
*
|
|
147
|
+
* const exponent = asPositiveInt(4);
|
|
148
|
+
*
|
|
149
|
+
* const power = PositiveInt.pow(base, exponent);
|
|
150
|
+
*
|
|
151
|
+
* assert.isTrue(power === 16);
|
|
152
|
+
* ```
|
|
153
|
+
*
|
|
154
|
+
* @param a - The base positive integer
|
|
155
|
+
* @param b - The exponent positive integer
|
|
156
|
+
* @returns `a ** b` as a PositiveInt, but never less than 1
|
|
157
|
+
*/
|
|
158
|
+
pow,
|
|
159
|
+
/**
|
|
160
|
+
* Adds two positive integers, ensuring the result is never less than 1.
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
*
|
|
164
|
+
* ```ts
|
|
165
|
+
* const sum = PositiveInt.add(asPositiveInt(4), asPositiveInt(5));
|
|
166
|
+
*
|
|
167
|
+
* assert.isTrue(sum === 9);
|
|
168
|
+
* ```
|
|
169
|
+
*
|
|
170
|
+
* @param a - First positive integer
|
|
171
|
+
* @param b - Second positive integer
|
|
172
|
+
* @returns `a + b` as a PositiveInt, but never less than 1
|
|
173
|
+
*/
|
|
174
|
+
add,
|
|
175
|
+
/**
|
|
176
|
+
* Subtracts two positive integers, clamping the result to remain positive.
|
|
177
|
+
*
|
|
178
|
+
* If the mathematical result would be <= 0, it is clamped to 1 to maintain
|
|
179
|
+
* the positive integer constraint.
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
*
|
|
183
|
+
* ```ts
|
|
184
|
+
* const difference = PositiveInt.sub(asPositiveInt(5), asPositiveInt(7));
|
|
185
|
+
*
|
|
186
|
+
* assert.isTrue(difference === 1);
|
|
187
|
+
* ```
|
|
188
|
+
*
|
|
189
|
+
* @param a - The minuend (positive integer)
|
|
190
|
+
* @param b - The subtrahend (positive integer)
|
|
191
|
+
* @returns `max(1, a - b)` as a PositiveInt
|
|
192
|
+
*/
|
|
193
|
+
sub,
|
|
194
|
+
/**
|
|
195
|
+
* Multiplies two positive integers, ensuring the result is never less than 1.
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
*
|
|
199
|
+
* ```ts
|
|
200
|
+
* const product = PositiveInt.mul(asPositiveInt(3), asPositiveInt(7));
|
|
201
|
+
*
|
|
202
|
+
* assert.isTrue(product === 21);
|
|
203
|
+
* ```
|
|
204
|
+
*
|
|
205
|
+
* @param a - First positive integer
|
|
206
|
+
* @param b - Second positive integer
|
|
207
|
+
* @returns `a * b` as a PositiveInt, but never less than 1
|
|
208
|
+
*/
|
|
209
|
+
mul,
|
|
210
|
+
/**
|
|
211
|
+
* Divides two positive integers using floor division, clamping to remain
|
|
212
|
+
* positive.
|
|
213
|
+
*
|
|
214
|
+
* Performs mathematical floor division: `⌊a / b⌋`. If the result would be 0
|
|
215
|
+
* (when a < b), it is clamped to 1 to maintain the positive integer
|
|
216
|
+
* constraint.
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
*
|
|
220
|
+
* ```ts
|
|
221
|
+
* const quotient = PositiveInt.div(asPositiveInt(9), asPositiveInt(2));
|
|
222
|
+
*
|
|
223
|
+
* const clamped = PositiveInt.div(asPositiveInt(3), asPositiveInt(10));
|
|
224
|
+
*
|
|
225
|
+
* assert.isTrue(quotient === 4);
|
|
226
|
+
*
|
|
227
|
+
* assert.isTrue(clamped === 1);
|
|
228
|
+
* ```
|
|
229
|
+
*
|
|
230
|
+
* @param a - The dividend (positive integer)
|
|
231
|
+
* @param b - The divisor (positive integer, guaranteed non-zero)
|
|
232
|
+
* @returns `max(1, ⌊a / b⌋)` as a PositiveInt
|
|
233
|
+
*/
|
|
234
|
+
div
|
|
278
235
|
};
|
|
279
236
|
|
|
280
237
|
export { PositiveInt, asPositiveInt, isPositiveInt };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"positive-int.mjs","sources":["../../../src/number/branded-types/positive-int.mts"],"sourcesContent":[null],"names":[],"mappings":";;AAQA,MAAM,iBAAiB,GAAG,oBAAoB;AAE9C,MAAM,EACJ,SAAS,EACT,GAAG,EACH,QAAQ,EACR,KAAK,EACL,GAAG,EACH,EAAE,EACF,GAAG,EAAE,IAAI,EACT,GAAG,EAAE,IAAI,EACT,GAAG,EACH,GAAG,EACH,MAAM,EACN,GAAG,GACJ,GAAG,oBAAoB,CAAC,kBAAkB,CAAC,mBAAmB,CAI7D;AACA,IAAA,oBAAoB,EAAE,SAAS;AAC/B,IAAA,SAAS,EAAE,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC,SAAS;IAC3B,iBAAiB;AACT,CAAA,CAAC;AAEX;;;;;;;;;;;;;;;;;;AAkBG;AACI,MAAM,aAAa,GAAG;AAE7B;;;;;;;;;;;;;;;;;;;;AAoBG;AACI,MAAM,aAAa,GAAG;AAE7B;;;;;;;;;;;;;;;AAeG;AACI,MAAM,WAAW,GAAG;AACzB;;;;;;;;;;;;;;;;AAgBG;IACH,EAAE;AAEF;;;;AAIG;IACH,SAAS;AAET;;;;;;;;;;;;;;;;;;;;AAoBG;AACH,IAAA,GAAG,EAAE,IAAI;AAET;;;;;;;;;;;;;;;;;AAiBG;AACH,IAAA,GAAG,EAAE,IAAI;AAET;;;;;;;;;;;;;;;;;;;;AAoBG;IACH,KAAK;AAEL;;;;;;;;;;;;;;;;;;;;;;;AAuBG;IACH,MAAM;AAEN;;;;;;;;;;;;;;;;;;;AAmBG;IACH,GAAG;AAEH;;;;;;;;;;;;;;AAcG;IACH,GAAG;AAEH;;;;;;;;;;;;;;;;;AAiBG;IACH,GAAG;AAEH;;;;;;;;;;;;;;AAcG;IACH,GAAG;AAEH;;;;;;;;;;;;;;;;;;;;;;;AAuBG;IACH,GAAG;;;;;"}
|
|
1
|
+
{"version":3,"file":"positive-int.mjs","sources":["../../../src/number/branded-types/positive-int.mts"],"sourcesContent":["import { type PositiveInt as TtfImported_PositiveInt } from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type PositiveInt = TtfImported_PositiveInt;\n\ntype ElementType = PositiveInt;\n\nconst typeNameInMessage = 'a positive integer';\n\nconst {\n MIN_VALUE,\n add,\n castType,\n clamp,\n div,\n is,\n max: max_,\n min: min_,\n mul,\n pow,\n random,\n sub,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<\n ElementType,\n 1,\n number\n>({\n integerOrSafeInteger: 'Integer',\n MIN_VALUE: 1,\n MAX_VALUE: Number.MAX_VALUE,\n typeNameInMessage,\n} as const);\n\n/**\n * Type guard that checks if a value is a positive integer.\n *\n * A positive integer is any integer greater than zero (>= 1). This excludes\n * zero, negative numbers, and non-integers.\n *\n * @example\n *\n * ```ts\n * assert.isTrue(isPositiveInt(5));\n *\n * assert.isFalse(isPositiveInt(0));\n *\n * assert.isTrue(PositiveInt.is(10));\n * ```\n *\n * @param value - The value to check\n * @returns `true` if the value is a positive integer, `false` otherwise\n */\nexport const isPositiveInt = is;\n\n/**\n * Casts a number to a PositiveInt branded type.\n *\n * This function validates that the input is a positive integer (>= 1) and\n * returns it with the PositiveInt brand. This ensures type safety for\n * operations that require strictly positive integer values.\n *\n * @example\n *\n * ```ts\n * const branded = asPositiveInt(7);\n *\n * assert.isTrue(branded === 7);\n *\n * assert.isTrue(PositiveInt.is(branded));\n * ```\n *\n * @param value - The value to cast\n * @returns The value as a PositiveInt branded type\n * @throws {TypeError} If the value is not a positive integer\n */\nexport const asPositiveInt = castType;\n\n/**\n * Namespace providing type-safe operations for PositiveInt branded types.\n *\n * PositiveInt represents integers that are strictly greater than zero (>= 1).\n * All operations automatically clamp results to maintain the positive\n * constraint, ensuring that arithmetic operations never produce zero or\n * negative values.\n *\n * This type is essential for:\n *\n * - Array lengths and sizes (length >= 1)\n * - Counts and quantities that must be positive\n * - Denominators in division operations\n * - Loop counters and iteration counts\n * - Database primary keys and IDs\n */\nexport const PositiveInt = {\n /**\n * Type guard that checks if a value is a positive integer.\n *\n * @example\n *\n * ```ts\n * assert.isTrue(isPositiveInt(5));\n *\n * assert.isFalse(isPositiveInt(0));\n *\n * assert.isTrue(PositiveInt.is(10));\n * ```\n *\n * @param value - The value to check\n * @returns `true` if the value is a positive integer, `false` otherwise\n * @see {@link isPositiveInt} for usage examples\n */\n is,\n\n /**\n * The minimum value for a PositiveInt.\n *\n * @readonly\n */\n MIN_VALUE,\n\n /**\n * Returns the minimum value from a list of positive integers.\n *\n * Since all inputs are guaranteed to be >= 1, the result is also guaranteed\n * to be a positive integer.\n *\n * @example\n *\n * ```ts\n * const smallest = PositiveInt.min(\n * asPositiveInt(9),\n * asPositiveInt(3),\n * asPositiveInt(12),\n * );\n *\n * assert.isTrue(smallest === 3);\n * ```\n *\n * @param values - The positive integers to compare (at least one required)\n * @returns The smallest value as a PositiveInt\n */\n min: min_,\n\n /**\n * Returns the maximum value from a list of positive integers.\n *\n * @example\n *\n * ```ts\n * const largest = PositiveInt.max(\n * asPositiveInt(9),\n * asPositiveInt(3),\n * asPositiveInt(12),\n * );\n *\n * assert.isTrue(largest === 12);\n * ```\n *\n * @param values - The positive integers to compare (at least one required)\n * @returns The largest value as a PositiveInt\n */\n max: max_,\n\n /**\n * Clamps a number to the positive integer range.\n *\n * Since PositiveInt has a minimum value of 1, this function ensures that any\n * input less than 1 is clamped to 1.\n *\n * @example\n *\n * ```ts\n * const belowRange = PositiveInt.clamp(0);\n *\n * const withinRange = PositiveInt.clamp(10);\n *\n * assert.isTrue(belowRange === 1);\n *\n * assert.isTrue(withinRange === 10);\n * ```\n *\n * @param value - The number to clamp\n * @returns The value clamped to >= 1 as a PositiveInt\n */\n clamp,\n\n /**\n * Generates a random positive integer within the specified range (inclusive).\n *\n * Both bounds are inclusive, and both min and max must be positive integers.\n * If min > max, they are automatically swapped.\n *\n * @example\n *\n * ```ts\n * const min = asPositiveInt(3);\n *\n * const max = asPositiveInt(6);\n *\n * const randomValue = PositiveInt.random(min, max);\n *\n * assert.isTrue(PositiveInt.is(randomValue));\n *\n * assert.isTrue(randomValue >= 3 && randomValue <= 6);\n * ```\n *\n * @param min - The minimum value (inclusive, must be >= 1)\n * @param max - The maximum value (inclusive, must be >= min)\n * @returns A random PositiveInt in the range [min, max]\n */\n random,\n\n /**\n * Raises a positive integer to a power, ensuring the result is never less\n * than 1.\n *\n * @example\n *\n * ```ts\n * const base = asPositiveInt(2);\n *\n * const exponent = asPositiveInt(4);\n *\n * const power = PositiveInt.pow(base, exponent);\n *\n * assert.isTrue(power === 16);\n * ```\n *\n * @param a - The base positive integer\n * @param b - The exponent positive integer\n * @returns `a ** b` as a PositiveInt, but never less than 1\n */\n pow,\n\n /**\n * Adds two positive integers, ensuring the result is never less than 1.\n *\n * @example\n *\n * ```ts\n * const sum = PositiveInt.add(asPositiveInt(4), asPositiveInt(5));\n *\n * assert.isTrue(sum === 9);\n * ```\n *\n * @param a - First positive integer\n * @param b - Second positive integer\n * @returns `a + b` as a PositiveInt, but never less than 1\n */\n add,\n\n /**\n * Subtracts two positive integers, clamping the result to remain positive.\n *\n * If the mathematical result would be <= 0, it is clamped to 1 to maintain\n * the positive integer constraint.\n *\n * @example\n *\n * ```ts\n * const difference = PositiveInt.sub(asPositiveInt(5), asPositiveInt(7));\n *\n * assert.isTrue(difference === 1);\n * ```\n *\n * @param a - The minuend (positive integer)\n * @param b - The subtrahend (positive integer)\n * @returns `max(1, a - b)` as a PositiveInt\n */\n sub,\n\n /**\n * Multiplies two positive integers, ensuring the result is never less than 1.\n *\n * @example\n *\n * ```ts\n * const product = PositiveInt.mul(asPositiveInt(3), asPositiveInt(7));\n *\n * assert.isTrue(product === 21);\n * ```\n *\n * @param a - First positive integer\n * @param b - Second positive integer\n * @returns `a * b` as a PositiveInt, but never less than 1\n */\n mul,\n\n /**\n * Divides two positive integers using floor division, clamping to remain\n * positive.\n *\n * Performs mathematical floor division: `⌊a / b⌋`. If the result would be 0\n * (when a < b), it is clamped to 1 to maintain the positive integer\n * constraint.\n *\n * @example\n *\n * ```ts\n * const quotient = PositiveInt.div(asPositiveInt(9), asPositiveInt(2));\n *\n * const clamped = PositiveInt.div(asPositiveInt(3), asPositiveInt(10));\n *\n * assert.isTrue(quotient === 4);\n *\n * assert.isTrue(clamped === 1);\n * ```\n *\n * @param a - The dividend (positive integer)\n * @param b - The divisor (positive integer, guaranteed non-zero)\n * @returns `max(1, ⌊a / b⌋)` as a PositiveInt\n */\n div,\n} as const;\n\nexpectType<\n keyof typeof PositiveInt,\n keyof TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'positive'\n >\n>('=');\n\nexpectType<\n typeof PositiveInt,\n TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'positive'\n >\n>('<=');\n"],"names":[],"mappings":";;AAQA,MAAM,iBAAA,GAAoB,oBAAA;AAE1B,MAAM;AAAA,EACJ,SAAA;AAAA,EACA,GAAA;AAAA,EACA,QAAA;AAAA,EACA,KAAA;AAAA,EACA,GAAA;AAAA,EACA,EAAA;AAAA,EACA,GAAA,EAAK,IAAA;AAAA,EACL,GAAA,EAAK,IAAA;AAAA,EACL,GAAA;AAAA,EACA,GAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAA,GAAI,oBAAA,CAAqB,mBAAmB,mBAAA,CAI1C;AAAA,EACA,oBAAA,EAAsB,SAAA;AAAA,EACtB,SAAA,EAAW,CAAA;AAAA,EACX,WAAW,MAAA,CAAO,SAAA;AAAA,EAClB;AACF,CAAU,CAAA;AAqBH,MAAM,aAAA,GAAgB;AAuBtB,MAAM,aAAA,GAAgB;AAkBtB,MAAM,WAAA,GAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkBzB,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAuBA,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoBL,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAuBL,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA0BA,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAsBA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoBA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA0BA;AACF;;;;"}
|
|
@@ -16,20 +16,20 @@ export declare const isPositiveInt16: (a: number) => a is TtfImported_PositiveIn
|
|
|
16
16
|
* @throws {TypeError} If the value is not a positive integer in [1, 2^15).
|
|
17
17
|
*/
|
|
18
18
|
export declare const asPositiveInt16: <N extends number>(x: N) => number & {
|
|
19
|
-
readonly NaNValue: false;
|
|
20
|
-
readonly Finite: true;
|
|
21
|
-
readonly Int: true;
|
|
22
|
-
readonly "> -2^16": true;
|
|
23
|
-
readonly "> -2^32": true;
|
|
24
|
-
readonly ">= -2^15": true;
|
|
25
|
-
readonly ">= -2^31": true;
|
|
26
|
-
readonly ">=0": true;
|
|
27
19
|
readonly "!=0": true;
|
|
28
|
-
readonly "<=0": false;
|
|
29
20
|
readonly "< 2^15": true;
|
|
30
21
|
readonly "< 2^16": true;
|
|
31
22
|
readonly "< 2^31": true;
|
|
32
23
|
readonly "< 2^32": true;
|
|
24
|
+
readonly "<=0": false;
|
|
25
|
+
readonly "> -2^16": true;
|
|
26
|
+
readonly "> -2^32": true;
|
|
27
|
+
readonly ">= -2^15": true;
|
|
28
|
+
readonly ">= -2^31": true;
|
|
29
|
+
readonly ">=0": true;
|
|
30
|
+
readonly Finite: true;
|
|
31
|
+
readonly Int: true;
|
|
32
|
+
readonly NaNValue: false;
|
|
33
33
|
readonly SafeInt: true;
|
|
34
34
|
} & Readonly<{
|
|
35
35
|
'TSTypeForgeInternals--edd2f9ce-7ca5-45b0-9d1a-bd61b9b5d9c3': unknown;
|
|
@@ -132,21 +132,21 @@ export declare const PositiveInt16: {
|
|
|
132
132
|
* @param b The divisor PositiveInt16.
|
|
133
133
|
* @returns `⌊a / b⌋` clamped to [1, 32767] as a PositiveInt16.
|
|
134
134
|
*/
|
|
135
|
-
readonly div: (x: import("ts-type-forge").WithSmallInt<TtfImported_PositiveInt16>, y: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
|
|
136
|
-
readonly NaNValue: false;
|
|
137
|
-
readonly Finite: true;
|
|
138
|
-
readonly Int: true;
|
|
139
|
-
readonly "> -2^16": true;
|
|
140
|
-
readonly "> -2^32": true;
|
|
141
|
-
readonly ">= -2^15": true;
|
|
142
|
-
readonly ">= -2^31": true;
|
|
143
|
-
readonly ">=0": true;
|
|
135
|
+
readonly div: (x: import("ts-type-forge").WithSmallInt<TtfImported_PositiveInt16>, y: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | import("ts-type-forge").NormalizeBrandUnion<number & {
|
|
144
136
|
readonly "!=0": true;
|
|
145
|
-
readonly "<=0": false;
|
|
146
137
|
readonly "< 2^15": true;
|
|
147
138
|
readonly "< 2^16": true;
|
|
148
139
|
readonly "< 2^31": true;
|
|
149
140
|
readonly "< 2^32": true;
|
|
141
|
+
readonly "<=0": false;
|
|
142
|
+
readonly "> -2^16": true;
|
|
143
|
+
readonly "> -2^32": true;
|
|
144
|
+
readonly ">= -2^15": true;
|
|
145
|
+
readonly ">= -2^31": true;
|
|
146
|
+
readonly ">=0": true;
|
|
147
|
+
readonly Finite: true;
|
|
148
|
+
readonly Int: true;
|
|
149
|
+
readonly NaNValue: false;
|
|
150
150
|
readonly SafeInt: true;
|
|
151
151
|
} & Readonly<{
|
|
152
152
|
'TSTypeForgeInternals--edd2f9ce-7ca5-45b0-9d1a-bd61b9b5d9c3': unknown;
|