ts-data-forge 8.0.0 → 9.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/array/impl/array-utils-creation.d.mts.map +1 -1
- package/dist/array/impl/array-utils-creation.mjs +17 -112
- package/dist/array/impl/array-utils-creation.mjs.map +1 -1
- package/dist/array/impl/array-utils-element-access.d.mts.map +1 -1
- package/dist/array/impl/array-utils-element-access.mjs +22 -61
- package/dist/array/impl/array-utils-element-access.mjs.map +1 -1
- package/dist/array/impl/array-utils-iterators.d.mts.map +1 -1
- package/dist/array/impl/array-utils-iterators.mjs +9 -63
- package/dist/array/impl/array-utils-iterators.mjs.map +1 -1
- package/dist/array/impl/array-utils-modification.mjs +78 -78
- package/dist/array/impl/array-utils-modification.mjs.map +1 -1
- package/dist/array/impl/array-utils-reducing-value.mjs +95 -89
- package/dist/array/impl/array-utils-reducing-value.mjs.map +1 -1
- package/dist/array/impl/array-utils-search.mjs +100 -92
- package/dist/array/impl/array-utils-search.mjs.map +1 -1
- package/dist/array/impl/array-utils-set-op.d.mts.map +1 -1
- package/dist/array/impl/array-utils-set-op.mjs +31 -141
- package/dist/array/impl/array-utils-set-op.mjs.map +1 -1
- package/dist/array/impl/array-utils-size.d.mts.map +1 -1
- package/dist/array/impl/array-utils-size.mjs +4 -8
- package/dist/array/impl/array-utils-size.mjs.map +1 -1
- package/dist/array/impl/array-utils-slice-clamped.mjs +11 -12
- package/dist/array/impl/array-utils-slice-clamped.mjs.map +1 -1
- package/dist/array/impl/array-utils-slicing.d.mts.map +1 -1
- package/dist/array/impl/array-utils-slicing.mjs +44 -96
- package/dist/array/impl/array-utils-slicing.mjs.map +1 -1
- package/dist/array/impl/array-utils-transformation.d.mts +1 -1
- package/dist/array/impl/array-utils-transformation.d.mts.map +1 -1
- package/dist/array/impl/array-utils-transformation.mjs +150 -292
- package/dist/array/impl/array-utils-transformation.mjs.map +1 -1
- package/dist/array/impl/array-utils-validation.d.mts.map +1 -1
- package/dist/array/impl/array-utils-validation.mjs +18 -169
- package/dist/array/impl/array-utils-validation.mjs.map +1 -1
- package/dist/collections/imap-mapped.d.mts.map +1 -1
- package/dist/collections/imap-mapped.mjs +243 -330
- package/dist/collections/imap-mapped.mjs.map +1 -1
- package/dist/collections/imap.d.mts.map +1 -1
- package/dist/collections/imap.mjs +190 -275
- package/dist/collections/imap.mjs.map +1 -1
- package/dist/collections/iset-mapped.d.mts +1 -1
- package/dist/collections/iset-mapped.d.mts.map +1 -1
- package/dist/collections/iset-mapped.mjs +222 -444
- package/dist/collections/iset-mapped.mjs.map +1 -1
- package/dist/collections/iset.d.mts +1 -1
- package/dist/collections/iset.d.mts.map +1 -1
- package/dist/collections/iset.mjs +158 -324
- package/dist/collections/iset.mjs.map +1 -1
- package/dist/collections/queue.d.mts.map +1 -1
- package/dist/collections/queue.mjs +106 -178
- package/dist/collections/queue.mjs.map +1 -1
- package/dist/collections/stack.d.mts.map +1 -1
- package/dist/collections/stack.mjs +95 -165
- package/dist/collections/stack.mjs.map +1 -1
- package/dist/entry-point.mjs +1 -0
- package/dist/entry-point.mjs.map +1 -1
- package/dist/expect-type.d.mts +1 -1
- package/dist/expect-type.d.mts.map +1 -1
- package/dist/expect-type.mjs +1 -69
- package/dist/expect-type.mjs.map +1 -1
- package/dist/functional/match.mjs +9 -9
- package/dist/functional/match.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-expect-to-be.mjs +13 -14
- package/dist/functional/optional/impl/optional-expect-to-be.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-filter.mjs +14 -15
- package/dist/functional/optional/impl/optional-filter.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-flat-map.mjs +10 -11
- package/dist/functional/optional/impl/optional-flat-map.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-from-nullable.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-from-nullable.mjs +1 -25
- package/dist/functional/optional/impl/optional-from-nullable.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-is-none.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-is-none.mjs +0 -19
- package/dist/functional/optional/impl/optional-is-none.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-is-optional.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-is-optional.mjs +1 -23
- package/dist/functional/optional/impl/optional-is-optional.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-is-some.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-is-some.mjs +0 -20
- package/dist/functional/optional/impl/optional-is-some.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-map.mjs +13 -14
- package/dist/functional/optional/impl/optional-map.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-none.mjs +0 -16
- package/dist/functional/optional/impl/optional-none.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-or-else.mjs +10 -11
- package/dist/functional/optional/impl/optional-or-else.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-some.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-some.mjs +2 -21
- package/dist/functional/optional/impl/optional-some.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-to-nullable.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-to-nullable.mjs +1 -27
- package/dist/functional/optional/impl/optional-to-nullable.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-unwrap-or.mjs +9 -10
- package/dist/functional/optional/impl/optional-unwrap-or.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-unwrap-throw.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-unwrap-throw.mjs +4 -32
- package/dist/functional/optional/impl/optional-unwrap-throw.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-unwrap.mjs +4 -4
- package/dist/functional/optional/impl/optional-unwrap.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-zip.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-zip.mjs +1 -35
- package/dist/functional/optional/impl/optional-zip.mjs.map +1 -1
- package/dist/functional/optional/impl/tag.mjs +2 -3
- package/dist/functional/optional/impl/tag.mjs.map +1 -1
- package/dist/functional/pipe.d.mts.map +1 -1
- package/dist/functional/pipe.mjs +9 -34
- package/dist/functional/pipe.mjs.map +1 -1
- package/dist/functional/result/impl/result-err.d.mts.map +1 -1
- package/dist/functional/result/impl/result-err.mjs +2 -27
- package/dist/functional/result/impl/result-err.mjs.map +1 -1
- package/dist/functional/result/impl/result-expect-to-be.mjs +13 -15
- package/dist/functional/result/impl/result-expect-to-be.mjs.map +1 -1
- package/dist/functional/result/impl/result-flat-map.mjs +16 -16
- package/dist/functional/result/impl/result-flat-map.mjs.map +1 -1
- package/dist/functional/result/impl/result-fold.mjs +16 -16
- package/dist/functional/result/impl/result-fold.mjs.map +1 -1
- package/dist/functional/result/impl/result-from-promise.d.mts.map +1 -1
- package/dist/functional/result/impl/result-from-promise.mjs +4 -31
- package/dist/functional/result/impl/result-from-promise.mjs.map +1 -1
- package/dist/functional/result/impl/result-from-throwable.d.mts.map +1 -1
- package/dist/functional/result/impl/result-from-throwable.mjs +8 -38
- package/dist/functional/result/impl/result-from-throwable.mjs.map +1 -1
- package/dist/functional/result/impl/result-is-err.d.mts.map +1 -1
- package/dist/functional/result/impl/result-is-err.mjs +0 -19
- package/dist/functional/result/impl/result-is-err.mjs.map +1 -1
- package/dist/functional/result/impl/result-is-ok.d.mts.map +1 -1
- package/dist/functional/result/impl/result-is-ok.mjs +0 -19
- package/dist/functional/result/impl/result-is-ok.mjs.map +1 -1
- package/dist/functional/result/impl/result-is-result.d.mts.map +1 -1
- package/dist/functional/result/impl/result-is-result.mjs +1 -23
- package/dist/functional/result/impl/result-is-result.mjs.map +1 -1
- package/dist/functional/result/impl/result-map-err.mjs +16 -16
- package/dist/functional/result/impl/result-map-err.mjs.map +1 -1
- package/dist/functional/result/impl/result-map.mjs +16 -16
- package/dist/functional/result/impl/result-map.mjs.map +1 -1
- package/dist/functional/result/impl/result-ok.d.mts.map +1 -1
- package/dist/functional/result/impl/result-ok.mjs +2 -27
- package/dist/functional/result/impl/result-ok.mjs.map +1 -1
- package/dist/functional/result/impl/result-or-else.mjs +10 -12
- package/dist/functional/result/impl/result-or-else.mjs.map +1 -1
- package/dist/functional/result/impl/result-swap.d.mts.map +1 -1
- package/dist/functional/result/impl/result-swap.mjs +4 -22
- package/dist/functional/result/impl/result-swap.mjs.map +1 -1
- package/dist/functional/result/impl/result-to-optional.d.mts.map +1 -1
- package/dist/functional/result/impl/result-to-optional.mjs +0 -27
- package/dist/functional/result/impl/result-to-optional.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-err-or.mjs +9 -11
- package/dist/functional/result/impl/result-unwrap-err-or.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-err-throw.d.mts.map +1 -1
- package/dist/functional/result/impl/result-unwrap-err-throw.mjs +13 -40
- package/dist/functional/result/impl/result-unwrap-err-throw.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-err.d.mts.map +1 -1
- package/dist/functional/result/impl/result-unwrap-err.mjs +4 -32
- package/dist/functional/result/impl/result-unwrap-err.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-ok-or.mjs +9 -11
- package/dist/functional/result/impl/result-unwrap-ok-or.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-ok.mjs +4 -4
- package/dist/functional/result/impl/result-unwrap-ok.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-throw.d.mts.map +1 -1
- package/dist/functional/result/impl/result-unwrap-throw.mjs +4 -35
- package/dist/functional/result/impl/result-unwrap-throw.mjs.map +1 -1
- package/dist/functional/result/impl/result-zip.d.mts.map +1 -1
- package/dist/functional/result/impl/result-zip.mjs +1 -34
- package/dist/functional/result/impl/result-zip.mjs.map +1 -1
- package/dist/functional/result/impl/tag.mjs +2 -3
- package/dist/functional/result/impl/tag.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/tag.mjs +3 -5
- package/dist/functional/ternary-result/impl/tag.mjs.map +1 -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 +2 -15
- package/dist/functional/ternary-result/impl/ternary-result-err.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs +13 -13
- 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.mjs +27 -26
- package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-fold.mjs +21 -22
- 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.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs +4 -20
- 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.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs +7 -25
- package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-is-err.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs +0 -17
- package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs.map +1 -1
- 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 +0 -19
- 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.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs +1 -25
- 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.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs +0 -18
- package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs +13 -15
- package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs +18 -18
- package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-map.mjs +21 -22
- package/dist/functional/ternary-result/impl/ternary-result-map.mjs.map +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 +2 -16
- package/dist/functional/ternary-result/impl/ternary-result-ok.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs +9 -9
- 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.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs +4 -22
- 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.mjs +9 -9
- 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.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs +12 -27
- 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.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs +4 -19
- 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.mjs +9 -9
- 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.mjs +4 -5
- 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.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs +15 -27
- 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.mjs +9 -9
- 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.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs +10 -24
- 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.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs +4 -19
- 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.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-warn.mjs +3 -19
- package/dist/functional/ternary-result/impl/ternary-result-warn.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-zip.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-zip.mjs +14 -45
- package/dist/functional/ternary-result/impl/ternary-result-zip.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/variant-name.d.mts +1 -1
- package/dist/functional/ternary-result/impl/variant-name.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/variant-name.mjs +8 -9
- package/dist/functional/ternary-result/impl/variant-name.mjs.map +1 -1
- package/dist/functional/ternary-result/ternary-result.d.mts.map +1 -1
- package/dist/guard/has-key.d.mts.map +1 -1
- package/dist/guard/has-key.mjs +0 -41
- package/dist/guard/has-key.mjs.map +1 -1
- package/dist/guard/index.d.mts +1 -0
- package/dist/guard/index.d.mts.map +1 -1
- package/dist/guard/index.mjs +1 -0
- package/dist/guard/index.mjs.map +1 -1
- package/dist/guard/is-length-bounded-string.d.mts +164 -0
- package/dist/guard/is-length-bounded-string.d.mts.map +1 -0
- package/dist/guard/is-length-bounded-string.mjs +7 -0
- package/dist/guard/is-length-bounded-string.mjs.map +1 -0
- package/dist/guard/is-non-empty-string.d.mts +1 -1
- package/dist/guard/is-non-empty-string.d.mts.map +1 -1
- package/dist/guard/is-non-empty-string.mjs +1 -38
- package/dist/guard/is-non-empty-string.mjs.map +1 -1
- package/dist/guard/is-non-null-object.d.mts.map +1 -1
- package/dist/guard/is-non-null-object.mjs +1 -35
- package/dist/guard/is-non-null-object.mjs.map +1 -1
- package/dist/guard/is-primitive.d.mts.map +1 -1
- package/dist/guard/is-primitive.mjs +12 -43
- package/dist/guard/is-primitive.mjs.map +1 -1
- package/dist/guard/is-record.d.mts.map +1 -1
- package/dist/guard/is-record.mjs +0 -86
- package/dist/guard/is-record.mjs.map +1 -1
- package/dist/guard/is-type.d.mts.map +1 -1
- package/dist/guard/is-type.mjs +12 -399
- package/dist/guard/is-type.mjs.map +1 -1
- package/dist/guard/key-is-in.d.mts.map +1 -1
- package/dist/guard/key-is-in.mjs +0 -40
- package/dist/guard/key-is-in.mjs.map +1 -1
- package/dist/index.mjs +1 -0
- package/dist/index.mjs.map +1 -1
- package/dist/iterator/range.mjs +16 -16
- package/dist/iterator/range.mjs.map +1 -1
- package/dist/json/json.d.mts.map +1 -1
- package/dist/json/json.mjs +52 -340
- package/dist/json/json.mjs.map +1 -1
- package/dist/number/branded-types/finite-number.d.mts +3 -3
- package/dist/number/branded-types/finite-number.mjs +135 -154
- package/dist/number/branded-types/finite-number.mjs.map +1 -1
- package/dist/number/branded-types/int.d.mts +4 -4
- package/dist/number/branded-types/int.mjs +205 -245
- package/dist/number/branded-types/int.mjs.map +1 -1
- package/dist/number/branded-types/int16.d.mts +15 -15
- package/dist/number/branded-types/int16.mjs +116 -123
- package/dist/number/branded-types/int16.mjs.map +1 -1
- package/dist/number/branded-types/int32.d.mts +11 -11
- package/dist/number/branded-types/int32.mjs +116 -123
- package/dist/number/branded-types/int32.mjs.map +1 -1
- package/dist/number/branded-types/negative-finite-number.d.mts +4 -4
- package/dist/number/branded-types/negative-finite-number.mjs +129 -144
- package/dist/number/branded-types/negative-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/negative-int.d.mts +5 -5
- package/dist/number/branded-types/negative-int.mjs +94 -113
- package/dist/number/branded-types/negative-int.mjs.map +1 -1
- package/dist/number/branded-types/negative-safe-int.d.mts +5 -5
- package/dist/number/branded-types/negative-safe-int.mjs +103 -124
- package/dist/number/branded-types/negative-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/non-negative-finite-number.d.mts +5 -5
- package/dist/number/branded-types/non-negative-finite-number.mjs +136 -142
- package/dist/number/branded-types/non-negative-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/non-negative-int16.d.mts +16 -16
- package/dist/number/branded-types/non-negative-int16.mjs +109 -118
- package/dist/number/branded-types/non-negative-int16.mjs.map +1 -1
- package/dist/number/branded-types/non-negative-int32.d.mts +12 -12
- package/dist/number/branded-types/non-negative-int32.mjs +110 -119
- package/dist/number/branded-types/non-negative-int32.mjs.map +1 -1
- package/dist/number/branded-types/non-positive-finite-number.d.mts +3 -3
- package/dist/number/branded-types/non-positive-finite-number.mjs +120 -124
- package/dist/number/branded-types/non-positive-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/non-positive-int.d.mts +4 -4
- package/dist/number/branded-types/non-positive-int.mjs +167 -212
- package/dist/number/branded-types/non-positive-int.mjs.map +1 -1
- package/dist/number/branded-types/non-positive-safe-int.d.mts +4 -4
- package/dist/number/branded-types/non-positive-safe-int.mjs +95 -106
- package/dist/number/branded-types/non-positive-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-finite-number.d.mts +4 -4
- package/dist/number/branded-types/non-zero-finite-number.mjs +114 -123
- package/dist/number/branded-types/non-zero-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-int.d.mts +2 -2
- package/dist/number/branded-types/non-zero-int.mjs +72 -83
- package/dist/number/branded-types/non-zero-int.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-int16.d.mts +7 -7
- package/dist/number/branded-types/non-zero-int16.mjs +96 -107
- package/dist/number/branded-types/non-zero-int16.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-int32.d.mts +5 -5
- package/dist/number/branded-types/non-zero-int32.mjs +97 -108
- package/dist/number/branded-types/non-zero-int32.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-safe-int.d.mts +2 -2
- package/dist/number/branded-types/non-zero-safe-int.mjs +100 -111
- package/dist/number/branded-types/non-zero-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-uint16.d.mts +8 -8
- package/dist/number/branded-types/non-zero-uint16.mjs +96 -107
- package/dist/number/branded-types/non-zero-uint16.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-uint32.d.mts +6 -6
- package/dist/number/branded-types/non-zero-uint32.mjs +96 -107
- package/dist/number/branded-types/non-zero-uint32.mjs.map +1 -1
- package/dist/number/branded-types/positive-finite-number.d.mts +8 -8
- package/dist/number/branded-types/positive-finite-number.mjs +139 -141
- package/dist/number/branded-types/positive-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/positive-int.d.mts +11 -11
- package/dist/number/branded-types/positive-int.mjs +228 -271
- package/dist/number/branded-types/positive-int.mjs.map +1 -1
- package/dist/number/branded-types/positive-int16.d.mts +19 -19
- package/dist/number/branded-types/positive-int16.mjs +109 -118
- package/dist/number/branded-types/positive-int16.mjs.map +1 -1
- package/dist/number/branded-types/positive-int32.d.mts +15 -15
- package/dist/number/branded-types/positive-int32.mjs +109 -118
- package/dist/number/branded-types/positive-int32.mjs.map +1 -1
- package/dist/number/branded-types/positive-safe-int.d.mts +11 -11
- package/dist/number/branded-types/positive-safe-int.mjs +244 -275
- package/dist/number/branded-types/positive-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/positive-uint16.d.mts +17 -17
- package/dist/number/branded-types/positive-uint16.mjs +109 -118
- package/dist/number/branded-types/positive-uint16.mjs.map +1 -1
- package/dist/number/branded-types/positive-uint32.d.mts +13 -13
- package/dist/number/branded-types/positive-uint32.mjs +110 -119
- package/dist/number/branded-types/positive-uint32.mjs.map +1 -1
- package/dist/number/branded-types/safe-int.d.mts +4 -4
- package/dist/number/branded-types/safe-int.mjs +251 -292
- package/dist/number/branded-types/safe-int.mjs.map +1 -1
- package/dist/number/branded-types/safe-uint.d.mts +8 -8
- package/dist/number/branded-types/safe-uint.mjs +111 -119
- package/dist/number/branded-types/safe-uint.mjs.map +1 -1
- package/dist/number/branded-types/uint.d.mts +8 -8
- package/dist/number/branded-types/uint.mjs +198 -225
- package/dist/number/branded-types/uint.mjs.map +1 -1
- package/dist/number/branded-types/uint16.d.mts +14 -14
- package/dist/number/branded-types/uint16.mjs +109 -119
- package/dist/number/branded-types/uint16.mjs.map +1 -1
- package/dist/number/branded-types/uint32.d.mts +10 -10
- package/dist/number/branded-types/uint32.mjs +110 -117
- package/dist/number/branded-types/uint32.mjs.map +1 -1
- package/dist/number/enum/int8.mjs +119 -145
- package/dist/number/enum/int8.mjs.map +1 -1
- package/dist/number/enum/uint8.mjs +107 -121
- package/dist/number/enum/uint8.mjs.map +1 -1
- package/dist/number/num.d.mts +2 -2
- package/dist/number/num.d.mts.map +1 -1
- package/dist/number/num.mjs +76 -537
- package/dist/number/num.mjs.map +1 -1
- package/dist/number/refined-number-utils.d.mts +1 -1
- package/dist/number/refined-number-utils.d.mts.map +1 -1
- package/dist/number/refined-number-utils.mjs +127 -263
- package/dist/number/refined-number-utils.mjs.map +1 -1
- package/dist/object/object.d.mts.map +1 -1
- package/dist/object/object.mjs +107 -222
- package/dist/object/object.mjs.map +1 -1
- package/dist/others/cast-mutable.d.mts.map +1 -1
- package/dist/others/cast-mutable.mjs +8 -37
- package/dist/others/cast-mutable.mjs.map +1 -1
- package/dist/others/cast-readonly.d.mts.map +1 -1
- package/dist/others/cast-readonly.mjs +8 -36
- package/dist/others/cast-readonly.mjs.map +1 -1
- package/dist/others/debounce-function.d.mts.map +1 -1
- package/dist/others/debounce-function.mjs +7 -16
- package/dist/others/debounce-function.mjs.map +1 -1
- package/dist/others/fast-deep-equal.d.mts.map +1 -1
- package/dist/others/fast-deep-equal.mjs +43 -59
- package/dist/others/fast-deep-equal.mjs.map +1 -1
- package/dist/others/if-then.d.mts.map +1 -1
- package/dist/others/if-then.mjs +0 -29
- package/dist/others/if-then.mjs.map +1 -1
- package/dist/others/map-nullable.mjs +9 -9
- package/dist/others/map-nullable.mjs.map +1 -1
- package/dist/others/memoize-function.mjs +12 -12
- package/dist/others/memoize-function.mjs.map +1 -1
- package/dist/others/tuple.d.mts.map +1 -1
- package/dist/others/tuple.mjs +0 -50
- 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 +41 -88
- package/dist/others/unknown-to-string.mjs.map +1 -1
- package/dist/promise/promise.d.mts.map +1 -1
- package/dist/promise/promise.mjs +4 -49
- package/dist/promise/promise.mjs.map +1 -1
- package/package.json +17 -16
- package/src/array/impl/array-utils-transformation.mts +1 -2
- package/src/array/impl/array-utils-transformation.test.mts +3 -36
- package/src/array/impl/array-utils-validation.test.mts +1 -3
- package/src/expect-type.mts +4 -5
- package/src/functional/ternary-result/ternary-result.mts +2 -6
- package/src/guard/index.mts +1 -0
- package/src/guard/is-length-bounded-string.mts +199 -0
- package/src/guard/is-length-bounded-string.test.mts +170 -0
- package/src/number/refined-number-utils.mts +1 -9
- package/src/object/object.mts +25 -23
|
@@ -35,462 +35,240 @@ import '../number/enum/uint8.mjs';
|
|
|
35
35
|
import '../number/num.mjs';
|
|
36
36
|
import '../number/refined-number-utils.mjs';
|
|
37
37
|
|
|
38
|
-
/** Provides utility functions for ISetMapped. */
|
|
39
38
|
var ISetMapped;
|
|
40
|
-
(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
* element type for iteration and access.
|
|
50
|
-
*
|
|
51
|
-
* **Performance:** O(n) where n is the number of elements in the iterable.
|
|
52
|
-
*
|
|
53
|
-
* @example
|
|
54
|
-
*
|
|
55
|
-
* ```ts
|
|
56
|
-
* type Point = Readonly<{ x: number; tag: string }>;
|
|
57
|
-
*
|
|
58
|
-
* const toKey = (point: Point) => JSON.stringify(point);
|
|
59
|
-
*
|
|
60
|
-
* // eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
61
|
-
* const fromKey = (key: string) => JSON.parse(key) as Point;
|
|
62
|
-
*
|
|
63
|
-
* const set = ISetMapped.create<Point, string>(
|
|
64
|
-
* [
|
|
65
|
-
* { x: 1, tag: 'a' },
|
|
66
|
-
* { x: 1, tag: 'a' },
|
|
67
|
-
* { x: 2, tag: 'b' },
|
|
68
|
-
* ],
|
|
69
|
-
* toKey,
|
|
70
|
-
* fromKey,
|
|
71
|
-
* );
|
|
72
|
-
*
|
|
73
|
-
* assert.deepStrictEqual(Array.from(set), [
|
|
74
|
-
* { x: 1, tag: 'a' },
|
|
75
|
-
* { x: 2, tag: 'b' },
|
|
76
|
-
* ]);
|
|
77
|
-
* ```
|
|
78
|
-
*
|
|
79
|
-
* @template K The type of the custom elements.
|
|
80
|
-
* @template KM The type of the mapped primitive keys.
|
|
81
|
-
* @param iterable An iterable of elements using the custom element type.
|
|
82
|
-
* @param toKey A function that converts a custom element `K` to a primitive
|
|
83
|
-
* key `KM`. This function must be deterministic and produce unique values
|
|
84
|
-
* for unique elements.
|
|
85
|
-
* @param fromKey A function that converts a primitive key `KM` back to the
|
|
86
|
-
* custom element `K`. This should be the inverse of `toKey`.
|
|
87
|
-
* @returns A new ISetMapped instance containing all unique elements from the
|
|
88
|
-
* iterable.
|
|
89
|
-
*/
|
|
90
|
-
ISetMapped.create = (iterable, toKey, fromKey) => new ISetMappedClass(iterable, toKey, fromKey);
|
|
91
|
-
/**
|
|
92
|
-
* Checks if two ISetMapped instances are structurally equal.
|
|
93
|
-
*
|
|
94
|
-
* Two ISetMapped instances are considered equal if they have the same size
|
|
95
|
-
* and contain exactly the same elements. The comparison is performed on the
|
|
96
|
-
* underlying mapped keys, so the transformation functions themselves don't
|
|
97
|
-
* need to be identical. Elements are compared based on their mapped key
|
|
98
|
-
* representations.
|
|
99
|
-
*
|
|
100
|
-
* **Performance:** O(n) where n is the size of the smaller set.
|
|
101
|
-
*
|
|
102
|
-
* @example
|
|
103
|
-
*
|
|
104
|
-
* ```ts
|
|
105
|
-
* type Point = Readonly<{ x: number; tag: string }>;
|
|
106
|
-
*
|
|
107
|
-
* const toKey = (point: Point) => JSON.stringify(point);
|
|
108
|
-
*
|
|
109
|
-
* // eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
110
|
-
* const fromKey = (key: string) => JSON.parse(key) as Point;
|
|
111
|
-
*
|
|
112
|
-
* const first = ISetMapped.create<Point, string>(
|
|
113
|
-
* [
|
|
114
|
-
* { x: 1, tag: 'a' },
|
|
115
|
-
* { x: 2, tag: 'b' },
|
|
116
|
-
* ],
|
|
117
|
-
* toKey,
|
|
118
|
-
* fromKey,
|
|
119
|
-
* );
|
|
120
|
-
*
|
|
121
|
-
* const second = ISetMapped.create<Point, string>(
|
|
122
|
-
* [
|
|
123
|
-
* { x: 2, tag: 'b' },
|
|
124
|
-
* { x: 1, tag: 'a' },
|
|
125
|
-
* ],
|
|
126
|
-
* toKey,
|
|
127
|
-
* fromKey,
|
|
128
|
-
* );
|
|
129
|
-
*
|
|
130
|
-
* const third = ISetMapped.create<Point, string>(
|
|
131
|
-
* [{ x: 3, tag: 'c' }],
|
|
132
|
-
* toKey,
|
|
133
|
-
* fromKey,
|
|
134
|
-
* );
|
|
135
|
-
*
|
|
136
|
-
* assert.isTrue(ISetMapped.equal(first, second));
|
|
137
|
-
*
|
|
138
|
-
* assert.isFalse(ISetMapped.equal(first, third));
|
|
139
|
-
* ```
|
|
140
|
-
*
|
|
141
|
-
* @template K The type of the custom elements.
|
|
142
|
-
* @template KM The type of the mapped primitive keys.
|
|
143
|
-
* @param a The first ISetMapped instance to compare.
|
|
144
|
-
* @param b The second ISetMapped instance to compare.
|
|
145
|
-
* @returns `true` if the sets contain exactly the same elements, `false`
|
|
146
|
-
* otherwise.
|
|
147
|
-
*/
|
|
148
|
-
ISetMapped.equal = (a, b) => a.size === b.size && a.every((e) => b.has(e));
|
|
149
|
-
/**
|
|
150
|
-
* Computes the difference between two ISetMapped instances.
|
|
151
|
-
*
|
|
152
|
-
* @example
|
|
153
|
-
*
|
|
154
|
-
* ```ts
|
|
155
|
-
* type Point = Readonly<{ x: number; tag: string }>;
|
|
156
|
-
*
|
|
157
|
-
* const toKey = (point: Point) => JSON.stringify(point);
|
|
158
|
-
*
|
|
159
|
-
* // eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
160
|
-
* const fromKey = (key: string) => JSON.parse(key) as Point;
|
|
161
|
-
*
|
|
162
|
-
* const previous = ISetMapped.create<Point, string>(
|
|
163
|
-
* [
|
|
164
|
-
* { x: 1, tag: 'a' },
|
|
165
|
-
* { x: 2, tag: 'b' },
|
|
166
|
-
* ],
|
|
167
|
-
* toKey,
|
|
168
|
-
* fromKey,
|
|
169
|
-
* );
|
|
170
|
-
*
|
|
171
|
-
* const current = ISetMapped.create<Point, string>(
|
|
172
|
-
* [
|
|
173
|
-
* { x: 2, tag: 'b' },
|
|
174
|
-
* { x: 3, tag: 'c' },
|
|
175
|
-
* ],
|
|
176
|
-
* toKey,
|
|
177
|
-
* fromKey,
|
|
178
|
-
* );
|
|
179
|
-
*
|
|
180
|
-
* const { added, deleted } = ISetMapped.diff(previous, current);
|
|
181
|
-
*
|
|
182
|
-
* assert.deepStrictEqual(Array.from(added), [{ x: 3, tag: 'c' }]);
|
|
183
|
-
*
|
|
184
|
-
* assert.deepStrictEqual(Array.from(deleted), [{ x: 1, tag: 'a' }]);
|
|
185
|
-
* ```
|
|
186
|
-
*
|
|
187
|
-
* @template K The type of the elements.
|
|
188
|
-
* @template KM The type of the mapped keys.
|
|
189
|
-
* @param oldSet The original set.
|
|
190
|
-
* @param newSet The new set.
|
|
191
|
-
* @returns An object containing sets of added and deleted elements.
|
|
192
|
-
*/
|
|
193
|
-
ISetMapped.diff = (oldSet, newSet) => ({
|
|
194
|
-
deleted: oldSet.subtract(newSet),
|
|
195
|
-
added: newSet.subtract(oldSet),
|
|
196
|
-
});
|
|
197
|
-
/**
|
|
198
|
-
* Computes the intersection of two ISetMapped instances.
|
|
199
|
-
*
|
|
200
|
-
* @example
|
|
201
|
-
*
|
|
202
|
-
* ```ts
|
|
203
|
-
* type Point = Readonly<{ x: number; tag: string }>;
|
|
204
|
-
*
|
|
205
|
-
* const toKey = (point: Point) => JSON.stringify(point);
|
|
206
|
-
*
|
|
207
|
-
* // eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
208
|
-
* const fromKey = (key: string) => JSON.parse(key) as Point;
|
|
209
|
-
*
|
|
210
|
-
* const left = ISetMapped.create<Point, string>(
|
|
211
|
-
* [
|
|
212
|
-
* { x: 1, tag: 'a' },
|
|
213
|
-
* { x: 2, tag: 'b' },
|
|
214
|
-
* ],
|
|
215
|
-
* toKey,
|
|
216
|
-
* fromKey,
|
|
217
|
-
* );
|
|
218
|
-
*
|
|
219
|
-
* const right = ISetMapped.create<Point, string>(
|
|
220
|
-
* [{ x: 2, tag: 'b' }],
|
|
221
|
-
* toKey,
|
|
222
|
-
* fromKey,
|
|
223
|
-
* );
|
|
224
|
-
*
|
|
225
|
-
* const overlap = ISetMapped.intersection(left, right);
|
|
226
|
-
*
|
|
227
|
-
* assert.deepStrictEqual(Array.from(overlap), [{ x: 2, tag: 'b' }]);
|
|
228
|
-
* ```
|
|
229
|
-
*
|
|
230
|
-
* @template K The type of the elements.
|
|
231
|
-
* @template KM The type of the mapped keys.
|
|
232
|
-
* @param a The first set.
|
|
233
|
-
* @param b The second set.
|
|
234
|
-
* @returns A new ISetMapped instance representing the intersection.
|
|
235
|
-
*/
|
|
236
|
-
ISetMapped.intersection = (a, b) => a.intersect(b);
|
|
237
|
-
/**
|
|
238
|
-
* Computes the union of two ISetMapped instances.
|
|
239
|
-
*
|
|
240
|
-
* @example
|
|
241
|
-
*
|
|
242
|
-
* ```ts
|
|
243
|
-
* type Point = Readonly<{ x: number; tag: string }>;
|
|
244
|
-
*
|
|
245
|
-
* const toKey = (point: Point) => JSON.stringify(point);
|
|
246
|
-
*
|
|
247
|
-
* // eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
248
|
-
* const fromKey = (key: string) => JSON.parse(key) as Point;
|
|
249
|
-
*
|
|
250
|
-
* const left = ISetMapped.create<Point, string>(
|
|
251
|
-
* [{ x: 1, tag: 'a' }],
|
|
252
|
-
* toKey,
|
|
253
|
-
* fromKey,
|
|
254
|
-
* );
|
|
255
|
-
*
|
|
256
|
-
* const right = ISetMapped.create<Point, string>(
|
|
257
|
-
* [{ x: 2, tag: 'b' }],
|
|
258
|
-
* toKey,
|
|
259
|
-
* fromKey,
|
|
260
|
-
* );
|
|
261
|
-
*
|
|
262
|
-
* const combined = ISetMapped.union(left, right);
|
|
263
|
-
*
|
|
264
|
-
* assert.deepStrictEqual(Array.from(combined), [
|
|
265
|
-
* { x: 1, tag: 'a' },
|
|
266
|
-
* { x: 2, tag: 'b' },
|
|
267
|
-
* ]);
|
|
268
|
-
* ```
|
|
269
|
-
*
|
|
270
|
-
* @template K The type of the elements.
|
|
271
|
-
* @template KM The type of the mapped keys.
|
|
272
|
-
* @param a The first set.
|
|
273
|
-
* @param b The second set.
|
|
274
|
-
* @returns A new ISetMapped instance representing the union.
|
|
275
|
-
*/
|
|
276
|
-
ISetMapped.union = (a, b) => a.union(b);
|
|
39
|
+
((ISetMapped2) => {
|
|
40
|
+
ISetMapped2.create = (iterable, toKey, fromKey) => new ISetMappedClass(iterable, toKey, fromKey);
|
|
41
|
+
ISetMapped2.equal = (a, b) => a.size === b.size && a.every((e) => b.has(e));
|
|
42
|
+
ISetMapped2.diff = (oldSet, newSet) => ({
|
|
43
|
+
deleted: oldSet.subtract(newSet),
|
|
44
|
+
added: newSet.subtract(oldSet)
|
|
45
|
+
});
|
|
46
|
+
ISetMapped2.intersection = (a, b) => a.intersect(b);
|
|
47
|
+
ISetMapped2.union = (a, b) => a.union(b);
|
|
277
48
|
})(ISetMapped || (ISetMapped = {}));
|
|
278
|
-
/**
|
|
279
|
-
* Internal class implementation for ISetMapped providing immutable set
|
|
280
|
-
* operations with element transformation.
|
|
281
|
-
*
|
|
282
|
-
* This class implements the ISetMapped interface by maintaining a JavaScript
|
|
283
|
-
* Set with primitive keys internally while exposing an API that works with
|
|
284
|
-
* custom element types. The transformation between custom and primitive
|
|
285
|
-
* elements is handled transparently through the provided `toKey` and `fromKey`
|
|
286
|
-
* functions.
|
|
287
|
-
*
|
|
288
|
-
* **Implementation Details:**
|
|
289
|
-
*
|
|
290
|
-
* - Uses ReadonlySet<KM> internally where KM is the primitive key type
|
|
291
|
-
* - Stores transformation functions for bidirectional element conversion
|
|
292
|
-
* - Implements copy-on-write semantics for efficiency
|
|
293
|
-
* - Provides optional debug messaging for development
|
|
294
|
-
*
|
|
295
|
-
* @template K The type of the custom elements.
|
|
296
|
-
* @template KM The type of the mapped primitive keys.
|
|
297
|
-
* @implements ISetMapped
|
|
298
|
-
* @implements Iterable
|
|
299
|
-
* @internal This class should not be used directly. Use ISetMapped.create() instead.
|
|
300
|
-
*/
|
|
301
49
|
class ISetMappedClass {
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
50
|
+
#set;
|
|
51
|
+
#toKey;
|
|
52
|
+
#fromKey;
|
|
53
|
+
#showNotFoundMessage;
|
|
54
|
+
/**
|
|
55
|
+
* Constructs an ISetMappedClass instance with custom element transformation.
|
|
56
|
+
*
|
|
57
|
+
* @param iterable An iterable of elements using the custom element type K.
|
|
58
|
+
* @param toKey A function that converts a custom element K to a primitive key
|
|
59
|
+
* KM. Must be deterministic and produce unique values for unique elements.
|
|
60
|
+
* @param fromKey A function that converts a primitive key KM back to the
|
|
61
|
+
* custom element K. Should be the inverse of the toKey function.
|
|
62
|
+
* @param showNotFoundMessage Whether to log warning messages when operations
|
|
63
|
+
* are performed on non-existent elements. Useful for debugging. Defaults to
|
|
64
|
+
* false for production use.
|
|
65
|
+
* @internal Use ISetMapped.create() instead of calling this constructor directly.
|
|
66
|
+
*/
|
|
67
|
+
constructor(iterable, toKey, fromKey, showNotFoundMessage = false) {
|
|
68
|
+
this.#set = new Set(Array.from(iterable, toKey));
|
|
69
|
+
this.#toKey = toKey;
|
|
70
|
+
this.#fromKey = fromKey;
|
|
71
|
+
this.#showNotFoundMessage = showNotFoundMessage;
|
|
72
|
+
}
|
|
73
|
+
/** @inheritdoc */
|
|
74
|
+
get size() {
|
|
75
|
+
return asUint32(this.#set.size);
|
|
76
|
+
}
|
|
77
|
+
/** @inheritdoc */
|
|
78
|
+
get isEmpty() {
|
|
79
|
+
return this.size === 0;
|
|
80
|
+
}
|
|
81
|
+
/** @inheritdoc */
|
|
82
|
+
has(key) {
|
|
83
|
+
return this.#set.has(this.#toKey(key));
|
|
84
|
+
}
|
|
85
|
+
/** @inheritdoc */
|
|
86
|
+
every(predicate) {
|
|
87
|
+
for (const key of this.values()) {
|
|
88
|
+
if (!predicate(key)) return false;
|
|
324
89
|
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
/** @inheritdoc */
|
|
93
|
+
some(predicate) {
|
|
94
|
+
for (const key of this.values()) {
|
|
95
|
+
if (predicate(key)) return true;
|
|
328
96
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
/** @inheritdoc */
|
|
100
|
+
add(key) {
|
|
101
|
+
if (this.has(key)) return this;
|
|
102
|
+
return ISetMapped.create(
|
|
103
|
+
[...this.#set, this.#toKey(key)].map(this.#fromKey),
|
|
104
|
+
this.#toKey,
|
|
105
|
+
this.#fromKey
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
/** @inheritdoc */
|
|
109
|
+
delete(key) {
|
|
110
|
+
if (!this.has(key)) {
|
|
111
|
+
if (this.#showNotFoundMessage) {
|
|
112
|
+
console.warn(
|
|
113
|
+
`ISetMapped.delete: key not found: ${String(this.#toKey(key))}`
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
return this;
|
|
332
117
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
118
|
+
const keyMapped = this.#toKey(key);
|
|
119
|
+
return ISetMapped.create(
|
|
120
|
+
Array.from(this.#set).filter((k) => !Object.is(k, keyMapped)).map(this.#fromKey),
|
|
121
|
+
this.#toKey,
|
|
122
|
+
this.#fromKey
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
/** @inheritdoc */
|
|
126
|
+
withMutations(actions) {
|
|
127
|
+
const mut_result = new Set(this.#set);
|
|
128
|
+
const updateFn = (action) => {
|
|
129
|
+
const key = this.#toKey(action.key);
|
|
130
|
+
switch (action.type) {
|
|
131
|
+
case "delete":
|
|
132
|
+
mut_result.delete(key);
|
|
133
|
+
break;
|
|
134
|
+
case "add":
|
|
135
|
+
mut_result.add(key);
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
for (const action of actions) {
|
|
140
|
+
updateFn(action);
|
|
337
141
|
}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
142
|
+
return ISetMapped.create(
|
|
143
|
+
Array.from(mut_result, this.#fromKey),
|
|
144
|
+
this.#toKey,
|
|
145
|
+
this.#fromKey
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
/** @inheritdoc */
|
|
149
|
+
map(mapFn) {
|
|
150
|
+
return ISetMapped.create(
|
|
151
|
+
this.toArray().map(mapFn),
|
|
152
|
+
this.#toKey,
|
|
153
|
+
this.#fromKey
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
/** @inheritdoc */
|
|
157
|
+
filter(predicate) {
|
|
158
|
+
return ISetMapped.create(
|
|
159
|
+
this.toArray().filter(predicate),
|
|
160
|
+
this.#toKey,
|
|
161
|
+
this.#fromKey
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
/** @inheritdoc */
|
|
165
|
+
filterNot(predicate) {
|
|
166
|
+
return ISetMapped.create(
|
|
167
|
+
this.toArray().filter((k) => !predicate(k)),
|
|
168
|
+
this.#toKey,
|
|
169
|
+
this.#fromKey
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
/** @inheritdoc */
|
|
173
|
+
forEach(callbackfn) {
|
|
174
|
+
for (const km of this.#set) {
|
|
175
|
+
callbackfn(this.#fromKey(km));
|
|
345
176
|
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
177
|
+
}
|
|
178
|
+
/** @inheritdoc */
|
|
179
|
+
isSubsetOf(set) {
|
|
180
|
+
return this.every((k) => set.has(k));
|
|
181
|
+
}
|
|
182
|
+
/** @inheritdoc */
|
|
183
|
+
isSupersetOf(set) {
|
|
184
|
+
return set.every((k) => this.has(k));
|
|
185
|
+
}
|
|
186
|
+
/** @inheritdoc */
|
|
187
|
+
subtract(set) {
|
|
188
|
+
return ISetMapped.create(
|
|
189
|
+
this.toArray().filter((k) => !set.has(k)),
|
|
190
|
+
this.#toKey,
|
|
191
|
+
this.#fromKey
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
/** @inheritdoc */
|
|
195
|
+
intersect(set) {
|
|
196
|
+
return ISetMapped.create(
|
|
197
|
+
this.toArray().filter((k) => set.has(k)),
|
|
198
|
+
this.#toKey,
|
|
199
|
+
this.#fromKey
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
/** @inheritdoc */
|
|
203
|
+
union(set) {
|
|
204
|
+
return ISetMapped.create(
|
|
205
|
+
[...this.values(), ...set.values()],
|
|
206
|
+
this.#toKey,
|
|
207
|
+
this.#fromKey
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* @example
|
|
212
|
+
*
|
|
213
|
+
* ```ts
|
|
214
|
+
* type Point = Readonly<{ x: number; tag: string }>;
|
|
215
|
+
*
|
|
216
|
+
* const toKey = (point: Point) => JSON.stringify(point);
|
|
217
|
+
*
|
|
218
|
+
* // eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
219
|
+
* const fromKey = (key: string) => JSON.parse(key) as Point;
|
|
220
|
+
*
|
|
221
|
+
* const set = ISetMapped.create<Point, string>(
|
|
222
|
+
* [
|
|
223
|
+
* { x: 1, tag: 'a' },
|
|
224
|
+
* { x: 2, tag: 'b' },
|
|
225
|
+
* ],
|
|
226
|
+
* toKey,
|
|
227
|
+
* fromKey,
|
|
228
|
+
* );
|
|
229
|
+
*
|
|
230
|
+
* const collected = Array.from(set);
|
|
231
|
+
*
|
|
232
|
+
* assert.deepStrictEqual(collected, [
|
|
233
|
+
* { x: 1, tag: 'a' },
|
|
234
|
+
* { x: 2, tag: 'b' },
|
|
235
|
+
* ]);
|
|
236
|
+
* ```
|
|
237
|
+
*
|
|
238
|
+
* @inheritdoc
|
|
239
|
+
*/
|
|
240
|
+
*[Symbol.iterator]() {
|
|
241
|
+
for (const k of this.keys()) {
|
|
242
|
+
yield k;
|
|
353
243
|
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
244
|
+
}
|
|
245
|
+
/** @inheritdoc */
|
|
246
|
+
*keys() {
|
|
247
|
+
for (const km of this.#set) {
|
|
248
|
+
yield this.#fromKey(km);
|
|
359
249
|
}
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
}
|
|
366
|
-
return this;
|
|
367
|
-
}
|
|
368
|
-
const keyMapped = this.#toKey(key);
|
|
369
|
-
return ISetMapped.create(Array.from(this.#set)
|
|
370
|
-
.filter((k) => !Object.is(k, keyMapped))
|
|
371
|
-
.map(this.#fromKey), this.#toKey, this.#fromKey);
|
|
250
|
+
}
|
|
251
|
+
/** @inheritdoc */
|
|
252
|
+
*values() {
|
|
253
|
+
for (const km of this.#set) {
|
|
254
|
+
yield this.#fromKey(km);
|
|
372
255
|
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
case 'delete':
|
|
380
|
-
mut_result.delete(key);
|
|
381
|
-
break;
|
|
382
|
-
case 'add':
|
|
383
|
-
mut_result.add(key);
|
|
384
|
-
break;
|
|
385
|
-
}
|
|
386
|
-
};
|
|
387
|
-
for (const action of actions) {
|
|
388
|
-
updateFn(action);
|
|
389
|
-
}
|
|
390
|
-
return ISetMapped.create(Array.from(mut_result, this.#fromKey), this.#toKey, this.#fromKey);
|
|
391
|
-
}
|
|
392
|
-
/** @inheritdoc */
|
|
393
|
-
map(mapFn) {
|
|
394
|
-
return ISetMapped.create(this.toArray().map(mapFn), this.#toKey, this.#fromKey);
|
|
395
|
-
}
|
|
396
|
-
/** @inheritdoc */
|
|
397
|
-
filter(predicate) {
|
|
398
|
-
return ISetMapped.create(this.toArray().filter(predicate), this.#toKey, this.#fromKey);
|
|
399
|
-
}
|
|
400
|
-
/** @inheritdoc */
|
|
401
|
-
filterNot(predicate) {
|
|
402
|
-
return ISetMapped.create(this.toArray().filter((k) => !predicate(k)), this.#toKey, this.#fromKey);
|
|
403
|
-
}
|
|
404
|
-
/** @inheritdoc */
|
|
405
|
-
forEach(callbackfn) {
|
|
406
|
-
for (const km of this.#set) {
|
|
407
|
-
callbackfn(this.#fromKey(km));
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
/** @inheritdoc */
|
|
411
|
-
isSubsetOf(set) {
|
|
412
|
-
return this.every((k) => set.has(k));
|
|
413
|
-
}
|
|
414
|
-
/** @inheritdoc */
|
|
415
|
-
isSupersetOf(set) {
|
|
416
|
-
return set.every((k) => this.has(k));
|
|
417
|
-
}
|
|
418
|
-
/** @inheritdoc */
|
|
419
|
-
subtract(set) {
|
|
420
|
-
return ISetMapped.create(this.toArray().filter((k) => !set.has(k)), this.#toKey, this.#fromKey);
|
|
421
|
-
}
|
|
422
|
-
/** @inheritdoc */
|
|
423
|
-
intersect(set) {
|
|
424
|
-
return ISetMapped.create(this.toArray().filter((k) => set.has(k)), this.#toKey, this.#fromKey);
|
|
425
|
-
}
|
|
426
|
-
/** @inheritdoc */
|
|
427
|
-
union(set) {
|
|
428
|
-
return ISetMapped.create([...this.values(), ...set.values()], this.#toKey, this.#fromKey);
|
|
429
|
-
}
|
|
430
|
-
/**
|
|
431
|
-
* @example
|
|
432
|
-
*
|
|
433
|
-
* ```ts
|
|
434
|
-
* type Point = Readonly<{ x: number; tag: string }>;
|
|
435
|
-
*
|
|
436
|
-
* const toKey = (point: Point) => JSON.stringify(point);
|
|
437
|
-
*
|
|
438
|
-
* // eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
439
|
-
* const fromKey = (key: string) => JSON.parse(key) as Point;
|
|
440
|
-
*
|
|
441
|
-
* const set = ISetMapped.create<Point, string>(
|
|
442
|
-
* [
|
|
443
|
-
* { x: 1, tag: 'a' },
|
|
444
|
-
* { x: 2, tag: 'b' },
|
|
445
|
-
* ],
|
|
446
|
-
* toKey,
|
|
447
|
-
* fromKey,
|
|
448
|
-
* );
|
|
449
|
-
*
|
|
450
|
-
* const collected = Array.from(set);
|
|
451
|
-
*
|
|
452
|
-
* assert.deepStrictEqual(collected, [
|
|
453
|
-
* { x: 1, tag: 'a' },
|
|
454
|
-
* { x: 2, tag: 'b' },
|
|
455
|
-
* ]);
|
|
456
|
-
* ```
|
|
457
|
-
*
|
|
458
|
-
* @inheritdoc
|
|
459
|
-
*/
|
|
460
|
-
*[Symbol.iterator]() {
|
|
461
|
-
for (const k of this.keys()) {
|
|
462
|
-
yield k;
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
/** @inheritdoc */
|
|
466
|
-
*keys() {
|
|
467
|
-
for (const km of this.#set) {
|
|
468
|
-
yield this.#fromKey(km);
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
/** @inheritdoc */
|
|
472
|
-
*values() {
|
|
473
|
-
for (const km of this.#set) {
|
|
474
|
-
// JavaScript Set's values() is an alias for keys()
|
|
475
|
-
yield this.#fromKey(km);
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
/** @inheritdoc */
|
|
479
|
-
*entries() {
|
|
480
|
-
for (const km of this.#set) {
|
|
481
|
-
// JavaScript Set's entries() yields [value, value]
|
|
482
|
-
const a = this.#fromKey(km);
|
|
483
|
-
yield [a, a];
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
/** @inheritdoc */
|
|
487
|
-
toArray() {
|
|
488
|
-
return Array.from(this.values());
|
|
489
|
-
}
|
|
490
|
-
/** @inheritdoc */
|
|
491
|
-
toRawSet() {
|
|
492
|
-
return this.#set;
|
|
256
|
+
}
|
|
257
|
+
/** @inheritdoc */
|
|
258
|
+
*entries() {
|
|
259
|
+
for (const km of this.#set) {
|
|
260
|
+
const a = this.#fromKey(km);
|
|
261
|
+
yield [a, a];
|
|
493
262
|
}
|
|
263
|
+
}
|
|
264
|
+
/** @inheritdoc */
|
|
265
|
+
toArray() {
|
|
266
|
+
return Array.from(this.values());
|
|
267
|
+
}
|
|
268
|
+
/** @inheritdoc */
|
|
269
|
+
toRawSet() {
|
|
270
|
+
return this.#set;
|
|
271
|
+
}
|
|
494
272
|
}
|
|
495
273
|
|
|
496
274
|
export { ISetMapped };
|