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
|
@@ -20,19 +20,24 @@ import {
|
|
|
20
20
|
|
|
21
21
|
describe(isUndefined, () => {
|
|
22
22
|
test('should return true for undefined', () => {
|
|
23
|
-
|
|
23
|
+
assert.isTrue(isUndefined(undefined));
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
test('should return false for non-undefined values', () => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
assert.isFalse(isUndefined(null));
|
|
28
|
+
|
|
29
|
+
assert.isFalse(isUndefined(0));
|
|
30
|
+
|
|
31
|
+
assert.isFalse(isUndefined(''));
|
|
32
|
+
|
|
33
|
+
assert.isFalse(isUndefined(false));
|
|
34
|
+
|
|
35
|
+
assert.isFalse(isUndefined({}));
|
|
32
36
|
});
|
|
33
37
|
|
|
34
38
|
test('should act as a type guard', () => {
|
|
35
39
|
const value: string | undefined = undefined;
|
|
40
|
+
|
|
36
41
|
if (isUndefined(value)) {
|
|
37
42
|
expectType<typeof value, undefined>('=');
|
|
38
43
|
}
|
|
@@ -41,18 +46,22 @@ describe(isUndefined, () => {
|
|
|
41
46
|
|
|
42
47
|
describe(isNotUndefined, () => {
|
|
43
48
|
test('should return false for undefined', () => {
|
|
44
|
-
|
|
49
|
+
assert.isFalse(isNotUndefined(undefined));
|
|
45
50
|
});
|
|
46
51
|
|
|
47
52
|
test('should return true for non-undefined values', () => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
53
|
+
assert.isTrue(isNotUndefined(null));
|
|
54
|
+
|
|
55
|
+
assert.isTrue(isNotUndefined(0));
|
|
56
|
+
|
|
57
|
+
assert.isTrue(isNotUndefined(''));
|
|
58
|
+
|
|
59
|
+
assert.isTrue(isNotUndefined(false));
|
|
52
60
|
});
|
|
53
61
|
|
|
54
62
|
test('should narrow types correctly', () => {
|
|
55
63
|
const value: string | undefined = 'test';
|
|
64
|
+
|
|
56
65
|
if (isNotUndefined(value)) {
|
|
57
66
|
expectType<typeof value, string>('=');
|
|
58
67
|
}
|
|
@@ -61,19 +70,24 @@ describe(isNotUndefined, () => {
|
|
|
61
70
|
|
|
62
71
|
describe(isNull, () => {
|
|
63
72
|
test('should return true for null', () => {
|
|
64
|
-
|
|
73
|
+
assert.isTrue(isNull(null));
|
|
65
74
|
});
|
|
66
75
|
|
|
67
76
|
test('should return false for non-null values', () => {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
77
|
+
assert.isFalse(isNull(undefined));
|
|
78
|
+
|
|
79
|
+
assert.isFalse(isNull(0));
|
|
80
|
+
|
|
81
|
+
assert.isFalse(isNull(''));
|
|
82
|
+
|
|
83
|
+
assert.isFalse(isNull(false));
|
|
84
|
+
|
|
85
|
+
assert.isFalse(isNull({}));
|
|
73
86
|
});
|
|
74
87
|
|
|
75
88
|
test('should act as a type guard', () => {
|
|
76
89
|
const value: string | null = null;
|
|
90
|
+
|
|
77
91
|
if (isNull(value)) {
|
|
78
92
|
expectType<typeof value, null>('=');
|
|
79
93
|
}
|
|
@@ -82,17 +96,20 @@ describe(isNull, () => {
|
|
|
82
96
|
|
|
83
97
|
describe(isNotNull, () => {
|
|
84
98
|
test('should return false for null', () => {
|
|
85
|
-
|
|
99
|
+
assert.isFalse(isNotNull(null));
|
|
86
100
|
});
|
|
87
101
|
|
|
88
102
|
test('should return true for non-null values', () => {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
103
|
+
assert.isTrue(isNotNull(undefined));
|
|
104
|
+
|
|
105
|
+
assert.isTrue(isNotNull(0));
|
|
106
|
+
|
|
107
|
+
assert.isTrue(isNotNull(''));
|
|
92
108
|
});
|
|
93
109
|
|
|
94
110
|
test('should narrow types correctly', () => {
|
|
95
111
|
const value: string | null = 'test';
|
|
112
|
+
|
|
96
113
|
if (isNotNull(value)) {
|
|
97
114
|
expectType<typeof value, string>('=');
|
|
98
115
|
}
|
|
@@ -101,23 +118,31 @@ describe(isNotNull, () => {
|
|
|
101
118
|
|
|
102
119
|
describe(isString, () => {
|
|
103
120
|
test('should return true for strings', () => {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
121
|
+
assert.isTrue(isString(''));
|
|
122
|
+
|
|
123
|
+
assert.isTrue(isString('hello'));
|
|
124
|
+
|
|
125
|
+
assert.isTrue(isString('123'));
|
|
126
|
+
|
|
127
|
+
assert.isTrue(isString(`template`));
|
|
108
128
|
});
|
|
109
129
|
|
|
110
130
|
test('should return false for non-strings', () => {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
131
|
+
assert.isFalse(isString(123));
|
|
132
|
+
|
|
133
|
+
assert.isFalse(isString(true));
|
|
134
|
+
|
|
135
|
+
assert.isFalse(isString(null));
|
|
136
|
+
|
|
137
|
+
assert.isFalse(isString(undefined));
|
|
138
|
+
|
|
115
139
|
// eslint-disable-next-line unicorn/new-for-builtins
|
|
116
|
-
|
|
140
|
+
assert.isFalse(isString(new String('hello')));
|
|
117
141
|
});
|
|
118
142
|
|
|
119
143
|
test('should act as a type guard', () => {
|
|
120
144
|
const value: unknown = 'test';
|
|
145
|
+
|
|
121
146
|
if (isString(value)) {
|
|
122
147
|
expectType<typeof value, string>('=');
|
|
123
148
|
|
|
@@ -128,25 +153,35 @@ describe(isString, () => {
|
|
|
128
153
|
|
|
129
154
|
describe(isNumber, () => {
|
|
130
155
|
test('should return true for numbers', () => {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
156
|
+
assert.isTrue(isNumber(0));
|
|
157
|
+
|
|
158
|
+
assert.isTrue(isNumber(42));
|
|
159
|
+
|
|
160
|
+
assert.isTrue(isNumber(-3.14));
|
|
161
|
+
|
|
162
|
+
assert.isTrue(isNumber(Number.NaN));
|
|
163
|
+
|
|
164
|
+
assert.isTrue(isNumber(Number.POSITIVE_INFINITY));
|
|
165
|
+
|
|
166
|
+
assert.isTrue(isNumber(Number.NEGATIVE_INFINITY));
|
|
137
167
|
});
|
|
138
168
|
|
|
139
169
|
test('should return false for non-numbers', () => {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
170
|
+
assert.isFalse(isNumber('123'));
|
|
171
|
+
|
|
172
|
+
assert.isFalse(isNumber(true));
|
|
173
|
+
|
|
174
|
+
assert.isFalse(isNumber(null));
|
|
175
|
+
|
|
176
|
+
assert.isFalse(isNumber(123n));
|
|
177
|
+
|
|
144
178
|
// eslint-disable-next-line unicorn/new-for-builtins
|
|
145
|
-
|
|
179
|
+
assert.isFalse(isNumber(new Number(42)));
|
|
146
180
|
});
|
|
147
181
|
|
|
148
182
|
test('should act as a type guard', () => {
|
|
149
183
|
const value: unknown = 42;
|
|
184
|
+
|
|
150
185
|
if (isNumber(value)) {
|
|
151
186
|
expectType<typeof value, number>('=');
|
|
152
187
|
|
|
@@ -157,20 +192,26 @@ describe(isNumber, () => {
|
|
|
157
192
|
|
|
158
193
|
describe(isBigint, () => {
|
|
159
194
|
test('should return true for bigints', () => {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
195
|
+
assert.isTrue(isBigint(0n));
|
|
196
|
+
|
|
197
|
+
assert.isTrue(isBigint(123n));
|
|
198
|
+
|
|
199
|
+
assert.isTrue(isBigint(-456n));
|
|
163
200
|
});
|
|
164
201
|
|
|
165
202
|
test('should return false for non-bigints', () => {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
203
|
+
assert.isFalse(isBigint(123));
|
|
204
|
+
|
|
205
|
+
assert.isFalse(isBigint('123'));
|
|
206
|
+
|
|
207
|
+
assert.isFalse(isBigint(true));
|
|
208
|
+
|
|
209
|
+
assert.isFalse(isBigint(null));
|
|
170
210
|
});
|
|
171
211
|
|
|
172
212
|
test('should act as a type guard', () => {
|
|
173
213
|
const value: unknown = 123n;
|
|
214
|
+
|
|
174
215
|
if (isBigint(value)) {
|
|
175
216
|
expectType<typeof value, bigint>('=');
|
|
176
217
|
|
|
@@ -181,44 +222,55 @@ describe(isBigint, () => {
|
|
|
181
222
|
|
|
182
223
|
describe(isBoolean, () => {
|
|
183
224
|
test('should return true for booleans', () => {
|
|
184
|
-
|
|
185
|
-
|
|
225
|
+
assert.isTrue(isBoolean(true));
|
|
226
|
+
|
|
227
|
+
assert.isTrue(isBoolean(false));
|
|
186
228
|
});
|
|
187
229
|
|
|
188
230
|
test('should return false for non-booleans', () => {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
231
|
+
assert.isFalse(isBoolean(1));
|
|
232
|
+
|
|
233
|
+
assert.isFalse(isBoolean(0));
|
|
234
|
+
|
|
235
|
+
assert.isFalse(isBoolean('true'));
|
|
236
|
+
|
|
237
|
+
assert.isFalse(isBoolean(null));
|
|
238
|
+
|
|
193
239
|
// eslint-disable-next-line unicorn/new-for-builtins
|
|
194
|
-
|
|
240
|
+
assert.isFalse(isBoolean(new Boolean(true)));
|
|
195
241
|
});
|
|
196
242
|
|
|
197
243
|
test('should act as a type guard', () => {
|
|
198
244
|
const value: unknown = true;
|
|
245
|
+
|
|
199
246
|
if (isBoolean(value)) {
|
|
200
247
|
expectType<typeof value, boolean>('=');
|
|
201
248
|
|
|
202
|
-
|
|
249
|
+
assert.isTrue(value);
|
|
203
250
|
}
|
|
204
251
|
});
|
|
205
252
|
});
|
|
206
253
|
|
|
207
254
|
describe(isSymbol, () => {
|
|
208
255
|
test('should return true for symbols', () => {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
256
|
+
assert.isTrue(isSymbol(Symbol()));
|
|
257
|
+
|
|
258
|
+
assert.isTrue(isSymbol(Symbol('test')));
|
|
259
|
+
|
|
260
|
+
assert.isTrue(isSymbol(Symbol.iterator));
|
|
212
261
|
});
|
|
213
262
|
|
|
214
263
|
test('should return false for non-symbols', () => {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
264
|
+
assert.isFalse(isSymbol('symbol'));
|
|
265
|
+
|
|
266
|
+
assert.isFalse(isSymbol(123));
|
|
267
|
+
|
|
268
|
+
assert.isFalse(isSymbol(null));
|
|
218
269
|
});
|
|
219
270
|
|
|
220
271
|
test('should act as a type guard', () => {
|
|
221
272
|
const value: unknown = Symbol('test');
|
|
273
|
+
|
|
222
274
|
if (isSymbol(value)) {
|
|
223
275
|
expectType<typeof value, symbol>('=');
|
|
224
276
|
|
|
@@ -229,86 +281,117 @@ describe(isSymbol, () => {
|
|
|
229
281
|
|
|
230
282
|
describe(isNotBoolean, () => {
|
|
231
283
|
test('should return false for boolean values', () => {
|
|
232
|
-
|
|
233
|
-
|
|
284
|
+
assert.isFalse(isNotBoolean(true));
|
|
285
|
+
|
|
286
|
+
assert.isFalse(isNotBoolean(false));
|
|
234
287
|
});
|
|
235
288
|
|
|
236
289
|
test('should return true for non-boolean values', () => {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
290
|
+
assert.isTrue(isNotBoolean(0));
|
|
291
|
+
|
|
292
|
+
assert.isTrue(isNotBoolean(1));
|
|
293
|
+
|
|
294
|
+
assert.isTrue(isNotBoolean('true'));
|
|
295
|
+
|
|
296
|
+
assert.isTrue(isNotBoolean('false'));
|
|
297
|
+
|
|
298
|
+
assert.isTrue(isNotBoolean(null));
|
|
299
|
+
|
|
300
|
+
assert.isTrue(isNotBoolean(undefined));
|
|
301
|
+
|
|
302
|
+
assert.isTrue(isNotBoolean({}));
|
|
303
|
+
|
|
304
|
+
assert.isTrue(isNotBoolean([]));
|
|
245
305
|
});
|
|
246
306
|
|
|
247
307
|
test('should act as a type guard', () => {
|
|
248
308
|
const value: string | number | boolean = 'test';
|
|
309
|
+
|
|
249
310
|
if (isNotBoolean(value)) {
|
|
250
311
|
expectType<typeof value, string | number>('<=');
|
|
251
312
|
|
|
252
313
|
// Should not have boolean methods
|
|
253
|
-
|
|
314
|
+
assert.isTrue(typeof value === 'string' || typeof value === 'number');
|
|
254
315
|
}
|
|
255
316
|
});
|
|
256
317
|
});
|
|
257
318
|
|
|
258
319
|
describe(isNotNumber, () => {
|
|
259
320
|
test('should return false for number values', () => {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
321
|
+
assert.isFalse(isNotNumber(0));
|
|
322
|
+
|
|
323
|
+
assert.isFalse(isNotNumber(42));
|
|
324
|
+
|
|
325
|
+
assert.isFalse(isNotNumber(-3.14));
|
|
326
|
+
|
|
327
|
+
assert.isFalse(isNotNumber(Number.NaN));
|
|
328
|
+
|
|
329
|
+
assert.isFalse(isNotNumber(Number.POSITIVE_INFINITY));
|
|
330
|
+
|
|
331
|
+
assert.isFalse(isNotNumber(Number.NEGATIVE_INFINITY));
|
|
266
332
|
});
|
|
267
333
|
|
|
268
334
|
test('should return true for non-number values', () => {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
335
|
+
assert.isTrue(isNotNumber('123'));
|
|
336
|
+
|
|
337
|
+
assert.isTrue(isNotNumber(true));
|
|
338
|
+
|
|
339
|
+
assert.isTrue(isNotNumber(false));
|
|
340
|
+
|
|
341
|
+
assert.isTrue(isNotNumber(null));
|
|
342
|
+
|
|
343
|
+
assert.isTrue(isNotNumber(undefined));
|
|
344
|
+
|
|
345
|
+
assert.isTrue(isNotNumber(123n));
|
|
346
|
+
|
|
347
|
+
assert.isTrue(isNotNumber({}));
|
|
348
|
+
|
|
349
|
+
assert.isTrue(isNotNumber([]));
|
|
350
|
+
|
|
351
|
+
assert.isTrue(isNotNumber(Symbol('test')));
|
|
278
352
|
});
|
|
279
353
|
|
|
280
354
|
test('should act as a type guard', () => {
|
|
281
355
|
const value: string | number | boolean = 'test';
|
|
356
|
+
|
|
282
357
|
if (isNotNumber(value)) {
|
|
283
358
|
expectType<typeof value, string | boolean>('<=');
|
|
284
359
|
|
|
285
|
-
|
|
286
|
-
true,
|
|
287
|
-
);
|
|
360
|
+
assert.isTrue(typeof value === 'string' || typeof value === 'boolean');
|
|
288
361
|
}
|
|
289
362
|
});
|
|
290
363
|
});
|
|
291
364
|
|
|
292
365
|
describe(isNotBigint, () => {
|
|
293
366
|
test('should return false for bigint values', () => {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
367
|
+
assert.isFalse(isNotBigint(0n));
|
|
368
|
+
|
|
369
|
+
assert.isFalse(isNotBigint(123n));
|
|
370
|
+
|
|
371
|
+
assert.isFalse(isNotBigint(-456n));
|
|
297
372
|
});
|
|
298
373
|
|
|
299
374
|
test('should return true for non-bigint values', () => {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
375
|
+
assert.isTrue(isNotBigint(123));
|
|
376
|
+
|
|
377
|
+
assert.isTrue(isNotBigint('123'));
|
|
378
|
+
|
|
379
|
+
assert.isTrue(isNotBigint(true));
|
|
380
|
+
|
|
381
|
+
assert.isTrue(isNotBigint(false));
|
|
382
|
+
|
|
383
|
+
assert.isTrue(isNotBigint(null));
|
|
384
|
+
|
|
385
|
+
assert.isTrue(isNotBigint(undefined));
|
|
386
|
+
|
|
387
|
+
assert.isTrue(isNotBigint({}));
|
|
388
|
+
|
|
389
|
+
assert.isTrue(isNotBigint(Symbol('test')));
|
|
308
390
|
});
|
|
309
391
|
|
|
310
392
|
test('should act as a type guard', () => {
|
|
311
393
|
const value: number | bigint = 123;
|
|
394
|
+
|
|
312
395
|
if (isNotBigint(value)) {
|
|
313
396
|
expectType<typeof value, number>('<=');
|
|
314
397
|
|
|
@@ -319,84 +402,114 @@ describe(isNotBigint, () => {
|
|
|
319
402
|
|
|
320
403
|
describe(isNotString, () => {
|
|
321
404
|
test('should return false for string values', () => {
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
405
|
+
assert.isFalse(isNotString(''));
|
|
406
|
+
|
|
407
|
+
assert.isFalse(isNotString('hello'));
|
|
408
|
+
|
|
409
|
+
assert.isFalse(isNotString('123'));
|
|
410
|
+
|
|
411
|
+
assert.isFalse(isNotString(`template`));
|
|
326
412
|
});
|
|
327
413
|
|
|
328
414
|
test('should return true for non-string values', () => {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
415
|
+
assert.isTrue(isNotString(123));
|
|
416
|
+
|
|
417
|
+
assert.isTrue(isNotString(true));
|
|
418
|
+
|
|
419
|
+
assert.isTrue(isNotString(false));
|
|
420
|
+
|
|
421
|
+
assert.isTrue(isNotString(null));
|
|
422
|
+
|
|
423
|
+
assert.isTrue(isNotString(undefined));
|
|
424
|
+
|
|
425
|
+
assert.isTrue(isNotString({}));
|
|
426
|
+
|
|
427
|
+
assert.isTrue(isNotString([]));
|
|
428
|
+
|
|
429
|
+
assert.isTrue(isNotString(Symbol('test')));
|
|
430
|
+
|
|
431
|
+
assert.isTrue(isNotString(123n));
|
|
338
432
|
});
|
|
339
433
|
|
|
340
434
|
test('should act as a type guard', () => {
|
|
341
435
|
const value: string | number | boolean = 42;
|
|
436
|
+
|
|
342
437
|
if (isNotString(value)) {
|
|
343
438
|
expectType<typeof value, number | boolean>('<=');
|
|
344
439
|
|
|
345
|
-
|
|
346
|
-
true,
|
|
347
|
-
);
|
|
440
|
+
assert.isTrue(typeof value === 'number' || typeof value === 'boolean');
|
|
348
441
|
}
|
|
349
442
|
});
|
|
350
443
|
});
|
|
351
444
|
|
|
352
445
|
describe(isNotSymbol, () => {
|
|
353
446
|
test('should return false for symbol values', () => {
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
447
|
+
assert.isFalse(isNotSymbol(Symbol()));
|
|
448
|
+
|
|
449
|
+
assert.isFalse(isNotSymbol(Symbol('test')));
|
|
450
|
+
|
|
451
|
+
assert.isFalse(isNotSymbol(Symbol.iterator));
|
|
357
452
|
});
|
|
358
453
|
|
|
359
454
|
test('should return true for non-symbol values', () => {
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
455
|
+
assert.isTrue(isNotSymbol('symbol'));
|
|
456
|
+
|
|
457
|
+
assert.isTrue(isNotSymbol(123));
|
|
458
|
+
|
|
459
|
+
assert.isTrue(isNotSymbol(true));
|
|
460
|
+
|
|
461
|
+
assert.isTrue(isNotSymbol(false));
|
|
462
|
+
|
|
463
|
+
assert.isTrue(isNotSymbol(null));
|
|
464
|
+
|
|
465
|
+
assert.isTrue(isNotSymbol(undefined));
|
|
466
|
+
|
|
467
|
+
assert.isTrue(isNotSymbol({}));
|
|
468
|
+
|
|
469
|
+
assert.isTrue(isNotSymbol([]));
|
|
470
|
+
|
|
471
|
+
assert.isTrue(isNotSymbol(123n));
|
|
369
472
|
});
|
|
370
473
|
|
|
371
474
|
test('should act as a type guard', () => {
|
|
372
475
|
const value: string | number | symbol = 'test';
|
|
476
|
+
|
|
373
477
|
if (isNotSymbol(value)) {
|
|
374
478
|
expectType<typeof value, string | number>('<=');
|
|
375
479
|
|
|
376
|
-
|
|
480
|
+
assert.isTrue(typeof value === 'string' || typeof value === 'number');
|
|
377
481
|
}
|
|
378
482
|
});
|
|
379
483
|
});
|
|
380
484
|
|
|
381
485
|
describe(isNullish, () => {
|
|
382
486
|
test('should return true for null and undefined', () => {
|
|
383
|
-
|
|
384
|
-
|
|
487
|
+
assert.isTrue(isNullish(null));
|
|
488
|
+
|
|
489
|
+
assert.isTrue(isNullish(undefined));
|
|
385
490
|
});
|
|
386
491
|
|
|
387
492
|
test('should return false for non-nullish values', () => {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
493
|
+
assert.isFalse(isNullish(0));
|
|
494
|
+
|
|
495
|
+
assert.isFalse(isNullish(false));
|
|
496
|
+
|
|
497
|
+
assert.isFalse(isNullish(''));
|
|
498
|
+
|
|
499
|
+
assert.isFalse(isNullish('null'));
|
|
500
|
+
|
|
501
|
+
assert.isFalse(isNullish('undefined'));
|
|
502
|
+
|
|
503
|
+
assert.isFalse(isNullish({}));
|
|
504
|
+
|
|
505
|
+
assert.isFalse(isNullish([]));
|
|
506
|
+
|
|
507
|
+
assert.isFalse(isNullish(Number.NaN));
|
|
396
508
|
});
|
|
397
509
|
|
|
398
510
|
test('should act as a type guard', () => {
|
|
399
511
|
const value: string | null | undefined = null;
|
|
512
|
+
|
|
400
513
|
if (isNullish(value)) {
|
|
401
514
|
expectType<typeof value, null | undefined>('<=');
|
|
402
515
|
|
|
@@ -407,32 +520,44 @@ describe(isNullish, () => {
|
|
|
407
520
|
|
|
408
521
|
test('should handle edge cases', () => {
|
|
409
522
|
// Test that it uses loose equality (==)
|
|
410
|
-
|
|
411
|
-
|
|
523
|
+
assert.isTrue(isNullish(null));
|
|
524
|
+
|
|
525
|
+
assert.isTrue(isNullish(undefined));
|
|
412
526
|
});
|
|
413
527
|
});
|
|
414
528
|
|
|
415
529
|
describe(isNonNullish, () => {
|
|
416
530
|
test('should return false for null and undefined', () => {
|
|
417
|
-
|
|
418
|
-
|
|
531
|
+
assert.isFalse(isNonNullish(null));
|
|
532
|
+
|
|
533
|
+
assert.isFalse(isNonNullish(undefined));
|
|
419
534
|
});
|
|
420
535
|
|
|
421
536
|
test('should return true for non-nullish values', () => {
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
537
|
+
assert.isTrue(isNonNullish(0));
|
|
538
|
+
|
|
539
|
+
assert.isTrue(isNonNullish(false));
|
|
540
|
+
|
|
541
|
+
assert.isTrue(isNonNullish(''));
|
|
542
|
+
|
|
543
|
+
assert.isTrue(isNonNullish('null'));
|
|
544
|
+
|
|
545
|
+
assert.isTrue(isNonNullish('undefined'));
|
|
546
|
+
|
|
547
|
+
assert.isTrue(isNonNullish({}));
|
|
548
|
+
|
|
549
|
+
assert.isTrue(isNonNullish([]));
|
|
550
|
+
|
|
551
|
+
assert.isTrue(isNonNullish(Number.NaN));
|
|
552
|
+
|
|
553
|
+
assert.isTrue(isNonNullish(Symbol('test')));
|
|
554
|
+
|
|
555
|
+
assert.isTrue(isNonNullish(123n));
|
|
432
556
|
});
|
|
433
557
|
|
|
434
558
|
test('should act as a type guard', () => {
|
|
435
559
|
const value: string | null | undefined = 'test';
|
|
560
|
+
|
|
436
561
|
if (isNonNullish(value)) {
|
|
437
562
|
expectType<typeof value, string>('<=');
|
|
438
563
|
|
|
@@ -450,6 +575,7 @@ describe(isNonNullish, () => {
|
|
|
450
575
|
];
|
|
451
576
|
|
|
452
577
|
const definedItems = items.filter(isNonNullish);
|
|
578
|
+
|
|
453
579
|
expectType<typeof definedItems, string[]>('<=');
|
|
454
580
|
|
|
455
581
|
expect(definedItems).toHaveLength(3);
|
|
@@ -459,6 +585,7 @@ describe(isNonNullish, () => {
|
|
|
459
585
|
|
|
460
586
|
test('should handle complex union types', () => {
|
|
461
587
|
type ComplexType = string | number | boolean | null | undefined;
|
|
588
|
+
|
|
462
589
|
const value: ComplexType = 42;
|
|
463
590
|
|
|
464
591
|
if (isNonNullish(value)) {
|
|
@@ -494,12 +621,15 @@ describe('type guard behavior in complex scenarios', () => {
|
|
|
494
621
|
];
|
|
495
622
|
|
|
496
623
|
const nonNullish = mixed.filter(isNonNullish);
|
|
624
|
+
|
|
497
625
|
expectType<typeof nonNullish, (string | number | boolean)[]>('<=');
|
|
498
626
|
|
|
499
627
|
const nonBooleans = nonNullish.filter(isNotBoolean);
|
|
628
|
+
|
|
500
629
|
expectType<typeof nonBooleans, (string | number)[]>('<=');
|
|
501
630
|
|
|
502
631
|
const strings = nonBooleans.filter(isNotNumber);
|
|
632
|
+
|
|
503
633
|
expectType<typeof strings, string[]>('<=');
|
|
504
634
|
|
|
505
635
|
assert.deepStrictEqual(strings, ['hello', 'world']);
|