ts-data-forge 5.0.1 → 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 +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 +26 -2
- 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 +30 -0
- 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 +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 +6 -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.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 +2 -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 +8 -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 +7 -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 +2 -0
- 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 +2 -0
- 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 +21 -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 +22 -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.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 +4 -0
- package/dist/promise/promise.mjs.map +1 -1
- package/package.json +18 -22
- 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 +53 -8
- 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 +4 -0
- 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 +3 -0
- 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 +2 -0
- 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
|
@@ -15,6 +15,7 @@ describe('ISet.create', () => {
|
|
|
15
15
|
const set = ISet.create<string>([]);
|
|
16
16
|
|
|
17
17
|
expect(set.size).toBe(0);
|
|
18
|
+
|
|
18
19
|
expect(set.isEmpty).toBe(true);
|
|
19
20
|
});
|
|
20
21
|
|
|
@@ -22,28 +23,39 @@ describe('ISet.create', () => {
|
|
|
22
23
|
const set = ISet.create([1, 2, 3, 2, 1]);
|
|
23
24
|
|
|
24
25
|
expect(set.size).toBe(3);
|
|
26
|
+
|
|
25
27
|
expect(set.has(1)).toBe(true);
|
|
28
|
+
|
|
26
29
|
expect(set.has(2)).toBe(true);
|
|
30
|
+
|
|
27
31
|
expect(set.has(3)).toBe(true);
|
|
28
32
|
});
|
|
29
33
|
|
|
30
34
|
test('should create set from JavaScript Set', () => {
|
|
31
35
|
const jsSet = new Set(['a', 'b', 'c']);
|
|
36
|
+
|
|
32
37
|
const set = ISet.create(jsSet);
|
|
33
38
|
|
|
34
39
|
expect(set.size).toBe(3);
|
|
40
|
+
|
|
35
41
|
expect(set.has('a')).toBe(true);
|
|
42
|
+
|
|
36
43
|
expect(set.has('b')).toBe(true);
|
|
44
|
+
|
|
37
45
|
expect(set.has('c')).toBe(true);
|
|
38
46
|
});
|
|
39
47
|
|
|
40
48
|
test('should create set from another ISet', () => {
|
|
41
49
|
const original = ISet.create([1, 2, 3]);
|
|
50
|
+
|
|
42
51
|
const copy = ISet.create(original);
|
|
43
52
|
|
|
44
53
|
expect(copy.size).toBe(3);
|
|
54
|
+
|
|
45
55
|
expect(copy.has(1)).toBe(true);
|
|
56
|
+
|
|
46
57
|
expect(copy.has(2)).toBe(true);
|
|
58
|
+
|
|
47
59
|
expect(copy.has(3)).toBe(true);
|
|
48
60
|
});
|
|
49
61
|
});
|
|
@@ -109,6 +121,7 @@ describe('ISet.has', () => {
|
|
|
109
121
|
const set = ISet.create([true, false]);
|
|
110
122
|
|
|
111
123
|
expect(set.has(true)).toBe(true);
|
|
124
|
+
|
|
112
125
|
expect(set.has(false)).toBe(true);
|
|
113
126
|
});
|
|
114
127
|
|
|
@@ -116,6 +129,7 @@ describe('ISet.has', () => {
|
|
|
116
129
|
const set = ISet.create([null, undefined]);
|
|
117
130
|
|
|
118
131
|
expect(set.has(null)).toBe(true);
|
|
132
|
+
|
|
119
133
|
expect(set.has(undefined)).toBe(true);
|
|
120
134
|
});
|
|
121
135
|
});
|
|
@@ -166,9 +180,11 @@ describe('ISet.every', () => {
|
|
|
166
180
|
describe('every method as type guard', () => {
|
|
167
181
|
test('should narrow type when used as type guard', () => {
|
|
168
182
|
const set = ISet.create<string | number>(['hello', 'world']);
|
|
183
|
+
|
|
169
184
|
if (set.every((value): value is string => typeof value === 'string')) {
|
|
170
185
|
// Type should be narrowed to ISet<string>
|
|
171
186
|
const values = set.toArray();
|
|
187
|
+
|
|
172
188
|
for (const value of values) {
|
|
173
189
|
expect(isString(value)).toBe(true);
|
|
174
190
|
}
|
|
@@ -230,6 +246,7 @@ describe('ISet.some', () => {
|
|
|
230
246
|
const set = ISet.create(['hello', 'world', 'test']);
|
|
231
247
|
|
|
232
248
|
expect(set.some((str) => str.includes('o'))).toBe(true);
|
|
249
|
+
|
|
233
250
|
expect(set.some((str) => str.includes('z'))).toBe(false);
|
|
234
251
|
});
|
|
235
252
|
});
|
|
@@ -239,9 +256,11 @@ describe('ISet.add', () => {
|
|
|
239
256
|
const s0 = ISet.create<number>([1, 2, 3]);
|
|
240
257
|
|
|
241
258
|
expectType<typeof s0.add, (value: number) => ISet<number>>('<=');
|
|
259
|
+
|
|
242
260
|
const s1 = ISet.create<number>([1, 2, 3, 4]);
|
|
243
261
|
|
|
244
262
|
assert.deepStrictEqual(s0.add(4), s1);
|
|
263
|
+
|
|
245
264
|
assert.deepStrictEqual(s0, ISet.create<number>([1, 2, 3]));
|
|
246
265
|
});
|
|
247
266
|
|
|
@@ -249,6 +268,7 @@ describe('ISet.add', () => {
|
|
|
249
268
|
const s0 = ISet.create<number>([1, 2, 3]);
|
|
250
269
|
|
|
251
270
|
assert.deepStrictEqual(s0.add(2), ISet.create([1, 2, 3]));
|
|
271
|
+
|
|
252
272
|
assert.deepStrictEqual(s0, ISet.create([1, 2, 3]));
|
|
253
273
|
});
|
|
254
274
|
|
|
@@ -256,21 +276,27 @@ describe('ISet.add', () => {
|
|
|
256
276
|
const s0 = ISet.create<number>([]);
|
|
257
277
|
|
|
258
278
|
assert.deepStrictEqual(s0.add(1), ISet.create([1]));
|
|
279
|
+
|
|
259
280
|
assert.deepStrictEqual(s0, ISet.create<number>([]));
|
|
260
281
|
});
|
|
261
282
|
|
|
262
283
|
test('should add new elements and maintain immutability', () => {
|
|
263
284
|
const original = ISet.create<number>([1, 2, 3]);
|
|
285
|
+
|
|
264
286
|
const modified = original.add(4);
|
|
265
287
|
|
|
266
288
|
expect(original.size).toBe(3);
|
|
289
|
+
|
|
267
290
|
expect(modified.size).toBe(4);
|
|
291
|
+
|
|
268
292
|
expect(original.has(4)).toBe(false);
|
|
293
|
+
|
|
269
294
|
expect(modified.has(4)).toBe(true);
|
|
270
295
|
});
|
|
271
296
|
|
|
272
297
|
test('should return same instance when adding existing element', () => {
|
|
273
298
|
const set = ISet.create([1, 2, 3]);
|
|
299
|
+
|
|
274
300
|
const result = set.add(2);
|
|
275
301
|
|
|
276
302
|
expect(result).toBe(set);
|
|
@@ -278,12 +304,17 @@ describe('ISet.add', () => {
|
|
|
278
304
|
|
|
279
305
|
test('should handle special values', () => {
|
|
280
306
|
const set = ISet.create<number | null | undefined>([]);
|
|
307
|
+
|
|
281
308
|
const withNull = set.add(null);
|
|
309
|
+
|
|
282
310
|
const withUndefined = withNull.add(undefined);
|
|
311
|
+
|
|
283
312
|
const withNaN = withUndefined.add(Number.NaN);
|
|
284
313
|
|
|
285
314
|
expect(withNaN.has(null)).toBe(true);
|
|
315
|
+
|
|
286
316
|
expect(withNaN.has(undefined)).toBe(true);
|
|
317
|
+
|
|
287
318
|
expect(withNaN.has(Number.NaN)).toBe(true);
|
|
288
319
|
});
|
|
289
320
|
});
|
|
@@ -295,6 +326,7 @@ describe('ISet.delete', () => {
|
|
|
295
326
|
expectType<typeof s0.delete, (value: number) => ISet<number>>('<=');
|
|
296
327
|
|
|
297
328
|
assert.deepStrictEqual(s0.delete(4), ISet.create<number>([1, 2, 3]));
|
|
329
|
+
|
|
298
330
|
assert.deepStrictEqual(s0, ISet.create<number>([1, 2, 3]));
|
|
299
331
|
});
|
|
300
332
|
|
|
@@ -302,6 +334,7 @@ describe('ISet.delete', () => {
|
|
|
302
334
|
const s0 = ISet.create([1, 2, 3]);
|
|
303
335
|
|
|
304
336
|
assert.deepStrictEqual(s0.delete(2), ISet.create<1 | 2 | 3>([1, 3]));
|
|
337
|
+
|
|
305
338
|
assert.deepStrictEqual(s0, ISet.create([1, 2, 3]));
|
|
306
339
|
});
|
|
307
340
|
|
|
@@ -309,21 +342,27 @@ describe('ISet.delete', () => {
|
|
|
309
342
|
const s0 = ISet.create<number>([]);
|
|
310
343
|
|
|
311
344
|
assert.deepStrictEqual(s0.delete(1), ISet.create<number>([]));
|
|
345
|
+
|
|
312
346
|
assert.deepStrictEqual(s0, ISet.create<number>([]));
|
|
313
347
|
});
|
|
314
348
|
|
|
315
349
|
test('should delete existing elements and maintain immutability', () => {
|
|
316
350
|
const original = ISet.create([1, 2, 3, 4]);
|
|
351
|
+
|
|
317
352
|
const modified = original.delete(2);
|
|
318
353
|
|
|
319
354
|
expect(original.size).toBe(4);
|
|
355
|
+
|
|
320
356
|
expect(modified.size).toBe(3);
|
|
357
|
+
|
|
321
358
|
expect(original.has(2)).toBe(true);
|
|
359
|
+
|
|
322
360
|
expect(modified.has(2)).toBe(false);
|
|
323
361
|
});
|
|
324
362
|
|
|
325
363
|
test('should return same instance when deleting non-existent element', () => {
|
|
326
364
|
const set = ISet.create<number>([1, 2, 3]);
|
|
365
|
+
|
|
327
366
|
const result = set.delete(4);
|
|
328
367
|
|
|
329
368
|
expect(result).toBe(set);
|
|
@@ -356,6 +395,7 @@ describe('ISet.map', () => {
|
|
|
356
395
|
|
|
357
396
|
test('should transform all elements', () => {
|
|
358
397
|
const set = ISet.create([1, 2, 3]);
|
|
398
|
+
|
|
359
399
|
const doubled = set.map((x) => x * 2);
|
|
360
400
|
|
|
361
401
|
assert.deepStrictEqual(
|
|
@@ -366,10 +406,13 @@ describe('ISet.map', () => {
|
|
|
366
406
|
|
|
367
407
|
test('should handle type transformations', () => {
|
|
368
408
|
const set = ISet.create([1, 2, 3]);
|
|
409
|
+
|
|
369
410
|
const strings = set.map((x) => x.toString());
|
|
370
411
|
|
|
371
412
|
expect(strings.has('1')).toBe(true);
|
|
413
|
+
|
|
372
414
|
expect(strings.has('2')).toBe(true);
|
|
415
|
+
|
|
373
416
|
expect(strings.has('3')).toBe(true);
|
|
374
417
|
});
|
|
375
418
|
});
|
|
@@ -402,30 +445,39 @@ describe('ISet.filter', () => {
|
|
|
402
445
|
|
|
403
446
|
test('should filter elements based on predicate', () => {
|
|
404
447
|
const set = ISet.create([1, 2, 3, 4, 5, 6]);
|
|
448
|
+
|
|
405
449
|
const evens = set.filter((x) => x % 2 === 0);
|
|
406
450
|
|
|
407
451
|
expect(evens.size).toBe(3);
|
|
452
|
+
|
|
408
453
|
expect(evens.has(2)).toBe(true);
|
|
454
|
+
|
|
409
455
|
expect(evens.has(4)).toBe(true);
|
|
456
|
+
|
|
410
457
|
expect(evens.has(6)).toBe(true);
|
|
411
458
|
});
|
|
412
459
|
|
|
413
460
|
test('should work as type guard', () => {
|
|
414
461
|
const set = ISet.create<string | number>(['hello', 42, 'world', 123]);
|
|
462
|
+
|
|
415
463
|
const strings = set.filter(
|
|
416
464
|
(value): value is string => typeof value === 'string',
|
|
417
465
|
);
|
|
418
466
|
|
|
419
467
|
expect(strings.size).toBe(2);
|
|
468
|
+
|
|
420
469
|
expect(strings.has('hello')).toBe(true);
|
|
470
|
+
|
|
421
471
|
expect(strings.has('world')).toBe(true);
|
|
422
472
|
});
|
|
423
473
|
|
|
424
474
|
test('should return empty set when no elements match', () => {
|
|
425
475
|
const set = ISet.create([1, 3, 5]);
|
|
476
|
+
|
|
426
477
|
const evens = set.filter((x) => x % 2 === 0);
|
|
427
478
|
|
|
428
479
|
expect(evens.size).toBe(0);
|
|
480
|
+
|
|
429
481
|
expect(evens.isEmpty).toBe(true);
|
|
430
482
|
});
|
|
431
483
|
});
|
|
@@ -433,24 +485,31 @@ describe('ISet.filter', () => {
|
|
|
433
485
|
describe('ISet.filterNot', () => {
|
|
434
486
|
test('should filter out elements that satisfy predicate', () => {
|
|
435
487
|
const set = ISet.create([1, 2, 3, 4, 5, 6]);
|
|
488
|
+
|
|
436
489
|
const odds = set.filterNot((x) => x % 2 === 0);
|
|
437
490
|
|
|
438
491
|
expect(odds.size).toBe(3);
|
|
492
|
+
|
|
439
493
|
expect(odds.has(1)).toBe(true);
|
|
494
|
+
|
|
440
495
|
expect(odds.has(3)).toBe(true);
|
|
496
|
+
|
|
441
497
|
expect(odds.has(5)).toBe(true);
|
|
442
498
|
});
|
|
443
499
|
|
|
444
500
|
test('should return same set when no elements satisfy predicate', () => {
|
|
445
501
|
const set = ISet.create([1, 3, 5]);
|
|
502
|
+
|
|
446
503
|
const nonEvens = set.filterNot((x) => x % 2 === 0);
|
|
447
504
|
|
|
448
505
|
expect(nonEvens.size).toBe(3);
|
|
506
|
+
|
|
449
507
|
expect(ISet.equal(set, nonEvens)).toBe(true);
|
|
450
508
|
});
|
|
451
509
|
|
|
452
510
|
test('should return empty set when all elements satisfy predicate', () => {
|
|
453
511
|
const set = ISet.create([2, 4, 6]);
|
|
512
|
+
|
|
454
513
|
const nonEvens = set.filterNot((x) => x % 2 === 0);
|
|
455
514
|
|
|
456
515
|
expect(nonEvens.isEmpty).toBe(true);
|
|
@@ -460,6 +519,7 @@ describe('ISet.filterNot', () => {
|
|
|
460
519
|
describe('ISet.isSubsetOf', () => {
|
|
461
520
|
test('case 1', () => {
|
|
462
521
|
const s0 = ISet.create<number>([1, 2]);
|
|
522
|
+
|
|
463
523
|
const s1 = ISet.create<number>([1, 2, 3]);
|
|
464
524
|
|
|
465
525
|
expectType<typeof s0.isSubsetOf, (other: ISet<number>) => boolean>('<=');
|
|
@@ -469,6 +529,7 @@ describe('ISet.isSubsetOf', () => {
|
|
|
469
529
|
|
|
470
530
|
test('case 2', () => {
|
|
471
531
|
const s0 = ISet.create<number>([1, 2, 3]);
|
|
532
|
+
|
|
472
533
|
const s1 = ISet.create<number>([1, 2]);
|
|
473
534
|
|
|
474
535
|
expect(s0.isSubsetOf(s1)).toBe(false);
|
|
@@ -476,6 +537,7 @@ describe('ISet.isSubsetOf', () => {
|
|
|
476
537
|
|
|
477
538
|
test('case 3', () => {
|
|
478
539
|
const s0 = ISet.create<number>([]);
|
|
540
|
+
|
|
479
541
|
const s1 = ISet.create<number>([1, 2, 3]);
|
|
480
542
|
|
|
481
543
|
expect(s0.isSubsetOf(s1)).toBe(true);
|
|
@@ -483,6 +545,7 @@ describe('ISet.isSubsetOf', () => {
|
|
|
483
545
|
|
|
484
546
|
test('should return true for subset relationship', () => {
|
|
485
547
|
const subset = ISet.create<number>([1, 2]);
|
|
548
|
+
|
|
486
549
|
const superset = ISet.create<number>([1, 2, 3, 4]);
|
|
487
550
|
|
|
488
551
|
expect(subset.isSubsetOf(superset)).toBe(true);
|
|
@@ -490,6 +553,7 @@ describe('ISet.isSubsetOf', () => {
|
|
|
490
553
|
|
|
491
554
|
test('should return true for equal sets', () => {
|
|
492
555
|
const set1 = ISet.create<number>([1, 2, 3]);
|
|
556
|
+
|
|
493
557
|
const set2 = ISet.create<number>([1, 2, 3]);
|
|
494
558
|
|
|
495
559
|
expect(set1.isSubsetOf(set2)).toBe(true);
|
|
@@ -497,6 +561,7 @@ describe('ISet.isSubsetOf', () => {
|
|
|
497
561
|
|
|
498
562
|
test('should return false for non-subset', () => {
|
|
499
563
|
const set1 = ISet.create<number>([1, 2, 5]);
|
|
564
|
+
|
|
500
565
|
const set2 = ISet.create<number>([1, 2, 3, 4]);
|
|
501
566
|
|
|
502
567
|
expect(set1.isSubsetOf(set2)).toBe(false);
|
|
@@ -506,6 +571,7 @@ describe('ISet.isSubsetOf', () => {
|
|
|
506
571
|
describe('ISet.isSupersetOf', () => {
|
|
507
572
|
test('case 1', () => {
|
|
508
573
|
const s0 = ISet.create<number>([1, 2, 3]);
|
|
574
|
+
|
|
509
575
|
const s1 = ISet.create<number>([1, 2]);
|
|
510
576
|
|
|
511
577
|
expectType<typeof s0.isSupersetOf, (other: ISet<number>) => boolean>('<=');
|
|
@@ -515,6 +581,7 @@ describe('ISet.isSupersetOf', () => {
|
|
|
515
581
|
|
|
516
582
|
test('case 2', () => {
|
|
517
583
|
const s0 = ISet.create<number>([1, 2]);
|
|
584
|
+
|
|
518
585
|
const s1 = ISet.create<number>([1, 2, 3]);
|
|
519
586
|
|
|
520
587
|
expect(s0.isSupersetOf(s1)).toBe(false);
|
|
@@ -522,6 +589,7 @@ describe('ISet.isSupersetOf', () => {
|
|
|
522
589
|
|
|
523
590
|
test('case 3', () => {
|
|
524
591
|
const s0 = ISet.create<number>([1, 2, 3]);
|
|
592
|
+
|
|
525
593
|
const s1 = ISet.create<number>([]);
|
|
526
594
|
|
|
527
595
|
expect(s0.isSupersetOf(s1)).toBe(true);
|
|
@@ -529,6 +597,7 @@ describe('ISet.isSupersetOf', () => {
|
|
|
529
597
|
|
|
530
598
|
test('should return true for superset relationship', () => {
|
|
531
599
|
const superset = ISet.create<number>([1, 2, 3, 4]);
|
|
600
|
+
|
|
532
601
|
const subset = ISet.create<number>([1, 2]);
|
|
533
602
|
|
|
534
603
|
expect(superset.isSupersetOf(subset)).toBe(true);
|
|
@@ -536,6 +605,7 @@ describe('ISet.isSupersetOf', () => {
|
|
|
536
605
|
|
|
537
606
|
test('should return true for equal sets', () => {
|
|
538
607
|
const set1 = ISet.create<number>([1, 2, 3]);
|
|
608
|
+
|
|
539
609
|
const set2 = ISet.create<number>([1, 2, 3]);
|
|
540
610
|
|
|
541
611
|
expect(set1.isSupersetOf(set2)).toBe(true);
|
|
@@ -543,6 +613,7 @@ describe('ISet.isSupersetOf', () => {
|
|
|
543
613
|
|
|
544
614
|
test('should return false for non-superset', () => {
|
|
545
615
|
const set1 = ISet.create<number>([1, 2, 3]);
|
|
616
|
+
|
|
546
617
|
const set2 = ISet.create<number>([1, 2, 3, 4]);
|
|
547
618
|
|
|
548
619
|
expect(set1.isSupersetOf(set2)).toBe(false);
|
|
@@ -552,6 +623,7 @@ describe('ISet.isSupersetOf', () => {
|
|
|
552
623
|
describe('ISet.subtract', () => {
|
|
553
624
|
test('case 1', () => {
|
|
554
625
|
const s0 = ISet.create<number>([1, 2, 3]);
|
|
626
|
+
|
|
555
627
|
const s1 = ISet.create<number>([2, 4]);
|
|
556
628
|
|
|
557
629
|
expectType<typeof s0.subtract, (other: ISet<number>) => ISet<number>>('<=');
|
|
@@ -561,6 +633,7 @@ describe('ISet.subtract', () => {
|
|
|
561
633
|
|
|
562
634
|
test('case 2', () => {
|
|
563
635
|
const s0 = ISet.create<number>([1, 2, 3]);
|
|
636
|
+
|
|
564
637
|
const s1 = ISet.create<number>([]);
|
|
565
638
|
|
|
566
639
|
assert.deepStrictEqual(s0.subtract(s1), ISet.create<number>([1, 2, 3]));
|
|
@@ -568,6 +641,7 @@ describe('ISet.subtract', () => {
|
|
|
568
641
|
|
|
569
642
|
test('case 3', () => {
|
|
570
643
|
const s0 = ISet.create<number>([]);
|
|
644
|
+
|
|
571
645
|
const s1 = ISet.create<number>([1, 2, 3]);
|
|
572
646
|
|
|
573
647
|
assert.deepStrictEqual(s0.subtract(s1), ISet.create<number>([]));
|
|
@@ -575,17 +649,23 @@ describe('ISet.subtract', () => {
|
|
|
575
649
|
|
|
576
650
|
test('should return elements in first set but not in second', () => {
|
|
577
651
|
const set1 = ISet.create<number>([1, 2, 3, 4, 5]);
|
|
652
|
+
|
|
578
653
|
const set2 = ISet.create<number>([3, 4, 5, 6, 7]);
|
|
654
|
+
|
|
579
655
|
const result = set1.subtract(set2);
|
|
580
656
|
|
|
581
657
|
expect(result.size).toBe(2);
|
|
658
|
+
|
|
582
659
|
expect(result.has(1)).toBe(true);
|
|
660
|
+
|
|
583
661
|
expect(result.has(2)).toBe(true);
|
|
584
662
|
});
|
|
585
663
|
|
|
586
664
|
test('should return empty set when all elements are removed', () => {
|
|
587
665
|
const set1 = ISet.create<number>([1, 2, 3]);
|
|
666
|
+
|
|
588
667
|
const set2 = ISet.create<number>([1, 2, 3, 4, 5]);
|
|
668
|
+
|
|
589
669
|
const result = set1.subtract(set2);
|
|
590
670
|
|
|
591
671
|
expect(result.isEmpty).toBe(true);
|
|
@@ -595,6 +675,7 @@ describe('ISet.subtract', () => {
|
|
|
595
675
|
describe('ISet.intersection', () => {
|
|
596
676
|
test('case 1', () => {
|
|
597
677
|
const s0 = ISet.create<number>([1, 2, 3]);
|
|
678
|
+
|
|
598
679
|
const s1 = ISet.create<number>([2, 3, 4]);
|
|
599
680
|
|
|
600
681
|
expectType<
|
|
@@ -610,6 +691,7 @@ describe('ISet.intersection', () => {
|
|
|
610
691
|
|
|
611
692
|
test('case 2', () => {
|
|
612
693
|
const s0 = ISet.create<number>([1, 2, 3]);
|
|
694
|
+
|
|
613
695
|
const s1 = ISet.create<number>([]);
|
|
614
696
|
|
|
615
697
|
assert.deepStrictEqual(ISet.intersection(s0, s1), ISet.create<number>([]));
|
|
@@ -617,6 +699,7 @@ describe('ISet.intersection', () => {
|
|
|
617
699
|
|
|
618
700
|
test('case 3', () => {
|
|
619
701
|
const s0 = ISet.create<number>([]);
|
|
702
|
+
|
|
620
703
|
const s1 = ISet.create<number>([1, 2, 3]);
|
|
621
704
|
|
|
622
705
|
assert.deepStrictEqual(ISet.intersection(s0, s1), ISet.create<number>([]));
|
|
@@ -624,17 +707,23 @@ describe('ISet.intersection', () => {
|
|
|
624
707
|
|
|
625
708
|
test('should return common elements', () => {
|
|
626
709
|
const set1 = ISet.create<number>([1, 2, 3, 4]);
|
|
710
|
+
|
|
627
711
|
const set2 = ISet.create<number>([3, 4, 5, 6]);
|
|
712
|
+
|
|
628
713
|
const result = ISet.intersection(set1, set2);
|
|
629
714
|
|
|
630
715
|
expect(result.size).toBe(2);
|
|
716
|
+
|
|
631
717
|
expect(result.has(3)).toBe(true);
|
|
718
|
+
|
|
632
719
|
expect(result.has(4)).toBe(true);
|
|
633
720
|
});
|
|
634
721
|
|
|
635
722
|
test('should return empty set when no common elements', () => {
|
|
636
723
|
const set1 = ISet.create<number>([1, 2]);
|
|
724
|
+
|
|
637
725
|
const set2 = ISet.create<number>([3, 4]);
|
|
726
|
+
|
|
638
727
|
const result = ISet.intersection(set1, set2);
|
|
639
728
|
|
|
640
729
|
expect(result.isEmpty).toBe(true);
|
|
@@ -644,6 +733,7 @@ describe('ISet.intersection', () => {
|
|
|
644
733
|
describe('ISet.intersect', () => {
|
|
645
734
|
test('case 1', () => {
|
|
646
735
|
const s0 = ISet.create<number>([1, 2, 3]);
|
|
736
|
+
|
|
647
737
|
const s1 = ISet.create<number>([2, 3, 4]);
|
|
648
738
|
|
|
649
739
|
expectType<typeof s0.intersect, (other: ISet<number>) => ISet<number>>(
|
|
@@ -655,6 +745,7 @@ describe('ISet.intersect', () => {
|
|
|
655
745
|
|
|
656
746
|
test('case 2', () => {
|
|
657
747
|
const s0 = ISet.create<number>([1, 2, 3]);
|
|
748
|
+
|
|
658
749
|
const s1 = ISet.create<number>([]);
|
|
659
750
|
|
|
660
751
|
assert.deepStrictEqual(s0.intersect(s1), ISet.create<number>([]));
|
|
@@ -662,6 +753,7 @@ describe('ISet.intersect', () => {
|
|
|
662
753
|
|
|
663
754
|
test('case 3', () => {
|
|
664
755
|
const s0 = ISet.create<number>([]);
|
|
756
|
+
|
|
665
757
|
const s1 = ISet.create<number>([1, 2, 3]);
|
|
666
758
|
|
|
667
759
|
assert.deepStrictEqual(s0.intersect(s1), ISet.create<number>([]));
|
|
@@ -669,11 +761,15 @@ describe('ISet.intersect', () => {
|
|
|
669
761
|
|
|
670
762
|
test('should return common elements using instance method', () => {
|
|
671
763
|
const set1 = ISet.create<number>([1, 2, 3, 4]);
|
|
764
|
+
|
|
672
765
|
const set2 = ISet.create<number>([3, 4, 5, 6]);
|
|
766
|
+
|
|
673
767
|
const result = set1.intersect(set2);
|
|
674
768
|
|
|
675
769
|
expect(result.size).toBe(2);
|
|
770
|
+
|
|
676
771
|
expect(result.has(3)).toBe(true);
|
|
772
|
+
|
|
677
773
|
expect(result.has(4)).toBe(true);
|
|
678
774
|
});
|
|
679
775
|
});
|
|
@@ -681,6 +777,7 @@ describe('ISet.intersect', () => {
|
|
|
681
777
|
describe('ISet.union', () => {
|
|
682
778
|
test('case 1', () => {
|
|
683
779
|
const s0 = ISet.create<number>([1, 2, 3]);
|
|
780
|
+
|
|
684
781
|
const s1 = ISet.create<number>([3, 4, 5]);
|
|
685
782
|
|
|
686
783
|
expectType<
|
|
@@ -696,6 +793,7 @@ describe('ISet.union', () => {
|
|
|
696
793
|
|
|
697
794
|
test('case 2', () => {
|
|
698
795
|
const s0 = ISet.create([1, 2, 3]);
|
|
796
|
+
|
|
699
797
|
const s1 = ISet.create<number>([]);
|
|
700
798
|
|
|
701
799
|
assert.deepStrictEqual(ISet.union(s0, s1), ISet.create<number>([1, 2, 3]));
|
|
@@ -703,6 +801,7 @@ describe('ISet.union', () => {
|
|
|
703
801
|
|
|
704
802
|
test('case 3', () => {
|
|
705
803
|
const s0 = ISet.create<number>([]);
|
|
804
|
+
|
|
706
805
|
const s1 = ISet.create<number>([1, 2, 3]);
|
|
707
806
|
|
|
708
807
|
assert.deepStrictEqual(ISet.union(s0, s1), ISet.create<number>([1, 2, 3]));
|
|
@@ -710,20 +809,28 @@ describe('ISet.union', () => {
|
|
|
710
809
|
|
|
711
810
|
test('should return combined elements using static method', () => {
|
|
712
811
|
const set1 = ISet.create<number>([1, 2, 3]);
|
|
812
|
+
|
|
713
813
|
const set2 = ISet.create<number>([3, 4, 5]);
|
|
814
|
+
|
|
714
815
|
const result = ISet.union(set1, set2);
|
|
715
816
|
|
|
716
817
|
expect(result.size).toBe(5);
|
|
818
|
+
|
|
717
819
|
expect(result.has(1)).toBe(true);
|
|
820
|
+
|
|
718
821
|
expect(result.has(2)).toBe(true);
|
|
822
|
+
|
|
719
823
|
expect(result.has(3)).toBe(true);
|
|
824
|
+
|
|
720
825
|
expect(result.has(4)).toBe(true);
|
|
826
|
+
|
|
721
827
|
expect(result.has(5)).toBe(true);
|
|
722
828
|
});
|
|
723
829
|
|
|
724
830
|
describe('instance method', () => {
|
|
725
831
|
test('case 1', () => {
|
|
726
832
|
const s0 = ISet.create([1, 2, 3] as const);
|
|
833
|
+
|
|
727
834
|
const s1 = ISet.create([3, 4, 5] as const);
|
|
728
835
|
|
|
729
836
|
expectType<typeof s0.union, (other: ISet<number>) => ISet<number>>('<=');
|
|
@@ -736,6 +843,7 @@ describe('ISet.union', () => {
|
|
|
736
843
|
|
|
737
844
|
test('case 2', () => {
|
|
738
845
|
const s0 = ISet.create<number>([1, 2, 3]);
|
|
846
|
+
|
|
739
847
|
const s1 = ISet.create<number>([]);
|
|
740
848
|
|
|
741
849
|
assert.deepStrictEqual(s0.union(s1), ISet.create<number>([1, 2, 3]));
|
|
@@ -743,6 +851,7 @@ describe('ISet.union', () => {
|
|
|
743
851
|
|
|
744
852
|
test('case 3', () => {
|
|
745
853
|
const s0 = ISet.create<number>([]);
|
|
854
|
+
|
|
746
855
|
const s1 = ISet.create<number>([1, 2, 3]);
|
|
747
856
|
|
|
748
857
|
assert.deepStrictEqual(s0.union(s1), ISet.create<number>([1, 2, 3]));
|
|
@@ -750,14 +859,21 @@ describe('ISet.union', () => {
|
|
|
750
859
|
|
|
751
860
|
test('should return combined elements using instance method', () => {
|
|
752
861
|
const set1 = ISet.create<number>([1, 2, 3]);
|
|
862
|
+
|
|
753
863
|
const set2 = ISet.create<number>([3, 4, 5]);
|
|
864
|
+
|
|
754
865
|
const result = set1.union(set2);
|
|
755
866
|
|
|
756
867
|
expect(result.size).toBe(5);
|
|
868
|
+
|
|
757
869
|
expect(result.has(1)).toBe(true);
|
|
870
|
+
|
|
758
871
|
expect(result.has(2)).toBe(true);
|
|
872
|
+
|
|
759
873
|
expect(result.has(3)).toBe(true);
|
|
874
|
+
|
|
760
875
|
expect(result.has(4)).toBe(true);
|
|
876
|
+
|
|
761
877
|
expect(result.has(5)).toBe(true);
|
|
762
878
|
});
|
|
763
879
|
});
|
|
@@ -773,6 +889,7 @@ describe('ISet.forEach', () => {
|
|
|
773
889
|
>('<=');
|
|
774
890
|
|
|
775
891
|
const mut_result: (1 | 2 | 3)[] = [];
|
|
892
|
+
|
|
776
893
|
for (const x of s0) {
|
|
777
894
|
mut_result.push(x);
|
|
778
895
|
}
|
|
@@ -785,6 +902,7 @@ describe('ISet.forEach', () => {
|
|
|
785
902
|
|
|
786
903
|
test('should execute callback for each element', () => {
|
|
787
904
|
const set = ISet.create([1, 2, 3]);
|
|
905
|
+
|
|
788
906
|
const mut_collected: number[] = [];
|
|
789
907
|
|
|
790
908
|
for (const value of set) {
|
|
@@ -799,6 +917,7 @@ describe('ISet.forEach', () => {
|
|
|
799
917
|
|
|
800
918
|
test('should not call callback for empty set', () => {
|
|
801
919
|
const set = ISet.create<number>([]);
|
|
920
|
+
|
|
802
921
|
let mut_callCount = 0;
|
|
803
922
|
|
|
804
923
|
// eslint-disable-next-line unicorn/no-array-for-each
|
|
@@ -817,6 +936,7 @@ describe('ISet.keys', () => {
|
|
|
817
936
|
expectType<typeof s0.keys, () => IterableIterator<1 | 2 | 3>>('<=');
|
|
818
937
|
|
|
819
938
|
const mut_result: (1 | 2 | 3)[] = [];
|
|
939
|
+
|
|
820
940
|
for (const x of s0.keys()) {
|
|
821
941
|
mut_result.push(x);
|
|
822
942
|
}
|
|
@@ -835,6 +955,7 @@ describe('ISet.values', () => {
|
|
|
835
955
|
expectType<typeof s0.values, () => IterableIterator<1 | 2 | 3>>('<=');
|
|
836
956
|
|
|
837
957
|
const mut_result: (1 | 2 | 3)[] = [];
|
|
958
|
+
|
|
838
959
|
for (const x of s0.values()) {
|
|
839
960
|
mut_result.push(x);
|
|
840
961
|
}
|
|
@@ -856,6 +977,7 @@ describe('ISet.entries', () => {
|
|
|
856
977
|
>('<=');
|
|
857
978
|
|
|
858
979
|
const mut_result: [1 | 2 | 3, 1 | 2 | 3][] = [];
|
|
980
|
+
|
|
859
981
|
for (const x of s0.entries()) {
|
|
860
982
|
mut_result.push([x[0], x[1]]);
|
|
861
983
|
}
|
|
@@ -891,6 +1013,7 @@ describe('ISet.toArray', () => {
|
|
|
891
1013
|
|
|
892
1014
|
test('should convert set to array', () => {
|
|
893
1015
|
const set = ISet.create([1, 3, 2]);
|
|
1016
|
+
|
|
894
1017
|
const array = set.toArray();
|
|
895
1018
|
|
|
896
1019
|
expect(array).toHaveLength(3);
|
|
@@ -905,16 +1028,21 @@ describe('ISet.toArray', () => {
|
|
|
905
1028
|
describe('ISet.toRawSet', () => {
|
|
906
1029
|
test('should return underlying ReadonlySet', () => {
|
|
907
1030
|
const set = ISet.create([1, 2, 3]);
|
|
1031
|
+
|
|
908
1032
|
const rawSet = set.toRawSet();
|
|
909
1033
|
|
|
910
1034
|
expect(rawSet.size).toBe(3);
|
|
1035
|
+
|
|
911
1036
|
expect(rawSet.has(1)).toBe(true);
|
|
1037
|
+
|
|
912
1038
|
expect(rawSet.has(2)).toBe(true);
|
|
1039
|
+
|
|
913
1040
|
expect(rawSet.has(3)).toBe(true);
|
|
914
1041
|
});
|
|
915
1042
|
|
|
916
1043
|
test('should return empty ReadonlySet for empty ISet', () => {
|
|
917
1044
|
const set = ISet.create<number>([]);
|
|
1045
|
+
|
|
918
1046
|
const rawSet = set.toRawSet();
|
|
919
1047
|
|
|
920
1048
|
expect(rawSet.size).toBe(0);
|
|
@@ -924,6 +1052,7 @@ describe('ISet.toRawSet', () => {
|
|
|
924
1052
|
describe('ISet.equal', () => {
|
|
925
1053
|
test('should return true for equal sets', () => {
|
|
926
1054
|
const set1 = ISet.create([1, 2, 3]);
|
|
1055
|
+
|
|
927
1056
|
const set2 = ISet.create([3, 2, 1]); // Different order
|
|
928
1057
|
|
|
929
1058
|
expect(ISet.equal(set1, set2)).toBe(true);
|
|
@@ -931,6 +1060,7 @@ describe('ISet.equal', () => {
|
|
|
931
1060
|
|
|
932
1061
|
test('should return false for sets with different sizes', () => {
|
|
933
1062
|
const set1 = ISet.create<'a' | 'b' | 'c' | 'd'>(['a', 'b']);
|
|
1063
|
+
|
|
934
1064
|
const set2 = ISet.create<'a' | 'b' | 'c' | 'd'>(['a', 'b', 'c']);
|
|
935
1065
|
|
|
936
1066
|
expect(ISet.equal(set1, set2)).toBe(false);
|
|
@@ -938,6 +1068,7 @@ describe('ISet.equal', () => {
|
|
|
938
1068
|
|
|
939
1069
|
test('should return false for sets with different elements', () => {
|
|
940
1070
|
const set1 = ISet.create<'a' | 'b' | 'c' | 'd'>(['a', 'b', 'c']);
|
|
1071
|
+
|
|
941
1072
|
const set2 = ISet.create<'a' | 'b' | 'c' | 'd'>(['a', 'b', 'd']);
|
|
942
1073
|
|
|
943
1074
|
expect(ISet.equal(set1, set2)).toBe(false);
|
|
@@ -945,6 +1076,7 @@ describe('ISet.equal', () => {
|
|
|
945
1076
|
|
|
946
1077
|
test('should return true for empty sets', () => {
|
|
947
1078
|
const set1 = ISet.create<string>([]);
|
|
1079
|
+
|
|
948
1080
|
const set2 = ISet.create<string>([]);
|
|
949
1081
|
|
|
950
1082
|
expect(ISet.equal(set1, set2)).toBe(true);
|
|
@@ -952,6 +1084,7 @@ describe('ISet.equal', () => {
|
|
|
952
1084
|
|
|
953
1085
|
test('should handle sets with special values', () => {
|
|
954
1086
|
const set1 = ISet.create([Number.NaN, null, undefined]);
|
|
1087
|
+
|
|
955
1088
|
const set2 = ISet.create([undefined, Number.NaN, null]);
|
|
956
1089
|
|
|
957
1090
|
expect(ISet.equal(set1, set2)).toBe(true);
|
|
@@ -961,54 +1094,67 @@ describe('ISet.equal', () => {
|
|
|
961
1094
|
describe('ISet.diff', () => {
|
|
962
1095
|
test('should compute differences between sets', () => {
|
|
963
1096
|
const oldSet = ISet.create<'a' | 'b' | 'c' | 'd'>(['a', 'b', 'c']);
|
|
1097
|
+
|
|
964
1098
|
const newSet = ISet.create<'a' | 'b' | 'c' | 'd'>(['b', 'c', 'd']);
|
|
965
1099
|
|
|
966
1100
|
const diff = ISet.diff(oldSet, newSet);
|
|
967
1101
|
|
|
968
1102
|
expect(diff.deleted.size).toBe(1);
|
|
1103
|
+
|
|
969
1104
|
expect(diff.deleted.has('a')).toBe(true);
|
|
970
1105
|
|
|
971
1106
|
expect(diff.added.size).toBe(1);
|
|
1107
|
+
|
|
972
1108
|
expect(diff.added.has('d')).toBe(true);
|
|
973
1109
|
});
|
|
974
1110
|
|
|
975
1111
|
test('should handle no changes', () => {
|
|
976
1112
|
const set1 = ISet.create(['a', 'b', 'c']);
|
|
1113
|
+
|
|
977
1114
|
const set2 = ISet.create(['a', 'b', 'c']);
|
|
978
1115
|
|
|
979
1116
|
const diff = ISet.diff(set1, set2);
|
|
980
1117
|
|
|
981
1118
|
expect(diff.deleted.isEmpty).toBe(true);
|
|
1119
|
+
|
|
982
1120
|
expect(diff.added.isEmpty).toBe(true);
|
|
983
1121
|
});
|
|
984
1122
|
|
|
985
1123
|
test('should handle complete replacement', () => {
|
|
986
1124
|
const oldSet = ISet.create<'a' | 'b' | 'c' | 'd'>(['a', 'b']);
|
|
1125
|
+
|
|
987
1126
|
const newSet = ISet.create<'a' | 'b' | 'c' | 'd'>(['c', 'd']);
|
|
988
1127
|
|
|
989
1128
|
const diff = ISet.diff(oldSet, newSet);
|
|
990
1129
|
|
|
991
1130
|
expect(diff.deleted.size).toBe(2);
|
|
1131
|
+
|
|
992
1132
|
expect(diff.deleted.has('a')).toBe(true);
|
|
1133
|
+
|
|
993
1134
|
expect(diff.deleted.has('b')).toBe(true);
|
|
994
1135
|
|
|
995
1136
|
expect(diff.added.size).toBe(2);
|
|
1137
|
+
|
|
996
1138
|
expect(diff.added.has('c')).toBe(true);
|
|
1139
|
+
|
|
997
1140
|
expect(diff.added.has('d')).toBe(true);
|
|
998
1141
|
});
|
|
999
1142
|
|
|
1000
1143
|
test('should handle empty sets', () => {
|
|
1001
1144
|
const emptySet = ISet.create<string>([]);
|
|
1145
|
+
|
|
1002
1146
|
const nonEmptySet = ISet.create<string>(['a', 'b']);
|
|
1003
1147
|
|
|
1004
1148
|
const diff1 = ISet.diff(emptySet, nonEmptySet);
|
|
1005
1149
|
|
|
1006
1150
|
expect(diff1.deleted.isEmpty).toBe(true);
|
|
1151
|
+
|
|
1007
1152
|
expect(diff1.added.size).toBe(2);
|
|
1008
1153
|
|
|
1009
1154
|
const diff2 = ISet.diff(nonEmptySet, emptySet);
|
|
1010
1155
|
|
|
1011
1156
|
expect(diff2.deleted.size).toBe(2);
|
|
1157
|
+
|
|
1012
1158
|
expect(diff2.added.isEmpty).toBe(true);
|
|
1013
1159
|
});
|
|
1014
1160
|
});
|
|
@@ -1024,22 +1170,29 @@ describe('ISet.withMutations', () => {
|
|
|
1024
1170
|
]);
|
|
1025
1171
|
|
|
1026
1172
|
expect(updated.size).toBe(3);
|
|
1173
|
+
|
|
1027
1174
|
expect(updated.has('b')).toBe(true);
|
|
1175
|
+
|
|
1028
1176
|
expect(updated.has('c')).toBe(true);
|
|
1177
|
+
|
|
1029
1178
|
expect(updated.has('d')).toBe(true);
|
|
1179
|
+
|
|
1030
1180
|
expect(updated.has('a')).toBe(false);
|
|
1031
1181
|
});
|
|
1032
1182
|
|
|
1033
1183
|
test('should handle empty mutations array', () => {
|
|
1034
1184
|
const set = ISet.create(['a', 'b', 'c']);
|
|
1185
|
+
|
|
1035
1186
|
const updated = set.withMutations([]);
|
|
1036
1187
|
|
|
1037
1188
|
expect(updated.size).toBe(set.size);
|
|
1189
|
+
|
|
1038
1190
|
expect(ISet.equal(set, updated)).toBe(true);
|
|
1039
1191
|
});
|
|
1040
1192
|
|
|
1041
1193
|
test('should handle duplicate operations', () => {
|
|
1042
1194
|
const set = ISet.create<'a' | 'b'>(['a']);
|
|
1195
|
+
|
|
1043
1196
|
const updated = set.withMutations([
|
|
1044
1197
|
{ type: 'add', key: 'a' }, // Already exists
|
|
1045
1198
|
{ type: 'delete', key: 'b' }, // Doesn't exist
|
|
@@ -1047,7 +1200,9 @@ describe('ISet.withMutations', () => {
|
|
|
1047
1200
|
]);
|
|
1048
1201
|
|
|
1049
1202
|
expect(updated.size).toBe(2);
|
|
1203
|
+
|
|
1050
1204
|
expect(updated.has('a')).toBe(true);
|
|
1205
|
+
|
|
1051
1206
|
expect(updated.has('b')).toBe(true);
|
|
1052
1207
|
});
|
|
1053
1208
|
});
|
|
@@ -1055,6 +1210,7 @@ describe('ISet.withMutations', () => {
|
|
|
1055
1210
|
describe('iterable functionality', () => {
|
|
1056
1211
|
test('should work with for-of loops', () => {
|
|
1057
1212
|
const set = ISet.create([1, 2, 3]);
|
|
1213
|
+
|
|
1058
1214
|
const mut_collected: number[] = [];
|
|
1059
1215
|
|
|
1060
1216
|
for (const value of set) {
|
|
@@ -1069,6 +1225,7 @@ describe('iterable functionality', () => {
|
|
|
1069
1225
|
|
|
1070
1226
|
test('should work with spread operator', () => {
|
|
1071
1227
|
const set = ISet.create([1, 2, 3]);
|
|
1228
|
+
|
|
1072
1229
|
const array = Array.from(set);
|
|
1073
1230
|
|
|
1074
1231
|
assert.deepStrictEqual(
|
|
@@ -1079,6 +1236,7 @@ describe('iterable functionality', () => {
|
|
|
1079
1236
|
|
|
1080
1237
|
test('should work with Array.from', () => {
|
|
1081
1238
|
const set = ISet.create([1, 2, 3]);
|
|
1239
|
+
|
|
1082
1240
|
const array = Array.from(set);
|
|
1083
1241
|
|
|
1084
1242
|
assert.deepStrictEqual(
|
|
@@ -1089,6 +1247,7 @@ describe('iterable functionality', () => {
|
|
|
1089
1247
|
|
|
1090
1248
|
test('should work with destructuring', () => {
|
|
1091
1249
|
const set = ISet.create([1, 2]);
|
|
1250
|
+
|
|
1092
1251
|
const values = Array.from(set);
|
|
1093
1252
|
|
|
1094
1253
|
assert.deepStrictEqual(
|
|
@@ -1103,6 +1262,7 @@ describe('edge cases', () => {
|
|
|
1103
1262
|
const set = ISet.create([Number.NaN, 1, 2]);
|
|
1104
1263
|
|
|
1105
1264
|
expect(set.has(Number.NaN)).toBe(true);
|
|
1265
|
+
|
|
1106
1266
|
expect(set.size).toBe(3);
|
|
1107
1267
|
});
|
|
1108
1268
|
|
|
@@ -1110,7 +1270,9 @@ describe('edge cases', () => {
|
|
|
1110
1270
|
const set = ISet.create([true, false, true]);
|
|
1111
1271
|
|
|
1112
1272
|
expect(set.size).toBe(2);
|
|
1273
|
+
|
|
1113
1274
|
expect(set.has(true)).toBe(true);
|
|
1275
|
+
|
|
1114
1276
|
expect(set.has(false)).toBe(true);
|
|
1115
1277
|
});
|
|
1116
1278
|
|
|
@@ -1118,18 +1280,25 @@ describe('edge cases', () => {
|
|
|
1118
1280
|
const set = ISet.create([null, undefined, null]);
|
|
1119
1281
|
|
|
1120
1282
|
expect(set.size).toBe(2);
|
|
1283
|
+
|
|
1121
1284
|
expect(set.has(null)).toBe(true);
|
|
1285
|
+
|
|
1122
1286
|
expect(set.has(undefined)).toBe(true);
|
|
1123
1287
|
});
|
|
1124
1288
|
|
|
1125
1289
|
test('should handle symbols by reference', () => {
|
|
1126
1290
|
const sym1 = Symbol('test');
|
|
1291
|
+
|
|
1127
1292
|
const sym2 = Symbol('test'); // Different symbol, same description
|
|
1293
|
+
|
|
1128
1294
|
const set = ISet.create([sym1, sym2]);
|
|
1129
1295
|
|
|
1130
1296
|
expect(set.size).toBe(2);
|
|
1297
|
+
|
|
1131
1298
|
expect(set.has(sym1)).toBe(true);
|
|
1299
|
+
|
|
1132
1300
|
expect(set.has(sym2)).toBe(true);
|
|
1301
|
+
|
|
1133
1302
|
expect(set.has(Symbol('test'))).toBe(false); // Different symbol
|
|
1134
1303
|
});
|
|
1135
1304
|
});
|
|
@@ -1137,57 +1306,81 @@ describe('edge cases', () => {
|
|
|
1137
1306
|
describe('immutability', () => {
|
|
1138
1307
|
test('should not modify original set when adding', () => {
|
|
1139
1308
|
const original = ISet.create<number>([1, 2, 3]);
|
|
1309
|
+
|
|
1140
1310
|
const modified = original.add(4);
|
|
1141
1311
|
|
|
1142
1312
|
expect(original.size).toBe(3);
|
|
1313
|
+
|
|
1143
1314
|
expect(modified.size).toBe(4);
|
|
1315
|
+
|
|
1144
1316
|
expect(original.has(4)).toBe(false);
|
|
1317
|
+
|
|
1145
1318
|
expect(modified.has(4)).toBe(true);
|
|
1146
1319
|
});
|
|
1147
1320
|
|
|
1148
1321
|
test('should not modify original set when deleting', () => {
|
|
1149
1322
|
const original = ISet.create([1, 2, 3]);
|
|
1323
|
+
|
|
1150
1324
|
const modified = original.delete(2);
|
|
1151
1325
|
|
|
1152
1326
|
expect(original.size).toBe(3);
|
|
1327
|
+
|
|
1153
1328
|
expect(modified.size).toBe(2);
|
|
1329
|
+
|
|
1154
1330
|
expect(original.has(2)).toBe(true);
|
|
1331
|
+
|
|
1155
1332
|
expect(modified.has(2)).toBe(false);
|
|
1156
1333
|
});
|
|
1157
1334
|
|
|
1158
1335
|
test('should not modify original set when filtering', () => {
|
|
1159
1336
|
const original = ISet.create([1, 2, 3, 4, 5]);
|
|
1337
|
+
|
|
1160
1338
|
const filtered = original.filter((x) => x % 2 === 0);
|
|
1161
1339
|
|
|
1162
1340
|
expect(original.size).toBe(5);
|
|
1341
|
+
|
|
1163
1342
|
expect(filtered.size).toBe(2);
|
|
1343
|
+
|
|
1164
1344
|
expect(original.has(1)).toBe(true);
|
|
1345
|
+
|
|
1165
1346
|
expect(filtered.has(1)).toBe(false);
|
|
1166
1347
|
});
|
|
1167
1348
|
|
|
1168
1349
|
test('should not modify original set when mapping', () => {
|
|
1169
1350
|
const original = ISet.create([1, 2, 3]);
|
|
1351
|
+
|
|
1170
1352
|
const mapped = original.map((x) => x * 2);
|
|
1171
1353
|
|
|
1172
1354
|
expect(original.size).toBe(3);
|
|
1355
|
+
|
|
1173
1356
|
expect(mapped.size).toBe(3);
|
|
1357
|
+
|
|
1174
1358
|
expect(original.has(1)).toBe(true);
|
|
1359
|
+
|
|
1175
1360
|
expect(mapped.has(1)).toBe(false);
|
|
1361
|
+
|
|
1176
1362
|
expect(mapped.has(2)).toBe(true);
|
|
1177
1363
|
});
|
|
1178
1364
|
|
|
1179
1365
|
test('should not modify original sets during set operations', () => {
|
|
1180
1366
|
const set1 = ISet.create<number>([1, 2, 3]);
|
|
1367
|
+
|
|
1181
1368
|
const set2 = ISet.create<number>([3, 4, 5]);
|
|
1182
1369
|
|
|
1183
1370
|
const union = set1.union(set2);
|
|
1371
|
+
|
|
1184
1372
|
const intersection = set1.intersect(set2);
|
|
1373
|
+
|
|
1185
1374
|
const difference = set1.subtract(set2);
|
|
1186
1375
|
|
|
1187
1376
|
expect(set1.size).toBe(3);
|
|
1377
|
+
|
|
1188
1378
|
expect(set2.size).toBe(3);
|
|
1379
|
+
|
|
1189
1380
|
expect(union.size).toBe(5);
|
|
1381
|
+
|
|
1190
1382
|
expect(intersection.size).toBe(1);
|
|
1383
|
+
|
|
1191
1384
|
expect(difference.size).toBe(2);
|
|
1192
1385
|
});
|
|
1193
1386
|
});
|