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
|
@@ -10,20 +10,27 @@ describe('PositiveFiniteNumber test', () => {
|
|
|
10
10
|
describe(asPositiveFiniteNumber, () => {
|
|
11
11
|
test('accepts valid positive finite numbers', () => {
|
|
12
12
|
expect(() => asPositiveFiniteNumber(1)).not.toThrow();
|
|
13
|
+
|
|
13
14
|
expect(() => asPositiveFiniteNumber(3.14)).not.toThrow();
|
|
15
|
+
|
|
14
16
|
expect(() => asPositiveFiniteNumber(0.5)).not.toThrow();
|
|
17
|
+
|
|
15
18
|
expect(() => asPositiveFiniteNumber(Number.MIN_VALUE)).not.toThrow();
|
|
19
|
+
|
|
16
20
|
expect(() => asPositiveFiniteNumber(Number.MAX_VALUE)).not.toThrow();
|
|
17
21
|
});
|
|
18
22
|
|
|
19
23
|
test('rejects zero', () => {
|
|
20
24
|
expect(() => asPositiveFiniteNumber(0)).toThrow(TypeError);
|
|
25
|
+
|
|
21
26
|
expect(() => asPositiveFiniteNumber(-0)).toThrow(TypeError);
|
|
22
27
|
});
|
|
23
28
|
|
|
24
29
|
test('rejects negative numbers', () => {
|
|
25
30
|
expect(() => asPositiveFiniteNumber(-1)).toThrow(TypeError);
|
|
31
|
+
|
|
26
32
|
expect(() => asPositiveFiniteNumber(-0.1)).toThrow(TypeError);
|
|
33
|
+
|
|
27
34
|
expect(() => asPositiveFiniteNumber(-Number.MAX_VALUE)).toThrow(
|
|
28
35
|
TypeError,
|
|
29
36
|
);
|
|
@@ -31,9 +38,11 @@ describe('PositiveFiniteNumber test', () => {
|
|
|
31
38
|
|
|
32
39
|
test('rejects non-finite numbers', () => {
|
|
33
40
|
expect(() => asPositiveFiniteNumber(Number.NaN)).toThrow(TypeError);
|
|
41
|
+
|
|
34
42
|
expect(() => asPositiveFiniteNumber(Number.POSITIVE_INFINITY)).toThrow(
|
|
35
43
|
TypeError,
|
|
36
44
|
);
|
|
45
|
+
|
|
37
46
|
expect(() => asPositiveFiniteNumber(Number.NEGATIVE_INFINITY)).toThrow(
|
|
38
47
|
TypeError,
|
|
39
48
|
);
|
|
@@ -41,7 +50,9 @@ describe('PositiveFiniteNumber test', () => {
|
|
|
41
50
|
|
|
42
51
|
test('returns the same value for valid inputs', () => {
|
|
43
52
|
expect(asPositiveFiniteNumber(5.5)).toBe(5.5);
|
|
53
|
+
|
|
44
54
|
expect(asPositiveFiniteNumber(1)).toBe(1);
|
|
55
|
+
|
|
45
56
|
expect(asPositiveFiniteNumber(10)).toBe(10);
|
|
46
57
|
});
|
|
47
58
|
|
|
@@ -62,35 +73,46 @@ describe('PositiveFiniteNumber test', () => {
|
|
|
62
73
|
|
|
63
74
|
describe(isPositiveFiniteNumber, () => {
|
|
64
75
|
test('correctly identifies positive finite numbers', () => {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
76
|
+
assert.isTrue(isPositiveFiniteNumber(1));
|
|
77
|
+
|
|
78
|
+
assert.isTrue(isPositiveFiniteNumber(3.14));
|
|
79
|
+
|
|
80
|
+
assert.isTrue(isPositiveFiniteNumber(0.5));
|
|
81
|
+
|
|
82
|
+
assert.isTrue(isPositiveFiniteNumber(Number.MIN_VALUE));
|
|
83
|
+
|
|
84
|
+
assert.isTrue(isPositiveFiniteNumber(Number.MAX_VALUE));
|
|
70
85
|
});
|
|
71
86
|
|
|
72
87
|
test('correctly identifies zero', () => {
|
|
73
|
-
|
|
74
|
-
|
|
88
|
+
assert.isFalse(isPositiveFiniteNumber(0));
|
|
89
|
+
|
|
90
|
+
assert.isFalse(isPositiveFiniteNumber(-0));
|
|
75
91
|
});
|
|
76
92
|
|
|
77
93
|
test('correctly identifies negative numbers', () => {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
94
|
+
assert.isFalse(isPositiveFiniteNumber(-1));
|
|
95
|
+
|
|
96
|
+
assert.isFalse(isPositiveFiniteNumber(-0.1));
|
|
97
|
+
|
|
98
|
+
assert.isFalse(isPositiveFiniteNumber(-Number.MAX_VALUE));
|
|
81
99
|
});
|
|
82
100
|
|
|
83
101
|
test('correctly identifies non-finite numbers', () => {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
102
|
+
assert.isFalse(isPositiveFiniteNumber(Number.NaN));
|
|
103
|
+
|
|
104
|
+
assert.isFalse(isPositiveFiniteNumber(Number.POSITIVE_INFINITY));
|
|
105
|
+
|
|
106
|
+
assert.isFalse(isPositiveFiniteNumber(Number.NEGATIVE_INFINITY));
|
|
87
107
|
});
|
|
88
108
|
});
|
|
89
109
|
|
|
90
110
|
describe('PositiveFiniteNumber.is', () => {
|
|
91
111
|
test('same as isPositiveFiniteNumber function', () => {
|
|
92
112
|
expect(PositiveFiniteNumber.is(5)).toBe(isPositiveFiniteNumber(5));
|
|
113
|
+
|
|
93
114
|
expect(PositiveFiniteNumber.is(0)).toBe(isPositiveFiniteNumber(0));
|
|
115
|
+
|
|
94
116
|
expect(PositiveFiniteNumber.is(-1)).toBe(isPositiveFiniteNumber(-1));
|
|
95
117
|
});
|
|
96
118
|
});
|
|
@@ -103,32 +125,45 @@ describe('PositiveFiniteNumber test', () => {
|
|
|
103
125
|
|
|
104
126
|
describe('mathematical operations', () => {
|
|
105
127
|
const a = asPositiveFiniteNumber(5.5);
|
|
128
|
+
|
|
106
129
|
const b = asPositiveFiniteNumber(2.5);
|
|
130
|
+
|
|
107
131
|
const c = asPositiveFiniteNumber(0.5);
|
|
108
132
|
|
|
109
133
|
test('min and max', () => {
|
|
110
134
|
expect(PositiveFiniteNumber.min(a, b)).toBe(2.5);
|
|
135
|
+
|
|
111
136
|
expect(PositiveFiniteNumber.max(a, b)).toBe(5.5);
|
|
137
|
+
|
|
112
138
|
expect(PositiveFiniteNumber.min(a, c)).toBe(0.5);
|
|
139
|
+
|
|
113
140
|
expect(PositiveFiniteNumber.max(a, c)).toBe(5.5);
|
|
114
141
|
});
|
|
115
142
|
|
|
116
143
|
test('floor, ceil, round', () => {
|
|
117
144
|
expect(PositiveFiniteNumber.floor(a)).toBe(5);
|
|
145
|
+
|
|
118
146
|
expect(PositiveFiniteNumber.ceil(a)).toBe(6);
|
|
147
|
+
|
|
119
148
|
expect(PositiveFiniteNumber.round(a)).toBe(6);
|
|
149
|
+
|
|
120
150
|
expect(PositiveFiniteNumber.floor(b)).toBe(2);
|
|
151
|
+
|
|
121
152
|
expect(PositiveFiniteNumber.ceil(b)).toBe(3);
|
|
153
|
+
|
|
122
154
|
expect(PositiveFiniteNumber.round(b)).toBe(3);
|
|
123
155
|
|
|
124
156
|
// Test edge case with values less than 1
|
|
125
157
|
expect(PositiveFiniteNumber.floor(c)).toBe(0);
|
|
158
|
+
|
|
126
159
|
expect(PositiveFiniteNumber.ceil(c)).toBe(1);
|
|
160
|
+
|
|
127
161
|
expect(PositiveFiniteNumber.round(c)).toBe(1);
|
|
128
162
|
});
|
|
129
163
|
|
|
130
164
|
test('add (always greater than 0)', () => {
|
|
131
165
|
expect(PositiveFiniteNumber.add(a, b)).toBe(8);
|
|
166
|
+
|
|
132
167
|
expect(PositiveFiniteNumber.add(a, c)).toBe(6);
|
|
133
168
|
});
|
|
134
169
|
|
|
@@ -144,11 +179,13 @@ describe('PositiveFiniteNumber test', () => {
|
|
|
144
179
|
|
|
145
180
|
test('mul (always greater than 0)', () => {
|
|
146
181
|
expect(PositiveFiniteNumber.mul(a, b)).toBe(13.75);
|
|
182
|
+
|
|
147
183
|
expect(PositiveFiniteNumber.mul(a, c)).toBe(2.75);
|
|
148
184
|
});
|
|
149
185
|
|
|
150
186
|
test('div (always greater than 0)', () => {
|
|
151
187
|
expect(PositiveFiniteNumber.div(a, b)).toBe(2.2);
|
|
188
|
+
|
|
152
189
|
expect(PositiveFiniteNumber.div(a, asPositiveFiniteNumber(2))).toBe(2.75);
|
|
153
190
|
});
|
|
154
191
|
|
|
@@ -159,6 +196,7 @@ describe('PositiveFiniteNumber test', () => {
|
|
|
159
196
|
asPositiveFiniteNumber(3),
|
|
160
197
|
),
|
|
161
198
|
).toBe(8);
|
|
199
|
+
|
|
162
200
|
expect(
|
|
163
201
|
PositiveFiniteNumber.pow(
|
|
164
202
|
asPositiveFiniteNumber(3),
|
|
@@ -171,27 +209,34 @@ describe('PositiveFiniteNumber test', () => {
|
|
|
171
209
|
describe('random', () => {
|
|
172
210
|
test('generates positive numbers within specified range', () => {
|
|
173
211
|
const min = asPositiveFiniteNumber(1.5);
|
|
212
|
+
|
|
174
213
|
const max = asPositiveFiniteNumber(10.3);
|
|
175
214
|
|
|
176
215
|
for (const _ of range(10)) {
|
|
177
216
|
const result = PositiveFiniteNumber.random(min, max);
|
|
178
217
|
|
|
179
218
|
expect(result).toBeGreaterThanOrEqual(min);
|
|
219
|
+
|
|
180
220
|
expect(result).toBeLessThanOrEqual(max);
|
|
181
|
-
|
|
221
|
+
|
|
222
|
+
assert.isTrue(PositiveFiniteNumber.is(result));
|
|
223
|
+
|
|
182
224
|
expect(result).toBeGreaterThan(0);
|
|
183
225
|
}
|
|
184
226
|
});
|
|
185
227
|
|
|
186
228
|
test('generates numbers starting from MIN_VALUE', () => {
|
|
187
229
|
const min = asPositiveFiniteNumber(Number.MIN_VALUE);
|
|
230
|
+
|
|
188
231
|
const max = asPositiveFiniteNumber(1);
|
|
189
232
|
|
|
190
233
|
for (const _ of range(10)) {
|
|
191
234
|
const result = PositiveFiniteNumber.random(min, max);
|
|
192
235
|
|
|
193
236
|
expect(result).toBeGreaterThanOrEqual(Number.MIN_VALUE);
|
|
237
|
+
|
|
194
238
|
expect(result).toBeLessThanOrEqual(1);
|
|
239
|
+
|
|
195
240
|
expect(result).toBeGreaterThan(0);
|
|
196
241
|
}
|
|
197
242
|
});
|
|
@@ -38,9 +38,11 @@ const {
|
|
|
38
38
|
* @example
|
|
39
39
|
*
|
|
40
40
|
* ```ts
|
|
41
|
-
* assert.
|
|
42
|
-
*
|
|
43
|
-
* assert.
|
|
41
|
+
* assert.isTrue(isPositiveInt(5));
|
|
42
|
+
*
|
|
43
|
+
* assert.isFalse(isPositiveInt(0));
|
|
44
|
+
*
|
|
45
|
+
* assert.isTrue(PositiveInt.is(10));
|
|
44
46
|
* ```
|
|
45
47
|
*
|
|
46
48
|
* @param value - The value to check
|
|
@@ -60,8 +62,9 @@ export const isPositiveInt = is;
|
|
|
60
62
|
* ```ts
|
|
61
63
|
* const branded = asPositiveInt(7);
|
|
62
64
|
*
|
|
63
|
-
* assert(branded === 7);
|
|
64
|
-
*
|
|
65
|
+
* assert.isTrue(branded === 7);
|
|
66
|
+
*
|
|
67
|
+
* assert.isTrue(PositiveInt.is(branded));
|
|
65
68
|
* ```
|
|
66
69
|
*
|
|
67
70
|
* @param value - The value to cast
|
|
@@ -93,9 +96,11 @@ export const PositiveInt = {
|
|
|
93
96
|
* @example
|
|
94
97
|
*
|
|
95
98
|
* ```ts
|
|
96
|
-
* assert.
|
|
97
|
-
*
|
|
98
|
-
* assert.
|
|
99
|
+
* assert.isTrue(isPositiveInt(5));
|
|
100
|
+
*
|
|
101
|
+
* assert.isFalse(isPositiveInt(0));
|
|
102
|
+
*
|
|
103
|
+
* assert.isTrue(PositiveInt.is(10));
|
|
99
104
|
* ```
|
|
100
105
|
*
|
|
101
106
|
* @param value - The value to check
|
|
@@ -126,7 +131,7 @@ export const PositiveInt = {
|
|
|
126
131
|
* asPositiveInt(12),
|
|
127
132
|
* );
|
|
128
133
|
*
|
|
129
|
-
* assert(smallest === 3);
|
|
134
|
+
* assert.isTrue(smallest === 3);
|
|
130
135
|
* ```
|
|
131
136
|
*
|
|
132
137
|
* @param values - The positive integers to compare (at least one required)
|
|
@@ -146,7 +151,7 @@ export const PositiveInt = {
|
|
|
146
151
|
* asPositiveInt(12),
|
|
147
152
|
* );
|
|
148
153
|
*
|
|
149
|
-
* assert(largest === 12);
|
|
154
|
+
* assert.isTrue(largest === 12);
|
|
150
155
|
* ```
|
|
151
156
|
*
|
|
152
157
|
* @param values - The positive integers to compare (at least one required)
|
|
@@ -164,10 +169,12 @@ export const PositiveInt = {
|
|
|
164
169
|
*
|
|
165
170
|
* ```ts
|
|
166
171
|
* const belowRange = PositiveInt.clamp(0);
|
|
172
|
+
*
|
|
167
173
|
* const withinRange = PositiveInt.clamp(10);
|
|
168
174
|
*
|
|
169
|
-
* assert(belowRange === 1);
|
|
170
|
-
*
|
|
175
|
+
* assert.isTrue(belowRange === 1);
|
|
176
|
+
*
|
|
177
|
+
* assert.isTrue(withinRange === 10);
|
|
171
178
|
* ```
|
|
172
179
|
*
|
|
173
180
|
* @param value - The number to clamp
|
|
@@ -185,11 +192,14 @@ export const PositiveInt = {
|
|
|
185
192
|
*
|
|
186
193
|
* ```ts
|
|
187
194
|
* const min = asPositiveInt(3);
|
|
195
|
+
*
|
|
188
196
|
* const max = asPositiveInt(6);
|
|
197
|
+
*
|
|
189
198
|
* const randomValue = PositiveInt.random(min, max);
|
|
190
199
|
*
|
|
191
|
-
* assert.
|
|
192
|
-
*
|
|
200
|
+
* assert.isTrue(PositiveInt.is(randomValue));
|
|
201
|
+
*
|
|
202
|
+
* assert.isTrue(randomValue >= 3 && randomValue <= 6);
|
|
193
203
|
* ```
|
|
194
204
|
*
|
|
195
205
|
* @param min - The minimum value (inclusive, must be >= 1)
|
|
@@ -206,10 +216,12 @@ export const PositiveInt = {
|
|
|
206
216
|
*
|
|
207
217
|
* ```ts
|
|
208
218
|
* const base = asPositiveInt(2);
|
|
219
|
+
*
|
|
209
220
|
* const exponent = asPositiveInt(4);
|
|
221
|
+
*
|
|
210
222
|
* const power = PositiveInt.pow(base, exponent);
|
|
211
223
|
*
|
|
212
|
-
* assert(power === 16);
|
|
224
|
+
* assert.isTrue(power === 16);
|
|
213
225
|
* ```
|
|
214
226
|
*
|
|
215
227
|
* @param a - The base positive integer
|
|
@@ -226,7 +238,7 @@ export const PositiveInt = {
|
|
|
226
238
|
* ```ts
|
|
227
239
|
* const sum = PositiveInt.add(asPositiveInt(4), asPositiveInt(5));
|
|
228
240
|
*
|
|
229
|
-
* assert(sum === 9);
|
|
241
|
+
* assert.isTrue(sum === 9);
|
|
230
242
|
* ```
|
|
231
243
|
*
|
|
232
244
|
* @param a - First positive integer
|
|
@@ -246,7 +258,7 @@ export const PositiveInt = {
|
|
|
246
258
|
* ```ts
|
|
247
259
|
* const difference = PositiveInt.sub(asPositiveInt(5), asPositiveInt(7));
|
|
248
260
|
*
|
|
249
|
-
* assert(difference === 1);
|
|
261
|
+
* assert.isTrue(difference === 1);
|
|
250
262
|
* ```
|
|
251
263
|
*
|
|
252
264
|
* @param a - The minuend (positive integer)
|
|
@@ -263,7 +275,7 @@ export const PositiveInt = {
|
|
|
263
275
|
* ```ts
|
|
264
276
|
* const product = PositiveInt.mul(asPositiveInt(3), asPositiveInt(7));
|
|
265
277
|
*
|
|
266
|
-
* assert(product === 21);
|
|
278
|
+
* assert.isTrue(product === 21);
|
|
267
279
|
* ```
|
|
268
280
|
*
|
|
269
281
|
* @param a - First positive integer
|
|
@@ -284,10 +296,12 @@ export const PositiveInt = {
|
|
|
284
296
|
*
|
|
285
297
|
* ```ts
|
|
286
298
|
* const quotient = PositiveInt.div(asPositiveInt(9), asPositiveInt(2));
|
|
299
|
+
*
|
|
287
300
|
* const clamped = PositiveInt.div(asPositiveInt(3), asPositiveInt(10));
|
|
288
301
|
*
|
|
289
|
-
* assert(quotient === 4);
|
|
290
|
-
*
|
|
302
|
+
* assert.isTrue(quotient === 4);
|
|
303
|
+
*
|
|
304
|
+
* assert.isTrue(clamped === 1);
|
|
291
305
|
* ```
|
|
292
306
|
*
|
|
293
307
|
* @param a - The dividend (positive integer)
|
|
@@ -6,34 +6,47 @@ describe('PositiveInt test', () => {
|
|
|
6
6
|
describe(asPositiveInt, () => {
|
|
7
7
|
test('accepts valid positive integers', () => {
|
|
8
8
|
expect(() => asPositiveInt(1)).not.toThrow();
|
|
9
|
+
|
|
9
10
|
expect(() => asPositiveInt(2)).not.toThrow();
|
|
11
|
+
|
|
10
12
|
expect(() => asPositiveInt(42)).not.toThrow();
|
|
13
|
+
|
|
11
14
|
expect(() => asPositiveInt(100)).not.toThrow();
|
|
15
|
+
|
|
12
16
|
expect(() => asPositiveInt(Number.MAX_SAFE_INTEGER)).not.toThrow();
|
|
13
17
|
});
|
|
14
18
|
|
|
15
19
|
test('rejects zero', () => {
|
|
16
20
|
expect(() => asPositiveInt(0)).toThrow(TypeError);
|
|
21
|
+
|
|
17
22
|
expect(() => asPositiveInt(-0)).toThrow(TypeError);
|
|
18
23
|
});
|
|
19
24
|
|
|
20
25
|
test('rejects negative integers', () => {
|
|
21
26
|
expect(() => asPositiveInt(-1)).toThrow(TypeError);
|
|
27
|
+
|
|
22
28
|
expect(() => asPositiveInt(-42)).toThrow(TypeError);
|
|
29
|
+
|
|
23
30
|
expect(() => asPositiveInt(Number.MIN_SAFE_INTEGER)).toThrow(TypeError);
|
|
24
31
|
});
|
|
25
32
|
|
|
26
33
|
test('rejects non-integers', () => {
|
|
27
34
|
expect(() => asPositiveInt(Number.NaN)).toThrow(TypeError);
|
|
35
|
+
|
|
28
36
|
expect(() => asPositiveInt(Number.POSITIVE_INFINITY)).toThrow(TypeError);
|
|
37
|
+
|
|
29
38
|
expect(() => asPositiveInt(Number.NEGATIVE_INFINITY)).toThrow(TypeError);
|
|
39
|
+
|
|
30
40
|
expect(() => asPositiveInt(1.2)).toThrow(TypeError);
|
|
41
|
+
|
|
31
42
|
expect(() => asPositiveInt(-3.4)).toThrow(TypeError);
|
|
32
43
|
});
|
|
33
44
|
|
|
34
45
|
test('returns the same value for valid inputs', () => {
|
|
35
46
|
expect(asPositiveInt(5)).toBe(5);
|
|
47
|
+
|
|
36
48
|
expect(asPositiveInt(1)).toBe(1);
|
|
49
|
+
|
|
37
50
|
expect(asPositiveInt(10)).toBe(10);
|
|
38
51
|
});
|
|
39
52
|
|
|
@@ -57,37 +70,50 @@ describe('PositiveInt test', () => {
|
|
|
57
70
|
|
|
58
71
|
describe(isPositiveInt, () => {
|
|
59
72
|
test('correctly identifies positive integers', () => {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
73
|
+
assert.isTrue(isPositiveInt(1));
|
|
74
|
+
|
|
75
|
+
assert.isTrue(isPositiveInt(2));
|
|
76
|
+
|
|
77
|
+
assert.isTrue(isPositiveInt(42));
|
|
78
|
+
|
|
79
|
+
assert.isTrue(isPositiveInt(100));
|
|
80
|
+
|
|
81
|
+
assert.isTrue(isPositiveInt(Number.MAX_SAFE_INTEGER));
|
|
65
82
|
});
|
|
66
83
|
|
|
67
84
|
test('correctly identifies zero', () => {
|
|
68
|
-
|
|
69
|
-
|
|
85
|
+
assert.isFalse(isPositiveInt(0));
|
|
86
|
+
|
|
87
|
+
assert.isFalse(isPositiveInt(-0));
|
|
70
88
|
});
|
|
71
89
|
|
|
72
90
|
test('correctly identifies negative integers', () => {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
91
|
+
assert.isFalse(isPositiveInt(-1));
|
|
92
|
+
|
|
93
|
+
assert.isFalse(isPositiveInt(-42));
|
|
94
|
+
|
|
95
|
+
assert.isFalse(isPositiveInt(Number.MIN_SAFE_INTEGER));
|
|
76
96
|
});
|
|
77
97
|
|
|
78
98
|
test('correctly identifies non-integers', () => {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
99
|
+
assert.isFalse(isPositiveInt(Number.NaN));
|
|
100
|
+
|
|
101
|
+
assert.isFalse(isPositiveInt(Number.POSITIVE_INFINITY));
|
|
102
|
+
|
|
103
|
+
assert.isFalse(isPositiveInt(Number.NEGATIVE_INFINITY));
|
|
104
|
+
|
|
105
|
+
assert.isFalse(isPositiveInt(1.2));
|
|
106
|
+
|
|
107
|
+
assert.isFalse(isPositiveInt(-3.4));
|
|
84
108
|
});
|
|
85
109
|
});
|
|
86
110
|
|
|
87
111
|
describe('PositiveInt.is', () => {
|
|
88
112
|
test('same as isPositiveInt function', () => {
|
|
89
113
|
expect(PositiveInt.is(5)).toBe(isPositiveInt(5));
|
|
114
|
+
|
|
90
115
|
expect(PositiveInt.is(0)).toBe(isPositiveInt(0));
|
|
116
|
+
|
|
91
117
|
expect(PositiveInt.is(-10)).toBe(isPositiveInt(-10));
|
|
92
118
|
});
|
|
93
119
|
});
|
|
@@ -100,41 +126,54 @@ describe('PositiveInt test', () => {
|
|
|
100
126
|
|
|
101
127
|
describe('mathematical operations', () => {
|
|
102
128
|
const a = asPositiveInt(5);
|
|
129
|
+
|
|
103
130
|
const b = asPositiveInt(2);
|
|
131
|
+
|
|
104
132
|
const c = asPositiveInt(1);
|
|
105
133
|
|
|
106
134
|
test('min and max', () => {
|
|
107
135
|
expect(PositiveInt.min(a, b)).toBe(2);
|
|
136
|
+
|
|
108
137
|
expect(PositiveInt.max(a, b)).toBe(5);
|
|
138
|
+
|
|
109
139
|
expect(PositiveInt.min(a, c)).toBe(1);
|
|
140
|
+
|
|
110
141
|
expect(PositiveInt.max(a, c)).toBe(5);
|
|
111
142
|
});
|
|
112
143
|
|
|
113
144
|
test('add (never goes below 1)', () => {
|
|
114
145
|
expect(PositiveInt.add(a, b)).toBe(7);
|
|
146
|
+
|
|
115
147
|
expect(PositiveInt.add(a, c)).toBe(6);
|
|
116
148
|
});
|
|
117
149
|
|
|
118
150
|
test('sub (never goes below 1)', () => {
|
|
119
151
|
expect(PositiveInt.sub(a, b)).toBe(3);
|
|
152
|
+
|
|
120
153
|
expect(PositiveInt.sub(b, a)).toBe(1); // clamped to 1
|
|
154
|
+
|
|
121
155
|
expect(PositiveInt.sub(c, a)).toBe(1); // clamped to 1
|
|
122
156
|
});
|
|
123
157
|
|
|
124
158
|
test('mul (never goes below 1)', () => {
|
|
125
159
|
expect(PositiveInt.mul(a, b)).toBe(10);
|
|
160
|
+
|
|
126
161
|
expect(PositiveInt.mul(a, c)).toBe(5);
|
|
127
162
|
});
|
|
128
163
|
|
|
129
164
|
test('div (floor division, never goes below 1)', () => {
|
|
130
165
|
expect(PositiveInt.div(a, b)).toBe(2);
|
|
166
|
+
|
|
131
167
|
expect(PositiveInt.div(asPositiveInt(7), asPositiveInt(3))).toBe(2);
|
|
168
|
+
|
|
132
169
|
expect(PositiveInt.div(b, a)).toBe(1); // floor(2/5) = 0, but clamped to 1
|
|
133
170
|
});
|
|
134
171
|
|
|
135
172
|
test('pow (never goes below 1)', () => {
|
|
136
173
|
expect(PositiveInt.pow(asPositiveInt(2), asPositiveInt(3))).toBe(8);
|
|
174
|
+
|
|
137
175
|
expect(PositiveInt.pow(asPositiveInt(3), asPositiveInt(2))).toBe(9);
|
|
176
|
+
|
|
138
177
|
expect(PositiveInt.pow(asPositiveInt(5), asPositiveInt(1))).toBe(5);
|
|
139
178
|
});
|
|
140
179
|
});
|
|
@@ -142,28 +181,36 @@ describe('PositiveInt test', () => {
|
|
|
142
181
|
describe('random', () => {
|
|
143
182
|
test('generates positive integers within specified range', () => {
|
|
144
183
|
const min = 1;
|
|
184
|
+
|
|
145
185
|
const max = 10;
|
|
146
186
|
|
|
147
187
|
for (const _ of range(10)) {
|
|
148
188
|
const result = PositiveInt.random(min, max);
|
|
149
189
|
|
|
150
190
|
expect(result).toBeGreaterThanOrEqual(min);
|
|
191
|
+
|
|
151
192
|
expect(result).toBeLessThanOrEqual(max);
|
|
152
|
-
|
|
153
|
-
|
|
193
|
+
|
|
194
|
+
assert.isTrue(PositiveInt.is(result));
|
|
195
|
+
|
|
196
|
+
assert.isTrue(Number.isInteger(result));
|
|
197
|
+
|
|
154
198
|
expect(result).toBeGreaterThan(0);
|
|
155
199
|
}
|
|
156
200
|
});
|
|
157
201
|
|
|
158
202
|
test('generates integers starting from 1', () => {
|
|
159
203
|
const min = 1;
|
|
204
|
+
|
|
160
205
|
const max = 5;
|
|
161
206
|
|
|
162
207
|
for (const _ of range(10)) {
|
|
163
208
|
const result = PositiveInt.random(min, max);
|
|
164
209
|
|
|
165
210
|
expect(result).toBeGreaterThanOrEqual(1);
|
|
211
|
+
|
|
166
212
|
expect(result).toBeLessThanOrEqual(5);
|
|
213
|
+
|
|
167
214
|
expect(result).toBeGreaterThan(0);
|
|
168
215
|
}
|
|
169
216
|
});
|