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
package/src/number/num.test.mts
CHANGED
|
@@ -16,16 +16,22 @@ const testClamp = (
|
|
|
16
16
|
describe('Num test', () => {
|
|
17
17
|
describe('clamp', () => {
|
|
18
18
|
testClamp([0, 2], 2.3, 2);
|
|
19
|
+
|
|
19
20
|
testClamp([0, 2], -0.5, 0);
|
|
21
|
+
|
|
20
22
|
testClamp([0, 2], 1.5, 1.5);
|
|
23
|
+
|
|
21
24
|
testClamp([0, 2], Number.NaN, 0);
|
|
22
25
|
|
|
23
26
|
test('should support regular usage with three parameters', () => {
|
|
24
27
|
expectTypeOf(Num.clamp(15, 0, 10)).toEqualTypeOf<number>();
|
|
25
28
|
|
|
26
29
|
expect(Num.clamp(15, 0, 10)).toBe(10);
|
|
30
|
+
|
|
27
31
|
expect(Num.clamp(-5, 0, 10)).toBe(0);
|
|
32
|
+
|
|
28
33
|
expect(Num.clamp(5, 0, 10)).toBe(5);
|
|
34
|
+
|
|
29
35
|
expect(Num.clamp(Number.NaN, 0, 10)).toBe(0);
|
|
30
36
|
});
|
|
31
37
|
|
|
@@ -52,19 +58,25 @@ describe('Num test', () => {
|
|
|
52
58
|
|
|
53
59
|
// Invalid (non-finite) values return the lower bound
|
|
54
60
|
expect(clampTo5_15(Number.POSITIVE_INFINITY)).toBe(5);
|
|
61
|
+
|
|
55
62
|
expect(clampTo5_15(Number.NEGATIVE_INFINITY)).toBe(5);
|
|
63
|
+
|
|
56
64
|
expect(clampTo5_15(Number.NaN)).toBe(5);
|
|
57
65
|
});
|
|
58
66
|
|
|
59
67
|
test('should work with negative ranges', () => {
|
|
60
68
|
expect(Num.clamp(-15, -10, -5)).toBe(-10);
|
|
69
|
+
|
|
61
70
|
expect(Num.clamp(-7, -10, -5)).toBe(-7);
|
|
71
|
+
|
|
62
72
|
expect(Num.clamp(0, -10, -5)).toBe(-5);
|
|
63
73
|
|
|
64
74
|
const clampNegative = Num.clamp(-10, -5);
|
|
65
75
|
|
|
66
76
|
expect(clampNegative(-15)).toBe(-10);
|
|
77
|
+
|
|
67
78
|
expect(clampNegative(-7)).toBe(-7);
|
|
79
|
+
|
|
68
80
|
expect(clampNegative(0)).toBe(-5);
|
|
69
81
|
});
|
|
70
82
|
});
|
|
@@ -72,40 +84,49 @@ describe('Num test', () => {
|
|
|
72
84
|
describe('isUintInRangeInclusive', () => {
|
|
73
85
|
test('truthy case', () => {
|
|
74
86
|
const f = Num.isUintInRangeInclusive(0, 4);
|
|
87
|
+
|
|
75
88
|
const x: number = 2;
|
|
89
|
+
|
|
76
90
|
if (f(x)) {
|
|
77
91
|
expectType<typeof x, 0 | 1 | 2 | 3 | 4>('=');
|
|
78
92
|
} else {
|
|
79
93
|
expectType<typeof x, number>('=');
|
|
80
94
|
}
|
|
81
95
|
|
|
82
|
-
|
|
96
|
+
assert.isTrue(f(x));
|
|
83
97
|
});
|
|
84
98
|
|
|
85
99
|
test('falsy case', () => {
|
|
86
100
|
const f = Num.isUintInRangeInclusive(0, 4);
|
|
101
|
+
|
|
87
102
|
const x: number = 100;
|
|
103
|
+
|
|
88
104
|
if (f(x)) {
|
|
89
105
|
expectType<typeof x, 0 | 1 | 2 | 3 | 4>('=');
|
|
90
106
|
} else {
|
|
91
107
|
expectType<typeof x, number>('=');
|
|
92
108
|
}
|
|
93
109
|
|
|
94
|
-
|
|
110
|
+
assert.isFalse(f(x));
|
|
95
111
|
});
|
|
96
112
|
});
|
|
97
113
|
|
|
98
114
|
describe('from', () => {
|
|
99
115
|
test('converts string to number', () => {
|
|
100
116
|
expect(Num.from('123')).toBe(123);
|
|
117
|
+
|
|
101
118
|
expect(Num.from('123.45')).toBe(123.45);
|
|
119
|
+
|
|
102
120
|
expect(Num.from('-42')).toBe(-42);
|
|
103
121
|
});
|
|
104
122
|
|
|
105
123
|
test('handles edge cases', () => {
|
|
106
124
|
expect(Num.from('')).toBe(0);
|
|
125
|
+
|
|
107
126
|
expect(Num.from('abc')).toBeNaN();
|
|
127
|
+
|
|
108
128
|
expect(Num.from(true)).toBe(1);
|
|
129
|
+
|
|
109
130
|
expect(Num.from(false)).toBe(0);
|
|
110
131
|
});
|
|
111
132
|
});
|
|
@@ -114,11 +135,15 @@ describe('Num test', () => {
|
|
|
114
135
|
test('checks range (lower inclusive, upper exclusive)', () => {
|
|
115
136
|
const inRange = Num.isInRange(0, 10);
|
|
116
137
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
138
|
+
assert.isTrue(inRange(5));
|
|
139
|
+
|
|
140
|
+
assert.isTrue(inRange(0)); // inclusive lower bound
|
|
141
|
+
|
|
142
|
+
assert.isFalse(inRange(10)); // exclusive upper bound
|
|
143
|
+
|
|
144
|
+
assert.isFalse(inRange(-1));
|
|
145
|
+
|
|
146
|
+
assert.isFalse(inRange(15));
|
|
122
147
|
});
|
|
123
148
|
});
|
|
124
149
|
|
|
@@ -126,11 +151,15 @@ describe('Num test', () => {
|
|
|
126
151
|
test('checks range (inclusive)', () => {
|
|
127
152
|
const inRange = Num.isInRangeInclusive(0, 10);
|
|
128
153
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
154
|
+
assert.isTrue(inRange(5));
|
|
155
|
+
|
|
156
|
+
assert.isTrue(inRange(0)); // inclusive
|
|
157
|
+
|
|
158
|
+
assert.isTrue(inRange(10)); // inclusive
|
|
159
|
+
|
|
160
|
+
assert.isFalse(inRange(-1));
|
|
161
|
+
|
|
162
|
+
assert.isFalse(inRange(15));
|
|
134
163
|
});
|
|
135
164
|
});
|
|
136
165
|
|
|
@@ -138,47 +167,60 @@ describe('Num test', () => {
|
|
|
138
167
|
test('checks uint range (lower inclusive, upper exclusive)', () => {
|
|
139
168
|
const inRange = Num.isUintInRange(0, 5);
|
|
140
169
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
170
|
+
assert.isTrue(inRange(2));
|
|
171
|
+
|
|
172
|
+
assert.isTrue(inRange(0)); // inclusive lower bound
|
|
173
|
+
|
|
174
|
+
assert.isFalse(inRange(5)); // exclusive upper bound
|
|
175
|
+
|
|
176
|
+
assert.isFalse(inRange(-1));
|
|
145
177
|
});
|
|
146
178
|
});
|
|
147
179
|
|
|
148
180
|
describe('isNonZero', () => {
|
|
149
181
|
test('type guard for non-zero numbers', () => {
|
|
150
182
|
const x: number = 5;
|
|
183
|
+
|
|
151
184
|
if (Num.isNonZero(x)) {
|
|
152
185
|
expectType<typeof x, NonZeroNumber>('=');
|
|
153
186
|
}
|
|
154
187
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
188
|
+
assert.isTrue(Num.isNonZero(5));
|
|
189
|
+
|
|
190
|
+
assert.isTrue(Num.isNonZero(-3));
|
|
191
|
+
|
|
192
|
+
assert.isFalse(Num.isNonZero(0));
|
|
158
193
|
});
|
|
159
194
|
});
|
|
160
195
|
|
|
161
196
|
describe('isNonNegative', () => {
|
|
162
197
|
test('type guard for non-negative numbers', () => {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
198
|
+
assert.isTrue(Num.isNonNegative(5));
|
|
199
|
+
|
|
200
|
+
assert.isTrue(Num.isNonNegative(0));
|
|
201
|
+
|
|
202
|
+
assert.isFalse(Num.isNonNegative(-1));
|
|
166
203
|
});
|
|
167
204
|
});
|
|
168
205
|
|
|
169
206
|
describe('isPositive', () => {
|
|
170
207
|
test('type guard for positive numbers', () => {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
208
|
+
assert.isTrue(Num.isPositive(5));
|
|
209
|
+
|
|
210
|
+
assert.isTrue(Num.isPositive(0.1));
|
|
211
|
+
|
|
212
|
+
assert.isFalse(Num.isPositive(0));
|
|
213
|
+
|
|
214
|
+
assert.isFalse(Num.isPositive(-1));
|
|
175
215
|
});
|
|
176
216
|
});
|
|
177
217
|
|
|
178
218
|
describe('div', () => {
|
|
179
219
|
test('basic division', () => {
|
|
180
220
|
expect(Num.div(10, 2)).toBe(5);
|
|
221
|
+
|
|
181
222
|
expect(Num.div(7, 3)).toBe(7 / 3);
|
|
223
|
+
|
|
182
224
|
expect(Num.div(-10, 2)).toBe(-5);
|
|
183
225
|
});
|
|
184
226
|
});
|
|
@@ -186,8 +228,11 @@ describe('Num test', () => {
|
|
|
186
228
|
describe('divInt', () => {
|
|
187
229
|
test('integer division (floor)', () => {
|
|
188
230
|
expect(Num.divInt(10, 3)).toBe(3);
|
|
231
|
+
|
|
189
232
|
expect(Num.divInt(7, 2)).toBe(3);
|
|
233
|
+
|
|
190
234
|
expect(Num.divInt(-7, 2)).toBe(-4); // floor division
|
|
235
|
+
|
|
191
236
|
expect(Num.divInt(10.7, asNonZeroFiniteNumber(3.2))).toBe(3); // floors both operands
|
|
192
237
|
});
|
|
193
238
|
});
|
|
@@ -195,8 +240,11 @@ describe('Num test', () => {
|
|
|
195
240
|
describe('roundAt', () => {
|
|
196
241
|
test('rounds to specified decimal places', () => {
|
|
197
242
|
expect(Num.roundAt(3.141_59, 2)).toBe(3.14);
|
|
243
|
+
|
|
198
244
|
expect(Num.roundAt(3.141_59, 3)).toBe(3.142);
|
|
245
|
+
|
|
199
246
|
expect(Num.roundAt(2.555, 2)).toBe(2.56);
|
|
247
|
+
|
|
200
248
|
expect(Num.roundAt(123.456, 1)).toBe(123.5);
|
|
201
249
|
});
|
|
202
250
|
});
|
|
@@ -204,9 +252,13 @@ describe('Num test', () => {
|
|
|
204
252
|
describe('roundToInt', () => {
|
|
205
253
|
test('rounds to nearest integer', () => {
|
|
206
254
|
expect(Num.roundToInt(3.4)).toBe(3);
|
|
255
|
+
|
|
207
256
|
expect(Num.roundToInt(3.6)).toBe(4);
|
|
257
|
+
|
|
208
258
|
expect(Num.roundToInt(2.5)).toBe(3);
|
|
259
|
+
|
|
209
260
|
expect(Num.roundToInt(-2.3)).toBe(-1); // bitwise behavior: -2.3 + 0.5 = -1.8, then floor with bitwise OR
|
|
261
|
+
|
|
210
262
|
expect(Num.roundToInt(-2.7)).toBe(-2); // bitwise behavior: -2.7 + 0.5 = -2.2, then floor with bitwise OR
|
|
211
263
|
});
|
|
212
264
|
});
|
|
@@ -216,16 +268,19 @@ describe('Num test', () => {
|
|
|
216
268
|
const round2 = Num.round(2);
|
|
217
269
|
|
|
218
270
|
expect(round2(3.141_59)).toBe(3.14);
|
|
271
|
+
|
|
219
272
|
expect(round2(2.556)).toBe(2.56);
|
|
220
273
|
|
|
221
274
|
const round1 = Num.round(1);
|
|
222
275
|
|
|
223
276
|
expect(round1(3.141_59)).toBe(3.1);
|
|
277
|
+
|
|
224
278
|
expect(round1(2.56)).toBe(2.6);
|
|
225
279
|
|
|
226
280
|
const round3 = Num.round(3);
|
|
227
281
|
|
|
228
282
|
expect(round3(3.1416)).toBe(3.142);
|
|
283
|
+
|
|
229
284
|
expect(round3(2.7182)).toBe(2.718);
|
|
230
285
|
});
|
|
231
286
|
});
|
|
@@ -233,8 +288,11 @@ describe('Num test', () => {
|
|
|
233
288
|
describe('mapNaN2Undefined', () => {
|
|
234
289
|
test('maps NaN to undefined', () => {
|
|
235
290
|
expect(Num.mapNaN2Undefined(5)).toBe(5);
|
|
291
|
+
|
|
236
292
|
expect(Num.mapNaN2Undefined(0)).toBe(0);
|
|
293
|
+
|
|
237
294
|
expect(Num.mapNaN2Undefined(-3.14)).toBe(-3.14);
|
|
295
|
+
|
|
238
296
|
expect(Num.mapNaN2Undefined(Number.NaN)).toBeUndefined();
|
|
239
297
|
});
|
|
240
298
|
});
|
|
@@ -242,7 +300,9 @@ describe('Num test', () => {
|
|
|
242
300
|
describe('increment', () => {
|
|
243
301
|
test('increments SmallUint values', () => {
|
|
244
302
|
expect(Num.increment(0)).toBe(1);
|
|
303
|
+
|
|
245
304
|
expect(Num.increment(5)).toBe(6);
|
|
305
|
+
|
|
246
306
|
expect(Num.increment(38)).toBe(39);
|
|
247
307
|
});
|
|
248
308
|
});
|
|
@@ -250,7 +310,9 @@ describe('Num test', () => {
|
|
|
250
310
|
describe('decrement', () => {
|
|
251
311
|
test('decrements PositiveSmallInt values', () => {
|
|
252
312
|
expect(Num.decrement(1)).toBe(0);
|
|
313
|
+
|
|
253
314
|
expect(Num.decrement(5)).toBe(4);
|
|
315
|
+
|
|
254
316
|
expect(Num.decrement(39)).toBe(38);
|
|
255
317
|
});
|
|
256
318
|
});
|
|
@@ -36,6 +36,7 @@ export namespace TsDataForgeInternals {
|
|
|
36
36
|
if (!is(a)) {
|
|
37
37
|
throw new TypeError(`Expected ${typeNameInErrorMessage}, got: ${a}`);
|
|
38
38
|
}
|
|
39
|
+
|
|
39
40
|
return a;
|
|
40
41
|
};
|
|
41
42
|
|
|
@@ -223,8 +224,8 @@ export namespace TsDataForgeInternals {
|
|
|
223
224
|
ElementType extends Int,
|
|
224
225
|
MIN_VALUE extends number,
|
|
225
226
|
MAX_VALUE extends number,
|
|
226
|
-
ElementTypeWithSmallInt extends
|
|
227
|
-
WithSmallInt<ElementType
|
|
227
|
+
ElementTypeWithSmallInt extends WithSmallInt<ElementType> =
|
|
228
|
+
WithSmallInt<ElementType>,
|
|
228
229
|
> = Readonly<{
|
|
229
230
|
MIN_VALUE: MIN_VALUE;
|
|
230
231
|
MAX_VALUE: MAX_VALUE;
|
|
@@ -308,20 +309,32 @@ export namespace TsDataForgeInternals {
|
|
|
308
309
|
* } as const);
|
|
309
310
|
*
|
|
310
311
|
* const six = intOps.castType(6);
|
|
312
|
+
*
|
|
311
313
|
* const four = intOps.castType(4);
|
|
314
|
+
*
|
|
312
315
|
* const sum = intOps.add(six, four);
|
|
316
|
+
*
|
|
313
317
|
* const difference = intOps.sub(six, four);
|
|
318
|
+
*
|
|
314
319
|
* const product = intOps.mul(six, four);
|
|
320
|
+
*
|
|
315
321
|
* const quotient = intOps.div(six, intOps.castType(2));
|
|
322
|
+
*
|
|
316
323
|
* const roundedClamp = intOps.clamp(1.5);
|
|
324
|
+
*
|
|
317
325
|
* const randomValue = intOps.random();
|
|
318
326
|
*
|
|
319
|
-
* assert(sum === 10);
|
|
320
|
-
*
|
|
321
|
-
* assert(
|
|
322
|
-
*
|
|
323
|
-
* assert(
|
|
324
|
-
*
|
|
327
|
+
* assert.isTrue(sum === 10);
|
|
328
|
+
*
|
|
329
|
+
* assert.isTrue(difference === 2);
|
|
330
|
+
*
|
|
331
|
+
* assert.isTrue(product === 24);
|
|
332
|
+
*
|
|
333
|
+
* assert.isTrue(quotient === 3);
|
|
334
|
+
*
|
|
335
|
+
* assert.isTrue(roundedClamp === 2);
|
|
336
|
+
*
|
|
337
|
+
* assert.isTrue(Number.isSafeInteger(randomValue));
|
|
325
338
|
* ```
|
|
326
339
|
*
|
|
327
340
|
* @template ElementType - The integer branded type
|
|
@@ -437,6 +450,7 @@ export namespace TsDataForgeInternals {
|
|
|
437
450
|
): ElementType => {
|
|
438
451
|
while (true) {
|
|
439
452
|
const r = randomImpl(min, max);
|
|
453
|
+
|
|
440
454
|
if (Num.isNonZero(r)) return clampOrCastFn(r);
|
|
441
455
|
}
|
|
442
456
|
};
|
|
@@ -522,21 +536,31 @@ export namespace TsDataForgeInternals {
|
|
|
522
536
|
* } as const);
|
|
523
537
|
*
|
|
524
538
|
* const fortyTwo = floatOps.castType(42.5);
|
|
539
|
+
*
|
|
525
540
|
* const seven = floatOps.castType(7.5);
|
|
541
|
+
*
|
|
526
542
|
* const sum = floatOps.add(fortyTwo, seven);
|
|
543
|
+
*
|
|
527
544
|
* const ratio = floatOps.div(sum, floatOps.castType(10));
|
|
545
|
+
*
|
|
528
546
|
* const clamped = floatOps.clamp(0);
|
|
547
|
+
*
|
|
529
548
|
* const boundedRandom = floatOps.random(
|
|
530
549
|
* floatOps.castType(10),
|
|
531
550
|
* floatOps.castType(20),
|
|
532
551
|
* );
|
|
552
|
+
*
|
|
533
553
|
* const nonZeroRandom = floatOps.randomNonZero();
|
|
534
554
|
*
|
|
535
|
-
* assert(sum === 50);
|
|
536
|
-
*
|
|
537
|
-
* assert.
|
|
538
|
-
*
|
|
539
|
-
* assert.
|
|
555
|
+
* assert.isTrue(sum === 50);
|
|
556
|
+
*
|
|
557
|
+
* assert.isTrue(ratio === 5);
|
|
558
|
+
*
|
|
559
|
+
* assert.isTrue(clamped >= Number.MIN_VALUE);
|
|
560
|
+
*
|
|
561
|
+
* assert.isTrue(boundedRandom >= 10 && boundedRandom <= 20);
|
|
562
|
+
*
|
|
563
|
+
* assert.isTrue(nonZeroRandom > 0);
|
|
540
564
|
* ```
|
|
541
565
|
*
|
|
542
566
|
* @template ElementType - The floating-point branded type
|
|
@@ -624,6 +648,7 @@ export namespace TsDataForgeInternals {
|
|
|
624
648
|
): ElementType => {
|
|
625
649
|
while (true) {
|
|
626
650
|
const r = random(min, max);
|
|
651
|
+
|
|
627
652
|
if (isNonZero(r)) return r;
|
|
628
653
|
}
|
|
629
654
|
};
|
package/src/object/object.mts
CHANGED
|
@@ -17,24 +17,29 @@ export namespace Obj {
|
|
|
17
17
|
*
|
|
18
18
|
* ```ts
|
|
19
19
|
* const obj1 = { name: 'Alice', age: 30 };
|
|
20
|
+
*
|
|
20
21
|
* const obj2 = { name: 'Alice', age: 30 };
|
|
22
|
+
*
|
|
21
23
|
* const obj3 = { name: 'Alice', age: 31 };
|
|
22
24
|
*
|
|
23
|
-
* assert.
|
|
24
|
-
*
|
|
25
|
+
* assert.isTrue(Obj.shallowEq(obj1, obj2));
|
|
26
|
+
*
|
|
27
|
+
* assert.isFalse(Obj.shallowEq(obj1, obj3));
|
|
25
28
|
*
|
|
26
29
|
* // Custom equality function
|
|
27
30
|
* const obj4 = { value: 1 };
|
|
31
|
+
*
|
|
28
32
|
* const obj5 = { value: 1.00001 };
|
|
29
33
|
*
|
|
30
34
|
* const closeEnough = (a: unknown, b: unknown): boolean => {
|
|
31
35
|
* if (typeof a === 'number' && typeof b === 'number') {
|
|
32
36
|
* return Math.abs(a - b) < 0.001;
|
|
33
37
|
* }
|
|
38
|
+
*
|
|
34
39
|
* return Object.is(a, b);
|
|
35
40
|
* };
|
|
36
41
|
*
|
|
37
|
-
* assert.
|
|
42
|
+
* assert.isTrue(Obj.shallowEq(obj4, obj5, closeEnough));
|
|
38
43
|
* ```
|
|
39
44
|
*
|
|
40
45
|
* @param a - The first record to compare
|
|
@@ -50,6 +55,7 @@ export namespace Obj {
|
|
|
50
55
|
eq: (x: unknown, y: unknown) => boolean = Object.is,
|
|
51
56
|
): boolean => {
|
|
52
57
|
const aEntries = Object.entries(a);
|
|
58
|
+
|
|
53
59
|
const bEntries = Object.entries(b);
|
|
54
60
|
|
|
55
61
|
if (aEntries.length !== bEntries.length) return false;
|
|
@@ -78,6 +84,7 @@ export namespace Obj {
|
|
|
78
84
|
*
|
|
79
85
|
* // Direct usage
|
|
80
86
|
* const publicInfo = Obj.pick(user, ['id', 'name', 'role']);
|
|
87
|
+
*
|
|
81
88
|
* assert.deepStrictEqual(publicInfo, {
|
|
82
89
|
* id: 1,
|
|
83
90
|
* name: 'Bob',
|
|
@@ -122,6 +129,7 @@ export namespace Obj {
|
|
|
122
129
|
switch (args.length) {
|
|
123
130
|
case 2: {
|
|
124
131
|
const [record, keys] = args;
|
|
132
|
+
|
|
125
133
|
const keysSet = new Set<keyof R>(keys);
|
|
126
134
|
|
|
127
135
|
return (
|
|
@@ -134,6 +142,7 @@ export namespace Obj {
|
|
|
134
142
|
|
|
135
143
|
case 1: {
|
|
136
144
|
const [keys] = args;
|
|
145
|
+
|
|
137
146
|
return (record: R) => pick(record, keys);
|
|
138
147
|
}
|
|
139
148
|
}
|
|
@@ -161,6 +170,7 @@ export namespace Obj {
|
|
|
161
170
|
*
|
|
162
171
|
* // Direct usage - remove sensitive fields
|
|
163
172
|
* const safeUser = Obj.omit(user, ['password', 'internalNote']);
|
|
173
|
+
*
|
|
164
174
|
* assert.deepStrictEqual(safeUser, {
|
|
165
175
|
* id: 1,
|
|
166
176
|
* name: 'Charlie',
|
|
@@ -206,6 +216,7 @@ export namespace Obj {
|
|
|
206
216
|
switch (args.length) {
|
|
207
217
|
case 2: {
|
|
208
218
|
const [record, keys] = args;
|
|
219
|
+
|
|
209
220
|
const keysSet = new Set<keyof R>(keys);
|
|
210
221
|
|
|
211
222
|
return (
|
|
@@ -218,12 +229,14 @@ export namespace Obj {
|
|
|
218
229
|
|
|
219
230
|
case 1: {
|
|
220
231
|
const [keys] = args;
|
|
232
|
+
|
|
221
233
|
return <R2 extends UnknownRecord>(record: R2) => {
|
|
222
234
|
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
223
235
|
const result = omit(record, keys as readonly (keyof R2)[]) as Omit<
|
|
224
236
|
R2,
|
|
225
237
|
ArrayElement<Keys>
|
|
226
238
|
>;
|
|
239
|
+
|
|
227
240
|
return result;
|
|
228
241
|
};
|
|
229
242
|
}
|
|
@@ -253,6 +266,7 @@ export namespace Obj {
|
|
|
253
266
|
* ] as const;
|
|
254
267
|
*
|
|
255
268
|
* const obj1 = Obj.fromEntries(entries1);
|
|
269
|
+
*
|
|
256
270
|
* assert.deepStrictEqual(obj1, {
|
|
257
271
|
* name: 'David',
|
|
258
272
|
* age: 25,
|
|
@@ -266,6 +280,7 @@ export namespace Obj {
|
|
|
266
280
|
* ];
|
|
267
281
|
*
|
|
268
282
|
* const obj2 = Obj.fromEntries(dynamicEntries);
|
|
283
|
+
*
|
|
269
284
|
* assert.deepStrictEqual(obj2, { x: 10, y: 20 });
|
|
270
285
|
* ```
|
|
271
286
|
*
|
|
@@ -355,6 +370,7 @@ export namespace Obj {
|
|
|
355
370
|
: TypeEq<Entries['length'], 0> extends true
|
|
356
371
|
? K
|
|
357
372
|
: ValuesOfEntriesImpl<
|
|
373
|
+
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
358
374
|
K | Entries[0][1],
|
|
359
375
|
List.Tail<Entries>,
|
|
360
376
|
Decrement<RemainingNumRecursions>
|
|
@@ -4,27 +4,27 @@ import { Obj } from './object.mjs';
|
|
|
4
4
|
|
|
5
5
|
describe('shallowEq', () => {
|
|
6
6
|
test('truthy case 1', () => {
|
|
7
|
-
|
|
7
|
+
assert.isTrue(Obj.shallowEq({ x: 0 }, { x: 0 }));
|
|
8
8
|
});
|
|
9
9
|
|
|
10
10
|
test('truthy case 2', () => {
|
|
11
|
-
|
|
11
|
+
assert.isTrue(Obj.shallowEq({}, {}));
|
|
12
12
|
});
|
|
13
13
|
|
|
14
14
|
test('falsy case 1', () => {
|
|
15
|
-
|
|
15
|
+
assert.isFalse(Obj.shallowEq({ x: 0 }, { x: 0, y: 0 }));
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
test('falsy case 2', () => {
|
|
19
|
-
|
|
19
|
+
assert.isFalse(Obj.shallowEq({ x: 0, y: 0 }, { x: 0 }));
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
test('falsy case 3', () => {
|
|
23
|
-
|
|
23
|
+
assert.isFalse(Obj.shallowEq({ x: 0 }, { y: 0 }));
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
test('falsy case 4', () => {
|
|
27
|
-
|
|
27
|
+
assert.isFalse(Obj.shallowEq({ x: [] }, { y: 0 }));
|
|
28
28
|
});
|
|
29
29
|
});
|
|
30
30
|
|
|
@@ -38,6 +38,7 @@ describe('pick', () => {
|
|
|
38
38
|
|
|
39
39
|
test('pick should support curried form', () => {
|
|
40
40
|
const pickAB = Obj.pick(['a', 'b']);
|
|
41
|
+
|
|
41
42
|
const result = pickAB({ a: 1, b: 2, c: 3, d: 4 });
|
|
42
43
|
|
|
43
44
|
assert.deepStrictEqual(result, { a: 1, b: 2 });
|
|
@@ -45,6 +46,7 @@ describe('pick', () => {
|
|
|
45
46
|
|
|
46
47
|
test('pick should work with pipe when curried', () => {
|
|
47
48
|
const pickIdAndName = Obj.pick(['id', 'name']);
|
|
49
|
+
|
|
48
50
|
const user = { id: 1, name: 'Alice', email: 'alice@example.com', age: 30 };
|
|
49
51
|
|
|
50
52
|
const result = pipe(user).map(pickIdAndName).value;
|
|
@@ -54,6 +56,7 @@ describe('pick', () => {
|
|
|
54
56
|
|
|
55
57
|
test('pick should handle empty keys in curried form', () => {
|
|
56
58
|
const pickNone = Obj.pick([]);
|
|
59
|
+
|
|
57
60
|
const result = pickNone({ a: 1, b: 2 });
|
|
58
61
|
|
|
59
62
|
assert.deepStrictEqual(result, {});
|
|
@@ -61,6 +64,7 @@ describe('pick', () => {
|
|
|
61
64
|
|
|
62
65
|
test('pick should work for records that only partially contain the key in curried form', () => {
|
|
63
66
|
const pickVisible = Obj.pick(['name', 'age']);
|
|
67
|
+
|
|
64
68
|
const user = {
|
|
65
69
|
id: 1,
|
|
66
70
|
name: 'Alice',
|
|
@@ -85,6 +89,7 @@ describe('omit', () => {
|
|
|
85
89
|
|
|
86
90
|
test('omit should support curried form', () => {
|
|
87
91
|
const omitC = Obj.omit(['c']);
|
|
92
|
+
|
|
88
93
|
const result = omitC({ a: 1, b: 2, c: 3, d: 4 });
|
|
89
94
|
|
|
90
95
|
assert.deepStrictEqual(result, { a: 1, b: 2, d: 4 });
|
|
@@ -92,6 +97,7 @@ describe('omit', () => {
|
|
|
92
97
|
|
|
93
98
|
test('omit should work with pipe when curried', () => {
|
|
94
99
|
const omitSensitive = Obj.omit(['password', 'email']);
|
|
100
|
+
|
|
95
101
|
const user = {
|
|
96
102
|
id: 1,
|
|
97
103
|
name: 'Alice',
|
|
@@ -106,7 +112,9 @@ describe('omit', () => {
|
|
|
106
112
|
|
|
107
113
|
test('omit should handle empty keys in curried form', () => {
|
|
108
114
|
const omitNone = Obj.omit([]);
|
|
115
|
+
|
|
109
116
|
const original = { a: 1, b: 2, c: 3 };
|
|
117
|
+
|
|
110
118
|
const result = omitNone(original);
|
|
111
119
|
|
|
112
120
|
assert.deepStrictEqual(result, original);
|
|
@@ -114,6 +122,7 @@ describe('omit', () => {
|
|
|
114
122
|
|
|
115
123
|
test('should omit multiple keys in curried form', () => {
|
|
116
124
|
const omitBAndD = Obj.omit(['b', 'd']);
|
|
125
|
+
|
|
117
126
|
const result = omitBAndD({ a: 1, b: 2, c: 3, d: 4, e: 5 });
|
|
118
127
|
|
|
119
128
|
assert.deepStrictEqual(result, { a: 1, c: 3, e: 5 });
|
|
@@ -121,6 +130,7 @@ describe('omit', () => {
|
|
|
121
130
|
|
|
122
131
|
test('omit should work for records that only partially contain the key in curried form', () => {
|
|
123
132
|
const omitSensitive = Obj.omit(['password', 'email']);
|
|
133
|
+
|
|
124
134
|
const user = {
|
|
125
135
|
id: 1,
|
|
126
136
|
name: 'Alice',
|
|
@@ -4,6 +4,7 @@ import { castDeepMutable, castMutable } from './cast-mutable.mjs';
|
|
|
4
4
|
describe(castMutable, () => {
|
|
5
5
|
test('should allow mutating arrays that were readonly', () => {
|
|
6
6
|
const readonlyArray: readonly number[] = [1, 2, 3];
|
|
7
|
+
|
|
7
8
|
const mut_array = castMutable(readonlyArray);
|
|
8
9
|
|
|
9
10
|
expectType<typeof mut_array, number[]>('=');
|
|
@@ -11,6 +12,7 @@ describe(castMutable, () => {
|
|
|
11
12
|
mut_array.push(4);
|
|
12
13
|
|
|
13
14
|
assert.deepStrictEqual(mut_array, [1, 2, 3, 4]);
|
|
15
|
+
|
|
14
16
|
assert.deepStrictEqual(readonlyArray, [1, 2, 3, 4]);
|
|
15
17
|
});
|
|
16
18
|
|
|
@@ -21,12 +23,15 @@ describe(castMutable, () => {
|
|
|
21
23
|
};
|
|
22
24
|
|
|
23
25
|
const mut_user = castMutable(readonlyUser);
|
|
26
|
+
|
|
24
27
|
expectType<typeof mut_user, { name: string; age: number }>('=');
|
|
25
28
|
|
|
26
29
|
mut_user.age = 31;
|
|
30
|
+
|
|
27
31
|
mut_user.name = 'Bob';
|
|
28
32
|
|
|
29
33
|
assert.deepStrictEqual(mut_user, { name: 'Bob', age: 31 });
|
|
34
|
+
|
|
30
35
|
assert.deepStrictEqual(readonlyUser, { name: 'Bob', age: 31 });
|
|
31
36
|
});
|
|
32
37
|
});
|
|
@@ -62,15 +67,17 @@ describe(castDeepMutable, () => {
|
|
|
62
67
|
};
|
|
63
68
|
};
|
|
64
69
|
|
|
65
|
-
expectType<typeof mut_state, MutableState>('
|
|
70
|
+
expectType<typeof mut_state, MutableState>('=');
|
|
66
71
|
|
|
67
72
|
mut_state.user.profile.tags.push('editor');
|
|
73
|
+
|
|
68
74
|
mut_state.user.profile.name = 'Bob';
|
|
69
75
|
|
|
70
76
|
assert.deepStrictEqual(mut_state.user.profile, {
|
|
71
77
|
name: 'Bob',
|
|
72
78
|
tags: ['admin', 'owner', 'editor'],
|
|
73
79
|
});
|
|
80
|
+
|
|
74
81
|
assert.deepStrictEqual(readonlyState.user.profile.tags, [
|
|
75
82
|
'admin',
|
|
76
83
|
'owner',
|