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
|
@@ -7,23 +7,33 @@ describe('FiniteNumber test', () => {
|
|
|
7
7
|
describe(asFiniteNumber, () => {
|
|
8
8
|
test('accepts valid finite numbers', () => {
|
|
9
9
|
expect(() => asFiniteNumber(0)).not.toThrow();
|
|
10
|
+
|
|
10
11
|
expect(() => asFiniteNumber(1)).not.toThrow();
|
|
12
|
+
|
|
11
13
|
expect(() => asFiniteNumber(-1)).not.toThrow();
|
|
14
|
+
|
|
12
15
|
expect(() => asFiniteNumber(3.14)).not.toThrow();
|
|
16
|
+
|
|
13
17
|
expect(() => asFiniteNumber(-2.5)).not.toThrow();
|
|
18
|
+
|
|
14
19
|
expect(() => asFiniteNumber(Number.MAX_VALUE)).not.toThrow();
|
|
20
|
+
|
|
15
21
|
expect(() => asFiniteNumber(-Number.MAX_VALUE)).not.toThrow();
|
|
16
22
|
});
|
|
17
23
|
|
|
18
24
|
test('rejects non-finite numbers', () => {
|
|
19
25
|
expect(() => asFiniteNumber(Number.NaN)).toThrow(TypeError);
|
|
26
|
+
|
|
20
27
|
expect(() => asFiniteNumber(Number.POSITIVE_INFINITY)).toThrow(TypeError);
|
|
28
|
+
|
|
21
29
|
expect(() => asFiniteNumber(Number.NEGATIVE_INFINITY)).toThrow(TypeError);
|
|
22
30
|
});
|
|
23
31
|
|
|
24
32
|
test('returns the same value for valid inputs', () => {
|
|
25
33
|
expect(asFiniteNumber(5.5)).toBe(5.5);
|
|
34
|
+
|
|
26
35
|
expect(asFiniteNumber(-10)).toBe(-10);
|
|
36
|
+
|
|
27
37
|
expect(asFiniteNumber(0)).toBe(0);
|
|
28
38
|
});
|
|
29
39
|
|
|
@@ -43,71 +53,98 @@ describe('FiniteNumber test', () => {
|
|
|
43
53
|
|
|
44
54
|
describe('FiniteNumber.is', () => {
|
|
45
55
|
test('correctly identifies finite numbers', () => {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
56
|
+
assert.isTrue(FiniteNumber.is(0));
|
|
57
|
+
|
|
58
|
+
assert.isTrue(FiniteNumber.is(1));
|
|
59
|
+
|
|
60
|
+
assert.isTrue(FiniteNumber.is(-1));
|
|
61
|
+
|
|
62
|
+
assert.isTrue(FiniteNumber.is(3.14));
|
|
63
|
+
|
|
64
|
+
assert.isTrue(FiniteNumber.is(-2.5));
|
|
65
|
+
|
|
66
|
+
assert.isTrue(FiniteNumber.is(-Number.MAX_VALUE));
|
|
67
|
+
|
|
68
|
+
assert.isTrue(FiniteNumber.is(Number.MAX_VALUE));
|
|
69
|
+
|
|
70
|
+
expectType<FiniteNumber, typeof Number.MAX_VALUE>('=');
|
|
53
71
|
});
|
|
54
72
|
|
|
55
73
|
test('correctly identifies non-finite numbers', () => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
74
|
+
assert.isFalse(FiniteNumber.is(Number.NaN));
|
|
75
|
+
|
|
76
|
+
assert.isFalse(FiniteNumber.is(Number.POSITIVE_INFINITY));
|
|
77
|
+
|
|
78
|
+
assert.isFalse(FiniteNumber.is(Number.NEGATIVE_INFINITY));
|
|
59
79
|
});
|
|
60
80
|
});
|
|
61
81
|
|
|
62
82
|
describe('mathematical operations', () => {
|
|
63
83
|
const a = asFiniteNumber(5.5);
|
|
84
|
+
|
|
64
85
|
const b = asFiniteNumber(2.5);
|
|
86
|
+
|
|
65
87
|
const c = asFiniteNumber(-3.5);
|
|
66
88
|
|
|
67
89
|
test('abs', () => {
|
|
68
90
|
expect(FiniteNumber.abs(a)).toBe(5.5);
|
|
91
|
+
|
|
69
92
|
expect(FiniteNumber.abs(c)).toBe(3.5);
|
|
93
|
+
|
|
70
94
|
expect(FiniteNumber.abs(asFiniteNumber(0))).toBe(0);
|
|
71
95
|
});
|
|
72
96
|
|
|
73
97
|
test('min and max', () => {
|
|
74
98
|
expect(FiniteNumber.min(a, b)).toBe(2.5);
|
|
99
|
+
|
|
75
100
|
expect(FiniteNumber.max(a, b)).toBe(5.5);
|
|
101
|
+
|
|
76
102
|
expect(FiniteNumber.min(a, c)).toBe(-3.5);
|
|
103
|
+
|
|
77
104
|
expect(FiniteNumber.max(a, c)).toBe(5.5);
|
|
78
105
|
});
|
|
79
106
|
|
|
80
107
|
test('floor, ceil, round', () => {
|
|
81
108
|
expect(FiniteNumber.floor(a)).toBe(5);
|
|
109
|
+
|
|
82
110
|
expect(FiniteNumber.ceil(a)).toBe(6);
|
|
111
|
+
|
|
83
112
|
expect(FiniteNumber.round(a)).toBe(6);
|
|
113
|
+
|
|
84
114
|
expect(FiniteNumber.floor(c)).toBe(-4);
|
|
115
|
+
|
|
85
116
|
expect(FiniteNumber.ceil(c)).toBe(-3);
|
|
117
|
+
|
|
86
118
|
expect(FiniteNumber.round(c)).toBe(-3);
|
|
87
119
|
});
|
|
88
120
|
|
|
89
121
|
test('add', () => {
|
|
90
122
|
expect(FiniteNumber.add(a, b)).toBe(8);
|
|
123
|
+
|
|
91
124
|
expect(FiniteNumber.add(a, c)).toBe(2);
|
|
92
125
|
});
|
|
93
126
|
|
|
94
127
|
test('sub', () => {
|
|
95
128
|
expect(FiniteNumber.sub(a, b)).toBe(3);
|
|
129
|
+
|
|
96
130
|
expect(FiniteNumber.sub(a, c)).toBe(9);
|
|
97
131
|
});
|
|
98
132
|
|
|
99
133
|
test('mul', () => {
|
|
100
134
|
expect(FiniteNumber.mul(a, b)).toBe(13.75);
|
|
135
|
+
|
|
101
136
|
expect(FiniteNumber.mul(a, c)).toBe(-19.25);
|
|
102
137
|
});
|
|
103
138
|
|
|
104
139
|
test('div', () => {
|
|
105
140
|
expect(FiniteNumber.div(a, asNonZeroFiniteNumber(2.5))).toBe(2.2);
|
|
141
|
+
|
|
106
142
|
expect(FiniteNumber.div(a, asNonZeroFiniteNumber(2))).toBe(2.75);
|
|
107
143
|
});
|
|
108
144
|
|
|
109
145
|
test('pow', () => {
|
|
110
146
|
expect(FiniteNumber.pow(asFiniteNumber(2), asFiniteNumber(3))).toBe(8);
|
|
147
|
+
|
|
111
148
|
expect(FiniteNumber.pow(asFiniteNumber(3), asFiniteNumber(2))).toBe(9);
|
|
112
149
|
});
|
|
113
150
|
});
|
|
@@ -115,14 +152,17 @@ describe('FiniteNumber test', () => {
|
|
|
115
152
|
describe('random', () => {
|
|
116
153
|
test('generates numbers within specified range', () => {
|
|
117
154
|
const min = asFiniteNumber(-5.5);
|
|
155
|
+
|
|
118
156
|
const max = asFiniteNumber(10.3);
|
|
119
157
|
|
|
120
158
|
for (const _ of range(10)) {
|
|
121
159
|
const result = FiniteNumber.random(min, max);
|
|
122
160
|
|
|
123
161
|
expect(result).toBeGreaterThanOrEqual(min);
|
|
162
|
+
|
|
124
163
|
expect(result).toBeLessThanOrEqual(max);
|
|
125
|
-
|
|
164
|
+
|
|
165
|
+
assert.isTrue(FiniteNumber.is(result));
|
|
126
166
|
}
|
|
127
167
|
});
|
|
128
168
|
});
|
|
@@ -38,9 +38,11 @@ const {
|
|
|
38
38
|
* @example
|
|
39
39
|
*
|
|
40
40
|
* ```ts
|
|
41
|
-
* assert.
|
|
42
|
-
*
|
|
43
|
-
* assert.
|
|
41
|
+
* assert.isTrue(isInt(5));
|
|
42
|
+
*
|
|
43
|
+
* assert.isFalse(isInt(5.25));
|
|
44
|
+
*
|
|
45
|
+
* assert.isTrue(Int.is(-10));
|
|
44
46
|
* ```
|
|
45
47
|
*
|
|
46
48
|
* @param value - The value to check
|
|
@@ -60,8 +62,9 @@ export const isInt = is;
|
|
|
60
62
|
* ```ts
|
|
61
63
|
* const branded = asInt(42);
|
|
62
64
|
*
|
|
63
|
-
* assert(branded === 42);
|
|
64
|
-
*
|
|
65
|
+
* assert.isTrue(branded === 42);
|
|
66
|
+
*
|
|
67
|
+
* assert.isTrue(Int.is(branded));
|
|
65
68
|
* ```
|
|
66
69
|
*
|
|
67
70
|
* @param value - The value to cast
|
|
@@ -88,9 +91,11 @@ export const Int = {
|
|
|
88
91
|
* @example
|
|
89
92
|
*
|
|
90
93
|
* ```ts
|
|
91
|
-
* assert.
|
|
92
|
-
*
|
|
93
|
-
* assert.
|
|
94
|
+
* assert.isTrue(isInt(5));
|
|
95
|
+
*
|
|
96
|
+
* assert.isFalse(isInt(5.25));
|
|
97
|
+
*
|
|
98
|
+
* assert.isTrue(Int.is(-10));
|
|
94
99
|
* ```
|
|
95
100
|
*
|
|
96
101
|
* @param value - The value to check
|
|
@@ -110,10 +115,12 @@ export const Int = {
|
|
|
110
115
|
*
|
|
111
116
|
* ```ts
|
|
112
117
|
* const negative = asInt(-12);
|
|
118
|
+
*
|
|
113
119
|
* const absolute = Int.abs(negative);
|
|
114
120
|
*
|
|
115
|
-
* assert(absolute === 12);
|
|
116
|
-
*
|
|
121
|
+
* assert.isTrue(absolute === 12);
|
|
122
|
+
*
|
|
123
|
+
* assert.isTrue(Int.is(absolute));
|
|
117
124
|
* ```
|
|
118
125
|
*
|
|
119
126
|
* @param a - The integer value
|
|
@@ -129,7 +136,7 @@ export const Int = {
|
|
|
129
136
|
* ```ts
|
|
130
137
|
* const smallest = Int.min(asInt(7), asInt(-3), asInt(2));
|
|
131
138
|
*
|
|
132
|
-
* assert(smallest === -3);
|
|
139
|
+
* assert.isTrue(smallest === -3);
|
|
133
140
|
* ```
|
|
134
141
|
*
|
|
135
142
|
* @param values - The integers to compare (at least one required)
|
|
@@ -145,7 +152,7 @@ export const Int = {
|
|
|
145
152
|
* ```ts
|
|
146
153
|
* const largest = Int.max(asInt(7), asInt(-3), asInt(2));
|
|
147
154
|
*
|
|
148
|
-
* assert(largest === 7);
|
|
155
|
+
* assert.isTrue(largest === 7);
|
|
149
156
|
* ```
|
|
150
157
|
*
|
|
151
158
|
* @param values - The integers to compare (at least one required)
|
|
@@ -163,11 +170,14 @@ export const Int = {
|
|
|
163
170
|
*
|
|
164
171
|
* ```ts
|
|
165
172
|
* const min = asInt(1);
|
|
173
|
+
*
|
|
166
174
|
* const max = asInt(6);
|
|
175
|
+
*
|
|
167
176
|
* const randomValue = Int.random(min, max);
|
|
168
177
|
*
|
|
169
|
-
* assert.
|
|
170
|
-
*
|
|
178
|
+
* assert.isTrue(Int.is(randomValue));
|
|
179
|
+
*
|
|
180
|
+
* assert.isTrue(randomValue >= 1 && randomValue <= 6);
|
|
171
181
|
* ```
|
|
172
182
|
*
|
|
173
183
|
* @param min - The minimum value (inclusive)
|
|
@@ -183,10 +193,12 @@ export const Int = {
|
|
|
183
193
|
*
|
|
184
194
|
* ```ts
|
|
185
195
|
* const base = asInt(2);
|
|
196
|
+
*
|
|
186
197
|
* const exponent = asInt(5);
|
|
198
|
+
*
|
|
187
199
|
* const power = Int.pow(base, exponent);
|
|
188
200
|
*
|
|
189
|
-
* assert(power === 32);
|
|
201
|
+
* assert.isTrue(power === 32);
|
|
190
202
|
* ```
|
|
191
203
|
*
|
|
192
204
|
* @param a - The base integer
|
|
@@ -203,7 +215,7 @@ export const Int = {
|
|
|
203
215
|
* ```ts
|
|
204
216
|
* const sum = Int.add(asInt(12), asInt(8));
|
|
205
217
|
*
|
|
206
|
-
* assert(sum === 20);
|
|
218
|
+
* assert.isTrue(sum === 20);
|
|
207
219
|
* ```
|
|
208
220
|
*
|
|
209
221
|
* @param a - First integer
|
|
@@ -220,7 +232,7 @@ export const Int = {
|
|
|
220
232
|
* ```ts
|
|
221
233
|
* const difference = Int.sub(asInt(12), asInt(8));
|
|
222
234
|
*
|
|
223
|
-
* assert(difference === 4);
|
|
235
|
+
* assert.isTrue(difference === 4);
|
|
224
236
|
* ```
|
|
225
237
|
*
|
|
226
238
|
* @param a - First integer
|
|
@@ -237,7 +249,7 @@ export const Int = {
|
|
|
237
249
|
* ```ts
|
|
238
250
|
* const product = Int.mul(asInt(-4), asInt(6));
|
|
239
251
|
*
|
|
240
|
-
* assert(product === -24);
|
|
252
|
+
* assert.isTrue(product === -24);
|
|
241
253
|
* ```
|
|
242
254
|
*
|
|
243
255
|
* @param a - First integer
|
|
@@ -256,10 +268,12 @@ export const Int = {
|
|
|
256
268
|
*
|
|
257
269
|
* ```ts
|
|
258
270
|
* const dividend = asInt(17);
|
|
271
|
+
*
|
|
259
272
|
* const divisor = asInt(5);
|
|
273
|
+
*
|
|
260
274
|
* const quotient = Int.div(dividend, divisor);
|
|
261
275
|
*
|
|
262
|
-
* assert(quotient === 3);
|
|
276
|
+
* assert.isTrue(quotient === 3);
|
|
263
277
|
* ```
|
|
264
278
|
*
|
|
265
279
|
* @param a - The dividend
|
|
@@ -7,25 +7,37 @@ describe('Int test', () => {
|
|
|
7
7
|
describe(asInt, () => {
|
|
8
8
|
test('accepts valid integers', () => {
|
|
9
9
|
expect(() => asInt(0)).not.toThrow();
|
|
10
|
+
|
|
10
11
|
expect(() => asInt(1)).not.toThrow();
|
|
12
|
+
|
|
11
13
|
expect(() => asInt(-1)).not.toThrow();
|
|
14
|
+
|
|
12
15
|
expect(() => asInt(42)).not.toThrow();
|
|
16
|
+
|
|
13
17
|
expect(() => asInt(-42)).not.toThrow();
|
|
18
|
+
|
|
14
19
|
expect(() => asInt(Number.MAX_SAFE_INTEGER)).not.toThrow();
|
|
20
|
+
|
|
15
21
|
expect(() => asInt(Number.MIN_SAFE_INTEGER)).not.toThrow();
|
|
16
22
|
});
|
|
17
23
|
|
|
18
24
|
test('rejects non-integers', () => {
|
|
19
25
|
expect(() => asInt(Number.NaN)).toThrow(TypeError);
|
|
26
|
+
|
|
20
27
|
expect(() => asInt(Number.POSITIVE_INFINITY)).toThrow(TypeError);
|
|
28
|
+
|
|
21
29
|
expect(() => asInt(Number.NEGATIVE_INFINITY)).toThrow(TypeError);
|
|
30
|
+
|
|
22
31
|
expect(() => asInt(1.2)).toThrow(TypeError);
|
|
32
|
+
|
|
23
33
|
expect(() => asInt(-3.4)).toThrow(TypeError);
|
|
24
34
|
});
|
|
25
35
|
|
|
26
36
|
test('returns the same value for valid inputs', () => {
|
|
27
37
|
expect(asInt(5)).toBe(5);
|
|
38
|
+
|
|
28
39
|
expect(asInt(-10)).toBe(-10);
|
|
40
|
+
|
|
29
41
|
expect(asInt(0)).toBe(0);
|
|
30
42
|
});
|
|
31
43
|
|
|
@@ -44,74 +56,100 @@ describe('Int test', () => {
|
|
|
44
56
|
|
|
45
57
|
describe(isInt, () => {
|
|
46
58
|
test('correctly identifies integers', () => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
59
|
+
assert.isTrue(isInt(0));
|
|
60
|
+
|
|
61
|
+
assert.isTrue(isInt(1));
|
|
62
|
+
|
|
63
|
+
assert.isTrue(isInt(-1));
|
|
64
|
+
|
|
65
|
+
assert.isTrue(isInt(42));
|
|
66
|
+
|
|
67
|
+
assert.isTrue(isInt(-42));
|
|
68
|
+
|
|
69
|
+
assert.isTrue(isInt(Number.MAX_SAFE_INTEGER));
|
|
70
|
+
|
|
71
|
+
assert.isTrue(isInt(Number.MIN_SAFE_INTEGER));
|
|
54
72
|
});
|
|
55
73
|
|
|
56
74
|
test('correctly identifies non-integers', () => {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
75
|
+
assert.isFalse(isInt(Number.NaN));
|
|
76
|
+
|
|
77
|
+
assert.isFalse(isInt(Number.POSITIVE_INFINITY));
|
|
78
|
+
|
|
79
|
+
assert.isFalse(isInt(Number.NEGATIVE_INFINITY));
|
|
80
|
+
|
|
81
|
+
assert.isFalse(isInt(1.2));
|
|
82
|
+
|
|
83
|
+
assert.isFalse(isInt(-3.4));
|
|
62
84
|
});
|
|
63
85
|
});
|
|
64
86
|
|
|
65
87
|
describe('Int.is', () => {
|
|
66
88
|
test('same as isInt function', () => {
|
|
67
89
|
expect(Int.is(5)).toBe(isInt(5));
|
|
90
|
+
|
|
68
91
|
expect(Int.is(1.5)).toBe(isInt(1.5));
|
|
92
|
+
|
|
69
93
|
expect(Int.is(-10)).toBe(isInt(-10));
|
|
70
94
|
});
|
|
71
95
|
});
|
|
72
96
|
|
|
73
97
|
describe('mathematical operations', () => {
|
|
74
98
|
const a = asInt(5);
|
|
99
|
+
|
|
75
100
|
const b = asInt(2);
|
|
101
|
+
|
|
76
102
|
const c = asInt(-3);
|
|
77
103
|
|
|
78
104
|
test('abs', () => {
|
|
79
105
|
expect(Int.abs(a)).toBe(5);
|
|
106
|
+
|
|
80
107
|
expect(Int.abs(c)).toBe(3);
|
|
108
|
+
|
|
81
109
|
expect(Int.abs(asInt(0))).toBe(0);
|
|
82
110
|
});
|
|
83
111
|
|
|
84
112
|
test('min and max', () => {
|
|
85
113
|
expect(Int.min(a, b)).toBe(2);
|
|
114
|
+
|
|
86
115
|
expect(Int.max(a, b)).toBe(5);
|
|
116
|
+
|
|
87
117
|
expect(Int.min(a, c)).toBe(-3);
|
|
118
|
+
|
|
88
119
|
expect(Int.max(a, c)).toBe(5);
|
|
89
120
|
});
|
|
90
121
|
|
|
91
122
|
test('add', () => {
|
|
92
123
|
expect(Int.add(a, b)).toBe(7);
|
|
124
|
+
|
|
93
125
|
expect(Int.add(a, c)).toBe(2);
|
|
94
126
|
});
|
|
95
127
|
|
|
96
128
|
test('sub', () => {
|
|
97
129
|
expect(Int.sub(a, b)).toBe(3);
|
|
130
|
+
|
|
98
131
|
expect(Int.sub(a, c)).toBe(8);
|
|
99
132
|
});
|
|
100
133
|
|
|
101
134
|
test('mul', () => {
|
|
102
135
|
expect(Int.mul(a, b)).toBe(10);
|
|
136
|
+
|
|
103
137
|
expect(Int.mul(a, c)).toBe(-15);
|
|
104
138
|
});
|
|
105
139
|
|
|
106
140
|
test('div (floor division)', () => {
|
|
107
141
|
expect(Int.div(a, asNonZeroInt(2))).toBe(2);
|
|
142
|
+
|
|
108
143
|
expect(Int.div(asInt(7), asNonZeroInt(3))).toBe(2);
|
|
144
|
+
|
|
109
145
|
expect(Int.div(asInt(-7), asNonZeroInt(3))).toBe(-3);
|
|
110
146
|
});
|
|
111
147
|
|
|
112
148
|
test('pow', () => {
|
|
113
149
|
expect(Int.pow(asInt(2), asInt(3))).toBe(8);
|
|
150
|
+
|
|
114
151
|
expect(Int.pow(asInt(3), asInt(2))).toBe(9);
|
|
152
|
+
|
|
115
153
|
expect(Int.pow(asInt(-2), asInt(3))).toBe(-8);
|
|
116
154
|
});
|
|
117
155
|
});
|
|
@@ -119,15 +157,19 @@ describe('Int test', () => {
|
|
|
119
157
|
describe('random', () => {
|
|
120
158
|
test('generates integers within specified range', () => {
|
|
121
159
|
const min = -5;
|
|
160
|
+
|
|
122
161
|
const max = 10;
|
|
123
162
|
|
|
124
163
|
for (const _ of range(10)) {
|
|
125
164
|
const result = Int.random(min, max);
|
|
126
165
|
|
|
127
166
|
expect(result).toBeGreaterThanOrEqual(min);
|
|
167
|
+
|
|
128
168
|
expect(result).toBeLessThanOrEqual(max);
|
|
129
|
-
|
|
130
|
-
|
|
169
|
+
|
|
170
|
+
assert.isTrue(Int.is(result));
|
|
171
|
+
|
|
172
|
+
assert.isTrue(Number.isInteger(result));
|
|
131
173
|
}
|
|
132
174
|
});
|
|
133
175
|
});
|
|
@@ -7,32 +7,47 @@ describe('Int16 test', () => {
|
|
|
7
7
|
describe(asInt16, () => {
|
|
8
8
|
test('accepts valid int16 values', () => {
|
|
9
9
|
expect(() => asInt16(0)).not.toThrow();
|
|
10
|
+
|
|
10
11
|
expect(() => asInt16(1)).not.toThrow();
|
|
12
|
+
|
|
11
13
|
expect(() => asInt16(-1)).not.toThrow();
|
|
14
|
+
|
|
12
15
|
expect(() => asInt16(32_767)).not.toThrow(); // 2^15 - 1
|
|
16
|
+
|
|
13
17
|
expect(() => asInt16(-32_768)).not.toThrow(); // -2^15
|
|
14
18
|
});
|
|
15
19
|
|
|
16
20
|
test('rejects values outside int16 range', () => {
|
|
17
21
|
expect(() => asInt16(32_768)).toThrow(TypeError); // 2^15
|
|
22
|
+
|
|
18
23
|
expect(() => asInt16(-32_769)).toThrow(TypeError); // -2^15 - 1
|
|
24
|
+
|
|
19
25
|
expect(() => asInt16(65_536)).toThrow(TypeError);
|
|
26
|
+
|
|
20
27
|
expect(() => asInt16(-65_536)).toThrow(TypeError);
|
|
21
28
|
});
|
|
22
29
|
|
|
23
30
|
test('rejects non-integers', () => {
|
|
24
31
|
expect(() => asInt16(Number.NaN)).toThrow(TypeError);
|
|
32
|
+
|
|
25
33
|
expect(() => asInt16(Number.POSITIVE_INFINITY)).toThrow(TypeError);
|
|
34
|
+
|
|
26
35
|
expect(() => asInt16(Number.NEGATIVE_INFINITY)).toThrow(TypeError);
|
|
36
|
+
|
|
27
37
|
expect(() => asInt16(1.2)).toThrow(TypeError);
|
|
38
|
+
|
|
28
39
|
expect(() => asInt16(-3.4)).toThrow(TypeError);
|
|
29
40
|
});
|
|
30
41
|
|
|
31
42
|
test('returns the same value for valid inputs', () => {
|
|
32
43
|
expect(asInt16(5)).toBe(5);
|
|
44
|
+
|
|
33
45
|
expect(asInt16(-10)).toBe(-10);
|
|
46
|
+
|
|
34
47
|
expect(asInt16(0)).toBe(0);
|
|
48
|
+
|
|
35
49
|
expect(asInt16(32_767)).toBe(32_767);
|
|
50
|
+
|
|
36
51
|
expect(asInt16(-32_768)).toBe(-32_768);
|
|
37
52
|
});
|
|
38
53
|
|
|
@@ -51,33 +66,46 @@ describe('Int16 test', () => {
|
|
|
51
66
|
|
|
52
67
|
describe(isInt16, () => {
|
|
53
68
|
test('correctly identifies int16 values', () => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
69
|
+
assert.isTrue(isInt16(0));
|
|
70
|
+
|
|
71
|
+
assert.isTrue(isInt16(1));
|
|
72
|
+
|
|
73
|
+
assert.isTrue(isInt16(-1));
|
|
74
|
+
|
|
75
|
+
assert.isTrue(isInt16(32_767));
|
|
76
|
+
|
|
77
|
+
assert.isTrue(isInt16(-32_768));
|
|
59
78
|
});
|
|
60
79
|
|
|
61
80
|
test('correctly identifies values outside int16 range', () => {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
81
|
+
assert.isFalse(isInt16(32_768));
|
|
82
|
+
|
|
83
|
+
assert.isFalse(isInt16(-32_769));
|
|
84
|
+
|
|
85
|
+
assert.isFalse(isInt16(65_536));
|
|
86
|
+
|
|
87
|
+
assert.isFalse(isInt16(-65_536));
|
|
66
88
|
});
|
|
67
89
|
|
|
68
90
|
test('correctly identifies non-integers', () => {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
91
|
+
assert.isFalse(isInt16(Number.NaN));
|
|
92
|
+
|
|
93
|
+
assert.isFalse(isInt16(Number.POSITIVE_INFINITY));
|
|
94
|
+
|
|
95
|
+
assert.isFalse(isInt16(Number.NEGATIVE_INFINITY));
|
|
96
|
+
|
|
97
|
+
assert.isFalse(isInt16(1.2));
|
|
98
|
+
|
|
99
|
+
assert.isFalse(isInt16(-3.4));
|
|
74
100
|
});
|
|
75
101
|
});
|
|
76
102
|
|
|
77
103
|
describe('Int16.is', () => {
|
|
78
104
|
test('same as isInt16 function', () => {
|
|
79
105
|
expect(Int16.is(5)).toBe(isInt16(5));
|
|
106
|
+
|
|
80
107
|
expect(Int16.is(32_768)).toBe(isInt16(32_768));
|
|
108
|
+
|
|
81
109
|
expect(Int16.is(-32_769)).toBe(isInt16(-32_769));
|
|
82
110
|
});
|
|
83
111
|
});
|
|
@@ -85,25 +113,33 @@ describe('Int16 test', () => {
|
|
|
85
113
|
describe('constants', () => {
|
|
86
114
|
test('MIN_VALUE and MAX_VALUE', () => {
|
|
87
115
|
expect(Int16.MIN_VALUE).toBe(-32_768);
|
|
116
|
+
|
|
88
117
|
expect(Int16.MAX_VALUE).toBe(32_767);
|
|
89
118
|
});
|
|
90
119
|
});
|
|
91
120
|
|
|
92
121
|
describe('mathematical operations', () => {
|
|
93
122
|
const a = asInt16(100);
|
|
123
|
+
|
|
94
124
|
const b = asInt16(50);
|
|
125
|
+
|
|
95
126
|
const c = asInt16(-30);
|
|
96
127
|
|
|
97
128
|
test('abs', () => {
|
|
98
129
|
expect(Int16.abs(a)).toBe(100);
|
|
130
|
+
|
|
99
131
|
expect(Int16.abs(c)).toBe(30);
|
|
132
|
+
|
|
100
133
|
expect(Int16.abs(asInt16(0))).toBe(0);
|
|
101
134
|
});
|
|
102
135
|
|
|
103
136
|
test('min and max', () => {
|
|
104
137
|
expect(Int16.min(a, b)).toBe(50);
|
|
138
|
+
|
|
105
139
|
expect(Int16.max(a, b)).toBe(100);
|
|
140
|
+
|
|
106
141
|
expect(Int16.min(a, c)).toBe(-30);
|
|
142
|
+
|
|
107
143
|
expect(Int16.max(a, c)).toBe(100);
|
|
108
144
|
});
|
|
109
145
|
|
|
@@ -111,6 +147,7 @@ describe('Int16 test', () => {
|
|
|
111
147
|
const result = Int16.add(asInt16(32_000), asInt16(1000));
|
|
112
148
|
|
|
113
149
|
expect(result).toBe(32_767); // clamped to max
|
|
150
|
+
|
|
114
151
|
expect(Int16.add(a, b)).toBe(150);
|
|
115
152
|
});
|
|
116
153
|
|
|
@@ -118,6 +155,7 @@ describe('Int16 test', () => {
|
|
|
118
155
|
const result = Int16.sub(asInt16(-32_000), asInt16(1000));
|
|
119
156
|
|
|
120
157
|
expect(result).toBe(-32_768); // clamped to min
|
|
158
|
+
|
|
121
159
|
expect(Int16.sub(a, b)).toBe(50);
|
|
122
160
|
});
|
|
123
161
|
|
|
@@ -125,12 +163,15 @@ describe('Int16 test', () => {
|
|
|
125
163
|
const result = Int16.mul(asInt16(1000), asInt16(100));
|
|
126
164
|
|
|
127
165
|
expect(result).toBe(32_767); // clamped to max
|
|
166
|
+
|
|
128
167
|
expect(Int16.mul(asInt16(10), asInt16(5))).toBe(50);
|
|
129
168
|
});
|
|
130
169
|
|
|
131
170
|
test('div (floor division with clamping)', () => {
|
|
132
171
|
expect(Int16.div(a, asNonZeroInt16(50))).toBe(2);
|
|
172
|
+
|
|
133
173
|
expect(Int16.div(asInt16(7), asNonZeroInt16(3))).toBe(2);
|
|
174
|
+
|
|
134
175
|
expect(Int16.div(asInt16(-7), asNonZeroInt16(3))).toBe(-3);
|
|
135
176
|
});
|
|
136
177
|
|
|
@@ -138,6 +179,7 @@ describe('Int16 test', () => {
|
|
|
138
179
|
const result = Int16.pow(asInt16(200), asInt16(3));
|
|
139
180
|
|
|
140
181
|
expect(result).toBe(32_767); // clamped to max
|
|
182
|
+
|
|
141
183
|
expect(Int16.pow(asInt16(2), asInt16(3))).toBe(8);
|
|
142
184
|
});
|
|
143
185
|
});
|
|
@@ -145,15 +187,19 @@ describe('Int16 test', () => {
|
|
|
145
187
|
describe('random', () => {
|
|
146
188
|
test('generates int16 values within specified range', () => {
|
|
147
189
|
const min = -10;
|
|
190
|
+
|
|
148
191
|
const max = 10;
|
|
149
192
|
|
|
150
193
|
for (const _ of range(10)) {
|
|
151
194
|
const result = Int16.random(min, max);
|
|
152
195
|
|
|
153
196
|
expect(result).toBeGreaterThanOrEqual(min);
|
|
197
|
+
|
|
154
198
|
expect(result).toBeLessThanOrEqual(max);
|
|
155
|
-
|
|
156
|
-
|
|
199
|
+
|
|
200
|
+
assert.isTrue(Int16.is(result));
|
|
201
|
+
|
|
202
|
+
assert.isTrue(Number.isInteger(result));
|
|
157
203
|
}
|
|
158
204
|
});
|
|
159
205
|
|
|
@@ -162,6 +208,7 @@ describe('Int16 test', () => {
|
|
|
162
208
|
const result = Int16.random(-20, 20);
|
|
163
209
|
|
|
164
210
|
expect(result).toBeGreaterThanOrEqual(Int16.MIN_VALUE);
|
|
211
|
+
|
|
165
212
|
expect(result).toBeLessThanOrEqual(Int16.MAX_VALUE);
|
|
166
213
|
}
|
|
167
214
|
});
|