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
|
@@ -1,155 +1,140 @@
|
|
|
1
1
|
import { TsDataForgeInternals } from '../refined-number-utils.mjs';
|
|
2
2
|
import { PositiveFiniteNumber } from './positive-finite-number.mjs';
|
|
3
3
|
|
|
4
|
-
const typeNameInMessage =
|
|
5
|
-
const {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
const typeNameInMessage = "a negative finite number";
|
|
5
|
+
const {
|
|
6
|
+
MAX_VALUE,
|
|
7
|
+
add,
|
|
8
|
+
castType,
|
|
9
|
+
clamp,
|
|
10
|
+
is,
|
|
11
|
+
max: max_,
|
|
12
|
+
min: min_,
|
|
13
|
+
pow,
|
|
14
|
+
random,
|
|
15
|
+
sub
|
|
16
|
+
} = TsDataForgeInternals.RefinedNumberUtils.operatorsForFloat({
|
|
17
|
+
nonZero: true,
|
|
18
|
+
MIN_VALUE: -Number.MAX_VALUE,
|
|
19
|
+
MAX_VALUE: -Number.MIN_VALUE,
|
|
20
|
+
typeNameInMessage
|
|
10
21
|
});
|
|
11
|
-
/**
|
|
12
|
-
* Returns the absolute value of a negative finite number.
|
|
13
|
-
*
|
|
14
|
-
* The absolute value of a negative finite number is always a positive finite
|
|
15
|
-
* number, so the result is typed as a {@link PositiveFiniteNumber}.
|
|
16
|
-
*
|
|
17
|
-
* @param x - The negative finite number.
|
|
18
|
-
* @returns `|x|` as a PositiveFiniteNumber.
|
|
19
|
-
*/
|
|
20
22
|
const abs = (x) => PositiveFiniteNumber.clamp(Math.abs(x));
|
|
21
|
-
const floor = (x) =>
|
|
22
|
-
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
23
|
-
Math.floor(x)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
*/
|
|
23
|
+
const floor = (x) => (
|
|
24
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
25
|
+
Math.floor(x)
|
|
26
|
+
);
|
|
27
|
+
const ceil = (x) => (
|
|
28
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
29
|
+
Math.ceil(x)
|
|
30
|
+
);
|
|
31
|
+
const round = (x) => (
|
|
32
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
33
|
+
Math.round(
|
|
34
|
+
x
|
|
35
|
+
)
|
|
36
|
+
);
|
|
36
37
|
const isNegativeFiniteNumber = is;
|
|
37
|
-
/**
|
|
38
|
-
* Casts a number to a NegativeFiniteNumber type.
|
|
39
|
-
*
|
|
40
|
-
* @param value The value to cast.
|
|
41
|
-
* @returns The value as a NegativeFiniteNumber type.
|
|
42
|
-
* @throws {TypeError} If the value is not a negative finite number.
|
|
43
|
-
*/
|
|
44
38
|
const asNegativeFiniteNumber = castType;
|
|
45
|
-
/**
|
|
46
|
-
* Namespace providing type-safe arithmetic operations for negative finite
|
|
47
|
-
* numbers.
|
|
48
|
-
*
|
|
49
|
-
* All operations keep results finite (excluding NaN and Infinity). Operations
|
|
50
|
-
* that stay within the negative finite numbers clamp their results to the valid
|
|
51
|
-
* range, while operations whose result leaves the set (`mul`, `div`, `abs`) are
|
|
52
|
-
* typed to reflect the actual sign of the result.
|
|
53
|
-
*/
|
|
54
39
|
const NegativeFiniteNumber = {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Type guard to check if a value is a NegativeFiniteNumber.
|
|
42
|
+
*
|
|
43
|
+
* @param value The value to check.
|
|
44
|
+
* @returns `true` if the value is a negative finite number, `false`
|
|
45
|
+
* otherwise.
|
|
46
|
+
*/
|
|
47
|
+
is,
|
|
48
|
+
/**
|
|
49
|
+
* The maximum value for a negative finite number.
|
|
50
|
+
*
|
|
51
|
+
* @readonly
|
|
52
|
+
*/
|
|
53
|
+
MAX_VALUE,
|
|
54
|
+
/**
|
|
55
|
+
* Returns the absolute value of a negative finite number.
|
|
56
|
+
*
|
|
57
|
+
* @param a The negative finite number.
|
|
58
|
+
* @returns The absolute value as a PositiveFiniteNumber.
|
|
59
|
+
*/
|
|
60
|
+
abs,
|
|
61
|
+
/**
|
|
62
|
+
* Returns the smaller of two NegativeFiniteNumber values.
|
|
63
|
+
*
|
|
64
|
+
* @param a The first NegativeFiniteNumber.
|
|
65
|
+
* @param b The second NegativeFiniteNumber.
|
|
66
|
+
* @returns The minimum value as a NegativeFiniteNumber.
|
|
67
|
+
*/
|
|
68
|
+
min: min_,
|
|
69
|
+
/**
|
|
70
|
+
* Returns the larger of two NegativeFiniteNumber values.
|
|
71
|
+
*
|
|
72
|
+
* @param a The first NegativeFiniteNumber.
|
|
73
|
+
* @param b The second NegativeFiniteNumber.
|
|
74
|
+
* @returns The maximum value as a NegativeFiniteNumber.
|
|
75
|
+
*/
|
|
76
|
+
max: max_,
|
|
77
|
+
/**
|
|
78
|
+
* Clamps a number to the negative finite range.
|
|
79
|
+
*
|
|
80
|
+
* @param value The number to clamp.
|
|
81
|
+
* @returns The value clamped to `(-∞, 0)` as a NegativeFiniteNumber.
|
|
82
|
+
*/
|
|
83
|
+
clamp,
|
|
84
|
+
/**
|
|
85
|
+
* Rounds down a NegativeFiniteNumber to the nearest integer.
|
|
86
|
+
*
|
|
87
|
+
* @param x The NegativeFiniteNumber to round down.
|
|
88
|
+
* @returns The floor value as a NegativeInt (always `<= -1`).
|
|
89
|
+
*/
|
|
90
|
+
floor,
|
|
91
|
+
/**
|
|
92
|
+
* Rounds up a NegativeFiniteNumber to the nearest integer.
|
|
93
|
+
*
|
|
94
|
+
* @param x The NegativeFiniteNumber to round up.
|
|
95
|
+
* @returns The ceiling value as a NonPositiveInt (can be 0).
|
|
96
|
+
*/
|
|
97
|
+
ceil,
|
|
98
|
+
/**
|
|
99
|
+
* Rounds a NegativeFiniteNumber to the nearest integer.
|
|
100
|
+
*
|
|
101
|
+
* @param x The NegativeFiniteNumber to round.
|
|
102
|
+
* @returns The rounded value as a NonPositiveInt (can be 0 if x > -0.5).
|
|
103
|
+
*/
|
|
104
|
+
round,
|
|
105
|
+
/**
|
|
106
|
+
* Generates a random NegativeFiniteNumber value.
|
|
107
|
+
*
|
|
108
|
+
* @returns A random negative finite number.
|
|
109
|
+
*/
|
|
110
|
+
random,
|
|
111
|
+
/**
|
|
112
|
+
* Raises a NegativeFiniteNumber to the power of another NegativeFiniteNumber.
|
|
113
|
+
*
|
|
114
|
+
* @param a The base NegativeFiniteNumber.
|
|
115
|
+
* @param b The exponent NegativeFiniteNumber.
|
|
116
|
+
* @returns `a ** b` clamped to `(-∞, 0)` as a NegativeFiniteNumber.
|
|
117
|
+
*/
|
|
118
|
+
pow,
|
|
119
|
+
/**
|
|
120
|
+
* Adds two NegativeFiniteNumber values.
|
|
121
|
+
*
|
|
122
|
+
* @param a The first NegativeFiniteNumber.
|
|
123
|
+
* @param b The second NegativeFiniteNumber.
|
|
124
|
+
* @returns `a + b` as a NegativeFiniteNumber.
|
|
125
|
+
*/
|
|
126
|
+
add,
|
|
127
|
+
/**
|
|
128
|
+
* Subtracts one NegativeFiniteNumber from another.
|
|
129
|
+
*
|
|
130
|
+
* The mathematical result can be positive, so it is clamped to the negative
|
|
131
|
+
* finite range (maximum `-Number.MIN_VALUE`).
|
|
132
|
+
*
|
|
133
|
+
* @param a The minuend NegativeFiniteNumber.
|
|
134
|
+
* @param b The subtrahend NegativeFiniteNumber.
|
|
135
|
+
* @returns `a - b` clamped to `(-∞, 0)` as a NegativeFiniteNumber.
|
|
136
|
+
*/
|
|
137
|
+
sub
|
|
153
138
|
};
|
|
154
139
|
|
|
155
140
|
export { NegativeFiniteNumber, asNegativeFiniteNumber, isNegativeFiniteNumber };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"negative-finite-number.mjs","sources":["../../../src/number/branded-types/negative-finite-number.mts"],"sourcesContent":[
|
|
1
|
+
{"version":3,"file":"negative-finite-number.mjs","sources":["../../../src/number/branded-types/negative-finite-number.mts"],"sourcesContent":["import { type NegativeFiniteNumber as TtfImported_NegativeFiniteNumber } from 'ts-type-forge';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\nimport { PositiveFiniteNumber } from './positive-finite-number.mjs';\n\nexport type NegativeFiniteNumber = TtfImported_NegativeFiniteNumber;\n\ntype ElementType = NegativeFiniteNumber;\n\nconst typeNameInMessage = 'a negative finite number';\n\nconst {\n MAX_VALUE,\n add,\n castType,\n clamp,\n is,\n max: max_,\n min: min_,\n pow,\n random,\n sub,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForFloat<\n ElementType,\n number,\n number\n>({\n nonZero: true,\n MIN_VALUE: -Number.MAX_VALUE,\n MAX_VALUE: -Number.MIN_VALUE,\n typeNameInMessage,\n} as const);\n\n/**\n * Returns the absolute value of a negative finite number.\n *\n * The absolute value of a negative finite number is always a positive finite\n * number, so the result is typed as a {@link PositiveFiniteNumber}.\n *\n * @param x - The negative finite number.\n * @returns `|x|` as a PositiveFiniteNumber.\n */\nconst abs = (x: ElementType): PositiveFiniteNumber =>\n PositiveFiniteNumber.clamp(Math.abs(x));\n\nconst floor = (\n x: ElementType,\n): TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Math.floor(x) as TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>;\n\nconst ceil = (\n x: ElementType,\n): TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Math.ceil(x) as TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n >;\n\nconst round = (\n x: ElementType,\n): TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Math.round(\n x,\n ) as TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n >;\n\n/**\n * Checks if a number is a NegativeFiniteNumber (a finite number `< 0`).\n *\n * @param value The value to check.\n * @returns `true` if the value is a NegativeFiniteNumber, `false` otherwise.\n */\nexport const isNegativeFiniteNumber = is;\n\n/**\n * Casts a number to a NegativeFiniteNumber type.\n *\n * @param value The value to cast.\n * @returns The value as a NegativeFiniteNumber type.\n * @throws {TypeError} If the value is not a negative finite number.\n */\nexport const asNegativeFiniteNumber = castType;\n\n/**\n * Namespace providing type-safe arithmetic operations for negative finite\n * numbers.\n *\n * All operations keep results finite (excluding NaN and Infinity). Operations\n * that stay within the negative finite numbers clamp their results to the valid\n * range, while operations whose result leaves the set (`mul`, `div`, `abs`) are\n * typed to reflect the actual sign of the result.\n */\nexport const NegativeFiniteNumber = {\n /**\n * Type guard to check if a value is a NegativeFiniteNumber.\n *\n * @param value The value to check.\n * @returns `true` if the value is a negative finite number, `false`\n * otherwise.\n */\n is,\n\n /**\n * The maximum value for a negative finite number.\n *\n * @readonly\n */\n MAX_VALUE,\n\n /**\n * Returns the absolute value of a negative finite number.\n *\n * @param a The negative finite number.\n * @returns The absolute value as a PositiveFiniteNumber.\n */\n abs,\n\n /**\n * Returns the smaller of two NegativeFiniteNumber values.\n *\n * @param a The first NegativeFiniteNumber.\n * @param b The second NegativeFiniteNumber.\n * @returns The minimum value as a NegativeFiniteNumber.\n */\n min: min_,\n\n /**\n * Returns the larger of two NegativeFiniteNumber values.\n *\n * @param a The first NegativeFiniteNumber.\n * @param b The second NegativeFiniteNumber.\n * @returns The maximum value as a NegativeFiniteNumber.\n */\n max: max_,\n\n /**\n * Clamps a number to the negative finite range.\n *\n * @param value The number to clamp.\n * @returns The value clamped to `(-∞, 0)` as a NegativeFiniteNumber.\n */\n clamp,\n\n /**\n * Rounds down a NegativeFiniteNumber to the nearest integer.\n *\n * @param x The NegativeFiniteNumber to round down.\n * @returns The floor value as a NegativeInt (always `<= -1`).\n */\n floor,\n\n /**\n * Rounds up a NegativeFiniteNumber to the nearest integer.\n *\n * @param x The NegativeFiniteNumber to round up.\n * @returns The ceiling value as a NonPositiveInt (can be 0).\n */\n ceil,\n\n /**\n * Rounds a NegativeFiniteNumber to the nearest integer.\n *\n * @param x The NegativeFiniteNumber to round.\n * @returns The rounded value as a NonPositiveInt (can be 0 if x > -0.5).\n */\n round,\n\n /**\n * Generates a random NegativeFiniteNumber value.\n *\n * @returns A random negative finite number.\n */\n random,\n\n /**\n * Raises a NegativeFiniteNumber to the power of another NegativeFiniteNumber.\n *\n * @param a The base NegativeFiniteNumber.\n * @param b The exponent NegativeFiniteNumber.\n * @returns `a ** b` clamped to `(-∞, 0)` as a NegativeFiniteNumber.\n */\n pow,\n\n /**\n * Adds two NegativeFiniteNumber values.\n *\n * @param a The first NegativeFiniteNumber.\n * @param b The second NegativeFiniteNumber.\n * @returns `a + b` as a NegativeFiniteNumber.\n */\n add,\n\n /**\n * Subtracts one NegativeFiniteNumber from another.\n *\n * The mathematical result can be positive, so it is clamped to the negative\n * finite range (maximum `-Number.MIN_VALUE`).\n *\n * @param a The minuend NegativeFiniteNumber.\n * @param b The subtrahend NegativeFiniteNumber.\n * @returns `a - b` clamped to `(-∞, 0)` as a NegativeFiniteNumber.\n */\n sub,\n} as const;\n"],"names":[],"mappings":";;;AAQA,MAAM,iBAAA,GAAoB,0BAAA;AAE1B,MAAM;AAAA,EACJ,SAAA;AAAA,EACA,GAAA;AAAA,EACA,QAAA;AAAA,EACA,KAAA;AAAA,EACA,EAAA;AAAA,EACA,GAAA,EAAK,IAAA;AAAA,EACL,GAAA,EAAK,IAAA;AAAA,EACL,GAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAA,GAAI,oBAAA,CAAqB,mBAAmB,iBAAA,CAI1C;AAAA,EACA,OAAA,EAAS,IAAA;AAAA,EACT,SAAA,EAAW,CAAC,MAAA,CAAO,SAAA;AAAA,EACnB,SAAA,EAAW,CAAC,MAAA,CAAO,SAAA;AAAA,EACnB;AACF,CAAU,CAAA;AAWV,MAAM,GAAA,GAAM,CAAC,CAAA,KACX,oBAAA,CAAqB,MAAM,IAAA,CAAK,GAAA,CAAI,CAAC,CAAC,CAAA;AAExC,MAAM,QAAQ,CACZ,CAAA;AAAA;AAAA,EAGA,IAAA,CAAK,MAAM,CAAC;AAAA,CAAA;AAEd,MAAM,OAAO,CACX,CAAA;AAAA;AAAA,EAKA,IAAA,CAAK,KAAK,CAAC;AAAA,CAAA;AAIb,MAAM,QAAQ,CACZ,CAAA;AAAA;AAAA,EAKA,IAAA,CAAK,KAAA;AAAA,IACH;AAAA;AACF,CAAA;AAUK,MAAM,sBAAA,GAAyB;AAS/B,MAAM,sBAAA,GAAyB;AAW/B,MAAM,oBAAA,GAAuB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQlC,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASL,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQL,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA;AACF;;;;"}
|
|
@@ -17,16 +17,16 @@ export declare const isNegativeInt: (a: number) => a is TtfImported_NegativeInt;
|
|
|
17
17
|
* @throws {TypeError} If the value is not a negative integer.
|
|
18
18
|
*/
|
|
19
19
|
export declare const asNegativeInt: <N extends number>(x: N) => number & {
|
|
20
|
-
readonly NaNValue: false;
|
|
21
|
-
readonly Finite: true;
|
|
22
|
-
readonly Int: true;
|
|
23
|
-
readonly ">=0": false;
|
|
24
20
|
readonly "!=0": true;
|
|
25
|
-
readonly "<=0": true;
|
|
26
21
|
readonly "< 2^15": true;
|
|
27
22
|
readonly "< 2^16": true;
|
|
28
23
|
readonly "< 2^31": true;
|
|
29
24
|
readonly "< 2^32": true;
|
|
25
|
+
readonly "<=0": true;
|
|
26
|
+
readonly ">=0": false;
|
|
27
|
+
readonly Finite: true;
|
|
28
|
+
readonly Int: true;
|
|
29
|
+
readonly NaNValue: false;
|
|
30
30
|
} & Readonly<{
|
|
31
31
|
'TSTypeForgeInternals--edd2f9ce-7ca5-45b0-9d1a-bd61b9b5d9c3': unknown;
|
|
32
32
|
}> & N;
|
|
@@ -1,124 +1,105 @@
|
|
|
1
1
|
import { TsDataForgeInternals } from '../refined-number-utils.mjs';
|
|
2
2
|
import { PositiveInt } from './positive-int.mjs';
|
|
3
3
|
|
|
4
|
-
const typeNameInMessage =
|
|
5
|
-
const {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
const typeNameInMessage = "a negative integer";
|
|
5
|
+
const {
|
|
6
|
+
MAX_VALUE,
|
|
7
|
+
add,
|
|
8
|
+
castType,
|
|
9
|
+
clamp,
|
|
10
|
+
is,
|
|
11
|
+
max: max_,
|
|
12
|
+
min: min_,
|
|
13
|
+
pow,
|
|
14
|
+
random,
|
|
15
|
+
sub
|
|
16
|
+
} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger({
|
|
17
|
+
integerOrSafeInteger: "Integer",
|
|
18
|
+
nonZero: true,
|
|
19
|
+
MIN_VALUE: -Number.MAX_VALUE,
|
|
20
|
+
MAX_VALUE: -1,
|
|
21
|
+
typeNameInMessage
|
|
11
22
|
});
|
|
12
|
-
/**
|
|
13
|
-
* Returns the absolute value of a negative integer.
|
|
14
|
-
*
|
|
15
|
-
* The absolute value of a negative integer is always a positive integer
|
|
16
|
-
* (`>= 1`), so the result is typed as a {@link PositiveInt}.
|
|
17
|
-
*
|
|
18
|
-
* @param x - The negative integer.
|
|
19
|
-
* @returns `|x|` as a PositiveInt.
|
|
20
|
-
*/
|
|
21
23
|
const abs = (x) => PositiveInt.clamp(Math.abs(x));
|
|
22
|
-
/**
|
|
23
|
-
* Checks if a number is a NegativeInt (a negative integer `<= -1`).
|
|
24
|
-
*
|
|
25
|
-
* @param value The value to check.
|
|
26
|
-
* @returns `true` if the value is a NegativeInt, `false` otherwise.
|
|
27
|
-
*/
|
|
28
24
|
const isNegativeInt = is;
|
|
29
|
-
/**
|
|
30
|
-
* Casts a number to a NegativeInt type.
|
|
31
|
-
*
|
|
32
|
-
* @param value The value to cast.
|
|
33
|
-
* @returns The value as a NegativeInt type.
|
|
34
|
-
* @throws {TypeError} If the value is not a negative integer.
|
|
35
|
-
*/
|
|
36
25
|
const asNegativeInt = castType;
|
|
37
|
-
/**
|
|
38
|
-
* Namespace providing type-safe arithmetic operations for negative integers.
|
|
39
|
-
*
|
|
40
|
-
* NegativeInt represents integers that are strictly less than zero (`<= -1`).
|
|
41
|
-
* Operations that stay within the negative integers (such as `add`) clamp their
|
|
42
|
-
* results to the valid range, while operations whose result leaves the set
|
|
43
|
-
* (`mul`, `div`, `abs`) are typed to reflect the actual sign of the result.
|
|
44
|
-
*/
|
|
45
26
|
const NegativeInt = {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Type guard to check if a value is a NegativeInt.
|
|
29
|
+
*
|
|
30
|
+
* @param value The value to check.
|
|
31
|
+
* @returns `true` if the value is a negative integer, `false` otherwise.
|
|
32
|
+
*/
|
|
33
|
+
is,
|
|
34
|
+
/**
|
|
35
|
+
* The maximum value for a negative integer.
|
|
36
|
+
*
|
|
37
|
+
* @readonly
|
|
38
|
+
*/
|
|
39
|
+
MAX_VALUE,
|
|
40
|
+
/**
|
|
41
|
+
* Returns the absolute value of a negative integer.
|
|
42
|
+
*
|
|
43
|
+
* @param a The negative integer.
|
|
44
|
+
* @returns The absolute value as a PositiveInt.
|
|
45
|
+
*/
|
|
46
|
+
abs,
|
|
47
|
+
/**
|
|
48
|
+
* Returns the smaller of two negative integers.
|
|
49
|
+
*
|
|
50
|
+
* @param a The first negative integer.
|
|
51
|
+
* @param b The second negative integer.
|
|
52
|
+
* @returns The minimum value as a NegativeInt.
|
|
53
|
+
*/
|
|
54
|
+
min: min_,
|
|
55
|
+
/**
|
|
56
|
+
* Returns the larger of two negative integers.
|
|
57
|
+
*
|
|
58
|
+
* @param a The first negative integer.
|
|
59
|
+
* @param b The second negative integer.
|
|
60
|
+
* @returns The maximum value as a NegativeInt.
|
|
61
|
+
*/
|
|
62
|
+
max: max_,
|
|
63
|
+
/**
|
|
64
|
+
* Clamps a number to the negative integer range.
|
|
65
|
+
*
|
|
66
|
+
* @param value The number to clamp.
|
|
67
|
+
* @returns The value clamped to `[-∞, -1]` as a NegativeInt.
|
|
68
|
+
*/
|
|
69
|
+
clamp,
|
|
70
|
+
/**
|
|
71
|
+
* Generates a random NegativeInt value within the valid range.
|
|
72
|
+
*
|
|
73
|
+
* @returns A random negative integer.
|
|
74
|
+
*/
|
|
75
|
+
random,
|
|
76
|
+
/**
|
|
77
|
+
* Raises a negative integer to the power of another negative integer.
|
|
78
|
+
*
|
|
79
|
+
* @param a The base negative integer.
|
|
80
|
+
* @param b The exponent negative integer.
|
|
81
|
+
* @returns `a ** b` clamped to the negative integer range.
|
|
82
|
+
*/
|
|
83
|
+
pow,
|
|
84
|
+
/**
|
|
85
|
+
* Adds two negative integers.
|
|
86
|
+
*
|
|
87
|
+
* @param a The first negative integer.
|
|
88
|
+
* @param b The second negative integer.
|
|
89
|
+
* @returns `a + b` as a NegativeInt.
|
|
90
|
+
*/
|
|
91
|
+
add,
|
|
92
|
+
/**
|
|
93
|
+
* Subtracts one negative integer from another.
|
|
94
|
+
*
|
|
95
|
+
* The mathematical result can be positive, so it is clamped to the negative
|
|
96
|
+
* integer range (maximum `-1`).
|
|
97
|
+
*
|
|
98
|
+
* @param a The minuend negative integer.
|
|
99
|
+
* @param b The subtrahend negative integer.
|
|
100
|
+
* @returns `a - b` clamped to the negative integer range.
|
|
101
|
+
*/
|
|
102
|
+
sub
|
|
122
103
|
};
|
|
123
104
|
|
|
124
105
|
export { NegativeInt, asNegativeInt, isNegativeInt };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"negative-int.mjs","sources":["../../../src/number/branded-types/negative-int.mts"],"sourcesContent":[
|
|
1
|
+
{"version":3,"file":"negative-int.mjs","sources":["../../../src/number/branded-types/negative-int.mts"],"sourcesContent":["import {\n type NegativeInt as TtfImported_NegativeInt,\n type WithSmallInt,\n} from 'ts-type-forge';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\nimport { PositiveInt } from './positive-int.mjs';\n\nexport type NegativeInt = TtfImported_NegativeInt;\n\ntype ElementType = NegativeInt;\n\nconst typeNameInMessage = 'a negative integer';\n\nconst {\n MAX_VALUE,\n add,\n castType,\n clamp,\n is,\n max: max_,\n min: min_,\n pow,\n random,\n sub,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<\n ElementType,\n number,\n -1\n>({\n integerOrSafeInteger: 'Integer',\n nonZero: true,\n MIN_VALUE: -Number.MAX_VALUE,\n MAX_VALUE: -1,\n typeNameInMessage,\n} as const);\n\n/**\n * Returns the absolute value of a negative integer.\n *\n * The absolute value of a negative integer is always a positive integer\n * (`>= 1`), so the result is typed as a {@link PositiveInt}.\n *\n * @param x - The negative integer.\n * @returns `|x|` as a PositiveInt.\n */\nconst abs = (x: WithSmallInt<ElementType>): PositiveInt =>\n PositiveInt.clamp(Math.abs(x));\n\n/**\n * Checks if a number is a NegativeInt (a negative integer `<= -1`).\n *\n * @param value The value to check.\n * @returns `true` if the value is a NegativeInt, `false` otherwise.\n */\nexport const isNegativeInt = is;\n\n/**\n * Casts a number to a NegativeInt type.\n *\n * @param value The value to cast.\n * @returns The value as a NegativeInt type.\n * @throws {TypeError} If the value is not a negative integer.\n */\nexport const asNegativeInt = castType;\n\n/**\n * Namespace providing type-safe arithmetic operations for negative integers.\n *\n * NegativeInt represents integers that are strictly less than zero (`<= -1`).\n * Operations that stay within the negative integers (such as `add`) clamp their\n * results to the valid range, while operations whose result leaves the set\n * (`mul`, `div`, `abs`) are typed to reflect the actual sign of the result.\n */\nexport const NegativeInt = {\n /**\n * Type guard to check if a value is a NegativeInt.\n *\n * @param value The value to check.\n * @returns `true` if the value is a negative integer, `false` otherwise.\n */\n is,\n\n /**\n * The maximum value for a negative integer.\n *\n * @readonly\n */\n MAX_VALUE,\n\n /**\n * Returns the absolute value of a negative integer.\n *\n * @param a The negative integer.\n * @returns The absolute value as a PositiveInt.\n */\n abs,\n\n /**\n * Returns the smaller of two negative integers.\n *\n * @param a The first negative integer.\n * @param b The second negative integer.\n * @returns The minimum value as a NegativeInt.\n */\n min: min_,\n\n /**\n * Returns the larger of two negative integers.\n *\n * @param a The first negative integer.\n * @param b The second negative integer.\n * @returns The maximum value as a NegativeInt.\n */\n max: max_,\n\n /**\n * Clamps a number to the negative integer range.\n *\n * @param value The number to clamp.\n * @returns The value clamped to `[-∞, -1]` as a NegativeInt.\n */\n clamp,\n\n /**\n * Generates a random NegativeInt value within the valid range.\n *\n * @returns A random negative integer.\n */\n random,\n\n /**\n * Raises a negative integer to the power of another negative integer.\n *\n * @param a The base negative integer.\n * @param b The exponent negative integer.\n * @returns `a ** b` clamped to the negative integer range.\n */\n pow,\n\n /**\n * Adds two negative integers.\n *\n * @param a The first negative integer.\n * @param b The second negative integer.\n * @returns `a + b` as a NegativeInt.\n */\n add,\n\n /**\n * Subtracts one negative integer from another.\n *\n * The mathematical result can be positive, so it is clamped to the negative\n * integer range (maximum `-1`).\n *\n * @param a The minuend negative integer.\n * @param b The subtrahend negative integer.\n * @returns `a - b` clamped to the negative integer range.\n */\n sub,\n} as const;\n"],"names":[],"mappings":";;;AAWA,MAAM,iBAAA,GAAoB,oBAAA;AAE1B,MAAM;AAAA,EACJ,SAAA;AAAA,EACA,GAAA;AAAA,EACA,QAAA;AAAA,EACA,KAAA;AAAA,EACA,EAAA;AAAA,EACA,GAAA,EAAK,IAAA;AAAA,EACL,GAAA,EAAK,IAAA;AAAA,EACL,GAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAA,GAAI,oBAAA,CAAqB,mBAAmB,mBAAA,CAI1C;AAAA,EACA,oBAAA,EAAsB,SAAA;AAAA,EACtB,OAAA,EAAS,IAAA;AAAA,EACT,SAAA,EAAW,CAAC,MAAA,CAAO,SAAA;AAAA,EACnB,SAAA,EAAW,EAAA;AAAA,EACX;AACF,CAAU,CAAA;AAWV,MAAM,GAAA,GAAM,CAAC,CAAA,KACX,WAAA,CAAY,MAAM,IAAA,CAAK,GAAA,CAAI,CAAC,CAAC,CAAA;AAQxB,MAAM,aAAA,GAAgB;AAStB,MAAM,aAAA,GAAgB;AAUtB,MAAM,WAAA,GAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOzB,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASL,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQL,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA;AACF;;;;"}
|
|
@@ -18,16 +18,16 @@ export declare const isNegativeSafeInt: (a: number) => a is TtfImported_Negative
|
|
|
18
18
|
* @throws {TypeError} If the value is not a negative safe integer.
|
|
19
19
|
*/
|
|
20
20
|
export declare const asNegativeSafeInt: <N extends number>(x: N) => number & {
|
|
21
|
-
readonly NaNValue: false;
|
|
22
|
-
readonly Finite: true;
|
|
23
|
-
readonly Int: true;
|
|
24
|
-
readonly ">=0": false;
|
|
25
21
|
readonly "!=0": true;
|
|
26
|
-
readonly "<=0": true;
|
|
27
22
|
readonly "< 2^15": true;
|
|
28
23
|
readonly "< 2^16": true;
|
|
29
24
|
readonly "< 2^31": true;
|
|
30
25
|
readonly "< 2^32": true;
|
|
26
|
+
readonly "<=0": true;
|
|
27
|
+
readonly ">=0": false;
|
|
28
|
+
readonly Finite: true;
|
|
29
|
+
readonly Int: true;
|
|
30
|
+
readonly NaNValue: false;
|
|
31
31
|
readonly SafeInt: true;
|
|
32
32
|
} & Readonly<{
|
|
33
33
|
'TSTypeForgeInternals--edd2f9ce-7ca5-45b0-9d1a-bd61b9b5d9c3': unknown;
|