ts-data-forge 14.6.0 → 14.6.2
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.mjs +126 -26
- package/dist/array/impl/array-utils-creation.mjs.map +1 -1
- package/dist/array/impl/array-utils-element-access.mjs +63 -30
- package/dist/array/impl/array-utils-element-access.mjs.map +1 -1
- package/dist/array/impl/array-utils-iterators.mjs +69 -53
- package/dist/array/impl/array-utils-iterators.mjs.map +1 -1
- package/dist/array/impl/array-utils-length-bounded-array-cast.mjs +109 -73
- package/dist/array/impl/array-utils-length-bounded-array-cast.mjs.map +1 -1
- package/dist/array/impl/array-utils-length-bounded-array-guard.mjs +71 -33
- package/dist/array/impl/array-utils-length-bounded-array-guard.mjs.map +1 -1
- package/dist/array/impl/array-utils-length-bounded-tuple-cast.mjs +102 -73
- package/dist/array/impl/array-utils-length-bounded-tuple-cast.mjs.map +1 -1
- package/dist/array/impl/array-utils-length-bounded-tuple-guard.mjs +77 -33
- package/dist/array/impl/array-utils-length-bounded-tuple-guard.mjs.map +1 -1
- package/dist/array/impl/array-utils-modification.mjs +75 -122
- package/dist/array/impl/array-utils-modification.mjs.map +1 -1
- package/dist/array/impl/array-utils-reducing-value.mjs +100 -150
- package/dist/array/impl/array-utils-reducing-value.mjs.map +1 -1
- package/dist/array/impl/array-utils-search.mjs +110 -134
- package/dist/array/impl/array-utils-search.mjs.map +1 -1
- package/dist/array/impl/array-utils-set-op.mjs +146 -38
- package/dist/array/impl/array-utils-set-op.mjs.map +1 -1
- package/dist/array/impl/array-utils-size.mjs +10 -8
- package/dist/array/impl/array-utils-size.mjs.map +1 -1
- package/dist/array/impl/array-utils-slice-clamped.mjs +13 -50
- package/dist/array/impl/array-utils-slice-clamped.mjs.map +1 -1
- package/dist/array/impl/array-utils-slicing.mjs +94 -78
- package/dist/array/impl/array-utils-slicing.mjs.map +1 -1
- package/dist/array/impl/array-utils-transformation.mjs +291 -199
- package/dist/array/impl/array-utils-transformation.mjs.map +1 -1
- package/dist/array/impl/array-utils-validation.mjs +54 -56
- package/dist/array/impl/array-utils-validation.mjs.map +1 -1
- package/dist/array/impl/index.mjs +17 -17
- package/dist/array/impl/index.mjs.map +1 -1
- package/dist/array/index.mjs +2 -3
- package/dist/array/index.mjs.map +1 -1
- package/dist/collections/imap-mapped.mjs +335 -291
- package/dist/collections/imap-mapped.mjs.map +1 -1
- package/dist/collections/imap.mjs +280 -239
- package/dist/collections/imap.mjs.map +1 -1
- package/dist/collections/index.mjs +7 -7
- package/dist/collections/index.mjs.map +1 -1
- package/dist/collections/iset-mapped.d.mts.map +1 -1
- package/dist/collections/iset-mapped.mjs +448 -263
- package/dist/collections/iset-mapped.mjs.map +1 -1
- package/dist/collections/iset.mjs +328 -201
- package/dist/collections/iset.mjs.map +1 -1
- package/dist/collections/queue.mjs +183 -151
- package/dist/collections/queue.mjs.map +1 -1
- package/dist/collections/stack.mjs +169 -140
- package/dist/collections/stack.mjs.map +1 -1
- package/dist/entry-point.mjs +4 -77
- package/dist/entry-point.mjs.map +1 -1
- package/dist/expect-type.mjs +70 -4
- package/dist/expect-type.mjs.map +1 -1
- package/dist/functional/async-result/async-result.mjs +2 -3
- package/dist/functional/async-result/async-result.mjs.map +1 -1
- package/dist/functional/async-result/impl/async-result-flat-map.mjs +19 -21
- package/dist/functional/async-result/impl/async-result-flat-map.mjs.map +1 -1
- package/dist/functional/async-result/impl/async-result-from-promise.mjs +9 -10
- package/dist/functional/async-result/impl/async-result-from-promise.mjs.map +1 -1
- package/dist/functional/async-result/impl/async-result-from-throwable.mjs +12 -14
- package/dist/functional/async-result/impl/async-result-from-throwable.mjs.map +1 -1
- package/dist/functional/async-result/impl/async-result-map-err.mjs +16 -19
- package/dist/functional/async-result/impl/async-result-map-err.mjs.map +1 -1
- package/dist/functional/async-result/impl/async-result-map.mjs +16 -19
- package/dist/functional/async-result/impl/async-result-map.mjs.map +1 -1
- package/dist/functional/async-result/impl/async-result-unwrap-or.mjs +36 -9
- package/dist/functional/async-result/impl/async-result-unwrap-or.mjs.map +1 -1
- package/dist/functional/async-result/impl/index.mjs +8 -7
- package/dist/functional/async-result/impl/index.mjs.map +1 -1
- package/dist/functional/async-result/impl/types.mjs +2 -2
- package/dist/functional/async-result/impl/types.mjs.map +1 -1
- package/dist/functional/async-result/index.mjs +2 -3
- package/dist/functional/async-result/index.mjs.map +1 -1
- package/dist/functional/index.mjs +7 -11
- package/dist/functional/index.mjs.map +1 -1
- package/dist/functional/match.mjs +27 -13
- package/dist/functional/match.mjs.map +1 -1
- package/dist/functional/optional/impl/index.mjs +19 -18
- package/dist/functional/optional/impl/index.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-expect-to-be.mjs +16 -18
- package/dist/functional/optional/impl/optional-expect-to-be.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-filter.mjs +17 -19
- package/dist/functional/optional/impl/optional-filter.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-flat-map.mjs +13 -15
- package/dist/functional/optional/impl/optional-flat-map.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-from-nullable.mjs +26 -5
- package/dist/functional/optional/impl/optional-from-nullable.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-is-none.mjs +21 -5
- package/dist/functional/optional/impl/optional-is-none.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-is-optional.mjs +26 -8
- package/dist/functional/optional/impl/optional-is-optional.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-is-some.mjs +22 -5
- package/dist/functional/optional/impl/optional-is-some.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-map.mjs +16 -18
- package/dist/functional/optional/impl/optional-map.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-match.mjs +16 -18
- package/dist/functional/optional/impl/optional-match.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-none.mjs +18 -5
- package/dist/functional/optional/impl/optional-none.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-or-else.mjs +13 -15
- package/dist/functional/optional/impl/optional-or-else.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-some.mjs +23 -7
- package/dist/functional/optional/impl/optional-some.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-to-nullable.mjs +28 -5
- package/dist/functional/optional/impl/optional-to-nullable.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-unwrap-or.mjs +12 -14
- package/dist/functional/optional/impl/optional-unwrap-or.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-unwrap-throw.mjs +34 -9
- package/dist/functional/optional/impl/optional-unwrap-throw.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-unwrap.mjs +6 -9
- package/dist/functional/optional/impl/optional-unwrap.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-zip.mjs +36 -5
- package/dist/functional/optional/impl/optional-zip.mjs.map +1 -1
- package/dist/functional/optional/impl/tag.mjs +4 -5
- package/dist/functional/optional/impl/tag.mjs.map +1 -1
- package/dist/functional/optional/impl/types.mjs +2 -2
- package/dist/functional/optional/impl/types.mjs.map +1 -1
- package/dist/functional/optional/index.mjs +2 -3
- package/dist/functional/optional/index.mjs.map +1 -1
- package/dist/functional/optional/optional.mjs +2 -3
- package/dist/functional/optional/optional.mjs.map +1 -1
- package/dist/functional/pipe.mjs +42 -14
- package/dist/functional/pipe.mjs.map +1 -1
- package/dist/functional/result/impl/index.mjs +28 -27
- package/dist/functional/result/impl/index.mjs.map +1 -1
- package/dist/functional/result/impl/result-err.mjs +29 -7
- package/dist/functional/result/impl/result-err.mjs.map +1 -1
- package/dist/functional/result/impl/result-expect-to-be.mjs +17 -18
- package/dist/functional/result/impl/result-expect-to-be.mjs.map +1 -1
- package/dist/functional/result/impl/result-flat-map.mjs +18 -21
- package/dist/functional/result/impl/result-flat-map.mjs.map +1 -1
- package/dist/functional/result/impl/result-fold.mjs +18 -21
- package/dist/functional/result/impl/result-fold.mjs.map +1 -1
- package/dist/functional/result/impl/result-from-optional.mjs +17 -20
- package/dist/functional/result/impl/result-from-optional.mjs.map +1 -1
- package/dist/functional/result/impl/result-from-promise.mjs +37 -8
- package/dist/functional/result/impl/result-from-promise.mjs.map +1 -1
- package/dist/functional/result/impl/result-from-throwable.mjs +41 -14
- package/dist/functional/result/impl/result-from-throwable.mjs.map +1 -1
- package/dist/functional/result/impl/result-is-err.mjs +21 -5
- package/dist/functional/result/impl/result-is-err.mjs.map +1 -1
- package/dist/functional/result/impl/result-is-ok.mjs +21 -5
- package/dist/functional/result/impl/result-is-ok.mjs.map +1 -1
- package/dist/functional/result/impl/result-is-result.mjs +25 -7
- package/dist/functional/result/impl/result-is-result.mjs.map +1 -1
- package/dist/functional/result/impl/result-map-err.mjs +18 -21
- package/dist/functional/result/impl/result-map-err.mjs.map +1 -1
- package/dist/functional/result/impl/result-map.mjs +18 -21
- package/dist/functional/result/impl/result-map.mjs.map +1 -1
- package/dist/functional/result/impl/result-match.mjs +17 -21
- package/dist/functional/result/impl/result-match.mjs.map +1 -1
- package/dist/functional/result/impl/result-ok.mjs +29 -7
- package/dist/functional/result/impl/result-ok.mjs.map +1 -1
- package/dist/functional/result/impl/result-or-else.mjs +14 -15
- package/dist/functional/result/impl/result-or-else.mjs.map +1 -1
- package/dist/functional/result/impl/result-safe-try.mjs +32 -21
- package/dist/functional/result/impl/result-safe-try.mjs.map +1 -1
- package/dist/functional/result/impl/result-safe-unwrap.mjs +40 -12
- package/dist/functional/result/impl/result-safe-unwrap.mjs.map +1 -1
- package/dist/functional/result/impl/result-swap.mjs +23 -8
- package/dist/functional/result/impl/result-swap.mjs.map +1 -1
- package/dist/functional/result/impl/result-to-optional.mjs +30 -7
- package/dist/functional/result/impl/result-to-optional.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-err-or.mjs +13 -14
- package/dist/functional/result/impl/result-unwrap-err-or.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-err-throw.mjs +43 -20
- package/dist/functional/result/impl/result-unwrap-err-throw.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-err.mjs +33 -8
- package/dist/functional/result/impl/result-unwrap-err.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-ok-or.mjs +13 -14
- package/dist/functional/result/impl/result-unwrap-ok-or.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-ok.mjs +6 -9
- package/dist/functional/result/impl/result-unwrap-ok.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-throw.mjs +38 -11
- package/dist/functional/result/impl/result-unwrap-throw.mjs.map +1 -1
- package/dist/functional/result/impl/result-zip.mjs +35 -5
- package/dist/functional/result/impl/result-zip.mjs.map +1 -1
- package/dist/functional/result/impl/tag.mjs +4 -5
- package/dist/functional/result/impl/tag.mjs.map +1 -1
- package/dist/functional/result/impl/types.mjs +2 -2
- package/dist/functional/result/impl/types.mjs.map +1 -1
- package/dist/functional/result/index.mjs +2 -3
- package/dist/functional/result/index.mjs.map +1 -1
- package/dist/functional/result/result.mjs +2 -3
- package/dist/functional/result/result.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/index.mjs +29 -28
- package/dist/functional/ternary-result/impl/index.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/tag.mjs +6 -6
- package/dist/functional/ternary-result/impl/tag.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-err.mjs +17 -7
- 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 +15 -18
- 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 +28 -32
- package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-fold.mjs +24 -26
- package/dist/functional/ternary-result/impl/ternary-result-fold.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs +21 -8
- package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs +28 -13
- package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs +19 -5
- package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs +21 -5
- 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.mjs +28 -8
- 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.mjs +20 -5
- 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 +17 -18
- 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 +20 -23
- package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-map.mjs +24 -26
- package/dist/functional/ternary-result/impl/ternary-result-map.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-ok.mjs +18 -7
- package/dist/functional/ternary-result/impl/ternary-result-ok.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs +11 -14
- package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs +24 -10
- 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 +11 -14
- 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.mjs +30 -19
- 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.mjs +20 -8
- 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 +11 -14
- 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 +7 -9
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs +30 -22
- 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 +11 -14
- 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.mjs +27 -17
- 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.mjs +20 -8
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-warn.mjs +21 -8
- package/dist/functional/ternary-result/impl/ternary-result-warn.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-zip.mjs +47 -19
- package/dist/functional/ternary-result/impl/ternary-result-zip.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/types.mjs +2 -2
- package/dist/functional/ternary-result/impl/types.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/variant-name.mjs +12 -14
- package/dist/functional/ternary-result/impl/variant-name.mjs.map +1 -1
- package/dist/functional/ternary-result/index.mjs +2 -3
- package/dist/functional/ternary-result/index.mjs.map +1 -1
- package/dist/functional/ternary-result/ternary-result.mjs +2 -3
- package/dist/functional/ternary-result/ternary-result.mjs.map +1 -1
- package/dist/guard/has-key.mjs +43 -4
- package/dist/guard/has-key.mjs.map +1 -1
- package/dist/guard/index.mjs +8 -8
- package/dist/guard/index.mjs.map +1 -1
- package/dist/guard/is-non-empty-string.mjs +39 -4
- package/dist/guard/is-non-empty-string.mjs.map +1 -1
- package/dist/guard/is-non-null-object.mjs +36 -4
- package/dist/guard/is-non-null-object.mjs.map +1 -1
- package/dist/guard/is-primitive.mjs +46 -15
- package/dist/guard/is-primitive.mjs.map +1 -1
- package/dist/guard/is-record.mjs +89 -6
- package/dist/guard/is-record.mjs.map +1 -1
- package/dist/guard/is-type.mjs +404 -19
- package/dist/guard/is-type.mjs.map +1 -1
- package/dist/guard/key-is-in.mjs +42 -4
- package/dist/guard/key-is-in.mjs.map +1 -1
- package/dist/index.mjs +12 -65
- package/dist/index.mjs.map +1 -1
- package/dist/iterator/index.mjs +2 -2
- package/dist/iterator/index.mjs.map +1 -1
- package/dist/iterator/range.mjs +19 -57
- package/dist/iterator/range.mjs.map +1 -1
- package/dist/json/index.mjs +2 -2
- package/dist/json/index.mjs.map +1 -1
- package/dist/json/json.mjs +346 -105
- package/dist/json/json.mjs.map +1 -1
- package/dist/number/branded-types/finite-number.mjs +148 -137
- package/dist/number/branded-types/finite-number.mjs.map +1 -1
- package/dist/number/branded-types/index.mjs +33 -33
- package/dist/number/branded-types/index.mjs.map +1 -1
- package/dist/number/branded-types/int.mjs +245 -209
- package/dist/number/branded-types/int.mjs.map +1 -1
- package/dist/number/branded-types/int16.mjs +141 -131
- package/dist/number/branded-types/int16.mjs.map +1 -1
- package/dist/number/branded-types/int32.mjs +141 -131
- package/dist/number/branded-types/int32.mjs.map +1 -1
- package/dist/number/branded-types/negative-finite-number.mjs +155 -149
- package/dist/number/branded-types/negative-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/negative-int.mjs +125 -110
- package/dist/number/branded-types/negative-int.mjs.map +1 -1
- package/dist/number/branded-types/negative-safe-int.mjs +126 -115
- package/dist/number/branded-types/negative-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/non-negative-finite-number.mjs +164 -154
- package/dist/number/branded-types/non-negative-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/non-negative-int16.mjs +137 -125
- package/dist/number/branded-types/non-negative-int16.mjs.map +1 -1
- package/dist/number/branded-types/non-negative-int32.mjs +137 -125
- package/dist/number/branded-types/non-negative-int32.mjs.map +1 -1
- package/dist/number/branded-types/non-positive-finite-number.mjs +143 -139
- package/dist/number/branded-types/non-positive-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/non-positive-int.mjs +116 -99
- package/dist/number/branded-types/non-positive-int.mjs.map +1 -1
- package/dist/number/branded-types/non-positive-safe-int.mjs +118 -107
- package/dist/number/branded-types/non-positive-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-finite-number.mjs +144 -129
- package/dist/number/branded-types/non-zero-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-int.mjs +102 -82
- package/dist/number/branded-types/non-zero-int.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-int16.mjs +118 -105
- package/dist/number/branded-types/non-zero-int16.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-int32.mjs +118 -105
- package/dist/number/branded-types/non-zero-int32.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-safe-int.mjs +122 -108
- package/dist/number/branded-types/non-zero-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-uint16.mjs +118 -104
- package/dist/number/branded-types/non-zero-uint16.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-uint32.mjs +118 -104
- package/dist/number/branded-types/non-zero-uint32.mjs.map +1 -1
- package/dist/number/branded-types/positive-finite-number.mjs +167 -160
- package/dist/number/branded-types/positive-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/positive-int.mjs +260 -224
- package/dist/number/branded-types/positive-int.mjs.map +1 -1
- package/dist/number/branded-types/positive-int16.mjs +134 -122
- package/dist/number/branded-types/positive-int16.mjs.map +1 -1
- package/dist/number/branded-types/positive-int32.mjs +134 -122
- package/dist/number/branded-types/positive-int32.mjs.map +1 -1
- package/dist/number/branded-types/positive-safe-int.mjs +292 -258
- package/dist/number/branded-types/positive-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/positive-uint16.mjs +134 -122
- package/dist/number/branded-types/positive-uint16.mjs.map +1 -1
- package/dist/number/branded-types/positive-uint32.mjs +134 -122
- package/dist/number/branded-types/positive-uint32.mjs.map +1 -1
- package/dist/number/branded-types/safe-int.mjs +284 -255
- package/dist/number/branded-types/safe-int.mjs.map +1 -1
- package/dist/number/branded-types/safe-uint.mjs +135 -124
- package/dist/number/branded-types/safe-uint.mjs.map +1 -1
- package/dist/number/branded-types/uint.mjs +248 -211
- package/dist/number/branded-types/uint.mjs.map +1 -1
- package/dist/number/branded-types/uint16.mjs +132 -121
- package/dist/number/branded-types/uint16.mjs.map +1 -1
- package/dist/number/branded-types/uint32.mjs +132 -121
- package/dist/number/branded-types/uint32.mjs.map +1 -1
- package/dist/number/enum/index.mjs +3 -3
- package/dist/number/enum/index.mjs.map +1 -1
- package/dist/number/enum/int8.mjs +146 -131
- package/dist/number/enum/int8.mjs.map +1 -1
- package/dist/number/enum/uint8.mjs +133 -119
- package/dist/number/enum/uint8.mjs.map +1 -1
- package/dist/number/index.mjs +6 -37
- package/dist/number/index.mjs.map +1 -1
- package/dist/number/num-arithmetic-types.mjs +42 -1
- package/dist/number/num-arithmetic-types.mjs.map +1 -1
- package/dist/number/num.mjs +541 -83
- package/dist/number/num.mjs.map +1 -1
- package/dist/number/refined-number-utils.mjs +294 -133
- package/dist/number/refined-number-utils.mjs.map +1 -1
- package/dist/object/index.mjs +2 -2
- package/dist/object/index.mjs.map +1 -1
- package/dist/object/object.mjs +355 -202
- package/dist/object/object.mjs.map +1 -1
- package/dist/others/cast-mutable.mjs +38 -11
- package/dist/others/cast-mutable.mjs.map +1 -1
- package/dist/others/cast-readonly.mjs +37 -11
- package/dist/others/cast-readonly.mjs.map +1 -1
- package/dist/others/debounce-function.mjs +22 -11
- package/dist/others/debounce-function.mjs.map +1 -1
- package/dist/others/fast-deep-equal.mjs +70 -51
- package/dist/others/fast-deep-equal.mjs.map +1 -1
- package/dist/others/if-then.mjs +32 -5
- package/dist/others/if-then.mjs.map +1 -1
- package/dist/others/index.mjs +10 -10
- package/dist/others/index.mjs.map +1 -1
- package/dist/others/map-nullable.mjs +11 -13
- package/dist/others/map-nullable.mjs.map +1 -1
- package/dist/others/memoize-function.mjs +14 -16
- package/dist/others/memoize-function.mjs.map +1 -1
- package/dist/others/tuple.mjs +52 -4
- package/dist/others/tuple.mjs.map +1 -1
- package/dist/others/unknown-to-string.mjs +91 -47
- package/dist/others/unknown-to-string.mjs.map +1 -1
- package/dist/promise/index.mjs +2 -2
- package/dist/promise/index.mjs.map +1 -1
- package/dist/promise/promise.mjs +51 -10
- package/dist/promise/promise.mjs.map +1 -1
- package/dist/string/index.mjs +2 -2
- package/dist/string/index.mjs.map +1 -1
- package/dist/string/str.mjs +250 -83
- package/dist/string/str.mjs.map +1 -1
- package/dist/types.mjs +3 -2
- package/dist/types.mjs.map +1 -1
- package/package.json +5 -6
- package/src/array/impl/array-utils-length-constraint-preservation.test.mts +2 -2
- package/src/collections/imap-mapped.mts +4 -4
- package/src/collections/imap.mts +1 -1
- package/src/collections/imap.test.mts +1 -1
- package/src/collections/iset-mapped.mts +2 -1
- package/src/collections/iset.mts +1 -1
- package/src/functional/async-result.test.mts +3 -2
- package/src/functional/optional.test.mts +2 -1
- package/src/functional/result.test.mts +0 -2
- package/src/guard/is-non-empty-string.test.mts +2 -2
- package/src/guard/is-non-null-object.test.mts +3 -3
- package/src/guard/is-primitive.test.mts +3 -3
- package/src/guard/is-type.test.mts +3 -3
- package/src/json/json.test.mts +1 -1
- package/src/number/enum/int8.mts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optional-zip.mjs","sources":["../../../../src/functional/optional/impl/optional-zip.mts"],"
|
|
1
|
+
{"version":3,"file":"optional-zip.mjs","sourceRoot":"","sources":["../../../../src/functional/optional/impl/optional-zip.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,CACjB,SAAsB,EACtB,SAAsB,EACK,EAAE,CAC7B,MAAM,CAAC,SAAS,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC;IACpC,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,CAAU,CAAC;IACnD,CAAC,CAAC,IAAI,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
const SomeTypeTagName =
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
//# sourceMappingURL=tag.mjs.map
|
|
1
|
+
export const SomeTypeTagName = 'ts-data-forge::Optional.some';
|
|
2
|
+
/** @internal String literal tag to identify the 'None' variant of Optional. */
|
|
3
|
+
export const NoneTypeTagName = 'ts-data-forge::Optional.none';
|
|
4
|
+
//# sourceMappingURL=tag.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tag.mjs","sources":["../../../../src/functional/optional/impl/tag.mts"],"
|
|
1
|
+
{"version":3,"file":"tag.mjs","sourceRoot":"","sources":["../../../../src/functional/optional/impl/tag.mts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,eAAe,GAC1B,8BAA8B,CAAC;AAEjC,+EAA+E;AAC/E,MAAM,CAAC,MAAM,eAAe,GAAkB,8BAA8B,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=types.mjs.map
|
|
1
|
+
export {};
|
|
2
|
+
//# sourceMappingURL=types.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","
|
|
1
|
+
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../../../src/functional/optional/impl/types.mts"],"names":[],"mappings":""}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
//# sourceMappingURL=index.mjs.map
|
|
1
|
+
export * from './optional.mjs';
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/functional/optional/index.mts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
//# sourceMappingURL=optional.mjs.map
|
|
1
|
+
export * as Optional from './impl/index.mjs';
|
|
2
|
+
//# sourceMappingURL=optional.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optional.mjs","
|
|
1
|
+
{"version":3,"file":"optional.mjs","sourceRoot":"","sources":["../../../src/functional/optional/optional.mts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC"}
|
package/dist/functional/pipe.mjs
CHANGED
|
@@ -1,17 +1,45 @@
|
|
|
1
|
-
import { isOptional } from './optional/impl/optional-is-optional.mjs';
|
|
2
|
-
import { map } from './optional/impl/optional-map.mjs';
|
|
3
1
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { Optional } from './optional/index.mjs';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a new pipe object that allows for chaining operations on a value.
|
|
5
|
+
*
|
|
6
|
+
* This function provides a fluent interface for applying transformations to
|
|
7
|
+
* values, with intelligent method selection based on the input type:
|
|
8
|
+
*
|
|
9
|
+
* - For `Optional` values: Provides `mapOptional` for safe Optional
|
|
10
|
+
* transformations
|
|
11
|
+
* - For other values: Provides `mapNullable` for null-safe transformations
|
|
12
|
+
* - All types get the basic `map` method for general transformations
|
|
13
|
+
*
|
|
14
|
+
* The pipe maintains type safety throughout the chain, automatically selecting
|
|
15
|
+
* the appropriate overload based on the current value type.
|
|
16
|
+
*
|
|
17
|
+
* @template A The type of the initial value to wrap in a pipe.
|
|
18
|
+
* @param a The initial value to wrap in a pipe.
|
|
19
|
+
* @returns A pipe object with chaining methods appropriate for the value type.
|
|
20
|
+
*/
|
|
21
|
+
export const pipe = (a) =>
|
|
22
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
23
|
+
({
|
|
7
24
|
value: a,
|
|
8
25
|
map: (fn) => pipe(fn(a)),
|
|
9
|
-
mapNullable: (fn) => pipe(a == null ?
|
|
10
|
-
...isOptional(a)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
26
|
+
mapNullable: (fn) => pipe(a == null ? undefined : fn(a)),
|
|
27
|
+
...(Optional.isOptional(a)
|
|
28
|
+
? {
|
|
29
|
+
mapOptional: (fn) => pipe(Optional.map(a, fn)),
|
|
30
|
+
}
|
|
31
|
+
: {}),
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=pipe.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipe.mjs","sources":["../../src/functional/pipe.mts"],"
|
|
1
|
+
{"version":3,"file":"pipe.mjs","sourceRoot":"","sources":["../../src/functional/pipe.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAwB,MAAM,sBAAsB,CAAC;AAEtE;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAW,CAAI,EAAW,EAAE;AAC9C,oEAAoE;AACpE,CAAC;IACC,KAAK,EAAE,CAAC;IACR,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACxB,WAAW,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAExD,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;QACxB,CAAC,CAAC;YACE,WAAW,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;SAC/C;QACH,CAAC,CAAC,EAAE,CAAC;CACR,CAA6C,CAAC;AAsBjD,6DAA6D;AAC7D,gFAAgF;AAChF,sCAAsC;AACtC,qEAAqE;AACrE,+DAA+D;AAC/D,yDAAyD;AAEzD,UAAU,CAAoC,IAAI,CAAC,CAAC;AAEpD,UAAU,CAAgC,IAAI,CAAC,CAAC;AAEhD,UAAU,CACR,GAAG,CACJ,CAAC;AAEF,UAAU,CAGR,GAAG,CAAC,CAAC;AAEP,UAAU,CAGR,GAAG,CAAC,CAAC;AAEP,UAAU,CAGR,GAAG,CAAC,CAAC"}
|
|
@@ -1,27 +1,28 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
export
|
|
20
|
-
export
|
|
21
|
-
export
|
|
22
|
-
export
|
|
23
|
-
export
|
|
24
|
-
export
|
|
25
|
-
export
|
|
26
|
-
export
|
|
27
|
-
|
|
1
|
+
export * from './result-err.mjs';
|
|
2
|
+
export * from './result-expect-to-be.mjs';
|
|
3
|
+
export * from './result-flat-map.mjs';
|
|
4
|
+
export * from './result-fold.mjs';
|
|
5
|
+
export * from './result-from-optional.mjs';
|
|
6
|
+
export * from './result-from-promise.mjs';
|
|
7
|
+
export * from './result-from-throwable.mjs';
|
|
8
|
+
export * from './result-is-err.mjs';
|
|
9
|
+
export * from './result-is-ok.mjs';
|
|
10
|
+
export * from './result-is-result.mjs';
|
|
11
|
+
export * from './result-map-err.mjs';
|
|
12
|
+
export * from './result-map.mjs';
|
|
13
|
+
export * from './result-match.mjs';
|
|
14
|
+
export * from './result-ok.mjs';
|
|
15
|
+
export * from './result-or-else.mjs';
|
|
16
|
+
export * from './result-safe-try.mjs';
|
|
17
|
+
export * from './result-safe-unwrap.mjs';
|
|
18
|
+
export * from './result-swap.mjs';
|
|
19
|
+
export * from './result-to-optional.mjs';
|
|
20
|
+
export * from './result-unwrap-err-or.mjs';
|
|
21
|
+
export * from './result-unwrap-err-throw.mjs';
|
|
22
|
+
export * from './result-unwrap-err.mjs';
|
|
23
|
+
export * from './result-unwrap-ok-or.mjs';
|
|
24
|
+
export * from './result-unwrap-ok.mjs';
|
|
25
|
+
export * from './result-unwrap-throw.mjs';
|
|
26
|
+
export * from './result-zip.mjs';
|
|
27
|
+
export * from './types.mjs';
|
|
28
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../../src/functional/result/impl/index.mts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC"}
|
|
@@ -1,9 +1,31 @@
|
|
|
1
1
|
import { ErrTypeTagName } from './tag.mjs';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Creates a `Result.Err` containing the given error value.
|
|
4
|
+
*
|
|
5
|
+
* Use this constructor when an operation fails and you want to wrap the error
|
|
6
|
+
* information in a Result type for consistent error handling.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* const success = Result.ok({ id: 1 });
|
|
12
|
+
*
|
|
13
|
+
* const failure = Result.err(new Error('missing data'));
|
|
14
|
+
*
|
|
15
|
+
* assert.deepStrictEqual(success, {
|
|
16
|
+
* $$tag: 'ts-data-forge::Result.ok',
|
|
17
|
+
* value: { id: 1 },
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* assert.isTrue(Result.isErr(failure));
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @template E The type of the error value.
|
|
24
|
+
* @param value The error value.
|
|
25
|
+
* @returns A `Result.Err<E>` containing the value.
|
|
26
|
+
*/
|
|
27
|
+
export const err = (value) => ({
|
|
28
|
+
$$tag: ErrTypeTagName,
|
|
29
|
+
value,
|
|
6
30
|
});
|
|
7
|
-
|
|
8
|
-
export { err };
|
|
9
|
-
//# sourceMappingURL=result-err.mjs.map
|
|
31
|
+
//# sourceMappingURL=result-err.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result-err.mjs","sources":["../../../../src/functional/result/impl/result-err.mts"],"
|
|
1
|
+
{"version":3,"file":"result-err.mjs","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-err.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,CAAW,KAAQ,EAAU,EAAE,CAChD,CAAC;IACC,KAAK,EAAE,cAAc;IACrB,KAAK;CACN,CAAU,CAAC"}
|
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
import { isOk } from './result-is-ok.mjs';
|
|
2
2
|
import { unwrapOk } from './result-unwrap-ok.mjs';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
export function expectToBe(...args) {
|
|
4
|
+
switch (args.length) {
|
|
5
|
+
case 2: {
|
|
6
|
+
// Direct version: first argument is result
|
|
7
|
+
const [result, message] = args;
|
|
8
|
+
return expectToBeImpl(result, message);
|
|
9
|
+
}
|
|
10
|
+
case 1: {
|
|
11
|
+
// Curried version: first argument is message
|
|
12
|
+
const [message] = args;
|
|
13
|
+
return (result) => expectToBeImpl(result, message);
|
|
14
|
+
}
|
|
9
15
|
}
|
|
10
|
-
case 1: {
|
|
11
|
-
const [message] = args;
|
|
12
|
-
return (result) => expectToBeImpl(result, message);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
16
|
}
|
|
16
17
|
const expectToBeImpl = (result, message) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
if (isOk(result)) {
|
|
19
|
+
return unwrapOk(result);
|
|
20
|
+
}
|
|
21
|
+
throw new Error(message);
|
|
21
22
|
};
|
|
22
|
-
|
|
23
|
-
export { expectToBe };
|
|
24
|
-
//# sourceMappingURL=result-expect-to-be.mjs.map
|
|
23
|
+
//# sourceMappingURL=result-expect-to-be.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result-expect-to-be.mjs","sources":["../../../../src/functional/result/impl/result-expect-to-be.mts"],"
|
|
1
|
+
{"version":3,"file":"result-expect-to-be.mjs","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-expect-to-be.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAyClD,MAAM,UAAU,UAAU,CACxB,GAAG,IAAwE;IAE3E,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;QACpB,KAAK,CAAC,EAAE,CAAC;YACP,2CAA2C;YAC3C,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;YAE/B,OAAO,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACzC,CAAC;QAED,KAAK,CAAC,EAAE,CAAC;YACP,6CAA6C;YAC7C,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;YAEvB,OAAO,CAAC,MAAS,EAAe,EAAE,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACrE,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,cAAc,GAAG,CACrB,MAAS,EACT,OAAe,EACF,EAAE;IACf,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACjB,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;AAC3B,CAAC,CAAC"}
|
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
import { isErr } from './result-is-err.mjs';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
export function flatMap(...args) {
|
|
3
|
+
switch (args.length) {
|
|
4
|
+
case 2: {
|
|
5
|
+
// Direct version: first argument is result
|
|
6
|
+
const [result, flatMapFn] = args;
|
|
7
|
+
return flatMapImpl(result, flatMapFn);
|
|
8
|
+
}
|
|
9
|
+
case 1: {
|
|
10
|
+
// Curried version
|
|
11
|
+
const [flatMapFn] = args;
|
|
12
|
+
return (result) => flatMapImpl(result, flatMapFn);
|
|
13
|
+
}
|
|
8
14
|
}
|
|
9
|
-
case 1: {
|
|
10
|
-
const [flatMapFn] = args;
|
|
11
|
-
return (result) => flatMapImpl(result, flatMapFn);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
15
|
}
|
|
15
|
-
const flatMapImpl = (result, flatMapFn) => isErr(result)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
export { flatMap };
|
|
24
|
-
//# sourceMappingURL=result-flat-map.mjs.map
|
|
16
|
+
const flatMapImpl = (result, flatMapFn) => isErr(result)
|
|
17
|
+
? // eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
18
|
+
result
|
|
19
|
+
: // eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
20
|
+
flatMapFn(result.value);
|
|
21
|
+
//# sourceMappingURL=result-flat-map.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result-flat-map.mjs","sources":["../../../../src/functional/result/impl/result-flat-map.mts"],"
|
|
1
|
+
{"version":3,"file":"result-flat-map.mjs","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-flat-map.mts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAqD5C,MAAM,UAAU,OAAO,CACrB,GAAG,IAE6D;IAIhE,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;QACpB,KAAK,CAAC,EAAE,CAAC;YACP,2CAA2C;YAC3C,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAI,CAAC;YAEjC,OAAO,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QACxC,CAAC;QAED,KAAK,CAAC,EAAE,CAAC;YACP,kBAAkB;YAClB,MAAM,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;YAEzB,OAAO,CAAC,MAAS,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,WAAW,GAAG,CAClB,MAAS,EACT,SAAiD,EAClB,EAAE,CACjC,KAAK,CAAC,MAAM,CAAC;IACX,CAAC,CAAC,oEAAoE;QACnE,MAA4B;IAC/B,CAAC,CAAC,oEAAoE;QACpE,SAAS,CAAC,MAAM,CAAC,KAAoB,CAAC,CAAC"}
|
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
import { err } from './result-err.mjs';
|
|
2
2
|
import { isOk } from './result-is-ok.mjs';
|
|
3
3
|
import { ok } from './result-ok.mjs';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
export function fold(...args) {
|
|
5
|
+
switch (args.length) {
|
|
6
|
+
case 3: {
|
|
7
|
+
// Direct version: first argument is result
|
|
8
|
+
const [result, mapFn, mapErrFn] = args;
|
|
9
|
+
return foldImpl(result, mapFn, mapErrFn);
|
|
10
|
+
}
|
|
11
|
+
case 2: {
|
|
12
|
+
// Curried version
|
|
13
|
+
const [mapFn, mapErrFn] = args;
|
|
14
|
+
return (result) => foldImpl(result, mapFn, mapErrFn);
|
|
15
|
+
}
|
|
10
16
|
}
|
|
11
|
-
case 2: {
|
|
12
|
-
const [mapFn, mapErrFn] = args;
|
|
13
|
-
return (result) => foldImpl(result, mapFn, mapErrFn);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
17
|
}
|
|
17
|
-
const foldImpl = (result, mapFn, mapErrFn) => isOk(result)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
export { fold };
|
|
26
|
-
//# sourceMappingURL=result-fold.mjs.map
|
|
18
|
+
const foldImpl = (result, mapFn, mapErrFn) => isOk(result)
|
|
19
|
+
? // eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
20
|
+
ok(mapFn(result.value))
|
|
21
|
+
: // eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
22
|
+
err(mapErrFn(result.value));
|
|
23
|
+
//# sourceMappingURL=result-fold.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result-fold.mjs","sources":["../../../../src/functional/result/impl/result-fold.mts"],"
|
|
1
|
+
{"version":3,"file":"result-fold.mjs","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-fold.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AA4DrC,MAAM,UAAU,IAAI,CAClB,GAAG,IASE;IAEL,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;QACpB,KAAK,CAAC,EAAE,CAAC;YACP,2CAA2C;YAC3C,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAI,CAAC;YAEvC,OAAO,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC3C,CAAC;QAED,KAAK,CAAC,EAAE,CAAC;YACP,kBAAkB;YAClB,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAI,CAAC;YAE/B,OAAO,CAAC,MAAS,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,QAAQ,GAAG,CACf,MAAS,EACT,KAAiC,EACjC,QAAqC,EACrB,EAAE,CAClB,IAAI,CAAC,MAAM,CAAC;IACV,CAAC,CAAC,oEAAoE;QACpE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,KAAoB,CAAC,CAAC;IACxC,CAAC,CAAC,oEAAoE;QACpE,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAqB,CAAC,CAAC,CAAC"}
|
|
@@ -1,24 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { unwrap } from '../../optional/impl/optional-unwrap.mjs';
|
|
1
|
+
import { Optional } from '../../optional/index.mjs';
|
|
3
2
|
import { err } from './result-err.mjs';
|
|
4
3
|
import { ok } from './result-ok.mjs';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
export function fromOptional(...args) {
|
|
5
|
+
switch (args.length) {
|
|
6
|
+
case 2: {
|
|
7
|
+
const [optional, error] = args;
|
|
8
|
+
return fromOptionalImpl(optional, error);
|
|
9
|
+
}
|
|
10
|
+
case 1: {
|
|
11
|
+
// Curried version: the only argument is the error value
|
|
12
|
+
const [error] = args;
|
|
13
|
+
return (optional) => fromOptionalImpl(optional, error);
|
|
14
|
+
}
|
|
11
15
|
}
|
|
12
|
-
case 1: {
|
|
13
|
-
const [error] = args;
|
|
14
|
-
return (optional) => fromOptionalImpl(optional, error);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
16
|
}
|
|
18
|
-
const fromOptionalImpl = (optional, error) => isSome(optional)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
export { fromOptional };
|
|
24
|
-
//# sourceMappingURL=result-from-optional.mjs.map
|
|
17
|
+
const fromOptionalImpl = (optional, error) => Optional.isSome(optional)
|
|
18
|
+
? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
19
|
+
ok(Optional.unwrap(optional))
|
|
20
|
+
: err(error);
|
|
21
|
+
//# sourceMappingURL=result-from-optional.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result-from-optional.mjs","sources":["../../../../src/functional/result/impl/result-from-optional.mts"],"
|
|
1
|
+
{"version":3,"file":"result-from-optional.mjs","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-from-optional.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAwB,MAAM,0BAA0B,CAAC;AAE1E,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAgDrC,MAAM,UAAU,YAAY,CAC1B,GAAG,IAA4D;IAI/D,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;QACpB,KAAK,CAAC,EAAE,CAAC;YACP,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;YAE/B,OAAO,gBAAgB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QAC3C,CAAC;QAED,KAAK,CAAC,EAAE,CAAC;YACP,wDAAwD;YACxD,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;YAErB,OAAO,CAAC,QAAW,EAAE,EAAE,CAAC,gBAAgB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,gBAAgB,GAAG,CACvB,QAAW,EACX,KAAQ,EACuB,EAAE,CACjC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC;IACvB,CAAC,CAAC,oEAAoE;QACpE,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAE,CAAC;IAChC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC"}
|
|
@@ -1,10 +1,39 @@
|
|
|
1
1
|
import { err } from './result-err.mjs';
|
|
2
2
|
import { ok } from './result-ok.mjs';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Converts a Promise into a Promise that resolves to a `Result`. If the input
|
|
5
|
+
* Promise resolves, the `Result` will be `Ok` with the resolved value. If the
|
|
6
|
+
* input Promise rejects, the `Result` will be `Err` with the rejection
|
|
7
|
+
* reason.
|
|
8
|
+
*
|
|
9
|
+
* The error channel is `unknown`, since the rejection reason is carried
|
|
10
|
+
* through untouched. For a concrete error type, use `AsyncResult.fromPromise`
|
|
11
|
+
* with a `mapError` function; called without one it behaves exactly as this
|
|
12
|
+
* function does.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* const successPromise = Result.fromPromise(Promise.resolve('ok'));
|
|
18
|
+
*
|
|
19
|
+
* const failurePromise = Result.fromPromise(
|
|
20
|
+
* Promise.reject(new Error('fail')),
|
|
21
|
+
* );
|
|
22
|
+
*
|
|
23
|
+
* const resolved = await successPromise;
|
|
24
|
+
*
|
|
25
|
+
* const rejected = await failurePromise;
|
|
26
|
+
*
|
|
27
|
+
* assert.deepStrictEqual(resolved, Result.ok('ok'));
|
|
28
|
+
*
|
|
29
|
+
* assert.isTrue(Result.isErr(rejected));
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @template P The type of the input Promise.
|
|
33
|
+
* @param promise The Promise to convert.
|
|
34
|
+
* @returns A Promise that resolves to `Result<UnwrapPromise<P>, unknown>`.
|
|
35
|
+
*/
|
|
36
|
+
export const fromPromise = (promise) =>
|
|
37
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
38
|
+
promise.then((v) => ok(v)).catch(err);
|
|
39
|
+
//# sourceMappingURL=result-from-promise.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result-from-promise.mjs","sources":["../../../../src/functional/result/impl/result-from-promise.mts"],"
|
|
1
|
+
{"version":3,"file":"result-from-promise.mjs","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-from-promise.mts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAUrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,OAAU,EACkC,EAAE;AAC9C,oEAAoE;AACpE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAyB,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC"}
|