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
|
@@ -13,18 +13,25 @@ import {
|
|
|
13
13
|
describe('Arr validations', () => {
|
|
14
14
|
describe(isArray, () => {
|
|
15
15
|
test('should return true for arrays', () => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
assert.isTrue(isArray([1, 2, 3]));
|
|
17
|
+
|
|
18
|
+
assert.isTrue(isArray([]));
|
|
19
|
+
|
|
20
|
+
assert.isTrue(isArray(['a', 'b']));
|
|
19
21
|
});
|
|
20
22
|
|
|
21
23
|
test('should return false for non-arrays', () => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
assert.isFalse(isArray('hello'));
|
|
25
|
+
|
|
26
|
+
assert.isFalse(isArray(123));
|
|
27
|
+
|
|
28
|
+
assert.isFalse(isArray(null));
|
|
29
|
+
|
|
30
|
+
assert.isFalse(isArray(undefined));
|
|
31
|
+
|
|
32
|
+
assert.isFalse(isArray({}));
|
|
33
|
+
|
|
34
|
+
assert.isFalse(isArray(new Set()));
|
|
28
35
|
});
|
|
29
36
|
|
|
30
37
|
test('should refine union types correctly', () => {
|
|
@@ -34,18 +41,23 @@ describe('Arr validations', () => {
|
|
|
34
41
|
if (isArray(value)) {
|
|
35
42
|
// value should be typed as number[]
|
|
36
43
|
expectType<typeof value, readonly number[]>('=');
|
|
44
|
+
|
|
37
45
|
return value.length;
|
|
38
46
|
}
|
|
47
|
+
|
|
39
48
|
return 0;
|
|
40
49
|
};
|
|
41
50
|
|
|
42
51
|
expect(processValue([1, 2, 3])).toBe(3);
|
|
52
|
+
|
|
43
53
|
expect(processValue('hello')).toBe(0);
|
|
54
|
+
|
|
44
55
|
expect(processValue(null)).toBe(0);
|
|
45
56
|
});
|
|
46
57
|
|
|
47
58
|
test('should work with readonly arrays', () => {
|
|
48
59
|
const readonlyArray: readonly number[] = [1, 2, 3];
|
|
60
|
+
|
|
49
61
|
if (isArray(readonlyArray)) {
|
|
50
62
|
expectType<typeof readonlyArray, readonly number[]>('=');
|
|
51
63
|
|
|
@@ -55,6 +67,7 @@ describe('Arr validations', () => {
|
|
|
55
67
|
|
|
56
68
|
test('should work with mutable arrays', () => {
|
|
57
69
|
const mutableArray: number[] = [1, 2, 3];
|
|
70
|
+
|
|
58
71
|
if (isArray(mutableArray)) {
|
|
59
72
|
expectType<typeof mutableArray, number[]>('=');
|
|
60
73
|
|
|
@@ -69,18 +82,24 @@ describe('Arr validations', () => {
|
|
|
69
82
|
if (isArray(value)) {
|
|
70
83
|
// Only number[] should remain
|
|
71
84
|
expectType<typeof value, readonly number[]>('=');
|
|
85
|
+
|
|
72
86
|
return value.length;
|
|
73
87
|
}
|
|
88
|
+
|
|
74
89
|
// Non-array types
|
|
75
90
|
expectType<typeof value, string | boolean | Readonly<{ a: number }>>(
|
|
76
91
|
'=',
|
|
77
92
|
);
|
|
93
|
+
|
|
78
94
|
return -1;
|
|
79
95
|
};
|
|
80
96
|
|
|
81
97
|
expect(checkUnion([1, 2])).toBe(2);
|
|
98
|
+
|
|
82
99
|
expect(checkUnion('test')).toBe(-1);
|
|
100
|
+
|
|
83
101
|
expect(checkUnion(true)).toBe(-1);
|
|
102
|
+
|
|
84
103
|
expect(checkUnion({ a: 1 })).toBe(-1);
|
|
85
104
|
});
|
|
86
105
|
|
|
@@ -97,38 +116,51 @@ describe('Arr validations', () => {
|
|
|
97
116
|
if (isArray(value)) {
|
|
98
117
|
// Only number[] should remain
|
|
99
118
|
expectType<typeof value, readonly unknown[]>('=');
|
|
119
|
+
|
|
100
120
|
return value.length;
|
|
101
121
|
}
|
|
122
|
+
|
|
102
123
|
// Non-array types
|
|
103
124
|
expectType<
|
|
104
125
|
typeof value,
|
|
105
126
|
string | boolean | Readonly<{ a: number }> | unknown | object
|
|
106
127
|
>('=');
|
|
128
|
+
|
|
107
129
|
return -1;
|
|
108
130
|
};
|
|
109
131
|
|
|
110
132
|
expect(checkUnion([1, 2])).toBe(2);
|
|
133
|
+
|
|
111
134
|
expect(checkUnion('test')).toBe(-1);
|
|
135
|
+
|
|
112
136
|
expect(checkUnion(true)).toBe(-1);
|
|
137
|
+
|
|
113
138
|
expect(checkUnion({ a: 1 })).toBe(-1);
|
|
114
139
|
});
|
|
115
140
|
|
|
116
141
|
test('should return true for arrays (additional)', () => {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
142
|
+
assert.isTrue(isArray([]));
|
|
143
|
+
|
|
144
|
+
assert.isTrue(isArray([1, 2, 3]));
|
|
145
|
+
|
|
146
|
+
assert.isTrue(isArray(['a', 'b']));
|
|
120
147
|
});
|
|
121
148
|
|
|
122
149
|
test('should return false for non-arrays (additional)', () => {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
150
|
+
assert.isFalse(isArray('string'));
|
|
151
|
+
|
|
152
|
+
assert.isFalse(isArray(123));
|
|
153
|
+
|
|
154
|
+
assert.isFalse(isArray({}));
|
|
155
|
+
|
|
156
|
+
assert.isFalse(isArray(null));
|
|
157
|
+
|
|
158
|
+
assert.isFalse(isArray(undefined));
|
|
128
159
|
});
|
|
129
160
|
|
|
130
161
|
test('should work as type guard (additional)', () => {
|
|
131
162
|
const value: unknown = [1, 2, 3];
|
|
163
|
+
|
|
132
164
|
if (isArray(value)) {
|
|
133
165
|
expectType<typeof value, readonly unknown[]>('=');
|
|
134
166
|
|
|
@@ -139,12 +171,13 @@ describe('Arr validations', () => {
|
|
|
139
171
|
test('should handle array-like objects', () => {
|
|
140
172
|
const arrayLike = { 0: 'a', 1: 'b', length: 2 };
|
|
141
173
|
|
|
142
|
-
|
|
174
|
+
assert.isFalse(isArray(arrayLike));
|
|
143
175
|
});
|
|
144
176
|
|
|
145
177
|
describe('comprehensive type guard tests', () => {
|
|
146
178
|
test('should narrow unknown type to array', () => {
|
|
147
179
|
const value: unknown = [1, 2, 3];
|
|
180
|
+
|
|
148
181
|
if (isArray(value)) {
|
|
149
182
|
expectType<typeof value, readonly unknown[]>('=');
|
|
150
183
|
} else {
|
|
@@ -154,6 +187,7 @@ describe('Arr validations', () => {
|
|
|
154
187
|
|
|
155
188
|
test('should handle any type', () => {
|
|
156
189
|
const value: any = [1, 2, 3];
|
|
190
|
+
|
|
157
191
|
if (isArray(value)) {
|
|
158
192
|
expectType<typeof value, readonly unknown[]>('=');
|
|
159
193
|
}
|
|
@@ -161,6 +195,7 @@ describe('Arr validations', () => {
|
|
|
161
195
|
|
|
162
196
|
test('should work with nested arrays', () => {
|
|
163
197
|
const nested: readonly (readonly number[])[] = [[1], [2], [3]];
|
|
198
|
+
|
|
164
199
|
if (isArray(nested)) {
|
|
165
200
|
expectType<typeof nested, readonly (readonly number[])[]>('=');
|
|
166
201
|
}
|
|
@@ -168,6 +203,7 @@ describe('Arr validations', () => {
|
|
|
168
203
|
|
|
169
204
|
test('should distinguish between array and tuple types', () => {
|
|
170
205
|
const tuple: readonly [1, 2, 3] = [1, 2, 3];
|
|
206
|
+
|
|
171
207
|
if (isArray(tuple)) {
|
|
172
208
|
expectType<typeof tuple, readonly [1, 2, 3]>('=');
|
|
173
209
|
}
|
|
@@ -175,6 +211,7 @@ describe('Arr validations', () => {
|
|
|
175
211
|
|
|
176
212
|
test('should work with empty tuple type', () => {
|
|
177
213
|
const emptyTuple: readonly [] = [];
|
|
214
|
+
|
|
178
215
|
if (isArray(emptyTuple)) {
|
|
179
216
|
expectType<typeof emptyTuple, readonly []>('=');
|
|
180
217
|
}
|
|
@@ -185,7 +222,9 @@ describe('Arr validations', () => {
|
|
|
185
222
|
| readonly string[]
|
|
186
223
|
| readonly number[]
|
|
187
224
|
| readonly boolean[];
|
|
225
|
+
|
|
188
226
|
const mixedArray: MixedArrayUnion = [1, 2, 3];
|
|
227
|
+
|
|
189
228
|
if (isArray(mixedArray)) {
|
|
190
229
|
expectType<typeof mixedArray, MixedArrayUnion>('<=');
|
|
191
230
|
}
|
|
@@ -197,16 +236,19 @@ describe('Arr validations', () => {
|
|
|
197
236
|
// Type is narrowed to array type within this block
|
|
198
237
|
return value.length;
|
|
199
238
|
}
|
|
239
|
+
|
|
200
240
|
return 0;
|
|
201
241
|
};
|
|
202
242
|
|
|
203
243
|
expect(processGeneric([1, 2, 3])).toBe(3);
|
|
244
|
+
|
|
204
245
|
expect(processGeneric('hello')).toBe(0);
|
|
205
246
|
});
|
|
206
247
|
|
|
207
248
|
test('should handle never type correctly', () => {
|
|
208
249
|
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
209
250
|
const neverValue = undefined as never;
|
|
251
|
+
|
|
210
252
|
if (isArray(neverValue)) {
|
|
211
253
|
expectType<typeof neverValue, never>('=');
|
|
212
254
|
}
|
|
@@ -214,22 +256,27 @@ describe('Arr validations', () => {
|
|
|
214
256
|
|
|
215
257
|
test('should work with conditional types', () => {
|
|
216
258
|
type ArrayOrValue<T> = T extends readonly unknown[] ? T : readonly T[];
|
|
259
|
+
|
|
217
260
|
const makeArray = <T,>(value: T): ArrayOrValue<T> => {
|
|
218
261
|
if (isArray(value)) {
|
|
219
262
|
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
220
263
|
return value as ArrayOrValue<T>;
|
|
221
264
|
}
|
|
265
|
+
|
|
222
266
|
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
223
267
|
return [value] as ArrayOrValue<T>;
|
|
224
268
|
};
|
|
225
269
|
|
|
226
270
|
assert.deepStrictEqual(makeArray([1, 2, 3]), [1, 2, 3]);
|
|
271
|
+
|
|
227
272
|
assert.deepStrictEqual(makeArray(5), [5]);
|
|
228
273
|
});
|
|
229
274
|
|
|
230
275
|
test('should handle intersection types', () => {
|
|
231
276
|
type TaggedArray = readonly number[] & { tag: string };
|
|
277
|
+
|
|
232
278
|
const tagged = Object.assign([1, 2, 3], { tag: 'test' }) as TaggedArray;
|
|
279
|
+
|
|
233
280
|
if (isArray(tagged)) {
|
|
234
281
|
expectType<typeof tagged, TaggedArray>('=');
|
|
235
282
|
|
|
@@ -239,8 +286,10 @@ describe('Arr validations', () => {
|
|
|
239
286
|
|
|
240
287
|
test('should work with branded types', () => {
|
|
241
288
|
type BrandedArray = readonly number[] & Readonly<{ __brand: unknown }>;
|
|
289
|
+
|
|
242
290
|
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
243
291
|
const branded = [1, 2, 3] as unknown as BrandedArray;
|
|
292
|
+
|
|
244
293
|
if (isArray(branded)) {
|
|
245
294
|
expectType<typeof branded, BrandedArray>('=');
|
|
246
295
|
}
|
|
@@ -258,32 +307,43 @@ describe('Arr validations', () => {
|
|
|
258
307
|
const processComplex = (value: ComplexUnion): number => {
|
|
259
308
|
if (isArray(value)) {
|
|
260
309
|
expectType<typeof value, readonly number[]>('=');
|
|
310
|
+
|
|
261
311
|
return value.length;
|
|
262
312
|
}
|
|
313
|
+
|
|
263
314
|
if (typeof value === 'string') {
|
|
264
315
|
expectType<typeof value, string>('=');
|
|
316
|
+
|
|
265
317
|
return value.length;
|
|
266
318
|
}
|
|
319
|
+
|
|
267
320
|
if (value === null) {
|
|
268
321
|
expectType<typeof value, null>('=');
|
|
322
|
+
|
|
269
323
|
return 0;
|
|
270
324
|
}
|
|
325
|
+
|
|
271
326
|
expectType<
|
|
272
327
|
typeof value,
|
|
273
328
|
| { type: 'array'; data: readonly string[] }
|
|
274
329
|
| { type: 'object'; data: Record<string, unknown> }
|
|
275
330
|
>('=');
|
|
331
|
+
|
|
276
332
|
return -1;
|
|
277
333
|
};
|
|
278
334
|
|
|
279
335
|
expect(processComplex([1, 2, 3])).toBe(3);
|
|
336
|
+
|
|
280
337
|
expect(processComplex('test')).toBe(4);
|
|
338
|
+
|
|
281
339
|
expect(processComplex(null)).toBe(0);
|
|
340
|
+
|
|
282
341
|
expect(processComplex({ type: 'array', data: ['a', 'b'] })).toBe(-1);
|
|
283
342
|
});
|
|
284
343
|
|
|
285
344
|
test('should preserve literal types in arrays', () => {
|
|
286
345
|
const literalArray = [1, 2, 3] as const;
|
|
346
|
+
|
|
287
347
|
if (isArray(literalArray)) {
|
|
288
348
|
expectType<typeof literalArray, readonly [1, 2, 3]>('=');
|
|
289
349
|
}
|
|
@@ -291,6 +351,7 @@ describe('Arr validations', () => {
|
|
|
291
351
|
|
|
292
352
|
test('should handle arrays with mixed element types', () => {
|
|
293
353
|
const mixed: readonly (string | number | boolean)[] = [1, 'two', true];
|
|
354
|
+
|
|
294
355
|
if (isArray(mixed)) {
|
|
295
356
|
expectType<typeof mixed, readonly (string | number | boolean)[]>('=');
|
|
296
357
|
}
|
|
@@ -298,7 +359,9 @@ describe('Arr validations', () => {
|
|
|
298
359
|
|
|
299
360
|
test('should work with symbol-keyed arrays', () => {
|
|
300
361
|
const sym = Symbol('test');
|
|
362
|
+
|
|
301
363
|
const arrWithSymbol = Object.assign([1, 2, 3], { [sym]: 'value' });
|
|
364
|
+
|
|
302
365
|
if (isArray(arrWithSymbol)) {
|
|
303
366
|
expect(arrWithSymbol).toHaveLength(3);
|
|
304
367
|
}
|
|
@@ -308,31 +371,33 @@ describe('Arr validations', () => {
|
|
|
308
371
|
|
|
309
372
|
describe(isEmpty, () => {
|
|
310
373
|
const xs = [1, 2, 3] as const;
|
|
374
|
+
|
|
311
375
|
const result = isEmpty(xs);
|
|
312
376
|
|
|
313
377
|
expectType<typeof result, boolean>('=');
|
|
314
378
|
|
|
315
379
|
test('case 1', () => {
|
|
316
|
-
|
|
380
|
+
assert.isFalse(result);
|
|
317
381
|
});
|
|
318
382
|
|
|
319
383
|
test('case 2', () => {
|
|
320
|
-
|
|
384
|
+
assert.isTrue(isEmpty([]));
|
|
321
385
|
});
|
|
322
386
|
});
|
|
323
387
|
|
|
324
388
|
describe(isNonEmpty, () => {
|
|
325
389
|
const xs = [1, 2, 3] as const;
|
|
390
|
+
|
|
326
391
|
const result = isNonEmpty(xs);
|
|
327
392
|
|
|
328
393
|
expectType<typeof result, boolean>('=');
|
|
329
394
|
|
|
330
395
|
test('case 1', () => {
|
|
331
|
-
|
|
396
|
+
assert.isTrue(result);
|
|
332
397
|
});
|
|
333
398
|
|
|
334
399
|
test('case 2', () => {
|
|
335
|
-
|
|
400
|
+
assert.isFalse(isNonEmpty([]));
|
|
336
401
|
});
|
|
337
402
|
});
|
|
338
403
|
|
|
@@ -340,7 +405,7 @@ describe('Arr validations', () => {
|
|
|
340
405
|
test('should return true if array has specified length', () => {
|
|
341
406
|
const arr = [1, 2, 3] as const;
|
|
342
407
|
|
|
343
|
-
|
|
408
|
+
assert.isTrue(isArrayOfLength(arr, 3));
|
|
344
409
|
|
|
345
410
|
if (isArrayOfLength(arr, 3)) {
|
|
346
411
|
expectType<typeof arr, readonly [1, 2, 3]>('=');
|
|
@@ -350,13 +415,13 @@ describe('Arr validations', () => {
|
|
|
350
415
|
test('should return false if array does not have specified length', () => {
|
|
351
416
|
const arr = [1, 2, 3] as const;
|
|
352
417
|
|
|
353
|
-
|
|
418
|
+
assert.isFalse(isArrayOfLength(arr, 2));
|
|
354
419
|
});
|
|
355
420
|
|
|
356
421
|
test('should return true for empty array and length 0', () => {
|
|
357
422
|
const arr = [] as const;
|
|
358
423
|
|
|
359
|
-
|
|
424
|
+
assert.isTrue(isArrayOfLength(arr, 0));
|
|
360
425
|
|
|
361
426
|
if (isArrayOfLength(arr, 0)) {
|
|
362
427
|
expectType<typeof arr, readonly []>('=');
|
|
@@ -366,47 +431,52 @@ describe('Arr validations', () => {
|
|
|
366
431
|
test('should return false for non-empty array and length 0', () => {
|
|
367
432
|
const arr = [1] as const;
|
|
368
433
|
|
|
369
|
-
|
|
434
|
+
assert.isFalse(isArrayOfLength(arr, 0));
|
|
370
435
|
});
|
|
371
436
|
|
|
372
437
|
test('should work with unknown array type', () => {
|
|
373
438
|
const arr: number[] = [1, 2];
|
|
374
439
|
|
|
375
|
-
|
|
440
|
+
assert.isTrue(isArrayOfLength(arr, 2));
|
|
376
441
|
|
|
377
442
|
if (isArrayOfLength(arr, 2)) {
|
|
378
443
|
expectType<typeof arr, number[] & ArrayOfLength<2, number>>('=');
|
|
379
444
|
}
|
|
380
445
|
|
|
381
|
-
|
|
446
|
+
assert.isFalse(isArrayOfLength(arr, 3));
|
|
382
447
|
});
|
|
383
448
|
|
|
384
449
|
test('should work with unknown readonly array type', () => {
|
|
385
450
|
const arr: readonly number[] = [1, 2];
|
|
386
451
|
|
|
387
|
-
|
|
452
|
+
assert.isTrue(isArrayOfLength(arr, 2));
|
|
388
453
|
|
|
389
454
|
if (isArrayOfLength(arr, 2)) {
|
|
390
455
|
expectType<typeof arr, ArrayOfLength<2, number>>('=');
|
|
391
456
|
}
|
|
392
457
|
|
|
393
|
-
|
|
458
|
+
assert.isFalse(isArrayOfLength(arr, 3));
|
|
394
459
|
});
|
|
395
460
|
|
|
396
461
|
test('should return true for arrays of exact length (additional)', () => {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
462
|
+
assert.isTrue(isArrayOfLength([1, 2, 3], 3));
|
|
463
|
+
|
|
464
|
+
assert.isTrue(isArrayOfLength([], 0));
|
|
465
|
+
|
|
466
|
+
assert.isTrue(isArrayOfLength(['a'], 1));
|
|
400
467
|
});
|
|
401
468
|
|
|
402
469
|
test('should return false for arrays of different length (additional)', () => {
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
470
|
+
assert.isFalse(isArrayOfLength([1, 2, 3], 2));
|
|
471
|
+
|
|
472
|
+
assert.isFalse(isArrayOfLength([1, 2, 3], 4));
|
|
473
|
+
|
|
474
|
+
assert.isFalse(isArrayOfLength([], 1));
|
|
406
475
|
});
|
|
407
476
|
|
|
408
477
|
test('should work as type guard with exact length (additional)', () => {
|
|
409
478
|
const array: readonly number[] = [1, 2, 3];
|
|
479
|
+
|
|
410
480
|
if (isArrayOfLength(array, 3)) {
|
|
411
481
|
expectType<typeof array, ArrayOfLength<3, number>>('=');
|
|
412
482
|
|
|
@@ -419,13 +489,13 @@ describe('Arr validations', () => {
|
|
|
419
489
|
test('should return true if array length is greater than or equal to specified length', () => {
|
|
420
490
|
const arr = [1, 2, 3] as const;
|
|
421
491
|
|
|
422
|
-
|
|
492
|
+
assert.isTrue(isArrayAtLeastLength(arr, 3));
|
|
423
493
|
|
|
424
494
|
if (isArrayAtLeastLength(arr, 3)) {
|
|
425
495
|
expectType<typeof arr, readonly [1, 2, 3]>('=');
|
|
426
496
|
}
|
|
427
497
|
|
|
428
|
-
|
|
498
|
+
assert.isTrue(isArrayAtLeastLength(arr, 2));
|
|
429
499
|
|
|
430
500
|
if (isArrayAtLeastLength(arr, 2)) {
|
|
431
501
|
expectType<typeof arr, readonly [1, 2, 3]>('=');
|
|
@@ -435,13 +505,13 @@ describe('Arr validations', () => {
|
|
|
435
505
|
test('should return false if array length is less than specified length', () => {
|
|
436
506
|
const arr = [1, 2, 3] as const;
|
|
437
507
|
|
|
438
|
-
|
|
508
|
+
assert.isFalse(isArrayAtLeastLength(arr, 4));
|
|
439
509
|
});
|
|
440
510
|
|
|
441
511
|
test('should return true for empty array and length 0', () => {
|
|
442
512
|
const arr = [] as const;
|
|
443
513
|
|
|
444
|
-
|
|
514
|
+
assert.isTrue(isArrayAtLeastLength(arr, 0));
|
|
445
515
|
|
|
446
516
|
if (isArrayAtLeastLength(arr, 0)) {
|
|
447
517
|
expectType<typeof arr, readonly []>('=');
|
|
@@ -451,41 +521,48 @@ describe('Arr validations', () => {
|
|
|
451
521
|
test('should return false for empty array and positive length', () => {
|
|
452
522
|
const arr = [] as const;
|
|
453
523
|
|
|
454
|
-
|
|
524
|
+
assert.isFalse(isArrayAtLeastLength(arr, 1));
|
|
455
525
|
});
|
|
456
526
|
|
|
457
527
|
test('should work with unknown array type', () => {
|
|
458
528
|
const arr: number[] = [1, 2];
|
|
459
529
|
|
|
460
|
-
|
|
530
|
+
assert.isTrue(isArrayAtLeastLength(arr, 2));
|
|
461
531
|
|
|
462
|
-
|
|
463
|
-
expectType<typeof arr, number[] & ArrayAtLeastLen<2, number>>('=');
|
|
464
|
-
}
|
|
532
|
+
expectType<typeof arr, number[] & ArrayAtLeastLen<2, number>>('=');
|
|
465
533
|
|
|
466
|
-
|
|
534
|
+
assert.isFalse(isArrayAtLeastLength(arr, 3));
|
|
535
|
+
});
|
|
467
536
|
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
}
|
|
537
|
+
test('should work with unknown array type 2', () => {
|
|
538
|
+
const arr: number[] = [1, 2];
|
|
471
539
|
|
|
472
|
-
|
|
540
|
+
assert.isTrue(isArrayAtLeastLength(arr, 1));
|
|
541
|
+
|
|
542
|
+
expectType<typeof arr, number[] & ArrayAtLeastLen<1, number>>('=');
|
|
543
|
+
|
|
544
|
+
assert.isFalse(isArrayAtLeastLength(arr, 3));
|
|
473
545
|
});
|
|
474
546
|
|
|
475
547
|
test('should return true for arrays of at least specified length (additional)', () => {
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
548
|
+
assert.isTrue(isArrayAtLeastLength([1, 2, 3], 3));
|
|
549
|
+
|
|
550
|
+
assert.isTrue(isArrayAtLeastLength([1, 2, 3], 2));
|
|
551
|
+
|
|
552
|
+
assert.isTrue(isArrayAtLeastLength([1, 2, 3], 1));
|
|
553
|
+
|
|
554
|
+
assert.isTrue(isArrayAtLeastLength([1, 2, 3], 0));
|
|
480
555
|
});
|
|
481
556
|
|
|
482
557
|
test('should return false for arrays shorter than specified length (additional)', () => {
|
|
483
|
-
|
|
484
|
-
|
|
558
|
+
assert.isFalse(isArrayAtLeastLength([1, 2, 3], 4));
|
|
559
|
+
|
|
560
|
+
assert.isFalse(isArrayAtLeastLength([], 1));
|
|
485
561
|
});
|
|
486
562
|
|
|
487
563
|
test('should work as type guard for at least length (additional)', () => {
|
|
488
564
|
const array: readonly number[] = [1, 2, 3];
|
|
565
|
+
|
|
489
566
|
if (isArrayAtLeastLength(array, 2)) {
|
|
490
567
|
expectType<typeof array, ArrayAtLeastLen<2, number>>('=');
|
|
491
568
|
|
|
@@ -497,38 +574,46 @@ describe('Arr validations', () => {
|
|
|
497
574
|
describe(every, () => {
|
|
498
575
|
test('should return true when all elements satisfy predicate', () => {
|
|
499
576
|
const evens = [2, 4, 6, 8];
|
|
577
|
+
|
|
500
578
|
const allEven = every(evens, (n) => n % 2 === 0);
|
|
501
579
|
|
|
502
|
-
|
|
580
|
+
assert.isTrue(allEven);
|
|
503
581
|
});
|
|
504
582
|
|
|
505
583
|
test('should return false when not all elements satisfy predicate', () => {
|
|
506
584
|
const mixed = [2, 3, 4, 6];
|
|
585
|
+
|
|
507
586
|
const allEven = every(mixed, (n) => n % 2 === 0);
|
|
508
587
|
|
|
509
|
-
|
|
588
|
+
assert.isFalse(allEven);
|
|
510
589
|
});
|
|
511
590
|
|
|
512
591
|
test('should work as type guard', () => {
|
|
513
592
|
const mixed: (string | number)[] = ['hello', 'world'];
|
|
593
|
+
|
|
514
594
|
if (every(mixed, (x): x is string => typeof x === 'string')) {
|
|
515
595
|
// TypeScript narrows mixed to readonly string[] here
|
|
516
|
-
|
|
596
|
+
assert.isTrue(mixed.every((s) => typeof s === 'string'));
|
|
517
597
|
}
|
|
518
598
|
});
|
|
519
599
|
|
|
520
600
|
test('should work with curried version', () => {
|
|
521
601
|
const isPositive = (n: number): boolean => n > 0;
|
|
602
|
+
|
|
522
603
|
const allPositive = every(isPositive);
|
|
523
604
|
|
|
524
|
-
|
|
525
|
-
|
|
605
|
+
assert.isTrue(allPositive([1, 2, 3]));
|
|
606
|
+
|
|
607
|
+
assert.isFalse(allPositive([1, -2, 3]));
|
|
526
608
|
});
|
|
527
609
|
|
|
528
610
|
test('should work with curried type guards', () => {
|
|
529
611
|
const isString = (x: unknown): x is string => typeof x === 'string';
|
|
612
|
+
|
|
530
613
|
const allStrings = every(isString);
|
|
614
|
+
|
|
531
615
|
const data: unknown[] = ['a', 'b', 'c'];
|
|
616
|
+
|
|
532
617
|
if (allStrings(data)) {
|
|
533
618
|
// TypeScript narrows data to readonly string[] here
|
|
534
619
|
expect(data.join('')).toBe('abc');
|
|
@@ -537,57 +622,65 @@ describe('Arr validations', () => {
|
|
|
537
622
|
|
|
538
623
|
test('should return true for empty array', () => {
|
|
539
624
|
const empty: number[] = [];
|
|
625
|
+
|
|
540
626
|
const result = every(empty, (n) => n > 0);
|
|
541
627
|
|
|
542
|
-
|
|
628
|
+
assert.isTrue(result);
|
|
543
629
|
});
|
|
544
630
|
|
|
545
631
|
test('should pass index to predicate', () => {
|
|
546
632
|
const numbers = [0, 1, 2, 3];
|
|
633
|
+
|
|
547
634
|
const indexMatchesValue = every(numbers, (val, idx) => val === idx);
|
|
548
635
|
|
|
549
|
-
|
|
636
|
+
assert.isTrue(indexMatchesValue);
|
|
550
637
|
});
|
|
551
638
|
});
|
|
552
639
|
|
|
553
640
|
describe(some, () => {
|
|
554
641
|
test('should return true when at least one element satisfies predicate', () => {
|
|
555
642
|
const numbers = [1, 3, 5, 8];
|
|
643
|
+
|
|
556
644
|
const hasEven = some(numbers, (n) => n % 2 === 0);
|
|
557
645
|
|
|
558
|
-
|
|
646
|
+
assert.isTrue(hasEven);
|
|
559
647
|
});
|
|
560
648
|
|
|
561
649
|
test('should return false when no elements satisfy predicate', () => {
|
|
562
650
|
const odds = [1, 3, 5, 7];
|
|
651
|
+
|
|
563
652
|
const hasEven = some(odds, (n) => n % 2 === 0);
|
|
564
653
|
|
|
565
|
-
|
|
654
|
+
assert.isFalse(hasEven);
|
|
566
655
|
});
|
|
567
656
|
|
|
568
657
|
test('should work with curried version', () => {
|
|
569
658
|
const isNegative = (n: number): boolean => n < 0;
|
|
659
|
+
|
|
570
660
|
const hasNegative = some(isNegative);
|
|
571
661
|
|
|
572
|
-
|
|
573
|
-
|
|
662
|
+
assert.isTrue(hasNegative([1, 2, -3]));
|
|
663
|
+
|
|
664
|
+
assert.isFalse(hasNegative([1, 2, 3]));
|
|
574
665
|
});
|
|
575
666
|
|
|
576
667
|
test('should return false for empty array', () => {
|
|
577
668
|
const empty: number[] = [];
|
|
669
|
+
|
|
578
670
|
const result = some(empty, (n) => n > 0);
|
|
579
671
|
|
|
580
|
-
|
|
672
|
+
assert.isFalse(result);
|
|
581
673
|
});
|
|
582
674
|
|
|
583
675
|
test('should pass index to predicate', () => {
|
|
584
676
|
const numbers = [10, 10, 10, 30];
|
|
677
|
+
|
|
585
678
|
const hasValueMatchingIndex = some(
|
|
586
679
|
numbers,
|
|
587
680
|
(val, idx) => val === idx * 10,
|
|
588
681
|
);
|
|
589
682
|
|
|
590
|
-
|
|
683
|
+
assert.isTrue(hasValueMatchingIndex);
|
|
591
684
|
});
|
|
592
685
|
});
|
|
593
686
|
|
|
@@ -595,33 +688,38 @@ describe('Arr validations', () => {
|
|
|
595
688
|
test('should return true for valid indices', () => {
|
|
596
689
|
const array = ['a', 'b', 'c'];
|
|
597
690
|
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
691
|
+
assert.isTrue(indexIsInRange(array, 0));
|
|
692
|
+
|
|
693
|
+
assert.isTrue(indexIsInRange(array, 1));
|
|
694
|
+
|
|
695
|
+
assert.isTrue(indexIsInRange(array, 2));
|
|
601
696
|
});
|
|
602
697
|
|
|
603
698
|
test('should return false for invalid indices', () => {
|
|
604
699
|
const array = ['a', 'b', 'c'];
|
|
605
700
|
|
|
606
|
-
|
|
607
|
-
|
|
701
|
+
assert.isFalse(indexIsInRange(array, 3));
|
|
702
|
+
|
|
703
|
+
assert.isFalse(indexIsInRange(array, 10));
|
|
608
704
|
});
|
|
609
705
|
|
|
610
706
|
test('should work with empty array', () => {
|
|
611
707
|
const empty: readonly string[] = [];
|
|
612
708
|
|
|
613
|
-
|
|
709
|
+
assert.isFalse(indexIsInRange(empty, 0));
|
|
710
|
+
|
|
614
711
|
// @ts-expect-error negative indices should not be allowed
|
|
615
|
-
|
|
712
|
+
assert.isFalse(indexIsInRange(empty, -1));
|
|
616
713
|
});
|
|
617
714
|
|
|
618
715
|
test('should be type error with floating point indices', () => {
|
|
619
716
|
const array = [1, 2, 3];
|
|
620
717
|
|
|
621
718
|
// @ts-expect-error floating point indices should not be allowed
|
|
622
|
-
|
|
719
|
+
assert.isTrue(indexIsInRange(array, 1.5)); // JavaScript arrays accept floating point indices
|
|
720
|
+
|
|
623
721
|
// @ts-expect-error floating point indices should not be allowed
|
|
624
|
-
|
|
722
|
+
assert.isFalse(indexIsInRange(array, 3.1));
|
|
625
723
|
});
|
|
626
724
|
});
|
|
627
725
|
});
|