ts-data-forge 14.6.1 → 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 -292
- 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.mjs +448 -265
- 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
|
@@ -1,146 +1,175 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import '
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
import '../number/branded-types/non-positive-int.mjs';
|
|
17
|
-
import '../number/branded-types/non-positive-safe-int.mjs';
|
|
18
|
-
import '../number/branded-types/non-zero-finite-number.mjs';
|
|
19
|
-
import '../number/branded-types/non-zero-int.mjs';
|
|
20
|
-
import '../number/branded-types/non-zero-int16.mjs';
|
|
21
|
-
import '../number/branded-types/non-zero-int32.mjs';
|
|
22
|
-
import '../number/branded-types/non-zero-safe-int.mjs';
|
|
23
|
-
import '../number/branded-types/non-zero-uint16.mjs';
|
|
24
|
-
import '../number/branded-types/non-zero-uint32.mjs';
|
|
25
|
-
import '../number/branded-types/positive-finite-number.mjs';
|
|
26
|
-
import '../number/branded-types/positive-int.mjs';
|
|
27
|
-
import '../number/branded-types/positive-int16.mjs';
|
|
28
|
-
import '../number/branded-types/positive-int32.mjs';
|
|
29
|
-
import '../number/branded-types/positive-safe-int.mjs';
|
|
30
|
-
import '../number/branded-types/positive-uint16.mjs';
|
|
31
|
-
import '../number/branded-types/positive-uint32.mjs';
|
|
32
|
-
import '../number/branded-types/safe-int.mjs';
|
|
33
|
-
import '../number/branded-types/safe-uint.mjs';
|
|
34
|
-
import '../number/branded-types/uint.mjs';
|
|
35
|
-
import '../number/branded-types/uint16.mjs';
|
|
36
|
-
import { asUint32, Uint32 } from '../number/branded-types/uint32.mjs';
|
|
37
|
-
import '../number/enum/int8.mjs';
|
|
38
|
-
import '../number/enum/uint8.mjs';
|
|
39
|
-
import '../number/num.mjs';
|
|
40
|
-
import '../number/refined-number-utils.mjs';
|
|
41
|
-
|
|
1
|
+
import { Optional } from '../functional/index.mjs';
|
|
2
|
+
import { range } from '../iterator/index.mjs';
|
|
3
|
+
import { asUint32, Uint32 } from '../number/index.mjs';
|
|
4
|
+
/**
|
|
5
|
+
* Class implementation for a stack with LIFO (Last-In, First-Out) behavior
|
|
6
|
+
* using a dynamic array. This implementation provides O(1) amortized push and
|
|
7
|
+
* O(1) pop operations by using a resizable buffer that grows as needed.
|
|
8
|
+
*
|
|
9
|
+
* The underlying array automatically resizes when it becomes full, ensuring
|
|
10
|
+
* that the stack can grow to accommodate any number of elements while
|
|
11
|
+
* maintaining efficient operations.
|
|
12
|
+
*
|
|
13
|
+
* @template T The type of elements in the stack.
|
|
14
|
+
* @implements Stack
|
|
15
|
+
*/
|
|
42
16
|
class StackClass {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
this.#mut_capacity = initialCapacity;
|
|
66
|
-
for (const value of initialValues) {
|
|
67
|
-
this.push(value);
|
|
17
|
+
/** @internal Initial capacity for new stacks. */
|
|
18
|
+
static #INITIAL_CAPACITY = 8;
|
|
19
|
+
/** @internal Dynamic array to store stack elements. */
|
|
20
|
+
#mut_buffer;
|
|
21
|
+
/** @internal Current number of elements in the stack. */
|
|
22
|
+
#mut_size;
|
|
23
|
+
/** @internal Current capacity of the buffer. */
|
|
24
|
+
#mut_capacity;
|
|
25
|
+
/**
|
|
26
|
+
* Constructs a new StackClass instance.
|
|
27
|
+
*
|
|
28
|
+
* @param initialValues Optional initial values to populate the stack.
|
|
29
|
+
*/
|
|
30
|
+
constructor(initialValues = []) {
|
|
31
|
+
const initialCapacity = asUint32(Math.max(StackClass.#INITIAL_CAPACITY, initialValues.length * 2));
|
|
32
|
+
this.#mut_buffer = Array.from({ length: initialCapacity }, () => undefined);
|
|
33
|
+
this.#mut_size = asUint32(0);
|
|
34
|
+
this.#mut_capacity = initialCapacity;
|
|
35
|
+
// Add initial values
|
|
36
|
+
for (const value of initialValues) {
|
|
37
|
+
this.push(value);
|
|
38
|
+
}
|
|
68
39
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
40
|
+
/**
|
|
41
|
+
* @internal
|
|
42
|
+
* Resizes the buffer when it becomes full.
|
|
43
|
+
* Doubles the capacity while preserving all elements.
|
|
44
|
+
*/
|
|
45
|
+
#resize() {
|
|
46
|
+
const newCapacity = asUint32(this.#mut_capacity * 2);
|
|
47
|
+
const newBuffer = Array.from({ length: newCapacity }, () => undefined);
|
|
48
|
+
// Copy existing elements
|
|
49
|
+
for (const i of range(this.#mut_size)) {
|
|
50
|
+
newBuffer[i] = this.#mut_buffer[i];
|
|
51
|
+
}
|
|
52
|
+
this.#mut_buffer = newBuffer;
|
|
53
|
+
this.#mut_capacity = newCapacity;
|
|
83
54
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
/** @inheritdoc */
|
|
88
|
-
get isEmpty() {
|
|
89
|
-
return this.#mut_size === 0;
|
|
90
|
-
}
|
|
91
|
-
/** @inheritdoc */
|
|
92
|
-
get size() {
|
|
93
|
-
return asUint32(this.#mut_size);
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Removes and returns the element at the top of the stack (LIFO).
|
|
97
|
-
*
|
|
98
|
-
* This operation removes the element that was added most recently (last-in)
|
|
99
|
-
* and returns it. If the stack is empty, returns `Optional.none`. The
|
|
100
|
-
* operation is guaranteed to be O(1) and does not require any array resizing
|
|
101
|
-
* or memory reallocation.
|
|
102
|
-
*
|
|
103
|
-
* **Time Complexity:** O(1) - constant time operation **Space Complexity:**
|
|
104
|
-
* O(1) - no additional memory allocation
|
|
105
|
-
*
|
|
106
|
-
* @returns An Optional containing the removed element, or `Optional.none` if
|
|
107
|
-
* the stack is empty.
|
|
108
|
-
*/
|
|
109
|
-
pop() {
|
|
110
|
-
if (this.isEmpty) {
|
|
111
|
-
return none;
|
|
55
|
+
/** @inheritdoc */
|
|
56
|
+
get isEmpty() {
|
|
57
|
+
return this.#mut_size === 0;
|
|
112
58
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
59
|
+
/** @inheritdoc */
|
|
60
|
+
get size() {
|
|
61
|
+
return asUint32(this.#mut_size);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Removes and returns the element at the top of the stack (LIFO).
|
|
65
|
+
*
|
|
66
|
+
* This operation removes the element that was added most recently (last-in)
|
|
67
|
+
* and returns it. If the stack is empty, returns `Optional.none`. The
|
|
68
|
+
* operation is guaranteed to be O(1) and does not require any array resizing
|
|
69
|
+
* or memory reallocation.
|
|
70
|
+
*
|
|
71
|
+
* **Time Complexity:** O(1) - constant time operation **Space Complexity:**
|
|
72
|
+
* O(1) - no additional memory allocation
|
|
73
|
+
*
|
|
74
|
+
* @returns An Optional containing the removed element, or `Optional.none` if
|
|
75
|
+
* the stack is empty.
|
|
76
|
+
*/
|
|
77
|
+
pop() {
|
|
78
|
+
if (this.isEmpty) {
|
|
79
|
+
return Optional.none;
|
|
80
|
+
}
|
|
81
|
+
this.#mut_size = Uint32.sub(this.#mut_size, 1);
|
|
82
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
83
|
+
const element = this.#mut_buffer[this.#mut_size];
|
|
84
|
+
this.#mut_buffer[this.#mut_size] = undefined; // Clear reference for garbage collection
|
|
85
|
+
return Optional.some(element);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Adds an element to the top of the stack (LIFO).
|
|
89
|
+
*
|
|
90
|
+
* This operation adds the element to the top of the stack, where it will be
|
|
91
|
+
* the first to be popped (last-in, first-out ordering). The operation is
|
|
92
|
+
* amortized O(1), meaning it's O(1) for most operations with occasional O(n)
|
|
93
|
+
* when the buffer needs resizing.
|
|
94
|
+
*
|
|
95
|
+
* **Time Complexity:** O(1) amortized - O(n) only when buffer resize is
|
|
96
|
+
* needed **Space Complexity:** O(1) - constant additional memory per element
|
|
97
|
+
*
|
|
98
|
+
* **Buffer Resizing:** When the internal buffer becomes full, it
|
|
99
|
+
* automatically doubles in size and copies existing elements to maintain the
|
|
100
|
+
* stack structure.
|
|
101
|
+
*
|
|
102
|
+
* @param value The element to add to the top of the stack.
|
|
103
|
+
*/
|
|
104
|
+
push(value) {
|
|
105
|
+
// Resize if buffer is full
|
|
106
|
+
if (this.#mut_size === this.#mut_capacity) {
|
|
107
|
+
this.#resize();
|
|
108
|
+
}
|
|
109
|
+
this.#mut_buffer[this.#mut_size] = value;
|
|
110
|
+
this.#mut_size = Uint32.add(this.#mut_size, 1);
|
|
138
111
|
}
|
|
139
|
-
this.#mut_buffer[this.#mut_size] = value;
|
|
140
|
-
this.#mut_size = Uint32.add(this.#mut_size, 1);
|
|
141
|
-
}
|
|
142
112
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
113
|
+
/**
|
|
114
|
+
* Creates a new Stack instance with LIFO (Last-In, First-Out) behavior using a
|
|
115
|
+
* high-performance dynamic array.
|
|
116
|
+
*
|
|
117
|
+
* This factory function creates an optimized stack implementation that
|
|
118
|
+
* maintains excellent performance characteristics for both push and pop
|
|
119
|
+
* operations. The underlying dynamic array automatically resizes to accommodate
|
|
120
|
+
* growing workloads while providing predictable O(1) operations.
|
|
121
|
+
*
|
|
122
|
+
* **Implementation Features:**
|
|
123
|
+
*
|
|
124
|
+
* - **O(1) push operations** (amortized - occasionally O(n) when resizing)
|
|
125
|
+
* - **O(1) pop operations** (always)
|
|
126
|
+
* - **Automatic buffer resizing** - starts at 8 elements, doubles when full
|
|
127
|
+
* - **Memory efficient** - garbage collects removed elements immediately
|
|
128
|
+
* - **Dynamic array design** - eliminates need for complex memory management
|
|
129
|
+
*
|
|
130
|
+
* **Performance Benefits:**
|
|
131
|
+
*
|
|
132
|
+
* - No array shifting required for stack operations
|
|
133
|
+
* - Minimal memory allocation overhead
|
|
134
|
+
* - Predictable performance under high load
|
|
135
|
+
* - Efficient memory usage with automatic cleanup
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
*
|
|
139
|
+
* ```ts
|
|
140
|
+
* const stack = createStack<string>();
|
|
141
|
+
*
|
|
142
|
+
* assert.isTrue(stack.isEmpty);
|
|
143
|
+
*
|
|
144
|
+
* assert.isTrue(stack.size === 0);
|
|
145
|
+
*
|
|
146
|
+
* stack.push('first');
|
|
147
|
+
*
|
|
148
|
+
* stack.push('second');
|
|
149
|
+
*
|
|
150
|
+
* assert.isFalse(stack.isEmpty);
|
|
151
|
+
*
|
|
152
|
+
* assert.isTrue(stack.size === 2);
|
|
153
|
+
*
|
|
154
|
+
* assert.deepStrictEqual(stack.pop(), Optional.some('second'));
|
|
155
|
+
*
|
|
156
|
+
* assert.deepStrictEqual(stack.pop(), Optional.some('first'));
|
|
157
|
+
*
|
|
158
|
+
* assert.deepStrictEqual(stack.pop(), Optional.none);
|
|
159
|
+
*
|
|
160
|
+
* const seededStack = createStack([10, 20, 30]);
|
|
161
|
+
*
|
|
162
|
+
* assert.isTrue(seededStack.size === 3);
|
|
163
|
+
*
|
|
164
|
+
* assert.deepStrictEqual(seededStack.pop(), Optional.some(30));
|
|
165
|
+
* ```
|
|
166
|
+
*
|
|
167
|
+
* @template T The type of elements stored in the stack.
|
|
168
|
+
* @param initialValues Optional array of initial elements to populate the
|
|
169
|
+
* stack. Elements will be popped in reverse order of how they appear in the
|
|
170
|
+
* array (last array element will be popped first). If provided, the initial
|
|
171
|
+
* buffer capacity will be at least twice the array length.
|
|
172
|
+
* @returns A new Stack instance optimized for high-performance LIFO operations.
|
|
173
|
+
*/
|
|
174
|
+
export const createStack = (initialValues) => new StackClass(initialValues);
|
|
175
|
+
//# sourceMappingURL=stack.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stack.mjs","sources":["../../src/collections/stack.mts"],"sourcesContent":["import { Optional } from '../functional/index.mjs';\nimport { range } from '../iterator/index.mjs';\nimport { asUint32, Uint32 } from '../number/index.mjs';\nimport { type SizeType } from '../types.mjs';\n\n/**\n * Interface for a high-performance stack with LIFO (Last-In, First-Out)\n * behavior.\n *\n * This interface defines a mutable stack data structure where elements are\n * added to and removed from the top, following the Last-In, First-Out\n * principle. The implementation uses a dynamic array for optimal performance,\n * providing O(1) operations for both push and pop operations.\n *\n * **LIFO Behavior:**\n *\n * - **push**: Adds elements to the top of the stack\n * - **pop**: Removes and returns elements from the top of the stack\n * - The last element added is the first element to be removed\n *\n * **Performance Characteristics:**\n *\n * - Push: O(1) amortized (O(n) when buffer needs resizing)\n * - Pop: O(1) always\n * - Size/isEmpty: O(1) always\n * - Memory efficient with automatic garbage collection of removed elements\n *\n * **Use Cases:**\n *\n * - Function call management and recursion\n * - Undo/redo functionality\n * - Expression evaluation and parsing\n * - Depth-first search algorithms\n * - Backtracking algorithms\n * - Browser history management\n *\n * @template T The type of elements stored in the stack.\n */\nexport type Stack<T> = Readonly<{\n /**\n * Checks if the stack is empty.\n *\n * @example\n *\n * ```ts\n * const stack = createStack<string>();\n *\n * assert.isTrue(stack.isEmpty);\n *\n * assert.isTrue(stack.size === 0);\n *\n * stack.push('first');\n *\n * stack.push('second');\n *\n * assert.isFalse(stack.isEmpty);\n *\n * assert.isTrue(stack.size === 2);\n *\n * assert.deepStrictEqual(stack.pop(), Optional.some('second'));\n *\n * assert.deepStrictEqual(stack.pop(), Optional.some('first'));\n *\n * assert.deepStrictEqual(stack.pop(), Optional.none);\n *\n * const seededStack = createStack([10, 20, 30]);\n *\n * assert.isTrue(seededStack.size === 3);\n *\n * assert.deepStrictEqual(seededStack.pop(), Optional.some(30));\n * ```\n */\n isEmpty: boolean;\n\n /**\n * The number of elements in the stack.\n *\n * @example\n *\n * ```ts\n * const stack = createStack<string>();\n *\n * assert.isTrue(stack.isEmpty);\n *\n * assert.isTrue(stack.size === 0);\n *\n * stack.push('first');\n *\n * stack.push('second');\n *\n * assert.isFalse(stack.isEmpty);\n *\n * assert.isTrue(stack.size === 2);\n *\n * assert.deepStrictEqual(stack.pop(), Optional.some('second'));\n *\n * assert.deepStrictEqual(stack.pop(), Optional.some('first'));\n *\n * assert.deepStrictEqual(stack.pop(), Optional.none);\n *\n * const seededStack = createStack([10, 20, 30]);\n *\n * assert.isTrue(seededStack.size === 3);\n *\n * assert.deepStrictEqual(seededStack.pop(), Optional.some(30));\n * ```\n */\n size: SizeType.Arr;\n\n /**\n * Removes and returns the element at the top of the stack.\n *\n * @example\n *\n * ```ts\n * const stack = createStack<string>();\n *\n * assert.isTrue(stack.isEmpty);\n *\n * assert.isTrue(stack.size === 0);\n *\n * stack.push('first');\n *\n * stack.push('second');\n *\n * assert.isFalse(stack.isEmpty);\n *\n * assert.isTrue(stack.size === 2);\n *\n * assert.deepStrictEqual(stack.pop(), Optional.some('second'));\n *\n * assert.deepStrictEqual(stack.pop(), Optional.some('first'));\n *\n * assert.deepStrictEqual(stack.pop(), Optional.none);\n *\n * const seededStack = createStack([10, 20, 30]);\n *\n * assert.isTrue(seededStack.size === 3);\n *\n * assert.deepStrictEqual(seededStack.pop(), Optional.some(30));\n * ```\n *\n * @returns The element at the top of the stack, or `Optional.none` if the\n * stack is empty.\n */\n pop: () => Optional<T>;\n\n /**\n * Adds an element to the top of the stack.\n *\n * @example\n *\n * ```ts\n * const stack = createStack<string>();\n *\n * assert.isTrue(stack.isEmpty);\n *\n * assert.isTrue(stack.size === 0);\n *\n * stack.push('first');\n *\n * stack.push('second');\n *\n * assert.isFalse(stack.isEmpty);\n *\n * assert.isTrue(stack.size === 2);\n *\n * assert.deepStrictEqual(stack.pop(), Optional.some('second'));\n *\n * assert.deepStrictEqual(stack.pop(), Optional.some('first'));\n *\n * assert.deepStrictEqual(stack.pop(), Optional.none);\n *\n * const seededStack = createStack([10, 20, 30]);\n *\n * assert.isTrue(seededStack.size === 3);\n *\n * assert.deepStrictEqual(seededStack.pop(), Optional.some(30));\n * ```\n *\n * @param value The element to add.\n */\n push: (value: T) => void;\n}>;\n\n/**\n * Class implementation for a stack with LIFO (Last-In, First-Out) behavior\n * using a dynamic array. This implementation provides O(1) amortized push and\n * O(1) pop operations by using a resizable buffer that grows as needed.\n *\n * The underlying array automatically resizes when it becomes full, ensuring\n * that the stack can grow to accommodate any number of elements while\n * maintaining efficient operations.\n *\n * @template T The type of elements in the stack.\n * @implements Stack\n */\nclass StackClass<T> implements Stack<T> {\n /** @internal Initial capacity for new stacks. */\n static readonly #INITIAL_CAPACITY = 8;\n\n /** @internal Dynamic array to store stack elements. */\n #mut_buffer: (T | undefined)[];\n\n /** @internal Current number of elements in the stack. */\n #mut_size: Uint32;\n\n /** @internal Current capacity of the buffer. */\n #mut_capacity: Uint32;\n\n /**\n * Constructs a new StackClass instance.\n *\n * @param initialValues Optional initial values to populate the stack.\n */\n constructor(initialValues: readonly T[] = []) {\n const initialCapacity = asUint32(\n Math.max(StackClass.#INITIAL_CAPACITY, initialValues.length * 2),\n );\n\n this.#mut_buffer = Array.from<unknown, T | undefined>(\n { length: initialCapacity },\n () => undefined,\n );\n\n this.#mut_size = asUint32(0);\n\n this.#mut_capacity = initialCapacity;\n\n // Add initial values\n for (const value of initialValues) {\n this.push(value);\n }\n }\n\n /**\n * @internal\n * Resizes the buffer when it becomes full.\n * Doubles the capacity while preserving all elements.\n */\n #resize(): void {\n const newCapacity = asUint32(this.#mut_capacity * 2);\n\n const newBuffer = Array.from<unknown, T | undefined>(\n { length: newCapacity },\n () => undefined,\n );\n\n // Copy existing elements\n for (const i of range(this.#mut_size)) {\n newBuffer[i] = this.#mut_buffer[i];\n }\n\n this.#mut_buffer = newBuffer;\n\n this.#mut_capacity = newCapacity;\n }\n\n /** @inheritdoc */\n get isEmpty(): boolean {\n return this.#mut_size === 0;\n }\n\n /** @inheritdoc */\n get size(): SizeType.Arr {\n return asUint32(this.#mut_size);\n }\n\n /**\n * Removes and returns the element at the top of the stack (LIFO).\n *\n * This operation removes the element that was added most recently (last-in)\n * and returns it. If the stack is empty, returns `Optional.none`. The\n * operation is guaranteed to be O(1) and does not require any array resizing\n * or memory reallocation.\n *\n * **Time Complexity:** O(1) - constant time operation **Space Complexity:**\n * O(1) - no additional memory allocation\n *\n * @returns An Optional containing the removed element, or `Optional.none` if\n * the stack is empty.\n */\n pop(): Optional<T> {\n if (this.isEmpty) {\n return Optional.none;\n }\n\n this.#mut_size = Uint32.sub(this.#mut_size, 1);\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const element = this.#mut_buffer[this.#mut_size]!;\n\n this.#mut_buffer[this.#mut_size] = undefined; // Clear reference for garbage collection\n\n return Optional.some(element);\n }\n\n /**\n * Adds an element to the top of the stack (LIFO).\n *\n * This operation adds the element to the top of the stack, where it will be\n * the first to be popped (last-in, first-out ordering). The operation is\n * amortized O(1), meaning it's O(1) for most operations with occasional O(n)\n * when the buffer needs resizing.\n *\n * **Time Complexity:** O(1) amortized - O(n) only when buffer resize is\n * needed **Space Complexity:** O(1) - constant additional memory per element\n *\n * **Buffer Resizing:** When the internal buffer becomes full, it\n * automatically doubles in size and copies existing elements to maintain the\n * stack structure.\n *\n * @param value The element to add to the top of the stack.\n */\n push(value: T): void {\n // Resize if buffer is full\n if (this.#mut_size === this.#mut_capacity) {\n this.#resize();\n }\n\n this.#mut_buffer[this.#mut_size] = value;\n\n this.#mut_size = Uint32.add(this.#mut_size, 1);\n }\n}\n\n/**\n * Creates a new Stack instance with LIFO (Last-In, First-Out) behavior using a\n * high-performance dynamic array.\n *\n * This factory function creates an optimized stack implementation that\n * maintains excellent performance characteristics for both push and pop\n * operations. The underlying dynamic array automatically resizes to accommodate\n * growing workloads while providing predictable O(1) operations.\n *\n * **Implementation Features:**\n *\n * - **O(1) push operations** (amortized - occasionally O(n) when resizing)\n * - **O(1) pop operations** (always)\n * - **Automatic buffer resizing** - starts at 8 elements, doubles when full\n * - **Memory efficient** - garbage collects removed elements immediately\n * - **Dynamic array design** - eliminates need for complex memory management\n *\n * **Performance Benefits:**\n *\n * - No array shifting required for stack operations\n * - Minimal memory allocation overhead\n * - Predictable performance under high load\n * - Efficient memory usage with automatic cleanup\n *\n * @example\n *\n * ```ts\n * const stack = createStack<string>();\n *\n * assert.isTrue(stack.isEmpty);\n *\n * assert.isTrue(stack.size === 0);\n *\n * stack.push('first');\n *\n * stack.push('second');\n *\n * assert.isFalse(stack.isEmpty);\n *\n * assert.isTrue(stack.size === 2);\n *\n * assert.deepStrictEqual(stack.pop(), Optional.some('second'));\n *\n * assert.deepStrictEqual(stack.pop(), Optional.some('first'));\n *\n * assert.deepStrictEqual(stack.pop(), Optional.none);\n *\n * const seededStack = createStack([10, 20, 30]);\n *\n * assert.isTrue(seededStack.size === 3);\n *\n * assert.deepStrictEqual(seededStack.pop(), Optional.some(30));\n * ```\n *\n * @template T The type of elements stored in the stack.\n * @param initialValues Optional array of initial elements to populate the\n * stack. Elements will be popped in reverse order of how they appear in the\n * array (last array element will be popped first). If provided, the initial\n * buffer capacity will be at least twice the array length.\n * @returns A new Stack instance optimized for high-performance LIFO operations.\n */\nexport const createStack = <T,>(initialValues?: readonly T[]): Stack<T> =>\n new StackClass<T>(initialValues);\n"],"names":["Optional.none","Optional.some"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"stack.mjs","sourceRoot":"","sources":["../../src/collections/stack.mts"],"names":[],"mappings":"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"}
|
package/dist/entry-point.mjs
CHANGED
|
@@ -1,77 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export { match } from './functional/match.mjs';
|
|
6
|
-
import * as index$2 from './functional/optional/impl/index.mjs';
|
|
7
|
-
export { index$2 as Optional };
|
|
8
|
-
export { pipe } from './functional/pipe.mjs';
|
|
9
|
-
import * as index$3 from './functional/result/impl/index.mjs';
|
|
10
|
-
export { index$3 as Result };
|
|
11
|
-
import * as index$4 from './functional/ternary-result/impl/index.mjs';
|
|
12
|
-
export { index$4 as TernaryResult };
|
|
13
|
-
export { IMapMapped } from './collections/imap-mapped.mjs';
|
|
14
|
-
export { IMap } from './collections/imap.mjs';
|
|
15
|
-
export { ISetMapped } from './collections/iset-mapped.mjs';
|
|
16
|
-
export { ISet } from './collections/iset.mjs';
|
|
17
|
-
export { createQueue } from './collections/queue.mjs';
|
|
18
|
-
export { createStack } from './collections/stack.mjs';
|
|
19
|
-
export { expectType } from './expect-type.mjs';
|
|
20
|
-
export { hasKey } from './guard/has-key.mjs';
|
|
21
|
-
export { isNonEmptyString } from './guard/is-non-empty-string.mjs';
|
|
22
|
-
export { isNonNullObject } from './guard/is-non-null-object.mjs';
|
|
23
|
-
export { isPrimitive } from './guard/is-primitive.mjs';
|
|
24
|
-
export { isMutableRecord, isRecord } from './guard/is-record.mjs';
|
|
25
|
-
export { isBigint, isBoolean, isNonNullish, isNotBigint, isNotBoolean, isNotNull, isNotNumber, isNotString, isNotSymbol, isNotUndefined, isNull, isNullish, isNumber, isString, isSymbol, isUndefined } from './guard/is-type.mjs';
|
|
26
|
-
export { keyIsIn } from './guard/key-is-in.mjs';
|
|
27
|
-
export { range } from './iterator/range.mjs';
|
|
28
|
-
export { Json } from './json/json.mjs';
|
|
29
|
-
export { FiniteNumber, asFiniteNumber, isFiniteNumber } from './number/branded-types/finite-number.mjs';
|
|
30
|
-
export { Int, asInt, isInt } from './number/branded-types/int.mjs';
|
|
31
|
-
export { Int16, asInt16, isInt16 } from './number/branded-types/int16.mjs';
|
|
32
|
-
export { Int32, asInt32, isInt32 } from './number/branded-types/int32.mjs';
|
|
33
|
-
export { NegativeFiniteNumber, asNegativeFiniteNumber, isNegativeFiniteNumber } from './number/branded-types/negative-finite-number.mjs';
|
|
34
|
-
export { NegativeInt, asNegativeInt, isNegativeInt } from './number/branded-types/negative-int.mjs';
|
|
35
|
-
export { NegativeSafeInt, asNegativeSafeInt, isNegativeSafeInt } from './number/branded-types/negative-safe-int.mjs';
|
|
36
|
-
export { NonNegativeFiniteNumber, asNonNegativeFiniteNumber, isNonNegativeFiniteNumber } from './number/branded-types/non-negative-finite-number.mjs';
|
|
37
|
-
export { NonNegativeInt16, asNonNegativeInt16, isNonNegativeInt16 } from './number/branded-types/non-negative-int16.mjs';
|
|
38
|
-
export { NonNegativeInt32, asNonNegativeInt32, isNonNegativeInt32 } from './number/branded-types/non-negative-int32.mjs';
|
|
39
|
-
export { NonPositiveFiniteNumber, asNonPositiveFiniteNumber, isNonPositiveFiniteNumber } from './number/branded-types/non-positive-finite-number.mjs';
|
|
40
|
-
export { NonPositiveInt, asNonPositiveInt, isNonPositiveInt } from './number/branded-types/non-positive-int.mjs';
|
|
41
|
-
export { NonPositiveSafeInt, asNonPositiveSafeInt, isNonPositiveSafeInt } from './number/branded-types/non-positive-safe-int.mjs';
|
|
42
|
-
export { NonZeroFiniteNumber, asNonZeroFiniteNumber, isNonZeroFiniteNumber } from './number/branded-types/non-zero-finite-number.mjs';
|
|
43
|
-
export { NonZeroInt, asNonZeroInt, isNonZeroInt } from './number/branded-types/non-zero-int.mjs';
|
|
44
|
-
export { NonZeroInt16, asNonZeroInt16, isNonZeroInt16 } from './number/branded-types/non-zero-int16.mjs';
|
|
45
|
-
export { NonZeroInt32, asNonZeroInt32, isNonZeroInt32 } from './number/branded-types/non-zero-int32.mjs';
|
|
46
|
-
export { NonZeroSafeInt, asNonZeroSafeInt, isNonZeroSafeInt } from './number/branded-types/non-zero-safe-int.mjs';
|
|
47
|
-
export { NonZeroUint16, asNonZeroUint16, isNonZeroUint16 } from './number/branded-types/non-zero-uint16.mjs';
|
|
48
|
-
export { NonZeroUint32, asNonZeroUint32, isNonZeroUint32 } from './number/branded-types/non-zero-uint32.mjs';
|
|
49
|
-
export { PositiveFiniteNumber, asPositiveFiniteNumber, isPositiveFiniteNumber } from './number/branded-types/positive-finite-number.mjs';
|
|
50
|
-
export { PositiveInt, asPositiveInt, isPositiveInt } from './number/branded-types/positive-int.mjs';
|
|
51
|
-
export { PositiveInt16, asPositiveInt16, isPositiveInt16 } from './number/branded-types/positive-int16.mjs';
|
|
52
|
-
export { PositiveInt32, asPositiveInt32, isPositiveInt32 } from './number/branded-types/positive-int32.mjs';
|
|
53
|
-
export { PositiveSafeInt, asPositiveSafeInt, isPositiveSafeInt } from './number/branded-types/positive-safe-int.mjs';
|
|
54
|
-
export { PositiveUint16, asPositiveUint16, isPositiveUint16 } from './number/branded-types/positive-uint16.mjs';
|
|
55
|
-
export { PositiveUint32, asPositiveUint32, isPositiveUint32 } from './number/branded-types/positive-uint32.mjs';
|
|
56
|
-
export { SafeInt, asSafeInt, isSafeInt } from './number/branded-types/safe-int.mjs';
|
|
57
|
-
export { SafeUint, asSafeUint, isSafeUint } from './number/branded-types/safe-uint.mjs';
|
|
58
|
-
export { Uint, asUint, isUint } from './number/branded-types/uint.mjs';
|
|
59
|
-
export { Uint16, asUint16, isUint16 } from './number/branded-types/uint16.mjs';
|
|
60
|
-
export { Uint32, asUint32, isUint32 } from './number/branded-types/uint32.mjs';
|
|
61
|
-
export { Int8, asInt8, isInt8 } from './number/enum/int8.mjs';
|
|
62
|
-
export { Uint8, asUint8, isUint8 } from './number/enum/uint8.mjs';
|
|
63
|
-
export { Num } from './number/num.mjs';
|
|
64
|
-
export { TsDataForgeInternals } from './number/refined-number-utils.mjs';
|
|
65
|
-
export { Obj } from './object/object.mjs';
|
|
66
|
-
export { castDeepMutable, castMutable } from './others/cast-mutable.mjs';
|
|
67
|
-
export { castDeepReadonly, castReadonly } from './others/cast-readonly.mjs';
|
|
68
|
-
export { debounce } from './others/debounce-function.mjs';
|
|
69
|
-
export { fastDeepEqual } from './others/fast-deep-equal.mjs';
|
|
70
|
-
export { ifThen, implies } from './others/if-then.mjs';
|
|
71
|
-
export { mapNullable } from './others/map-nullable.mjs';
|
|
72
|
-
export { memoizeFunction } from './others/memoize-function.mjs';
|
|
73
|
-
export { tp } from './others/tuple.mjs';
|
|
74
|
-
export { unknownToString } from './others/unknown-to-string.mjs';
|
|
75
|
-
export { createPromise } from './promise/promise.mjs';
|
|
76
|
-
export { Str } from './string/str.mjs';
|
|
77
|
-
//# sourceMappingURL=entry-point.mjs.map
|
|
1
|
+
export * from './array/index.mjs';
|
|
2
|
+
export * from './functional/index.mjs';
|
|
3
|
+
export * from './index.mjs';
|
|
4
|
+
//# sourceMappingURL=entry-point.mjs.map
|
package/dist/entry-point.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry-point.mjs","
|
|
1
|
+
{"version":3,"file":"entry-point.mjs","sourceRoot":"","sources":["../src/entry-point.mts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC"}
|
package/dist/expect-type.mjs
CHANGED
|
@@ -1,4 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Compile-time type assertion utility for TypeScript type testing.
|
|
3
|
+
*
|
|
4
|
+
* This function performs static type relationship checking at compile-time and
|
|
5
|
+
* has no runtime effect. It is primarily used in test files to verify that
|
|
6
|
+
* TypeScript's type inference and type relationships work as expected. The
|
|
7
|
+
* function will cause TypeScript compilation errors if the specified type
|
|
8
|
+
* relationship does not hold.
|
|
9
|
+
*
|
|
10
|
+
* ## Supported Type Relations
|
|
11
|
+
*
|
|
12
|
+
* ### Equality Relations
|
|
13
|
+
*
|
|
14
|
+
* - **`"="` (strict equality)**: Asserts that types `A` and `B` are exactly the
|
|
15
|
+
* same type. Uses TypeScript's internal type equality checking.
|
|
16
|
+
* - **`"!="` (strict inequality)**: Asserts that types `A` and `B` are not
|
|
17
|
+
* exactly the same type.
|
|
18
|
+
*
|
|
19
|
+
* ### Assignability Relations
|
|
20
|
+
*
|
|
21
|
+
* - **`"~="` (mutual assignability)**: Asserts that `A` extends `B` AND `B`
|
|
22
|
+
* extends `A`. Types are structurally equivalent and mutually assignable.
|
|
23
|
+
* - **`"<="` (subtype relation)**: Asserts that type `A` extends (is assignable
|
|
24
|
+
* to) type `B`. Type `A` is a subtype of `B`.
|
|
25
|
+
* - **`">="` (supertype relation)**: Asserts that type `B` extends (is assignable
|
|
26
|
+
* to) type `A`. Type `A` is a supertype of `B`.
|
|
27
|
+
*
|
|
28
|
+
* ### Negative Assignability Relations
|
|
29
|
+
*
|
|
30
|
+
* - **`"!<="` (not subtype)**: Asserts that type `A` does NOT extend type `B`.
|
|
31
|
+
* - **`"!>="` (not supertype)**: Asserts that type `B` does NOT extend type `A`.
|
|
32
|
+
*
|
|
33
|
+
* ## Type Parameter Constraints
|
|
34
|
+
*
|
|
35
|
+
* @since 1.0.0
|
|
36
|
+
* @template A - The first type for comparison. Can be any TypeScript type
|
|
37
|
+
* including:
|
|
38
|
+
*
|
|
39
|
+
* - Primitive types (string, number, boolean, etc.)
|
|
40
|
+
* - Object types and interfaces
|
|
41
|
+
* - Union and intersection types
|
|
42
|
+
* - Generic types and type parameters
|
|
43
|
+
* - Literal types and branded types
|
|
44
|
+
* - Function types and return types
|
|
45
|
+
*
|
|
46
|
+
* @template B - The second type for comparison. Same constraints as type `A`.
|
|
47
|
+
* @param _relation - A string literal representing the expected type
|
|
48
|
+
* relationship. TypeScript's type system automatically infers and restricts
|
|
49
|
+
* the available operators based on the actual relationship between types `A`
|
|
50
|
+
* and `B`. If an invalid relationship is specified, TypeScript will show a
|
|
51
|
+
* compilation error.
|
|
52
|
+
*
|
|
53
|
+
* Combine `expectType` with runtime assertions for comprehensive testing:
|
|
54
|
+
*
|
|
55
|
+
* ## Important Notes
|
|
56
|
+
*
|
|
57
|
+
* - **Compile-time only**: This function has no runtime behavior and will be
|
|
58
|
+
* optimized away.
|
|
59
|
+
* - **Type inference**: The available relation operators are automatically
|
|
60
|
+
* inferred by TypeScript based on the actual type relationship between
|
|
61
|
+
* `A` and `B`.
|
|
62
|
+
* - **Error feedback**: Invalid type relationships will cause clear TypeScript
|
|
63
|
+
* compilation errors.
|
|
64
|
+
* - **Test organization**: Typically used in `.test.mts` files alongside runtime
|
|
65
|
+
* assertions.
|
|
66
|
+
* - **Performance**: Has zero runtime overhead as it's purely a compile-time
|
|
67
|
+
* construct.
|
|
68
|
+
*/
|
|
69
|
+
export const expectType = (_relation) => undefined;
|
|
70
|
+
//# sourceMappingURL=expect-type.mjs.map
|
package/dist/expect-type.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expect-type.mjs","
|
|
1
|
+
{"version":3,"file":"expect-type.mjs","sourceRoot":"","sources":["../src/expect-type.mts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,SAKkE,EAC5D,EAAE,CAAC,SAAS,CAAC"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
//# sourceMappingURL=async-result.mjs.map
|
|
1
|
+
export * as AsyncResult from './impl/index.mjs';
|
|
2
|
+
//# sourceMappingURL=async-result.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async-result.mjs","
|
|
1
|
+
{"version":3,"file":"async-result.mjs","sourceRoot":"","sources":["../../../src/functional/async-result/async-result.mts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC"}
|
|
@@ -1,25 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { Result } from '../../result/index.mjs';
|
|
2
|
+
export function flatMap(...args) {
|
|
3
|
+
switch (args.length) {
|
|
4
|
+
case 2: {
|
|
5
|
+
// Direct version: first argument is asyncResult
|
|
6
|
+
const [asyncResult, flatMapFn] = args;
|
|
7
|
+
return flatMapImpl(asyncResult, flatMapFn);
|
|
8
|
+
}
|
|
9
|
+
case 1: {
|
|
10
|
+
// Curried version
|
|
11
|
+
const [flatMapFn] = args;
|
|
12
|
+
return (asyncResult) => flatMapImpl(asyncResult, flatMapFn);
|
|
13
|
+
}
|
|
9
14
|
}
|
|
10
|
-
case 1: {
|
|
11
|
-
const [flatMapFn] = args;
|
|
12
|
-
return (asyncResult) => flatMapImpl(asyncResult, flatMapFn);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
15
|
}
|
|
16
16
|
const flatMapImpl = async (asyncResult, flatMapFn) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
const result = await asyncResult;
|
|
18
|
+
return Result.isErr(result)
|
|
19
|
+
? result
|
|
20
|
+
: // eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
21
|
+
(await flatMapFn(result.value));
|
|
22
22
|
};
|
|
23
|
-
|
|
24
|
-
export { flatMap };
|
|
25
|
-
//# sourceMappingURL=async-result-flat-map.mjs.map
|
|
23
|
+
//# sourceMappingURL=async-result-flat-map.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async-result-flat-map.mjs","sources":["../../../../src/functional/async-result/impl/async-result-flat-map.mts"],"
|
|
1
|
+
{"version":3,"file":"async-result-flat-map.mjs","sourceRoot":"","sources":["../../../../src/functional/async-result/impl/async-result-flat-map.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAsB,MAAM,wBAAwB,CAAC;AA6DpE,MAAM,UAAU,OAAO,CACrB,GAAG,IAEuC;IAM1C,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;QACpB,KAAK,CAAC,EAAE,CAAC;YACP,gDAAgD;YAChD,MAAM,CAAC,WAAW,EAAE,SAAS,CAAC,GAAG,IAAI,CAAC;YAEtC,OAAO,WAAW,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QAC7C,CAAC;QAED,KAAK,CAAC,EAAE,CAAC;YACP,kBAAkB;YAClB,MAAM,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;YAEzB,OAAO,CAAC,WAA8B,EAAE,EAAE,CACxC,WAAW,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,WAAW,GAAG,KAAK,EACvB,WAA8B,EAC9B,SAA2B,EACmB,EAAE;IAChD,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC;IAEjC,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC;QACzB,CAAC,CAAC,MAAM;QACR,CAAC,CAAC,oEAAoE;YACnE,CAAC,MAAM,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAyC,CAAC;AAC/E,CAAC,CAAC"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return mapError === void 0 ? fromPromiseImpl(promise, (error) => error) : fromPromiseImpl(promise, mapError);
|
|
1
|
+
import { Result } from '../../result/index.mjs';
|
|
2
|
+
export function fromPromise(promise, mapError) {
|
|
3
|
+
return mapError === undefined
|
|
4
|
+
? fromPromiseImpl(promise, (error) => error)
|
|
5
|
+
: fromPromiseImpl(promise, mapError);
|
|
7
6
|
}
|
|
8
|
-
const fromPromiseImpl = (promise, mapError) => promise
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
//# sourceMappingURL=async-result-from-promise.mjs.map
|
|
7
|
+
const fromPromiseImpl = (promise, mapError) => promise
|
|
8
|
+
.then((value) => Result.ok(value))
|
|
9
|
+
.catch((error) => Result.err(mapError(error)));
|
|
10
|
+
//# sourceMappingURL=async-result-from-promise.mjs.map
|