ts-data-forge 5.0.0 → 5.1.0
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 +55 -6
- 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 +7 -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 +1 -0
- package/dist/array/impl/array-utils-modification.mjs.map +1 -1
- package/dist/array/impl/array-utils-reducing-value.d.mts +26 -2
- package/dist/array/impl/array-utils-reducing-value.d.mts.map +1 -1
- package/dist/array/impl/array-utils-reducing-value.mjs +2 -1
- package/dist/array/impl/array-utils-reducing-value.mjs.map +1 -1
- package/dist/array/impl/array-utils-search.d.mts +30 -0
- package/dist/array/impl/array-utils-search.d.mts.map +1 -1
- package/dist/array/impl/array-utils-search.mjs +1 -0
- package/dist/array/impl/array-utils-search.mjs.map +1 -1
- package/dist/array/impl/array-utils-set-op.d.mts +13 -0
- package/dist/array/impl/array-utils-set-op.d.mts.map +1 -1
- package/dist/array/impl/array-utils-set-op.mjs +13 -0
- package/dist/array/impl/array-utils-set-op.mjs.map +1 -1
- package/dist/array/impl/array-utils-size.d.mts +3 -0
- package/dist/array/impl/array-utils-size.d.mts.map +1 -1
- package/dist/array/impl/array-utils-size.mjs +3 -0
- 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 +15 -0
- package/dist/array/impl/array-utils-slicing.d.mts.map +1 -1
- package/dist/array/impl/array-utils-slicing.mjs +7 -0
- 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 +7 -0
- package/dist/array/impl/array-utils-transformation.mjs.map +1 -1
- package/dist/array/impl/array-utils-validation.d.mts +17 -0
- package/dist/array/impl/array-utils-validation.d.mts.map +1 -1
- package/dist/array/impl/array-utils-validation.mjs +11 -0
- package/dist/array/impl/array-utils-validation.mjs.map +1 -1
- package/dist/collections/imap-mapped.mjs +1 -0
- package/dist/collections/imap-mapped.mjs.map +1 -1
- package/dist/collections/imap.d.mts +20 -0
- package/dist/collections/imap.d.mts.map +1 -1
- package/dist/collections/imap.mjs +3 -0
- package/dist/collections/imap.mjs.map +1 -1
- package/dist/collections/iset-mapped.d.mts +27 -0
- package/dist/collections/iset-mapped.d.mts.map +1 -1
- package/dist/collections/iset-mapped.mjs +7 -0
- package/dist/collections/iset-mapped.mjs.map +1 -1
- package/dist/collections/iset.d.mts +29 -0
- package/dist/collections/iset.d.mts.map +1 -1
- package/dist/collections/iset.mjs +7 -0
- package/dist/collections/iset.mjs.map +1 -1
- package/dist/collections/queue.d.mts +40 -0
- package/dist/collections/queue.d.mts.map +1 -1
- package/dist/collections/queue.mjs +9 -0
- package/dist/collections/queue.mjs.map +1 -1
- package/dist/collections/stack.d.mts +35 -0
- package/dist/collections/stack.d.mts.map +1 -1
- package/dist/collections/stack.mjs +8 -0
- package/dist/collections/stack.mjs.map +1 -1
- package/dist/entry-point.mjs +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 +1 -0
- 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-optional.d.mts +2 -0
- package/dist/functional/optional/impl/optional-is-optional.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-is-optional.mjs +2 -0
- package/dist/functional/optional/impl/optional-is-optional.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-is-some.d.mts +1 -0
- package/dist/functional/optional/impl/optional-is-some.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-is-some.mjs +1 -0
- 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 +2 -0
- package/dist/functional/optional/impl/optional-none.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-none.mjs +2 -0
- 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 +3 -1
- package/dist/functional/optional/impl/optional-some.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-some.mjs +2 -0
- package/dist/functional/optional/impl/optional-some.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-to-nullable.d.mts +2 -0
- package/dist/functional/optional/impl/optional-to-nullable.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-to-nullable.mjs +2 -0
- package/dist/functional/optional/impl/optional-to-nullable.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-unwrap-or.d.mts +3 -0
- 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 +1 -0
- package/dist/functional/optional/impl/optional-unwrap-throw.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-unwrap-throw.mjs +1 -0
- package/dist/functional/optional/impl/optional-unwrap-throw.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-unwrap.d.mts +2 -0
- 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 +2 -0
- package/dist/functional/optional/impl/optional-zip.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-zip.mjs +2 -0
- package/dist/functional/optional/impl/optional-zip.mjs.map +1 -1
- package/dist/functional/result/impl/result-err.d.mts +3 -1
- package/dist/functional/result/impl/result-err.d.mts.map +1 -1
- package/dist/functional/result/impl/result-err.mjs +2 -0
- package/dist/functional/result/impl/result-err.mjs.map +1 -1
- package/dist/functional/result/impl/result-expect-to-be.d.mts +1 -0
- 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 +3 -0
- package/dist/functional/result/impl/result-from-promise.d.mts.map +1 -1
- package/dist/functional/result/impl/result-from-promise.mjs +3 -0
- package/dist/functional/result/impl/result-from-promise.mjs.map +1 -1
- package/dist/functional/result/impl/result-from-throwable.d.mts +2 -0
- package/dist/functional/result/impl/result-from-throwable.d.mts.map +1 -1
- package/dist/functional/result/impl/result-from-throwable.mjs +4 -1
- package/dist/functional/result/impl/result-from-throwable.mjs.map +1 -1
- package/dist/functional/result/impl/result-is-err.d.mts +2 -0
- package/dist/functional/result/impl/result-is-err.d.mts.map +1 -1
- package/dist/functional/result/impl/result-is-err.mjs +2 -0
- package/dist/functional/result/impl/result-is-err.mjs.map +1 -1
- package/dist/functional/result/impl/result-is-ok.d.mts +2 -0
- package/dist/functional/result/impl/result-is-ok.d.mts.map +1 -1
- package/dist/functional/result/impl/result-is-ok.mjs +2 -0
- package/dist/functional/result/impl/result-is-ok.mjs.map +1 -1
- package/dist/functional/result/impl/result-is-result.d.mts +4 -0
- package/dist/functional/result/impl/result-is-result.d.mts.map +1 -1
- package/dist/functional/result/impl/result-is-result.mjs +4 -0
- 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 +3 -1
- package/dist/functional/result/impl/result-ok.d.mts.map +1 -1
- package/dist/functional/result/impl/result-ok.mjs +2 -0
- 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 +3 -0
- 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 +2 -0
- package/dist/functional/result/impl/result-unwrap-err-throw.d.mts.map +1 -1
- package/dist/functional/result/impl/result-unwrap-err-throw.mjs +2 -0
- package/dist/functional/result/impl/result-unwrap-err-throw.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-err.d.mts +1 -0
- package/dist/functional/result/impl/result-unwrap-err.d.mts.map +1 -1
- package/dist/functional/result/impl/result-unwrap-err.mjs +1 -0
- package/dist/functional/result/impl/result-unwrap-err.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-ok-or.d.mts +3 -0
- 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 +1 -0
- 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 +2 -0
- package/dist/functional/result/impl/result-unwrap-throw.d.mts.map +1 -1
- package/dist/functional/result/impl/result-unwrap-throw.mjs +2 -0
- 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 +2 -1
- package/dist/functional/ternary-result/impl/ternary-result-err.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-err.mjs +1 -0
- 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 +2 -0
- 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 +2 -0
- 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 +2 -0
- 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 +4 -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 +4 -0
- 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 +4 -0
- 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 +10 -0
- 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 +1 -0
- package/dist/guard/key-is-in.d.mts.map +1 -1
- package/dist/guard/key-is-in.mjs +1 -0
- 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 +21 -0
- package/dist/json/json.d.mts.map +1 -1
- package/dist/json/json.mjs +22 -0
- package/dist/json/json.mjs.map +1 -1
- package/dist/number/branded-types/int.d.mts +14 -0
- package/dist/number/branded-types/int.d.mts.map +1 -1
- package/dist/number/branded-types/int.mjs +14 -0
- 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 +14 -0
- package/dist/number/branded-types/positive-int.d.mts.map +1 -1
- package/dist/number/branded-types/positive-int.mjs +14 -0
- package/dist/number/branded-types/positive-int.mjs.map +1 -1
- package/dist/number/branded-types/positive-safe-int.d.mts +21 -0
- package/dist/number/branded-types/positive-safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/positive-safe-int.mjs +22 -1
- package/dist/number/branded-types/positive-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/safe-int.d.mts +21 -0
- package/dist/number/branded-types/safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/safe-int.mjs +23 -2
- 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 +12 -0
- package/dist/number/branded-types/uint.d.mts.map +1 -1
- package/dist/number/branded-types/uint.mjs +12 -0
- package/dist/number/branded-types/uint.mjs.map +1 -1
- package/dist/number/num.d.mts +9 -0
- package/dist/number/num.d.mts.map +1 -1
- package/dist/number/num.mjs +8 -1
- package/dist/number/num.mjs.map +1 -1
- package/dist/number/refined-number-utils.d.mts +22 -0
- package/dist/number/refined-number-utils.d.mts.map +1 -1
- package/dist/number/refined-number-utils.mjs +23 -0
- package/dist/number/refined-number-utils.mjs.map +1 -1
- package/dist/object/object.d.mts +9 -0
- package/dist/object/object.d.mts.map +1 -1
- package/dist/object/object.mjs +7 -0
- package/dist/object/object.mjs.map +1 -1
- package/dist/others/map-nullable.mjs.map +1 -1
- package/dist/others/tuple.d.mts +11 -0
- package/dist/others/tuple.d.mts.map +1 -1
- package/dist/others/tuple.mjs +11 -0
- 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 +2 -1
- package/dist/others/unknown-to-string.mjs.map +1 -1
- package/dist/promise/promise.d.mts +4 -0
- package/dist/promise/promise.d.mts.map +1 -1
- package/dist/promise/promise.mjs +5 -0
- package/dist/promise/promise.mjs.map +1 -1
- package/package.json +20 -24
- package/src/array/impl/array-utils-creation.mts +20 -0
- package/src/array/impl/array-utils-creation.test.mts +71 -0
- package/src/array/impl/array-utils-element-access.mts +13 -0
- package/src/array/impl/array-utils-element-access.test.mts +21 -0
- package/src/array/impl/array-utils-iterators.test.mts +17 -0
- package/src/array/impl/array-utils-modification.mts +40 -0
- 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 +55 -9
- package/src/array/impl/array-utils-reducing-value.test.mts +90 -0
- package/src/array/impl/array-utils-search.mts +53 -0
- package/src/array/impl/array-utils-search.test.mts +51 -0
- package/src/array/impl/array-utils-set-op.mts +19 -0
- package/src/array/impl/array-utils-set-op.test.mts +116 -0
- package/src/array/impl/array-utils-size.mts +3 -0
- 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 +27 -0
- 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 +113 -1
- package/src/array/impl/array-utils-validation.mts +23 -0
- package/src/array/impl/array-utils-validation.test.mts +96 -0
- package/src/array/impl/array.test.mts +12 -0
- package/src/collections/imap-mapped.mts +11 -0
- package/src/collections/imap-mapped.test.mts +70 -0
- package/src/collections/imap.mts +32 -0
- package/src/collections/imap.test.mts +106 -0
- package/src/collections/iset-mapped.mts +35 -0
- package/src/collections/iset-mapped.test.mts +111 -0
- package/src/collections/iset.mts +34 -0
- package/src/collections/iset.test.mts +193 -0
- package/src/collections/queue.mts +53 -0
- package/src/collections/queue.test.mts +32 -0
- package/src/collections/stack.mts +42 -0
- package/src/collections/stack.test.mts +44 -0
- package/src/functional/match.mts +16 -0
- package/src/functional/match.test.mts +2 -0
- package/src/functional/optional/impl/optional-expect-to-be.mts +3 -0
- 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-optional.mts +2 -0
- package/src/functional/optional/impl/optional-is-some.mts +1 -0
- package/src/functional/optional/impl/optional-map.mts +5 -0
- package/src/functional/optional/impl/optional-none.mts +2 -0
- package/src/functional/optional/impl/optional-or-else.mts +6 -0
- package/src/functional/optional/impl/optional-some.mts +3 -1
- package/src/functional/optional/impl/optional-to-nullable.mts +2 -0
- package/src/functional/optional/impl/optional-unwrap-or.mts +5 -0
- package/src/functional/optional/impl/optional-unwrap-throw.mts +1 -0
- package/src/functional/optional/impl/optional-unwrap.mts +2 -0
- package/src/functional/optional/impl/optional-zip.mts +2 -0
- package/src/functional/optional.test.mts +73 -0
- package/src/functional/pipe.test.mts +3 -0
- package/src/functional/result/impl/result-err.mts +3 -1
- package/src/functional/result/impl/result-expect-to-be.mts +3 -0
- 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 +3 -0
- package/src/functional/result/impl/result-from-throwable.mts +6 -1
- package/src/functional/result/impl/result-is-err.mts +2 -0
- package/src/functional/result/impl/result-is-ok.mts +2 -0
- package/src/functional/result/impl/result-is-result.mts +4 -0
- 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 +3 -1
- 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 +5 -0
- package/src/functional/result/impl/result-unwrap-err-throw.mts +2 -0
- package/src/functional/result/impl/result-unwrap-err.mts +1 -0
- package/src/functional/result/impl/result-unwrap-ok-or.mts +5 -0
- package/src/functional/result/impl/result-unwrap-ok.mts +2 -0
- package/src/functional/result/impl/result-unwrap-throw.mts +2 -0
- package/src/functional/result/impl/result-zip.mts +3 -1
- package/src/functional/result.test.mts +88 -0
- package/src/functional/ternary-result/impl/ternary-result-err.mts +2 -1
- 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 +2 -0
- package/src/functional/ternary-result/impl/ternary-result-from-throwable.mts +5 -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 +4 -0
- 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 +91 -0
- package/src/globals.d.mts +10 -0
- package/src/guard/has-key.test.mts +9 -0
- package/src/guard/is-non-empty-string.test.mts +20 -0
- package/src/guard/is-non-null-object.test.mts +19 -0
- package/src/guard/is-primitive.test.mts +23 -0
- package/src/guard/is-record.mts +34 -0
- package/src/guard/is-record.test.mts +21 -0
- package/src/guard/is-type.mts +3 -0
- package/src/guard/is-type.test.mts +134 -0
- package/src/guard/key-is-in.mts +1 -0
- package/src/iterator/range.mts +9 -0
- package/src/json/json.mts +29 -0
- package/src/json/json.test.mts +87 -0
- package/src/number/branded-types/finite-number.test.mts +38 -0
- package/src/number/branded-types/int.mts +14 -0
- package/src/number/branded-types/int.test.mts +42 -0
- package/src/number/branded-types/int16.test.mts +47 -0
- package/src/number/branded-types/int32.test.mts +47 -0
- package/src/number/branded-types/non-negative-finite-number.test.mts +40 -0
- package/src/number/branded-types/non-negative-int16.test.mts +43 -0
- package/src/number/branded-types/non-negative-int32.test.mts +43 -0
- package/src/number/branded-types/non-zero-finite-number.test.mts +51 -0
- package/src/number/branded-types/non-zero-int.test.mts +53 -0
- package/src/number/branded-types/non-zero-int16.test.mts +44 -0
- package/src/number/branded-types/non-zero-int32.test.mts +44 -0
- package/src/number/branded-types/non-zero-safe-int.mts +2 -2
- package/src/number/branded-types/non-zero-safe-int.test.mts +62 -0
- package/src/number/branded-types/non-zero-uint16.test.mts +37 -0
- package/src/number/branded-types/non-zero-uint32.test.mts +37 -0
- package/src/number/branded-types/positive-finite-number.test.mts +45 -0
- package/src/number/branded-types/positive-int.mts +14 -0
- package/src/number/branded-types/positive-int.test.mts +47 -0
- package/src/number/branded-types/positive-int16.test.mts +35 -0
- package/src/number/branded-types/positive-int32.test.mts +35 -0
- package/src/number/branded-types/positive-safe-int.mts +22 -1
- package/src/number/branded-types/positive-safe-int.test.mts +49 -0
- package/src/number/branded-types/positive-uint16.test.mts +37 -0
- package/src/number/branded-types/positive-uint32.test.mts +37 -0
- package/src/number/branded-types/safe-int.mts +23 -2
- package/src/number/branded-types/safe-int.test.mts +52 -0
- package/src/number/branded-types/safe-uint.mts +1 -1
- package/src/number/branded-types/safe-uint.test.mts +48 -0
- package/src/number/branded-types/uint.mts +12 -0
- package/src/number/branded-types/uint.test.mts +43 -0
- package/src/number/branded-types/uint16.test.mts +41 -0
- package/src/number/branded-types/uint32.test.mts +41 -0
- package/src/number/enum/int8.test.mts +6 -0
- package/src/number/enum/uint8.test.mts +6 -0
- package/src/number/num.mts +12 -1
- package/src/number/num.test.mts +62 -0
- package/src/number/refined-number-utils.mts +25 -0
- package/src/object/object.mts +15 -0
- package/src/object/object.test.mts +10 -0
- package/src/others/cast-mutable.test.mts +7 -0
- package/src/others/cast-readonly.test.mts +17 -0
- package/src/others/if-then.test.mts +16 -0
- 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 +11 -0
- package/src/others/unknown-to-string.mts +4 -1
- package/src/others/unknown-to-string.test.mts +10 -0
- package/src/promise/promise.mts +4 -0
- package/src/promise/promise.test.mts +1 -0
|
@@ -27,6 +27,7 @@ describe('IMap[Symbol.iterator]', () => {
|
|
|
27
27
|
['a', 1],
|
|
28
28
|
['b', 2],
|
|
29
29
|
]);
|
|
30
|
+
|
|
30
31
|
const mut_collected: (readonly [string, number])[] = [];
|
|
31
32
|
|
|
32
33
|
for (const entry of map) {
|
|
@@ -34,7 +35,9 @@ describe('IMap[Symbol.iterator]', () => {
|
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
expect(mut_collected).toHaveLength(2);
|
|
38
|
+
|
|
37
39
|
expect(mut_collected).toContainEqual(['a', 1]);
|
|
40
|
+
|
|
38
41
|
expect(mut_collected).toContainEqual(['b', 2]);
|
|
39
42
|
});
|
|
40
43
|
|
|
@@ -43,10 +46,13 @@ describe('IMap[Symbol.iterator]', () => {
|
|
|
43
46
|
['a', 1],
|
|
44
47
|
['b', 2],
|
|
45
48
|
]);
|
|
49
|
+
|
|
46
50
|
const entries = Array.from(map);
|
|
47
51
|
|
|
48
52
|
expect(entries).toHaveLength(2);
|
|
53
|
+
|
|
49
54
|
expect(entries).toContainEqual(['a', 1]);
|
|
55
|
+
|
|
50
56
|
expect(entries).toContainEqual(['b', 2]);
|
|
51
57
|
});
|
|
52
58
|
|
|
@@ -55,10 +61,13 @@ describe('IMap[Symbol.iterator]', () => {
|
|
|
55
61
|
['a', 1],
|
|
56
62
|
['b', 2],
|
|
57
63
|
]);
|
|
64
|
+
|
|
58
65
|
const entries = Array.from(map);
|
|
59
66
|
|
|
60
67
|
expect(entries).toHaveLength(2);
|
|
68
|
+
|
|
61
69
|
expect(entries).toContainEqual(['a', 1]);
|
|
70
|
+
|
|
62
71
|
expect(entries).toContainEqual(['b', 2]);
|
|
63
72
|
});
|
|
64
73
|
});
|
|
@@ -75,10 +84,13 @@ describe('IMap.create', () => {
|
|
|
75
84
|
['a', 1],
|
|
76
85
|
['b', 2],
|
|
77
86
|
]);
|
|
87
|
+
|
|
78
88
|
const map = IMap.create(jsMap);
|
|
79
89
|
|
|
80
90
|
expect(map.size).toBe(2);
|
|
91
|
+
|
|
81
92
|
expect(Optional.unwrap(map.get('a'))).toBe(1);
|
|
93
|
+
|
|
82
94
|
expect(Optional.unwrap(map.get('b'))).toBe(2);
|
|
83
95
|
});
|
|
84
96
|
|
|
@@ -87,10 +99,13 @@ describe('IMap.create', () => {
|
|
|
87
99
|
['a', 1],
|
|
88
100
|
['b', 2],
|
|
89
101
|
]);
|
|
102
|
+
|
|
90
103
|
const copy = IMap.create(original);
|
|
91
104
|
|
|
92
105
|
expect(copy.size).toBe(2);
|
|
106
|
+
|
|
93
107
|
expect(Optional.unwrap(copy.get('a'))).toBe(1);
|
|
108
|
+
|
|
94
109
|
expect(Optional.unwrap(copy.get('b'))).toBe(2);
|
|
95
110
|
});
|
|
96
111
|
});
|
|
@@ -101,6 +116,7 @@ describe('IMap.equal', () => {
|
|
|
101
116
|
['a', 1],
|
|
102
117
|
['b', 2],
|
|
103
118
|
]);
|
|
119
|
+
|
|
104
120
|
const map2 = IMap.create([
|
|
105
121
|
['a', 1],
|
|
106
122
|
['b', 2],
|
|
@@ -114,6 +130,7 @@ describe('IMap.equal', () => {
|
|
|
114
130
|
['a', 1],
|
|
115
131
|
['b', 2],
|
|
116
132
|
]);
|
|
133
|
+
|
|
117
134
|
const map2 = IMap.create([
|
|
118
135
|
['b', 2],
|
|
119
136
|
['a', 1],
|
|
@@ -124,6 +141,7 @@ describe('IMap.equal', () => {
|
|
|
124
141
|
|
|
125
142
|
test('should return false for maps with different sizes', () => {
|
|
126
143
|
const map1 = IMap.create<'a' | 'b', number>([['a', 1]]);
|
|
144
|
+
|
|
127
145
|
const map2 = IMap.create([
|
|
128
146
|
['a', 1],
|
|
129
147
|
['b', 2],
|
|
@@ -137,6 +155,7 @@ describe('IMap.equal', () => {
|
|
|
137
155
|
['a', 1],
|
|
138
156
|
['b', 2],
|
|
139
157
|
]);
|
|
158
|
+
|
|
140
159
|
const map2 = IMap.create([
|
|
141
160
|
['a', 1],
|
|
142
161
|
['b', 3],
|
|
@@ -150,6 +169,7 @@ describe('IMap.equal', () => {
|
|
|
150
169
|
['a', 1],
|
|
151
170
|
['b', 2],
|
|
152
171
|
]);
|
|
172
|
+
|
|
153
173
|
const map2 = IMap.create<'a' | 'b' | 'c', number>([
|
|
154
174
|
['a', 1],
|
|
155
175
|
['c', 2],
|
|
@@ -160,6 +180,7 @@ describe('IMap.equal', () => {
|
|
|
160
180
|
|
|
161
181
|
test('should return true for empty maps', () => {
|
|
162
182
|
const map1 = IMap.create<string, number>([]);
|
|
183
|
+
|
|
163
184
|
const map2 = IMap.create<string, number>([]);
|
|
164
185
|
|
|
165
186
|
expect(IMap.equal(map1, map2)).toBe(true);
|
|
@@ -229,6 +250,7 @@ describe('IMap.has', () => {
|
|
|
229
250
|
]);
|
|
230
251
|
|
|
231
252
|
expect(map.has(true)).toBe(true);
|
|
253
|
+
|
|
232
254
|
expect(map.has(false)).toBe(true);
|
|
233
255
|
});
|
|
234
256
|
|
|
@@ -239,6 +261,7 @@ describe('IMap.has', () => {
|
|
|
239
261
|
]);
|
|
240
262
|
|
|
241
263
|
expect(map.has('1')).toBe(true);
|
|
264
|
+
|
|
242
265
|
expect(map.has(String(1))).toBe(true);
|
|
243
266
|
});
|
|
244
267
|
});
|
|
@@ -294,6 +317,7 @@ describe('IMap.get', () => {
|
|
|
294
317
|
]);
|
|
295
318
|
|
|
296
319
|
expect(Optional.unwrap(map.get('undef'))).toBeUndefined();
|
|
320
|
+
|
|
297
321
|
expect(Optional.unwrap(map.get('null'))).toBeNull();
|
|
298
322
|
});
|
|
299
323
|
});
|
|
@@ -319,6 +343,7 @@ describe('IMap.set', () => {
|
|
|
319
343
|
[9, 90],
|
|
320
344
|
]),
|
|
321
345
|
);
|
|
346
|
+
|
|
322
347
|
assert.deepStrictEqual(
|
|
323
348
|
m0,
|
|
324
349
|
IMap.create([
|
|
@@ -350,6 +375,7 @@ describe('IMap.set', () => {
|
|
|
350
375
|
[7, 70],
|
|
351
376
|
]),
|
|
352
377
|
);
|
|
378
|
+
|
|
353
379
|
assert.deepStrictEqual(
|
|
354
380
|
m0,
|
|
355
381
|
IMap.create([
|
|
@@ -366,34 +392,45 @@ describe('IMap.set', () => {
|
|
|
366
392
|
const m0 = IMap.create<number, number>([]);
|
|
367
393
|
|
|
368
394
|
assert.deepStrictEqual(m0.set(1, 10), IMap.create([[1, 10]]));
|
|
395
|
+
|
|
369
396
|
assert.deepStrictEqual(m0, IMap.create<number, number>([]));
|
|
370
397
|
});
|
|
371
398
|
|
|
372
399
|
test('should not create new instance when setting the same value', () => {
|
|
373
400
|
const map = IMap.create([['a', 1]]);
|
|
401
|
+
|
|
374
402
|
const updated = map.set('a', 1);
|
|
375
403
|
|
|
376
404
|
expect(updated).toBe(map);
|
|
405
|
+
|
|
377
406
|
expect(Optional.unwrap(updated.get('a'))).toBe(1);
|
|
378
407
|
});
|
|
379
408
|
|
|
380
409
|
test('should not create new instance even with same value', () => {
|
|
381
410
|
const map = IMap.create([['a', 1]]);
|
|
411
|
+
|
|
382
412
|
const curr = map.get('a');
|
|
413
|
+
|
|
383
414
|
assert(Optional.isSome(curr));
|
|
415
|
+
|
|
384
416
|
const updated = map.set('a', curr.value);
|
|
385
417
|
|
|
386
418
|
expect(updated).toBe(map);
|
|
419
|
+
|
|
387
420
|
expect(Optional.unwrap(updated.get('a'))).toBe(1);
|
|
388
421
|
});
|
|
389
422
|
|
|
390
423
|
test('should not modify original map when setting', () => {
|
|
391
424
|
const original = IMap.create<string, number>([['a', 1]]);
|
|
425
|
+
|
|
392
426
|
const modified = original.set('b', 2);
|
|
393
427
|
|
|
394
428
|
expect(original.size).toBe(1);
|
|
429
|
+
|
|
395
430
|
expect(modified.size).toBe(2);
|
|
431
|
+
|
|
396
432
|
expect(original.has('b')).toBe(false);
|
|
433
|
+
|
|
397
434
|
expect(modified.has('b')).toBe(true);
|
|
398
435
|
});
|
|
399
436
|
});
|
|
@@ -418,6 +455,7 @@ describe('IMap.update', () => {
|
|
|
418
455
|
[7, 70],
|
|
419
456
|
]),
|
|
420
457
|
);
|
|
458
|
+
|
|
421
459
|
assert.deepStrictEqual(
|
|
422
460
|
m0,
|
|
423
461
|
IMap.create([
|
|
@@ -449,6 +487,7 @@ describe('IMap.update', () => {
|
|
|
449
487
|
[7, 70],
|
|
450
488
|
]),
|
|
451
489
|
);
|
|
490
|
+
|
|
452
491
|
assert.deepStrictEqual(
|
|
453
492
|
m0,
|
|
454
493
|
IMap.create([
|
|
@@ -468,14 +507,17 @@ describe('IMap.update', () => {
|
|
|
468
507
|
m0.update(1, (x) => 2 * x),
|
|
469
508
|
IMap.create([]),
|
|
470
509
|
);
|
|
510
|
+
|
|
471
511
|
assert.deepStrictEqual(m0, IMap.create<number, number>([]));
|
|
472
512
|
});
|
|
473
513
|
|
|
474
514
|
test('should not modify original map when updating', () => {
|
|
475
515
|
const original = IMap.create([['a', 1]]);
|
|
516
|
+
|
|
476
517
|
const modified = original.update('a', (x) => x * 2);
|
|
477
518
|
|
|
478
519
|
expect(Optional.unwrap(original.get('a'))).toBe(1);
|
|
520
|
+
|
|
479
521
|
expect(Optional.unwrap(modified.get('a'))).toBe(2);
|
|
480
522
|
});
|
|
481
523
|
});
|
|
@@ -500,6 +542,7 @@ describe('IMap.delete', () => {
|
|
|
500
542
|
[7, 70],
|
|
501
543
|
]),
|
|
502
544
|
);
|
|
545
|
+
|
|
503
546
|
assert.deepStrictEqual(
|
|
504
547
|
m0,
|
|
505
548
|
IMap.create([
|
|
@@ -530,6 +573,7 @@ describe('IMap.delete', () => {
|
|
|
530
573
|
[7, 70],
|
|
531
574
|
]),
|
|
532
575
|
);
|
|
576
|
+
|
|
533
577
|
assert.deepStrictEqual(
|
|
534
578
|
m0,
|
|
535
579
|
IMap.create([
|
|
@@ -546,6 +590,7 @@ describe('IMap.delete', () => {
|
|
|
546
590
|
const m0 = IMap.create<number, number>([]);
|
|
547
591
|
|
|
548
592
|
assert.deepStrictEqual(m0.delete(1), IMap.create([]));
|
|
593
|
+
|
|
549
594
|
assert.deepStrictEqual(m0, IMap.create<number, number>([]));
|
|
550
595
|
});
|
|
551
596
|
|
|
@@ -554,11 +599,15 @@ describe('IMap.delete', () => {
|
|
|
554
599
|
['a', 1],
|
|
555
600
|
['b', 2],
|
|
556
601
|
]);
|
|
602
|
+
|
|
557
603
|
const modified = original.delete('a');
|
|
558
604
|
|
|
559
605
|
expect(original.size).toBe(2);
|
|
606
|
+
|
|
560
607
|
expect(modified.size).toBe(1);
|
|
608
|
+
|
|
561
609
|
expect(original.has('a')).toBe(true);
|
|
610
|
+
|
|
562
611
|
expect(modified.has('a')).toBe(false);
|
|
563
612
|
});
|
|
564
613
|
});
|
|
@@ -605,6 +654,7 @@ describe('IMap.every', () => {
|
|
|
605
654
|
['a', 'hello'],
|
|
606
655
|
['b', 'world'],
|
|
607
656
|
]);
|
|
657
|
+
|
|
608
658
|
if (map.every((value): value is string => typeof value === 'string')) {
|
|
609
659
|
// Type should be narrowed to IMap<string, string>
|
|
610
660
|
const firstValue = Optional.unwrap(map.get('a'));
|
|
@@ -666,8 +716,11 @@ describe('IMap.withMutations', () => {
|
|
|
666
716
|
]);
|
|
667
717
|
|
|
668
718
|
expect(updated.size).toBe(2);
|
|
719
|
+
|
|
669
720
|
expect(Optional.unwrap(updated.get('a'))).toBe(2);
|
|
721
|
+
|
|
670
722
|
expect(Optional.unwrap(updated.get('c'))).toBe(3);
|
|
723
|
+
|
|
671
724
|
expect(Optional.isNone(updated.get('b'))).toBe(true);
|
|
672
725
|
});
|
|
673
726
|
|
|
@@ -676,25 +729,31 @@ describe('IMap.withMutations', () => {
|
|
|
676
729
|
['a', 1],
|
|
677
730
|
['b', 2],
|
|
678
731
|
]);
|
|
732
|
+
|
|
679
733
|
const updated = map.withMutations([]);
|
|
680
734
|
|
|
681
735
|
expect(updated.size).toBe(map.size);
|
|
736
|
+
|
|
682
737
|
expect(Optional.unwrap(updated.get('a'))).toBe(1);
|
|
738
|
+
|
|
683
739
|
expect(Optional.unwrap(updated.get('b'))).toBe(2);
|
|
684
740
|
});
|
|
685
741
|
|
|
686
742
|
test('should handle update on non-existent key', () => {
|
|
687
743
|
const map = IMap.create<string, number>([['a', 1]]);
|
|
744
|
+
|
|
688
745
|
const updated = map.withMutations([
|
|
689
746
|
{ type: 'update', key: 'nonexistent', updater: (x: number) => x * 2 },
|
|
690
747
|
]);
|
|
691
748
|
|
|
692
749
|
expect(updated.size).toBe(map.size);
|
|
750
|
+
|
|
693
751
|
expect(Optional.isNone(updated.get('nonexistent'))).toBe(true);
|
|
694
752
|
});
|
|
695
753
|
|
|
696
754
|
test('should handle mixed operations', () => {
|
|
697
755
|
const map = IMap.create([['a', 1]]);
|
|
756
|
+
|
|
698
757
|
const updated = map.withMutations([
|
|
699
758
|
{ type: 'set', key: 'a', value: 10 },
|
|
700
759
|
{ type: 'update', key: 'a', updater: (x: number) => x + 5 },
|
|
@@ -711,10 +770,13 @@ describe('IMap.map', () => {
|
|
|
711
770
|
['b', 2],
|
|
712
771
|
['c', 3],
|
|
713
772
|
]);
|
|
773
|
+
|
|
714
774
|
const doubled = map.map((value) => value * 2);
|
|
715
775
|
|
|
716
776
|
expect(Optional.unwrap(doubled.get('a'))).toBe(2);
|
|
777
|
+
|
|
717
778
|
expect(Optional.unwrap(doubled.get('b'))).toBe(4);
|
|
779
|
+
|
|
718
780
|
expect(Optional.unwrap(doubled.get('c'))).toBe(6);
|
|
719
781
|
});
|
|
720
782
|
|
|
@@ -723,9 +785,11 @@ describe('IMap.map', () => {
|
|
|
723
785
|
['a', 1],
|
|
724
786
|
['b', 2],
|
|
725
787
|
]);
|
|
788
|
+
|
|
726
789
|
const mapped = map.map((value, key) => `${key}-${value}`);
|
|
727
790
|
|
|
728
791
|
expect(Optional.unwrap(mapped.get('a'))).toBe('a-1');
|
|
792
|
+
|
|
729
793
|
expect(Optional.unwrap(mapped.get('b'))).toBe('b-2');
|
|
730
794
|
});
|
|
731
795
|
|
|
@@ -734,9 +798,11 @@ describe('IMap.map', () => {
|
|
|
734
798
|
['a', 1],
|
|
735
799
|
['b', 2],
|
|
736
800
|
]);
|
|
801
|
+
|
|
737
802
|
const stringified = map.map((value) => value.toString());
|
|
738
803
|
|
|
739
804
|
expect(Optional.unwrap(stringified.get('a'))).toBe('1');
|
|
805
|
+
|
|
740
806
|
expect(Optional.unwrap(stringified.get('b'))).toBe('2');
|
|
741
807
|
});
|
|
742
808
|
});
|
|
@@ -747,10 +813,13 @@ describe('IMap.mapKeys', () => {
|
|
|
747
813
|
['a', 1],
|
|
748
814
|
['b', 2],
|
|
749
815
|
]);
|
|
816
|
+
|
|
750
817
|
const mapped = map.mapKeys((key) => key.toUpperCase());
|
|
751
818
|
|
|
752
819
|
expect(Optional.isNone(mapped.get('a'))).toBe(true);
|
|
820
|
+
|
|
753
821
|
expect(Optional.unwrap(mapped.get('A'))).toBe(1);
|
|
822
|
+
|
|
754
823
|
expect(Optional.unwrap(mapped.get('B'))).toBe(2);
|
|
755
824
|
});
|
|
756
825
|
|
|
@@ -759,9 +828,11 @@ describe('IMap.mapKeys', () => {
|
|
|
759
828
|
['1', 'one'],
|
|
760
829
|
['2', 'two'],
|
|
761
830
|
]);
|
|
831
|
+
|
|
762
832
|
const mapped = map.mapKeys((key) => Number.parseInt(key, 10));
|
|
763
833
|
|
|
764
834
|
expect(Optional.unwrap(mapped.get(1))).toBe('one');
|
|
835
|
+
|
|
765
836
|
expect(Optional.unwrap(mapped.get(2))).toBe('two');
|
|
766
837
|
});
|
|
767
838
|
});
|
|
@@ -772,12 +843,14 @@ describe('IMap.mapEntries', () => {
|
|
|
772
843
|
['a', 1],
|
|
773
844
|
['b', 2],
|
|
774
845
|
]);
|
|
846
|
+
|
|
775
847
|
const mapped = map.mapEntries(([key, value]) => [
|
|
776
848
|
key.toUpperCase(),
|
|
777
849
|
value * 2,
|
|
778
850
|
]);
|
|
779
851
|
|
|
780
852
|
expect(Optional.unwrap(mapped.get('A'))).toBe(2);
|
|
853
|
+
|
|
781
854
|
expect(Optional.unwrap(mapped.get('B'))).toBe(4);
|
|
782
855
|
});
|
|
783
856
|
|
|
@@ -786,9 +859,11 @@ describe('IMap.mapEntries', () => {
|
|
|
786
859
|
['a', 1],
|
|
787
860
|
['b', 2],
|
|
788
861
|
]);
|
|
862
|
+
|
|
789
863
|
const mapped = map.mapEntries(([key, value]) => [value, key]);
|
|
790
864
|
|
|
791
865
|
expect(Optional.unwrap(mapped.get(1))).toBe('a');
|
|
866
|
+
|
|
792
867
|
expect(Optional.unwrap(mapped.get(2))).toBe('b');
|
|
793
868
|
});
|
|
794
869
|
});
|
|
@@ -802,11 +877,14 @@ describe('IMap.forEach', () => {
|
|
|
802
877
|
[6, 60],
|
|
803
878
|
[7, 70],
|
|
804
879
|
] as const);
|
|
880
|
+
|
|
805
881
|
const keys = [1, 3, 5, 6, 7];
|
|
882
|
+
|
|
806
883
|
const values = [10, 30, 50, 60, 70];
|
|
807
884
|
|
|
808
885
|
for (const [key, value] of m0.entries()) {
|
|
809
886
|
expect(keys).toContain(key);
|
|
887
|
+
|
|
810
888
|
expect(values).toContain(value);
|
|
811
889
|
}
|
|
812
890
|
});
|
|
@@ -817,6 +895,7 @@ describe('IMap.forEach', () => {
|
|
|
817
895
|
['b', 2],
|
|
818
896
|
['c', 3],
|
|
819
897
|
]);
|
|
898
|
+
|
|
820
899
|
const mut_collected: [string, number][] = [];
|
|
821
900
|
|
|
822
901
|
for (const [key, value] of map.entries()) {
|
|
@@ -824,13 +903,17 @@ describe('IMap.forEach', () => {
|
|
|
824
903
|
}
|
|
825
904
|
|
|
826
905
|
expect(mut_collected).toHaveLength(3);
|
|
906
|
+
|
|
827
907
|
expect(mut_collected).toContainEqual(['a', 1]);
|
|
908
|
+
|
|
828
909
|
expect(mut_collected).toContainEqual(['b', 2]);
|
|
910
|
+
|
|
829
911
|
expect(mut_collected).toContainEqual(['c', 3]);
|
|
830
912
|
});
|
|
831
913
|
|
|
832
914
|
test('should work with empty map', () => {
|
|
833
915
|
const map = IMap.create<string, number>([]);
|
|
916
|
+
|
|
834
917
|
let mut_called = false;
|
|
835
918
|
|
|
836
919
|
// eslint-disable-next-line unicorn/no-array-for-each
|
|
@@ -851,6 +934,7 @@ describe('IMap.keys', () => {
|
|
|
851
934
|
[6, 60],
|
|
852
935
|
[7, 70],
|
|
853
936
|
] as const);
|
|
937
|
+
|
|
854
938
|
const keys = [1, 3, 5, 6, 7];
|
|
855
939
|
|
|
856
940
|
for (const k of m0.keys()) {
|
|
@@ -868,6 +952,7 @@ describe('IMap.values', () => {
|
|
|
868
952
|
[6, 60],
|
|
869
953
|
[7, 70],
|
|
870
954
|
]);
|
|
955
|
+
|
|
871
956
|
const values = [10, 30, 50, 60, 70];
|
|
872
957
|
|
|
873
958
|
for (const v of m0.values()) {
|
|
@@ -885,11 +970,14 @@ describe('IMap.entries', () => {
|
|
|
885
970
|
[6, 60],
|
|
886
971
|
[7, 70],
|
|
887
972
|
]);
|
|
973
|
+
|
|
888
974
|
const keys = [1, 3, 5, 6, 7];
|
|
975
|
+
|
|
889
976
|
const values = [10, 30, 50, 60, 70];
|
|
890
977
|
|
|
891
978
|
for (const [k, v] of m0.entries()) {
|
|
892
979
|
expect(keys).toContain(k);
|
|
980
|
+
|
|
893
981
|
expect(values).toContain(v);
|
|
894
982
|
}
|
|
895
983
|
});
|
|
@@ -902,11 +990,15 @@ describe('IMap.toKeysArray', () => {
|
|
|
902
990
|
['b', 2],
|
|
903
991
|
['c', 3],
|
|
904
992
|
]);
|
|
993
|
+
|
|
905
994
|
const keys = map.toKeysArray();
|
|
906
995
|
|
|
907
996
|
expect(keys).toHaveLength(3);
|
|
997
|
+
|
|
908
998
|
expect(keys).toContain('a');
|
|
999
|
+
|
|
909
1000
|
expect(keys).toContain('b');
|
|
1001
|
+
|
|
910
1002
|
expect(keys).toContain('c');
|
|
911
1003
|
});
|
|
912
1004
|
});
|
|
@@ -918,11 +1010,15 @@ describe('IMap.toValuesArray', () => {
|
|
|
918
1010
|
['b', 2],
|
|
919
1011
|
['c', 3],
|
|
920
1012
|
]);
|
|
1013
|
+
|
|
921
1014
|
const values = map.toValuesArray();
|
|
922
1015
|
|
|
923
1016
|
expect(values).toHaveLength(3);
|
|
1017
|
+
|
|
924
1018
|
expect(values).toContain(1);
|
|
1019
|
+
|
|
925
1020
|
expect(values).toContain(2);
|
|
1021
|
+
|
|
926
1022
|
expect(values).toContain(3);
|
|
927
1023
|
});
|
|
928
1024
|
});
|
|
@@ -934,11 +1030,15 @@ describe('IMap.toEntriesArray', () => {
|
|
|
934
1030
|
['b', 2],
|
|
935
1031
|
['c', 3],
|
|
936
1032
|
]);
|
|
1033
|
+
|
|
937
1034
|
const entries = map.toEntriesArray();
|
|
938
1035
|
|
|
939
1036
|
expect(entries).toHaveLength(3);
|
|
1037
|
+
|
|
940
1038
|
expect(entries).toContainEqual(['a', 1]);
|
|
1039
|
+
|
|
941
1040
|
expect(entries).toContainEqual(['b', 2]);
|
|
1041
|
+
|
|
942
1042
|
expect(entries).toContainEqual(['c', 3]);
|
|
943
1043
|
});
|
|
944
1044
|
});
|
|
@@ -950,7 +1050,9 @@ describe('IMap.toArray', () => {
|
|
|
950
1050
|
['b', 2],
|
|
951
1051
|
['c', 3],
|
|
952
1052
|
]);
|
|
1053
|
+
|
|
953
1054
|
const entries = map.toArray();
|
|
1055
|
+
|
|
954
1056
|
const entriesArray = map.toEntriesArray();
|
|
955
1057
|
|
|
956
1058
|
assert.deepStrictEqual(entries, entriesArray);
|
|
@@ -964,11 +1066,15 @@ describe('IMap.toRawMap', () => {
|
|
|
964
1066
|
['b', 2],
|
|
965
1067
|
['c', 3],
|
|
966
1068
|
]);
|
|
1069
|
+
|
|
967
1070
|
const rawMap = map.toRawMap();
|
|
968
1071
|
|
|
969
1072
|
expect(rawMap.size).toBe(3);
|
|
1073
|
+
|
|
970
1074
|
expect(rawMap.get('a')).toBe(1);
|
|
1075
|
+
|
|
971
1076
|
expect(rawMap.get('b')).toBe(2);
|
|
1077
|
+
|
|
972
1078
|
expect(rawMap.get('c')).toBe(3);
|
|
973
1079
|
});
|
|
974
1080
|
});
|