ts-data-forge 5.0.1 → 5.1.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/README.md +101 -50
- package/dist/array/impl/array-utils-creation.d.mts +14 -0
- package/dist/array/impl/array-utils-creation.d.mts.map +1 -1
- package/dist/array/impl/array-utils-creation.mjs +12 -0
- package/dist/array/impl/array-utils-creation.mjs.map +1 -1
- package/dist/array/impl/array-utils-element-access.d.mts +10 -0
- package/dist/array/impl/array-utils-element-access.d.mts.map +1 -1
- package/dist/array/impl/array-utils-element-access.mjs +6 -0
- package/dist/array/impl/array-utils-element-access.mjs.map +1 -1
- package/dist/array/impl/array-utils-modification.d.mts +14 -0
- package/dist/array/impl/array-utils-modification.d.mts.map +1 -1
- package/dist/array/impl/array-utils-modification.mjs.map +1 -1
- package/dist/array/impl/array-utils-reducing-value.d.mts +34 -10
- package/dist/array/impl/array-utils-reducing-value.d.mts.map +1 -1
- package/dist/array/impl/array-utils-reducing-value.mjs.map +1 -1
- package/dist/array/impl/array-utils-search.d.mts +34 -4
- package/dist/array/impl/array-utils-search.d.mts.map +1 -1
- package/dist/array/impl/array-utils-search.mjs.map +1 -1
- package/dist/array/impl/array-utils-set-op.d.mts +20 -7
- package/dist/array/impl/array-utils-set-op.d.mts.map +1 -1
- package/dist/array/impl/array-utils-set-op.mjs +20 -7
- package/dist/array/impl/array-utils-set-op.mjs.map +1 -1
- package/dist/array/impl/array-utils-size.d.mts +5 -2
- package/dist/array/impl/array-utils-size.d.mts.map +1 -1
- package/dist/array/impl/array-utils-size.mjs +5 -2
- package/dist/array/impl/array-utils-size.mjs.map +1 -1
- package/dist/array/impl/array-utils-slice-clamped.d.mts +2 -0
- package/dist/array/impl/array-utils-slice-clamped.d.mts.map +1 -1
- package/dist/array/impl/array-utils-slice-clamped.mjs.map +1 -1
- package/dist/array/impl/array-utils-slicing.d.mts +17 -2
- package/dist/array/impl/array-utils-slicing.d.mts.map +1 -1
- package/dist/array/impl/array-utils-slicing.mjs +9 -2
- package/dist/array/impl/array-utils-slicing.mjs.map +1 -1
- package/dist/array/impl/array-utils-transformation.d.mts +27 -0
- package/dist/array/impl/array-utils-transformation.d.mts.map +1 -1
- package/dist/array/impl/array-utils-transformation.mjs +6 -0
- package/dist/array/impl/array-utils-transformation.mjs.map +1 -1
- package/dist/array/impl/array-utils-validation.d.mts +35 -18
- package/dist/array/impl/array-utils-validation.d.mts.map +1 -1
- package/dist/array/impl/array-utils-validation.mjs +25 -14
- package/dist/array/impl/array-utils-validation.mjs.map +1 -1
- package/dist/collections/imap-mapped.mjs.map +1 -1
- package/dist/collections/imap.d.mts +35 -15
- package/dist/collections/imap.d.mts.map +1 -1
- package/dist/collections/imap.mjs +5 -3
- package/dist/collections/imap.mjs.map +1 -1
- package/dist/collections/iset-mapped.d.mts +46 -19
- package/dist/collections/iset-mapped.d.mts.map +1 -1
- package/dist/collections/iset-mapped.mjs +9 -2
- package/dist/collections/iset-mapped.mjs.map +1 -1
- package/dist/collections/iset.d.mts +48 -19
- package/dist/collections/iset.d.mts.map +1 -1
- package/dist/collections/iset.mjs +9 -2
- package/dist/collections/iset.mjs.map +1 -1
- package/dist/collections/queue.d.mts +65 -25
- package/dist/collections/queue.d.mts.map +1 -1
- package/dist/collections/queue.mjs +13 -5
- package/dist/collections/queue.mjs.map +1 -1
- package/dist/collections/stack.d.mts +60 -25
- package/dist/collections/stack.d.mts.map +1 -1
- package/dist/collections/stack.mjs +12 -5
- package/dist/collections/stack.mjs.map +1 -1
- package/dist/entry-point.mjs +1 -1
- package/dist/functional/match.d.mts +1 -1
- package/dist/functional/match.d.mts.map +1 -1
- package/dist/functional/match.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-expect-to-be.d.mts +3 -2
- package/dist/functional/optional/impl/optional-expect-to-be.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-expect-to-be.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-filter.d.mts +3 -0
- package/dist/functional/optional/impl/optional-filter.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-filter.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-flat-map.d.mts +2 -0
- package/dist/functional/optional/impl/optional-flat-map.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-flat-map.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-from-nullable.d.mts +2 -0
- package/dist/functional/optional/impl/optional-from-nullable.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-from-nullable.mjs +2 -0
- package/dist/functional/optional/impl/optional-from-nullable.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-is-none.d.mts +1 -1
- package/dist/functional/optional/impl/optional-is-none.mjs +1 -1
- package/dist/functional/optional/impl/optional-is-optional.d.mts +4 -2
- package/dist/functional/optional/impl/optional-is-optional.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-is-optional.mjs +4 -2
- package/dist/functional/optional/impl/optional-is-optional.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-is-some.d.mts +2 -1
- package/dist/functional/optional/impl/optional-is-some.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-is-some.mjs +2 -1
- package/dist/functional/optional/impl/optional-is-some.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-map.d.mts +2 -0
- package/dist/functional/optional/impl/optional-map.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-map.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-none.d.mts +4 -2
- package/dist/functional/optional/impl/optional-none.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-none.mjs +4 -2
- package/dist/functional/optional/impl/optional-none.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-or-else.d.mts +4 -0
- package/dist/functional/optional/impl/optional-or-else.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-or-else.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-some.d.mts +5 -3
- package/dist/functional/optional/impl/optional-some.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-some.mjs +4 -2
- package/dist/functional/optional/impl/optional-some.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-to-nullable.d.mts +4 -2
- package/dist/functional/optional/impl/optional-to-nullable.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-to-nullable.mjs +4 -2
- package/dist/functional/optional/impl/optional-to-nullable.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-unwrap-or.d.mts +7 -4
- package/dist/functional/optional/impl/optional-unwrap-or.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-unwrap-or.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-unwrap-throw.d.mts +2 -1
- package/dist/functional/optional/impl/optional-unwrap-throw.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-unwrap-throw.mjs +2 -1
- package/dist/functional/optional/impl/optional-unwrap-throw.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-unwrap.d.mts +4 -2
- package/dist/functional/optional/impl/optional-unwrap.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-unwrap.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-zip.d.mts +3 -1
- package/dist/functional/optional/impl/optional-zip.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-zip.mjs +3 -1
- package/dist/functional/optional/impl/optional-zip.mjs.map +1 -1
- package/dist/functional/pipe.d.mts +2 -2
- package/dist/functional/result/impl/result-err.d.mts +4 -2
- package/dist/functional/result/impl/result-err.d.mts.map +1 -1
- package/dist/functional/result/impl/result-err.mjs +3 -1
- package/dist/functional/result/impl/result-err.mjs.map +1 -1
- package/dist/functional/result/impl/result-expect-to-be.d.mts +3 -2
- package/dist/functional/result/impl/result-expect-to-be.d.mts.map +1 -1
- package/dist/functional/result/impl/result-expect-to-be.mjs.map +1 -1
- package/dist/functional/result/impl/result-flat-map.d.mts +5 -0
- package/dist/functional/result/impl/result-flat-map.d.mts.map +1 -1
- package/dist/functional/result/impl/result-flat-map.mjs.map +1 -1
- package/dist/functional/result/impl/result-fold.d.mts +4 -0
- package/dist/functional/result/impl/result-fold.d.mts.map +1 -1
- package/dist/functional/result/impl/result-fold.mjs.map +1 -1
- package/dist/functional/result/impl/result-from-promise.d.mts +4 -1
- package/dist/functional/result/impl/result-from-promise.d.mts.map +1 -1
- package/dist/functional/result/impl/result-from-promise.mjs +4 -1
- package/dist/functional/result/impl/result-from-promise.mjs.map +1 -1
- package/dist/functional/result/impl/result-from-throwable.d.mts +3 -1
- package/dist/functional/result/impl/result-from-throwable.d.mts.map +1 -1
- package/dist/functional/result/impl/result-from-throwable.mjs +3 -1
- package/dist/functional/result/impl/result-from-throwable.mjs.map +1 -1
- package/dist/functional/result/impl/result-is-err.d.mts +4 -2
- package/dist/functional/result/impl/result-is-err.d.mts.map +1 -1
- package/dist/functional/result/impl/result-is-err.mjs +4 -2
- package/dist/functional/result/impl/result-is-err.mjs.map +1 -1
- package/dist/functional/result/impl/result-is-ok.d.mts +4 -2
- package/dist/functional/result/impl/result-is-ok.d.mts.map +1 -1
- package/dist/functional/result/impl/result-is-ok.mjs +4 -2
- package/dist/functional/result/impl/result-is-ok.mjs.map +1 -1
- package/dist/functional/result/impl/result-is-result.d.mts +7 -3
- package/dist/functional/result/impl/result-is-result.d.mts.map +1 -1
- package/dist/functional/result/impl/result-is-result.mjs +7 -3
- package/dist/functional/result/impl/result-is-result.mjs.map +1 -1
- package/dist/functional/result/impl/result-map-err.d.mts +3 -0
- package/dist/functional/result/impl/result-map-err.d.mts.map +1 -1
- package/dist/functional/result/impl/result-map-err.mjs.map +1 -1
- package/dist/functional/result/impl/result-map.d.mts +4 -0
- package/dist/functional/result/impl/result-map.d.mts.map +1 -1
- package/dist/functional/result/impl/result-map.mjs.map +1 -1
- package/dist/functional/result/impl/result-ok.d.mts +4 -2
- package/dist/functional/result/impl/result-ok.d.mts.map +1 -1
- package/dist/functional/result/impl/result-ok.mjs +3 -1
- package/dist/functional/result/impl/result-ok.mjs.map +1 -1
- package/dist/functional/result/impl/result-or-else.d.mts +4 -0
- package/dist/functional/result/impl/result-or-else.d.mts.map +1 -1
- package/dist/functional/result/impl/result-or-else.mjs.map +1 -1
- package/dist/functional/result/impl/result-swap.d.mts +2 -0
- package/dist/functional/result/impl/result-swap.d.mts.map +1 -1
- package/dist/functional/result/impl/result-swap.mjs +2 -0
- package/dist/functional/result/impl/result-swap.mjs.map +1 -1
- package/dist/functional/result/impl/result-to-optional.d.mts +2 -0
- package/dist/functional/result/impl/result-to-optional.d.mts.map +1 -1
- package/dist/functional/result/impl/result-to-optional.mjs +2 -0
- package/dist/functional/result/impl/result-to-optional.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-err-or.d.mts +7 -4
- package/dist/functional/result/impl/result-unwrap-err-or.d.mts.map +1 -1
- package/dist/functional/result/impl/result-unwrap-err-or.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-err-throw.d.mts +3 -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 +3 -1
- package/dist/functional/result/impl/result-unwrap-err-throw.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-err.d.mts +3 -2
- package/dist/functional/result/impl/result-unwrap-err.d.mts.map +1 -1
- package/dist/functional/result/impl/result-unwrap-err.mjs +3 -2
- package/dist/functional/result/impl/result-unwrap-err.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-ok-or.d.mts +7 -4
- package/dist/functional/result/impl/result-unwrap-ok-or.d.mts.map +1 -1
- package/dist/functional/result/impl/result-unwrap-ok-or.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-ok.d.mts +3 -2
- package/dist/functional/result/impl/result-unwrap-ok.d.mts.map +1 -1
- package/dist/functional/result/impl/result-unwrap-ok.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-throw.d.mts +3 -1
- package/dist/functional/result/impl/result-unwrap-throw.d.mts.map +1 -1
- package/dist/functional/result/impl/result-unwrap-throw.mjs +3 -1
- package/dist/functional/result/impl/result-unwrap-throw.mjs.map +1 -1
- package/dist/functional/result/impl/result-zip.d.mts +3 -1
- package/dist/functional/result/impl/result-zip.d.mts.map +1 -1
- package/dist/functional/result/impl/result-zip.mjs +3 -1
- package/dist/functional/result/impl/result-zip.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-err.d.mts +3 -2
- 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 -1
- package/dist/functional/ternary-result/impl/ternary-result-err.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.d.mts +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.d.mts.map +1 -1
- 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.d.mts +4 -0
- package/dist/functional/ternary-result/impl/ternary-result-flat-map.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-fold.d.mts +2 -0
- package/dist/functional/ternary-result/impl/ternary-result-fold.d.mts.map +1 -1
- 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 +3 -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 +3 -1
- 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 +3 -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 +3 -1
- package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-is-ok.d.mts +1 -0
- 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 +1 -0
- 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 +7 -3
- 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 +7 -3
- 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 +1 -0
- 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 +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-map-err.d.mts +3 -0
- package/dist/functional/ternary-result/impl/ternary-result-map-err.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-map-warn.d.mts +3 -0
- package/dist/functional/ternary-result/impl/ternary-result-map-warn.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-map.d.mts +6 -0
- package/dist/functional/ternary-result/impl/ternary-result-map.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-map.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-ok.d.mts +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.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-or-else.d.mts +2 -0
- package/dist/functional/ternary-result/impl/ternary-result-or-else.d.mts.map +1 -1
- 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 +2 -0
- 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 +2 -0
- 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.d.mts +2 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.d.mts.map +1 -1
- 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 +1 -0
- 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 +1 -0
- 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 +2 -0
- 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 +2 -0
- 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.d.mts +2 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.d.mts.map +1 -1
- 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.d.mts +2 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.d.mts.map +1 -1
- 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 +1 -0
- 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 +1 -0
- 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.d.mts +2 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.d.mts.map +1 -1
- 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 +1 -0
- 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 +1 -0
- 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 +2 -0
- 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 +2 -0
- 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 +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.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-zip.d.mts +4 -0
- package/dist/functional/ternary-result/impl/ternary-result-zip.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-zip.mjs +4 -0
- package/dist/functional/ternary-result/impl/ternary-result-zip.mjs.map +1 -1
- package/dist/globals.d.mts +12 -1
- package/dist/guard/has-key.d.mts +6 -3
- package/dist/guard/has-key.d.mts.map +1 -1
- package/dist/guard/has-key.mjs +2 -2
- package/dist/guard/index.mjs +1 -1
- package/dist/guard/is-record.d.mts +31 -0
- package/dist/guard/is-record.d.mts.map +1 -1
- package/dist/guard/is-record.mjs +32 -1
- package/dist/guard/is-record.mjs.map +1 -1
- package/dist/guard/is-type.d.mts +3 -0
- package/dist/guard/is-type.d.mts.map +1 -1
- package/dist/guard/is-type.mjs +3 -0
- package/dist/guard/is-type.mjs.map +1 -1
- package/dist/guard/key-is-in.d.mts +3 -2
- package/dist/guard/key-is-in.d.mts.map +1 -1
- package/dist/guard/key-is-in.mjs +3 -2
- package/dist/guard/key-is-in.mjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/iterator/range.d.mts +4 -0
- package/dist/iterator/range.d.mts.map +1 -1
- package/dist/iterator/range.mjs +1 -0
- package/dist/iterator/range.mjs.map +1 -1
- package/dist/json/json.d.mts +42 -21
- package/dist/json/json.d.mts.map +1 -1
- package/dist/json/json.mjs +42 -21
- package/dist/json/json.mjs.map +1 -1
- package/dist/number/branded-types/int.d.mts +33 -19
- package/dist/number/branded-types/int.d.mts.map +1 -1
- package/dist/number/branded-types/int.mjs +33 -19
- package/dist/number/branded-types/int.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-safe-int.mjs +2 -2
- package/dist/number/branded-types/positive-int.d.mts +34 -20
- package/dist/number/branded-types/positive-int.d.mts.map +1 -1
- package/dist/number/branded-types/positive-int.mjs +34 -20
- package/dist/number/branded-types/positive-int.mjs.map +1 -1
- package/dist/number/branded-types/positive-safe-int.d.mts +47 -26
- package/dist/number/branded-types/positive-safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/positive-safe-int.mjs +48 -27
- package/dist/number/branded-types/positive-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/safe-int.d.mts +48 -27
- package/dist/number/branded-types/safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/safe-int.mjs +50 -29
- package/dist/number/branded-types/safe-int.mjs.map +1 -1
- package/dist/number/branded-types/safe-uint.mjs +1 -1
- package/dist/number/branded-types/uint.d.mts +31 -19
- package/dist/number/branded-types/uint.d.mts.map +1 -1
- package/dist/number/branded-types/uint.mjs +31 -19
- package/dist/number/branded-types/uint.mjs.map +1 -1
- package/dist/number/num.d.mts +29 -20
- package/dist/number/num.d.mts.map +1 -1
- package/dist/number/num.mjs +24 -17
- package/dist/number/num.mjs.map +1 -1
- package/dist/number/refined-number-utils.d.mts +33 -11
- package/dist/number/refined-number-utils.d.mts.map +1 -1
- package/dist/number/refined-number-utils.mjs +33 -11
- package/dist/number/refined-number-utils.mjs.map +1 -1
- package/dist/object/object.d.mts +12 -3
- package/dist/object/object.d.mts.map +1 -1
- package/dist/object/object.mjs +10 -3
- package/dist/object/object.mjs.map +1 -1
- package/dist/others/map-nullable.mjs.map +1 -1
- package/dist/others/tuple.d.mts +14 -3
- package/dist/others/tuple.d.mts.map +1 -1
- package/dist/others/tuple.mjs +14 -3
- 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.map +1 -1
- package/dist/promise/promise.d.mts +8 -4
- package/dist/promise/promise.d.mts.map +1 -1
- package/dist/promise/promise.mjs +8 -4
- package/dist/promise/promise.mjs.map +1 -1
- package/package.json +26 -28
- package/src/array/impl/array-utils-creation.mts +20 -0
- package/src/array/impl/array-utils-creation.test.mts +72 -1
- package/src/array/impl/array-utils-element-access.mts +13 -0
- package/src/array/impl/array-utils-element-access.test.mts +36 -15
- package/src/array/impl/array-utils-iterators.test.mts +17 -0
- package/src/array/impl/array-utils-modification.mts +78 -19
- package/src/array/impl/array-utils-modification.test.mts +75 -0
- package/src/array/impl/array-utils-overload-type-error.test.mts +19 -0
- package/src/array/impl/array-utils-reducing-value.mts +61 -16
- package/src/array/impl/array-utils-reducing-value.test.mts +107 -25
- package/src/array/impl/array-utils-search.mts +57 -4
- package/src/array/impl/array-utils-search.test.mts +61 -10
- package/src/array/impl/array-utils-set-op.mts +26 -7
- package/src/array/impl/array-utils-set-op.test.mts +129 -13
- package/src/array/impl/array-utils-size.mts +5 -2
- package/src/array/impl/array-utils-size.test.mts +1 -0
- package/src/array/impl/array-utils-slice-clamped.mts +7 -0
- package/src/array/impl/array-utils-slice-clamped.test.mts +20 -0
- package/src/array/impl/array-utils-slicing.mts +29 -2
- package/src/array/impl/array-utils-slicing.test.mts +57 -0
- package/src/array/impl/array-utils-transformation.mts +58 -0
- package/src/array/impl/array-utils-transformation.test.mts +115 -3
- package/src/array/impl/array-utils-validation.mts +41 -18
- package/src/array/impl/array-utils-validation.test.mts +176 -78
- package/src/array/impl/array.test.mts +18 -6
- package/src/collections/imap-mapped.mts +11 -0
- package/src/collections/imap-mapped.test.mts +86 -18
- package/src/collections/imap.mts +47 -15
- package/src/collections/imap.test.mts +137 -31
- package/src/collections/iset-mapped.mts +54 -19
- package/src/collections/iset-mapped.test.mts +163 -52
- package/src/collections/iset.mts +53 -19
- package/src/collections/iset.test.mts +323 -130
- package/src/collections/queue.mts +78 -25
- package/src/collections/queue.test.mts +65 -35
- package/src/collections/stack.mts +67 -25
- package/src/collections/stack.test.mts +59 -15
- package/src/functional/match.mts +17 -1
- package/src/functional/match.test.mts +2 -0
- package/src/functional/optional/impl/optional-expect-to-be.mts +5 -2
- package/src/functional/optional/impl/optional-filter.mts +6 -0
- package/src/functional/optional/impl/optional-flat-map.mts +4 -0
- package/src/functional/optional/impl/optional-from-nullable.mts +2 -0
- package/src/functional/optional/impl/optional-is-none.mts +1 -1
- package/src/functional/optional/impl/optional-is-optional.mts +4 -2
- package/src/functional/optional/impl/optional-is-some.mts +2 -1
- package/src/functional/optional/impl/optional-map.mts +5 -0
- package/src/functional/optional/impl/optional-none.mts +4 -2
- package/src/functional/optional/impl/optional-or-else.mts +6 -0
- package/src/functional/optional/impl/optional-some.mts +5 -3
- package/src/functional/optional/impl/optional-to-nullable.mts +4 -2
- package/src/functional/optional/impl/optional-unwrap-or.mts +9 -4
- package/src/functional/optional/impl/optional-unwrap-throw.mts +2 -1
- package/src/functional/optional/impl/optional-unwrap.mts +4 -2
- package/src/functional/optional/impl/optional-zip.mts +3 -1
- package/src/functional/optional.test.mts +126 -54
- package/src/functional/pipe.mts +2 -2
- package/src/functional/pipe.test.mts +7 -4
- package/src/functional/result/impl/result-err.mts +4 -2
- package/src/functional/result/impl/result-expect-to-be.mts +5 -2
- package/src/functional/result/impl/result-flat-map.mts +7 -0
- package/src/functional/result/impl/result-fold.mts +6 -0
- package/src/functional/result/impl/result-from-promise.mts +4 -1
- package/src/functional/result/impl/result-from-throwable.mts +5 -1
- package/src/functional/result/impl/result-is-err.mts +4 -2
- package/src/functional/result/impl/result-is-ok.mts +4 -2
- package/src/functional/result/impl/result-is-result.mts +7 -3
- package/src/functional/result/impl/result-map-err.mts +5 -0
- package/src/functional/result/impl/result-map.mts +6 -0
- package/src/functional/result/impl/result-ok.mts +4 -2
- package/src/functional/result/impl/result-or-else.mts +6 -0
- package/src/functional/result/impl/result-swap.mts +2 -0
- package/src/functional/result/impl/result-to-optional.mts +2 -0
- package/src/functional/result/impl/result-unwrap-err-or.mts +9 -4
- package/src/functional/result/impl/result-unwrap-err-throw.mts +3 -1
- package/src/functional/result/impl/result-unwrap-err.mts +3 -2
- package/src/functional/result/impl/result-unwrap-ok-or.mts +9 -4
- package/src/functional/result/impl/result-unwrap-ok.mts +4 -2
- package/src/functional/result/impl/result-unwrap-throw.mts +3 -1
- package/src/functional/result/impl/result-zip.mts +3 -1
- package/src/functional/result.test.mts +182 -152
- package/src/functional/ternary-result/impl/ternary-result-err.mts +3 -2
- package/src/functional/ternary-result/impl/ternary-result-expect-to-be.mts +4 -0
- package/src/functional/ternary-result/impl/ternary-result-flat-map.mts +7 -0
- package/src/functional/ternary-result/impl/ternary-result-fold.mts +5 -0
- package/src/functional/ternary-result/impl/ternary-result-from-promise.mts +3 -1
- package/src/functional/ternary-result/impl/ternary-result-from-throwable.mts +4 -1
- package/src/functional/ternary-result/impl/ternary-result-is-ok.mts +1 -0
- package/src/functional/ternary-result/impl/ternary-result-is-ternary-result.mts +7 -3
- package/src/functional/ternary-result/impl/ternary-result-is-warn.mts +1 -0
- package/src/functional/ternary-result/impl/ternary-result-map-err.mts +6 -0
- package/src/functional/ternary-result/impl/ternary-result-map-warn.mts +6 -0
- package/src/functional/ternary-result/impl/ternary-result-map.mts +9 -0
- package/src/functional/ternary-result/impl/ternary-result-ok.mts +1 -1
- package/src/functional/ternary-result/impl/ternary-result-or-else.mts +5 -0
- package/src/functional/ternary-result/impl/ternary-result-to-optional.mts +2 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-err-or.mts +5 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mts +1 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-err.mts +2 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mts +5 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-ok.mts +3 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-throw.mts +1 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mts +5 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mts +1 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-warn.mts +2 -0
- package/src/functional/ternary-result/impl/ternary-result-warn.mts +4 -1
- package/src/functional/ternary-result/impl/ternary-result-zip.mts +4 -0
- package/src/functional/ternary-result.test.mts +99 -8
- package/src/globals.d.mts +12 -1
- package/src/guard/has-key.mts +8 -5
- package/src/guard/has-key.test.mts +9 -5
- package/src/guard/is-error.test.mts +143 -0
- package/src/guard/is-non-empty-string.test.mts +44 -24
- package/src/guard/is-non-null-object.test.mts +45 -26
- package/src/guard/is-primitive.test.mts +51 -28
- package/src/guard/is-record.mts +34 -0
- package/src/guard/is-record.test.mts +28 -7
- package/src/guard/is-type.mts +3 -0
- package/src/guard/is-type.test.mts +285 -155
- package/src/guard/key-is-in.mts +3 -2
- package/src/guard/key-is-in.test.mts +2 -2
- package/src/iterator/range.mts +9 -0
- package/src/json/json.mts +50 -21
- package/src/json/json.test.mts +224 -176
- package/src/number/branded-types/finite-number.test.mts +51 -11
- package/src/number/branded-types/int.mts +33 -19
- package/src/number/branded-types/int.test.mts +56 -14
- package/src/number/branded-types/int16.test.mts +63 -16
- package/src/number/branded-types/int32.test.mts +63 -16
- package/src/number/branded-types/non-negative-finite-number.test.mts +52 -12
- package/src/number/branded-types/non-negative-int16.test.mts +59 -16
- package/src/number/branded-types/non-negative-int32.test.mts +59 -16
- package/src/number/branded-types/non-zero-finite-number.test.mts +65 -14
- package/src/number/branded-types/non-zero-int.test.mts +72 -19
- package/src/number/branded-types/non-zero-int16.test.mts +60 -16
- package/src/number/branded-types/non-zero-int32.test.mts +60 -16
- package/src/number/branded-types/non-zero-safe-int.mts +2 -2
- package/src/number/branded-types/non-zero-safe-int.test.mts +85 -23
- package/src/number/branded-types/non-zero-uint16.test.mts +53 -16
- package/src/number/branded-types/non-zero-uint32.test.mts +53 -16
- package/src/number/branded-types/positive-finite-number.test.mts +59 -14
- package/src/number/branded-types/positive-int.mts +34 -20
- package/src/number/branded-types/positive-int.test.mts +64 -17
- package/src/number/branded-types/positive-int16.test.mts +50 -15
- package/src/number/branded-types/positive-int32.test.mts +50 -15
- package/src/number/branded-types/positive-safe-int.mts +48 -27
- package/src/number/branded-types/positive-safe-int.test.mts +68 -19
- package/src/number/branded-types/positive-uint16.test.mts +53 -16
- package/src/number/branded-types/positive-uint32.test.mts +53 -16
- package/src/number/branded-types/safe-int.mts +50 -29
- package/src/number/branded-types/safe-int.test.mts +70 -18
- package/src/number/branded-types/safe-uint.mts +1 -1
- package/src/number/branded-types/safe-uint.test.mts +65 -17
- package/src/number/branded-types/uint.mts +31 -19
- package/src/number/branded-types/uint.test.mts +58 -15
- package/src/number/branded-types/uint16.test.mts +56 -15
- package/src/number/branded-types/uint32.test.mts +56 -15
- package/src/number/enum/int8.test.mts +7 -1
- package/src/number/enum/uint8.test.mts +7 -1
- package/src/number/num.mts +32 -21
- package/src/number/num.test.mts +88 -26
- package/src/number/refined-number-utils.mts +38 -13
- package/src/object/object.mts +19 -3
- package/src/object/object.test.mts +16 -6
- package/src/others/cast-mutable.test.mts +8 -1
- package/src/others/cast-readonly.test.mts +21 -4
- package/src/others/if-then.test.mts +40 -24
- package/src/others/map-nullable.mts +3 -0
- package/src/others/map-nullable.test.mts +27 -0
- package/src/others/memoize-function.test.mts +41 -0
- package/src/others/tuple.mts +14 -3
- package/src/others/unknown-to-string.mts +2 -0
- package/src/others/unknown-to-string.test.mts +10 -0
- package/src/promise/promise.mts +8 -4
- package/src/promise/promise.test.mts +8 -13
|
@@ -3,9 +3,9 @@ import { TsDataForgeInternals } from '../refined-number-utils.mjs';
|
|
|
3
3
|
const typeNameInMessage = 'a safe integer';
|
|
4
4
|
const { MAX_VALUE, MIN_VALUE, abs, add, castType, clamp, div, is, max: max_, min: min_, mul, pow, random, sub, } = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger({
|
|
5
5
|
integerOrSafeInteger: 'SafeInteger',
|
|
6
|
-
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
6
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion, math/prefer-number-min-safe-integer
|
|
7
7
|
MIN_VALUE: Number.MIN_SAFE_INTEGER,
|
|
8
|
-
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
8
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion, math/prefer-number-max-safe-integer
|
|
9
9
|
MAX_VALUE: Number.MAX_SAFE_INTEGER,
|
|
10
10
|
typeNameInMessage,
|
|
11
11
|
});
|
|
@@ -18,9 +18,11 @@ const { MAX_VALUE, MIN_VALUE, abs, add, castType, clamp, div, is, max: max_, min
|
|
|
18
18
|
* @example
|
|
19
19
|
*
|
|
20
20
|
* ```ts
|
|
21
|
-
* assert.
|
|
22
|
-
*
|
|
23
|
-
* assert.
|
|
21
|
+
* assert.isTrue(isSafeInt(Number.MAX_SAFE_INTEGER));
|
|
22
|
+
*
|
|
23
|
+
* assert.isFalse(isSafeInt(Number.MAX_SAFE_INTEGER + 0.5));
|
|
24
|
+
*
|
|
25
|
+
* assert.isTrue(SafeInt.is(Number.MIN_SAFE_INTEGER));
|
|
24
26
|
* ```
|
|
25
27
|
*
|
|
26
28
|
* @param value - The value to check
|
|
@@ -39,8 +41,9 @@ const isSafeInt = is;
|
|
|
39
41
|
* ```ts
|
|
40
42
|
* const branded = asSafeInt(123);
|
|
41
43
|
*
|
|
42
|
-
* assert(branded === 123);
|
|
43
|
-
*
|
|
44
|
+
* assert.isTrue(branded === 123);
|
|
45
|
+
*
|
|
46
|
+
* assert.isTrue(SafeInt.is(branded));
|
|
44
47
|
* ```
|
|
45
48
|
*
|
|
46
49
|
* @param value - The value to cast
|
|
@@ -71,9 +74,11 @@ const SafeInt = {
|
|
|
71
74
|
* @example
|
|
72
75
|
*
|
|
73
76
|
* ```ts
|
|
74
|
-
* assert.
|
|
75
|
-
*
|
|
76
|
-
* assert.
|
|
77
|
+
* assert.isTrue(isSafeInt(Number.MAX_SAFE_INTEGER));
|
|
78
|
+
*
|
|
79
|
+
* assert.isFalse(isSafeInt(Number.MAX_SAFE_INTEGER + 0.5));
|
|
80
|
+
*
|
|
81
|
+
* assert.isTrue(SafeInt.is(Number.MIN_SAFE_INTEGER));
|
|
77
82
|
* ```
|
|
78
83
|
*
|
|
79
84
|
* @param value - The value to check
|
|
@@ -103,10 +108,12 @@ const SafeInt = {
|
|
|
103
108
|
*
|
|
104
109
|
* ```ts
|
|
105
110
|
* const negative = asSafeInt(-900);
|
|
111
|
+
*
|
|
106
112
|
* const absolute = SafeInt.abs(negative);
|
|
107
113
|
*
|
|
108
|
-
* assert(absolute === 900);
|
|
109
|
-
*
|
|
114
|
+
* assert.isTrue(absolute === 900);
|
|
115
|
+
*
|
|
116
|
+
* assert.isTrue(SafeInt.is(absolute));
|
|
110
117
|
* ```
|
|
111
118
|
*
|
|
112
119
|
* @param a - The safe integer value
|
|
@@ -121,7 +128,7 @@ const SafeInt = {
|
|
|
121
128
|
* ```ts
|
|
122
129
|
* const smallest = SafeInt.min(asSafeInt(25), asSafeInt(-14), asSafeInt(99));
|
|
123
130
|
*
|
|
124
|
-
* assert(smallest === -14);
|
|
131
|
+
* assert.isTrue(smallest === -14);
|
|
125
132
|
* ```
|
|
126
133
|
*
|
|
127
134
|
* @param values - The safe integers to compare (at least one required)
|
|
@@ -136,7 +143,7 @@ const SafeInt = {
|
|
|
136
143
|
* ```ts
|
|
137
144
|
* const largest = SafeInt.max(asSafeInt(25), asSafeInt(-14), asSafeInt(99));
|
|
138
145
|
*
|
|
139
|
-
* assert(largest === 99);
|
|
146
|
+
* assert.isTrue(largest === 99);
|
|
140
147
|
* ```
|
|
141
148
|
*
|
|
142
149
|
* @param values - The safe integers to compare (at least one required)
|
|
@@ -150,12 +157,16 @@ const SafeInt = {
|
|
|
150
157
|
*
|
|
151
158
|
* ```ts
|
|
152
159
|
* const aboveRange = SafeInt.clamp(1e20);
|
|
160
|
+
*
|
|
153
161
|
* const withinRange = SafeInt.clamp(123);
|
|
162
|
+
*
|
|
154
163
|
* const belowRange = SafeInt.clamp(-1e20);
|
|
155
164
|
*
|
|
156
|
-
* assert(aboveRange === Number.MAX_SAFE_INTEGER);
|
|
157
|
-
*
|
|
158
|
-
* assert(
|
|
165
|
+
* assert.isTrue(aboveRange === Number.MAX_SAFE_INTEGER);
|
|
166
|
+
*
|
|
167
|
+
* assert.isTrue(withinRange === 123);
|
|
168
|
+
*
|
|
169
|
+
* assert.isTrue(belowRange === Number.MIN_SAFE_INTEGER);
|
|
159
170
|
* ```
|
|
160
171
|
*
|
|
161
172
|
* @param value The number to clamp.
|
|
@@ -173,11 +184,14 @@ const SafeInt = {
|
|
|
173
184
|
*
|
|
174
185
|
* ```ts
|
|
175
186
|
* const min = asSafeInt(-10);
|
|
187
|
+
*
|
|
176
188
|
* const max = asSafeInt(10);
|
|
189
|
+
*
|
|
177
190
|
* const randomValue = SafeInt.random(min, max);
|
|
178
191
|
*
|
|
179
|
-
* assert.
|
|
180
|
-
*
|
|
192
|
+
* assert.isTrue(SafeInt.is(randomValue));
|
|
193
|
+
*
|
|
194
|
+
* assert.isTrue(randomValue >= -10 && randomValue <= 10);
|
|
181
195
|
* ```
|
|
182
196
|
*
|
|
183
197
|
* @param min - The minimum value (inclusive)
|
|
@@ -192,11 +206,14 @@ const SafeInt = {
|
|
|
192
206
|
*
|
|
193
207
|
* ```ts
|
|
194
208
|
* const base = asSafeInt(3);
|
|
209
|
+
*
|
|
195
210
|
* const exponent = asSafeInt(5);
|
|
211
|
+
*
|
|
196
212
|
* const power = SafeInt.pow(base, exponent);
|
|
197
213
|
*
|
|
198
|
-
* assert(power === 243);
|
|
199
|
-
*
|
|
214
|
+
* assert.isTrue(power === 243);
|
|
215
|
+
*
|
|
216
|
+
* assert.isTrue(SafeInt.is(power));
|
|
200
217
|
* ```
|
|
201
218
|
*
|
|
202
219
|
* @param a The base SafeInt.
|
|
@@ -212,8 +229,9 @@ const SafeInt = {
|
|
|
212
229
|
* ```ts
|
|
213
230
|
* const sum = SafeInt.add(asSafeInt(9), asSafeInt(4));
|
|
214
231
|
*
|
|
215
|
-
* assert(sum === 13);
|
|
216
|
-
*
|
|
232
|
+
* assert.isTrue(sum === 13);
|
|
233
|
+
*
|
|
234
|
+
* assert.isTrue(SafeInt.is(sum));
|
|
217
235
|
* ```
|
|
218
236
|
*
|
|
219
237
|
* @param a The first SafeInt.
|
|
@@ -229,8 +247,9 @@ const SafeInt = {
|
|
|
229
247
|
* ```ts
|
|
230
248
|
* const difference = SafeInt.sub(asSafeInt(9), asSafeInt(14));
|
|
231
249
|
*
|
|
232
|
-
* assert(difference === -5);
|
|
233
|
-
*
|
|
250
|
+
* assert.isTrue(difference === -5);
|
|
251
|
+
*
|
|
252
|
+
* assert.isTrue(SafeInt.is(difference));
|
|
234
253
|
* ```
|
|
235
254
|
*
|
|
236
255
|
* @param a The minuend SafeInt.
|
|
@@ -246,8 +265,9 @@ const SafeInt = {
|
|
|
246
265
|
* ```ts
|
|
247
266
|
* const product = SafeInt.mul(asSafeInt(-8), asSafeInt(7));
|
|
248
267
|
*
|
|
249
|
-
* assert(product === -56);
|
|
250
|
-
*
|
|
268
|
+
* assert.isTrue(product === -56);
|
|
269
|
+
*
|
|
270
|
+
* assert.isTrue(SafeInt.is(product));
|
|
251
271
|
* ```
|
|
252
272
|
*
|
|
253
273
|
* @param a The first SafeInt.
|
|
@@ -266,8 +286,9 @@ const SafeInt = {
|
|
|
266
286
|
* ```ts
|
|
267
287
|
* const quotient = SafeInt.div(asSafeInt(-17), asSafeInt(5));
|
|
268
288
|
*
|
|
269
|
-
* assert(quotient === -4);
|
|
270
|
-
*
|
|
289
|
+
* assert.isTrue(quotient === -4);
|
|
290
|
+
*
|
|
291
|
+
* assert.isTrue(SafeInt.is(quotient));
|
|
271
292
|
* ```
|
|
272
293
|
*
|
|
273
294
|
* @param a - The dividend
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"safe-int.mjs","sources":["../../../src/number/branded-types/safe-int.mts"],"sourcesContent":[null],"names":[],"mappings":";;AAKA,MAAM,iBAAiB,GAAG,gBAAgB;AAE1C,MAAM,EACJ,SAAS,EACT,SAAS,EACT,GAAG,EACH,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,aAAa;;IAEnC,SAAS,EAAE,MAAM,CAAC,gBAA2B;;IAE7C,SAAS,EAAE,MAAM,CAAC,gBAA4B;IAC9C,iBAAiB;AACT,CAAA,CAAC;AAEX
|
|
1
|
+
{"version":3,"file":"safe-int.mjs","sources":["../../../src/number/branded-types/safe-int.mts"],"sourcesContent":[null],"names":[],"mappings":";;AAKA,MAAM,iBAAiB,GAAG,gBAAgB;AAE1C,MAAM,EACJ,SAAS,EACT,SAAS,EACT,GAAG,EACH,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,aAAa;;IAEnC,SAAS,EAAE,MAAM,CAAC,gBAA2B;;IAE7C,SAAS,EAAE,MAAM,CAAC,gBAA4B;IAC9C,iBAAiB;AACT,CAAA,CAAC;AAEX;;;;;;;;;;;;;;;;;;AAkBG;AACI,MAAM,SAAS,GAAG;AAEzB;;;;;;;;;;;;;;;;;;;;AAoBG;AACI,MAAM,SAAS,GAAG;AAEzB;;;;;;;;;;;;;;;AAeG;AACI,MAAM,OAAO,GAAG;AACrB;;;;;;;;;;;;;;;;AAgBG;IACH,EAAE;AAEF;;;;AAIG;IACH,SAAS;AAET;;;;AAIG;IACH,SAAS;AAET;;;;;;;;;;;;;;;;;;;;AAoBG;IACH,GAAG;AAEH;;;;;;;;;;;;;AAaG;AACH,IAAA,GAAG,EAAE,IAAI;AAET;;;;;;;;;;;;;AAaG;AACH,IAAA,GAAG,EAAE,IAAI;AAET;;;;;;;;;;;;;;;;;;;;;;AAsBG;IACH,KAAK;AAEL;;;;;;;;;;;;;;;;;;;;;;;AAuBG;IACH,MAAM;AAEN;;;;;;;;;;;;;;;;;;;;AAoBG;IACH,GAAG;AAEH;;;;;;;;;;;;;;;;AAgBG;IACH,GAAG;AAEH;;;;;;;;;;;;;;;;AAgBG;IACH,GAAG;AAEH;;;;;;;;;;;;;;;;AAgBG;IACH,GAAG;AAEH;;;;;;;;;;;;;;;;;;;AAmBG;IACH,GAAG;;;;;"}
|
|
@@ -4,7 +4,7 @@ const typeNameInMessage = 'a non-negative safe integer';
|
|
|
4
4
|
const { MAX_VALUE, MIN_VALUE, add, castType, clamp, div, is, max: max_, min: min_, mul, pow, random, sub, } = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger({
|
|
5
5
|
integerOrSafeInteger: 'SafeInteger',
|
|
6
6
|
MIN_VALUE: 0,
|
|
7
|
-
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
7
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion, math/prefer-number-max-safe-integer
|
|
8
8
|
MAX_VALUE: Number.MAX_SAFE_INTEGER,
|
|
9
9
|
typeNameInMessage,
|
|
10
10
|
});
|
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
* @example
|
|
5
5
|
*
|
|
6
6
|
* ```ts
|
|
7
|
-
* assert.
|
|
8
|
-
*
|
|
9
|
-
* assert.
|
|
7
|
+
* assert.isTrue(isUint(4));
|
|
8
|
+
*
|
|
9
|
+
* assert.isFalse(isUint(-1));
|
|
10
|
+
*
|
|
11
|
+
* assert.isTrue(Uint.is(0));
|
|
10
12
|
* ```
|
|
11
13
|
*
|
|
12
14
|
* @param value The value to check.
|
|
@@ -21,8 +23,9 @@ export declare const isUint: (a: number) => a is NonNegativeInt;
|
|
|
21
23
|
* ```ts
|
|
22
24
|
* const branded = asUint(12);
|
|
23
25
|
*
|
|
24
|
-
* assert(branded === 12);
|
|
25
|
-
*
|
|
26
|
+
* assert.isTrue(branded === 12);
|
|
27
|
+
*
|
|
28
|
+
* assert.isTrue(Uint.is(branded));
|
|
26
29
|
* ```
|
|
27
30
|
*
|
|
28
31
|
* @param value The value to cast.
|
|
@@ -55,9 +58,11 @@ export declare const Uint: {
|
|
|
55
58
|
* @example
|
|
56
59
|
*
|
|
57
60
|
* ```ts
|
|
58
|
-
* assert.
|
|
59
|
-
*
|
|
60
|
-
* assert.
|
|
61
|
+
* assert.isTrue(isUint(4));
|
|
62
|
+
*
|
|
63
|
+
* assert.isFalse(isUint(-1));
|
|
64
|
+
*
|
|
65
|
+
* assert.isTrue(Uint.is(0));
|
|
61
66
|
* ```
|
|
62
67
|
*
|
|
63
68
|
* @param value The value to check.
|
|
@@ -79,7 +84,7 @@ export declare const Uint: {
|
|
|
79
84
|
* ```ts
|
|
80
85
|
* const smallest = Uint.min(asUint(7), asUint(3));
|
|
81
86
|
*
|
|
82
|
-
* assert(smallest === 3);
|
|
87
|
+
* assert.isTrue(smallest === 3);
|
|
83
88
|
* ```
|
|
84
89
|
*
|
|
85
90
|
* @param a The first Uint.
|
|
@@ -95,7 +100,7 @@ export declare const Uint: {
|
|
|
95
100
|
* ```ts
|
|
96
101
|
* const largest = Uint.max(asUint(7), asUint(3));
|
|
97
102
|
*
|
|
98
|
-
* assert(largest === 7);
|
|
103
|
+
* assert.isTrue(largest === 7);
|
|
99
104
|
* ```
|
|
100
105
|
*
|
|
101
106
|
* @param a The first Uint.
|
|
@@ -110,10 +115,12 @@ export declare const Uint: {
|
|
|
110
115
|
*
|
|
111
116
|
* ```ts
|
|
112
117
|
* const clampedNegative = Uint.clamp(-5);
|
|
118
|
+
*
|
|
113
119
|
* const clampedPositive = Uint.clamp(42);
|
|
114
120
|
*
|
|
115
|
-
* assert(clampedNegative === 0);
|
|
116
|
-
*
|
|
121
|
+
* assert.isTrue(clampedNegative === 0);
|
|
122
|
+
*
|
|
123
|
+
* assert.isTrue(clampedPositive === 42);
|
|
117
124
|
* ```
|
|
118
125
|
*
|
|
119
126
|
* @param value The number to clamp.
|
|
@@ -127,11 +134,14 @@ export declare const Uint: {
|
|
|
127
134
|
*
|
|
128
135
|
* ```ts
|
|
129
136
|
* const min = asUint(0);
|
|
137
|
+
*
|
|
130
138
|
* const max = asUint(3);
|
|
139
|
+
*
|
|
131
140
|
* const randomValue = Uint.random(min, max);
|
|
132
141
|
*
|
|
133
|
-
* assert.
|
|
134
|
-
*
|
|
142
|
+
* assert.isTrue(Uint.is(randomValue));
|
|
143
|
+
*
|
|
144
|
+
* assert.isTrue(randomValue >= 0 && randomValue <= 3);
|
|
135
145
|
* ```
|
|
136
146
|
*
|
|
137
147
|
* @returns A random non-negative integer as a Uint.
|
|
@@ -144,10 +154,12 @@ export declare const Uint: {
|
|
|
144
154
|
*
|
|
145
155
|
* ```ts
|
|
146
156
|
* const base = asUint(2);
|
|
157
|
+
*
|
|
147
158
|
* const exponent = asUint(5);
|
|
159
|
+
*
|
|
148
160
|
* const power = Uint.pow(base, exponent);
|
|
149
161
|
*
|
|
150
|
-
* assert(power === 32);
|
|
162
|
+
* assert.isTrue(power === 32);
|
|
151
163
|
* ```
|
|
152
164
|
*
|
|
153
165
|
* @param a The base Uint.
|
|
@@ -163,7 +175,7 @@ export declare const Uint: {
|
|
|
163
175
|
* ```ts
|
|
164
176
|
* const sum = Uint.add(asUint(5), asUint(8));
|
|
165
177
|
*
|
|
166
|
-
* assert(sum === 13);
|
|
178
|
+
* assert.isTrue(sum === 13);
|
|
167
179
|
* ```
|
|
168
180
|
*
|
|
169
181
|
* @param a The first Uint.
|
|
@@ -179,7 +191,7 @@ export declare const Uint: {
|
|
|
179
191
|
* ```ts
|
|
180
192
|
* const difference = Uint.sub(asUint(5), asUint(8));
|
|
181
193
|
*
|
|
182
|
-
* assert(difference === 0);
|
|
194
|
+
* assert.isTrue(difference === 0);
|
|
183
195
|
* ```
|
|
184
196
|
*
|
|
185
197
|
* @param a The minuend Uint.
|
|
@@ -195,7 +207,7 @@ export declare const Uint: {
|
|
|
195
207
|
* ```ts
|
|
196
208
|
* const product = Uint.mul(asUint(7), asUint(6));
|
|
197
209
|
*
|
|
198
|
-
* assert(product === 42);
|
|
210
|
+
* assert.isTrue(product === 42);
|
|
199
211
|
* ```
|
|
200
212
|
*
|
|
201
213
|
* @param a The first Uint.
|
|
@@ -211,7 +223,7 @@ export declare const Uint: {
|
|
|
211
223
|
* ```ts
|
|
212
224
|
* const quotient = Uint.div(asUint(10), asUint(4));
|
|
213
225
|
*
|
|
214
|
-
* assert(quotient === 2);
|
|
226
|
+
* assert.isTrue(quotient === 2);
|
|
215
227
|
* ```
|
|
216
228
|
*
|
|
217
229
|
* @param a The dividend Uint.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uint.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/uint.mts"],"names":[],"mappings":"AA+BA
|
|
1
|
+
{"version":3,"file":"uint.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/uint.mts"],"names":[],"mappings":"AA+BA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,MAAM,oCAAK,CAAC;AAEzB;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;;MAAW,CAAC;AAE/B;;;;;;GAMG;AACH,eAAO,MAAM,IAAI;IACf;;;;;;;;;;;;;;;;OAgBG;;IAGH;;;;OAIG;;IAGH;;;;;;;;;;;;;;OAcG;;IAGH;;;;;;;;;;;;;;OAcG;;IAGH;;;;;;;;;;;;;;;;;OAiBG;;IAGH;;;;;;;;;;;;;;;;;;OAkBG;;IAGH;;;;;;;;;;;;;;;;;;OAkBG;;IAGH;;;;;;;;;;;;;;OAcG;;IAGH;;;;;;;;;;;;;;OAcG;;IAGH;;;;;;;;;;;;;;OAcG;;IAGH;;;;;;;;;;;;;;OAcG;;;;;;;;;;;;;;CAEK,CAAC"}
|
|
@@ -13,9 +13,11 @@ const { MIN_VALUE, add, castType, clamp, div, is, max: max_, min: min_, mul, pow
|
|
|
13
13
|
* @example
|
|
14
14
|
*
|
|
15
15
|
* ```ts
|
|
16
|
-
* assert.
|
|
17
|
-
*
|
|
18
|
-
* assert.
|
|
16
|
+
* assert.isTrue(isUint(4));
|
|
17
|
+
*
|
|
18
|
+
* assert.isFalse(isUint(-1));
|
|
19
|
+
*
|
|
20
|
+
* assert.isTrue(Uint.is(0));
|
|
19
21
|
* ```
|
|
20
22
|
*
|
|
21
23
|
* @param value The value to check.
|
|
@@ -30,8 +32,9 @@ const isUint = is;
|
|
|
30
32
|
* ```ts
|
|
31
33
|
* const branded = asUint(12);
|
|
32
34
|
*
|
|
33
|
-
* assert(branded === 12);
|
|
34
|
-
*
|
|
35
|
+
* assert.isTrue(branded === 12);
|
|
36
|
+
*
|
|
37
|
+
* assert.isTrue(Uint.is(branded));
|
|
35
38
|
* ```
|
|
36
39
|
*
|
|
37
40
|
* @param value The value to cast.
|
|
@@ -53,9 +56,11 @@ const Uint = {
|
|
|
53
56
|
* @example
|
|
54
57
|
*
|
|
55
58
|
* ```ts
|
|
56
|
-
* assert.
|
|
57
|
-
*
|
|
58
|
-
* assert.
|
|
59
|
+
* assert.isTrue(isUint(4));
|
|
60
|
+
*
|
|
61
|
+
* assert.isFalse(isUint(-1));
|
|
62
|
+
*
|
|
63
|
+
* assert.isTrue(Uint.is(0));
|
|
59
64
|
* ```
|
|
60
65
|
*
|
|
61
66
|
* @param value The value to check.
|
|
@@ -77,7 +82,7 @@ const Uint = {
|
|
|
77
82
|
* ```ts
|
|
78
83
|
* const smallest = Uint.min(asUint(7), asUint(3));
|
|
79
84
|
*
|
|
80
|
-
* assert(smallest === 3);
|
|
85
|
+
* assert.isTrue(smallest === 3);
|
|
81
86
|
* ```
|
|
82
87
|
*
|
|
83
88
|
* @param a The first Uint.
|
|
@@ -93,7 +98,7 @@ const Uint = {
|
|
|
93
98
|
* ```ts
|
|
94
99
|
* const largest = Uint.max(asUint(7), asUint(3));
|
|
95
100
|
*
|
|
96
|
-
* assert(largest === 7);
|
|
101
|
+
* assert.isTrue(largest === 7);
|
|
97
102
|
* ```
|
|
98
103
|
*
|
|
99
104
|
* @param a The first Uint.
|
|
@@ -108,10 +113,12 @@ const Uint = {
|
|
|
108
113
|
*
|
|
109
114
|
* ```ts
|
|
110
115
|
* const clampedNegative = Uint.clamp(-5);
|
|
116
|
+
*
|
|
111
117
|
* const clampedPositive = Uint.clamp(42);
|
|
112
118
|
*
|
|
113
|
-
* assert(clampedNegative === 0);
|
|
114
|
-
*
|
|
119
|
+
* assert.isTrue(clampedNegative === 0);
|
|
120
|
+
*
|
|
121
|
+
* assert.isTrue(clampedPositive === 42);
|
|
115
122
|
* ```
|
|
116
123
|
*
|
|
117
124
|
* @param value The number to clamp.
|
|
@@ -125,11 +132,14 @@ const Uint = {
|
|
|
125
132
|
*
|
|
126
133
|
* ```ts
|
|
127
134
|
* const min = asUint(0);
|
|
135
|
+
*
|
|
128
136
|
* const max = asUint(3);
|
|
137
|
+
*
|
|
129
138
|
* const randomValue = Uint.random(min, max);
|
|
130
139
|
*
|
|
131
|
-
* assert.
|
|
132
|
-
*
|
|
140
|
+
* assert.isTrue(Uint.is(randomValue));
|
|
141
|
+
*
|
|
142
|
+
* assert.isTrue(randomValue >= 0 && randomValue <= 3);
|
|
133
143
|
* ```
|
|
134
144
|
*
|
|
135
145
|
* @returns A random non-negative integer as a Uint.
|
|
@@ -142,10 +152,12 @@ const Uint = {
|
|
|
142
152
|
*
|
|
143
153
|
* ```ts
|
|
144
154
|
* const base = asUint(2);
|
|
155
|
+
*
|
|
145
156
|
* const exponent = asUint(5);
|
|
157
|
+
*
|
|
146
158
|
* const power = Uint.pow(base, exponent);
|
|
147
159
|
*
|
|
148
|
-
* assert(power === 32);
|
|
160
|
+
* assert.isTrue(power === 32);
|
|
149
161
|
* ```
|
|
150
162
|
*
|
|
151
163
|
* @param a The base Uint.
|
|
@@ -161,7 +173,7 @@ const Uint = {
|
|
|
161
173
|
* ```ts
|
|
162
174
|
* const sum = Uint.add(asUint(5), asUint(8));
|
|
163
175
|
*
|
|
164
|
-
* assert(sum === 13);
|
|
176
|
+
* assert.isTrue(sum === 13);
|
|
165
177
|
* ```
|
|
166
178
|
*
|
|
167
179
|
* @param a The first Uint.
|
|
@@ -177,7 +189,7 @@ const Uint = {
|
|
|
177
189
|
* ```ts
|
|
178
190
|
* const difference = Uint.sub(asUint(5), asUint(8));
|
|
179
191
|
*
|
|
180
|
-
* assert(difference === 0);
|
|
192
|
+
* assert.isTrue(difference === 0);
|
|
181
193
|
* ```
|
|
182
194
|
*
|
|
183
195
|
* @param a The minuend Uint.
|
|
@@ -193,7 +205,7 @@ const Uint = {
|
|
|
193
205
|
* ```ts
|
|
194
206
|
* const product = Uint.mul(asUint(7), asUint(6));
|
|
195
207
|
*
|
|
196
|
-
* assert(product === 42);
|
|
208
|
+
* assert.isTrue(product === 42);
|
|
197
209
|
* ```
|
|
198
210
|
*
|
|
199
211
|
* @param a The first Uint.
|
|
@@ -209,7 +221,7 @@ const Uint = {
|
|
|
209
221
|
* ```ts
|
|
210
222
|
* const quotient = Uint.div(asUint(10), asUint(4));
|
|
211
223
|
*
|
|
212
|
-
* assert(quotient === 2);
|
|
224
|
+
* assert.isTrue(quotient === 2);
|
|
213
225
|
* ```
|
|
214
226
|
*
|
|
215
227
|
* @param a The dividend Uint.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uint.mjs","sources":["../../../src/number/branded-types/uint.mts"],"sourcesContent":[null],"names":[],"mappings":";;AAKA,MAAM,iBAAiB,GAAG,wBAAwB;AAElD,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
|
|
1
|
+
{"version":3,"file":"uint.mjs","sources":["../../../src/number/branded-types/uint.mts"],"sourcesContent":[null],"names":[],"mappings":";;AAKA,MAAM,iBAAiB,GAAG,wBAAwB;AAElD,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;;;;;;;;;;;;;;;AAeG;AACI,MAAM,MAAM,GAAG;AAEtB;;;;;;;;;;;;;;;;AAgBG;AACI,MAAM,MAAM,GAAG;AAEtB;;;;;;AAMG;AACI,MAAM,IAAI,GAAG;AAClB;;;;;;;;;;;;;;;;AAgBG;IACH,EAAE;AAEF;;;;AAIG;IACH,SAAS;AAET;;;;;;;;;;;;;;AAcG;AACH,IAAA,GAAG,EAAE,IAAI;AAET;;;;;;;;;;;;;;AAcG;AACH,IAAA,GAAG,EAAE,IAAI;AAET;;;;;;;;;;;;;;;;;AAiBG;IACH,KAAK;AAEL;;;;;;;;;;;;;;;;;;AAkBG;IACH,MAAM;AAEN;;;;;;;;;;;;;;;;;;AAkBG;IACH,GAAG;AAEH;;;;;;;;;;;;;;AAcG;IACH,GAAG;AAEH;;;;;;;;;;;;;;AAcG;IACH,GAAG;AAEH;;;;;;;;;;;;;;AAcG;IACH,GAAG;AAEH;;;;;;;;;;;;;;AAcG;IACH,GAAG;;;;;"}
|
package/dist/number/num.d.mts
CHANGED
|
@@ -24,7 +24,7 @@ export declare namespace Num {
|
|
|
24
24
|
*
|
|
25
25
|
* const result = Num.from(input);
|
|
26
26
|
*
|
|
27
|
-
* assert(result === 123.45);
|
|
27
|
+
* assert.isTrue(result === 123.45);
|
|
28
28
|
* ```
|
|
29
29
|
*
|
|
30
30
|
* @param n The value to convert.
|
|
@@ -47,10 +47,11 @@ export declare namespace Num {
|
|
|
47
47
|
* // Safe to divide now that we know value is non-zero
|
|
48
48
|
* // eslint-disable-next-line total-functions/no-partial-division
|
|
49
49
|
* const inverted = 1 / value;
|
|
50
|
-
*
|
|
50
|
+
*
|
|
51
|
+
* assert.isTrue(inverted === 0.2);
|
|
51
52
|
* }
|
|
52
53
|
*
|
|
53
|
-
* assert.
|
|
54
|
+
* assert.isFalse(Num.isNonZero(0));
|
|
54
55
|
* ```
|
|
55
56
|
*
|
|
56
57
|
* @template N - The numeric literal type or number type to check
|
|
@@ -73,10 +74,11 @@ export declare namespace Num {
|
|
|
73
74
|
*
|
|
74
75
|
* if (Num.isNonNegative(candidate)) {
|
|
75
76
|
* const index: number = candidate;
|
|
76
|
-
*
|
|
77
|
+
*
|
|
78
|
+
* assert.isTrue(index === 10);
|
|
77
79
|
* }
|
|
78
80
|
*
|
|
79
|
-
* assert.
|
|
81
|
+
* assert.isFalse(Num.isNonNegative(-1));
|
|
80
82
|
* ```
|
|
81
83
|
*
|
|
82
84
|
* @template N - The numeric literal type or number type to check
|
|
@@ -97,10 +99,10 @@ export declare namespace Num {
|
|
|
97
99
|
* const amount = 42;
|
|
98
100
|
*
|
|
99
101
|
* if (Num.isPositive(amount)) {
|
|
100
|
-
* assert.
|
|
102
|
+
* assert.isTrue(amount > 0);
|
|
101
103
|
* }
|
|
102
104
|
*
|
|
103
|
-
* assert.
|
|
105
|
+
* assert.isFalse(Num.isPositive(0));
|
|
104
106
|
* ```
|
|
105
107
|
*
|
|
106
108
|
* @template N - The numeric literal type or number type to check
|
|
@@ -117,8 +119,9 @@ export declare namespace Num {
|
|
|
117
119
|
* ```ts
|
|
118
120
|
* const isGrade = Num.isInRange(0, 100);
|
|
119
121
|
*
|
|
120
|
-
* assert.
|
|
121
|
-
*
|
|
122
|
+
* assert.isTrue(isGrade(50));
|
|
123
|
+
*
|
|
124
|
+
* assert.isFalse(isGrade(100));
|
|
122
125
|
* ```
|
|
123
126
|
*
|
|
124
127
|
* @param lowerBound The lower bound (inclusive).
|
|
@@ -136,8 +139,9 @@ export declare namespace Num {
|
|
|
136
139
|
* ```ts
|
|
137
140
|
* const isPercentage = Num.isInRangeInclusive(0, 100);
|
|
138
141
|
*
|
|
139
|
-
* assert.
|
|
140
|
-
*
|
|
142
|
+
* assert.isTrue(isPercentage(100));
|
|
143
|
+
*
|
|
144
|
+
* assert.isFalse(isPercentage(-1));
|
|
141
145
|
* ```
|
|
142
146
|
*
|
|
143
147
|
* @param lowerBound The lower bound (inclusive).
|
|
@@ -189,9 +193,11 @@ export declare namespace Num {
|
|
|
189
193
|
* ```ts
|
|
190
194
|
* const indexGuard = Num.isUintInRange(0, 5);
|
|
191
195
|
*
|
|
192
|
-
* assert.
|
|
193
|
-
*
|
|
194
|
-
* assert.
|
|
196
|
+
* assert.isTrue(indexGuard(3));
|
|
197
|
+
*
|
|
198
|
+
* assert.isFalse(indexGuard(5));
|
|
199
|
+
*
|
|
200
|
+
* assert.isFalse(indexGuard(-1));
|
|
195
201
|
* ```
|
|
196
202
|
*
|
|
197
203
|
* @template L - The lower bound as a SmallUint literal type
|
|
@@ -219,8 +225,9 @@ export declare namespace Num {
|
|
|
219
225
|
* ```ts
|
|
220
226
|
* const inclusiveGuard = Num.isUintInRangeInclusive(0, 5);
|
|
221
227
|
*
|
|
222
|
-
* assert.
|
|
223
|
-
*
|
|
228
|
+
* assert.isTrue(inclusiveGuard(5));
|
|
229
|
+
*
|
|
230
|
+
* assert.isFalse(inclusiveGuard(6));
|
|
224
231
|
* ```
|
|
225
232
|
*
|
|
226
233
|
* @template L - The lower bound as a SmallUint literal type
|
|
@@ -243,13 +250,15 @@ export declare namespace Num {
|
|
|
243
250
|
* @example
|
|
244
251
|
*
|
|
245
252
|
* ```ts
|
|
246
|
-
* assert(Num.clamp(150, 0, 100) === 100);
|
|
247
|
-
*
|
|
253
|
+
* assert.isTrue(Num.clamp(150, 0, 100) === 100);
|
|
254
|
+
*
|
|
255
|
+
* assert.isTrue(Num.clamp(-50, 0, 100) === 0);
|
|
248
256
|
*
|
|
249
257
|
* const clampToPercentage = Num.clamp(0, 100);
|
|
250
258
|
*
|
|
251
|
-
* assert(clampToPercentage(75) === 75);
|
|
252
|
-
*
|
|
259
|
+
* assert.isTrue(clampToPercentage(75) === 75);
|
|
260
|
+
*
|
|
261
|
+
* assert.isTrue(clampToPercentage(150) === 100);
|
|
253
262
|
* ```
|
|
254
263
|
*/
|
|
255
264
|
export function clamp(target: number, lowerBound: number, upperBound: number): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"num.d.mts","sourceRoot":"","sources":["../../src/number/num.mts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,yBAAiB,GAAG,CAAC;IACnB;;;;;;;;;;;;;;;OAeG;IACH,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,MAAe,CAAC;IAEnD
|
|
1
|
+
{"version":3,"file":"num.d.mts","sourceRoot":"","sources":["../../src/number/num.mts"],"names":[],"mappings":"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"}
|