modern-ts 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +223 -0
- package/README.zh-CN.md +223 -0
- package/dist/chunks/Errors-BWEYu-AB.cjs +2 -0
- package/dist/chunks/Errors-BWEYu-AB.cjs.map +1 -0
- package/dist/chunks/Errors-DwUAvFIF.mjs +63 -0
- package/dist/chunks/Errors-DwUAvFIF.mjs.map +1 -0
- package/dist/chunks/Math-CGEH1ClN.mjs +68 -0
- package/dist/chunks/Math-CGEH1ClN.mjs.map +1 -0
- package/dist/chunks/Math-CWZVxSF-.cjs +2 -0
- package/dist/chunks/Math-CWZVxSF-.cjs.map +1 -0
- package/dist/chunks/base-B9k8Lqvf.mjs +56 -0
- package/dist/chunks/base-B9k8Lqvf.mjs.map +1 -0
- package/dist/chunks/base-BTXL1y_I.cjs +2 -0
- package/dist/chunks/base-BTXL1y_I.cjs.map +1 -0
- package/dist/chunks/base-BpECeKwU.mjs +19 -0
- package/dist/chunks/base-BpECeKwU.mjs.map +1 -0
- package/dist/chunks/base-BvHqpP_s.cjs +2 -0
- package/dist/chunks/base-BvHqpP_s.cjs.map +1 -0
- package/dist/chunks/base-K-RHLZ-S.mjs +46 -0
- package/dist/chunks/base-K-RHLZ-S.mjs.map +1 -0
- package/dist/chunks/base-r6kn0B0D.cjs +2 -0
- package/dist/chunks/base-r6kn0B0D.cjs.map +1 -0
- package/dist/chunks/combine-async-DcG-3p8i.cjs +2 -0
- package/dist/chunks/combine-async-DcG-3p8i.cjs.map +1 -0
- package/dist/chunks/combine-async-Dcg4ya1R.mjs +236 -0
- package/dist/chunks/combine-async-Dcg4ya1R.mjs.map +1 -0
- package/dist/chunks/delay-CG3cD7bk.cjs +2 -0
- package/dist/chunks/delay-CG3cD7bk.cjs.map +1 -0
- package/dist/chunks/delay-CKIXpP71.mjs +32 -0
- package/dist/chunks/delay-CKIXpP71.mjs.map +1 -0
- package/dist/chunks/helper-BVabbpmX.mjs +165 -0
- package/dist/chunks/helper-BVabbpmX.mjs.map +1 -0
- package/dist/chunks/helper-tsqZMRHW.cjs +3 -0
- package/dist/chunks/helper-tsqZMRHW.cjs.map +1 -0
- package/dist/chunks/local-8JVtLN0O.mjs +10 -0
- package/dist/chunks/local-8JVtLN0O.mjs.map +1 -0
- package/dist/chunks/local-Da4yU-nE.cjs +2 -0
- package/dist/chunks/local-Da4yU-nE.cjs.map +1 -0
- package/dist/chunks/types-B7X_LBjM.cjs +2 -0
- package/dist/chunks/types-B7X_LBjM.cjs.map +1 -0
- package/dist/chunks/types-DE2SnSbz.mjs +5 -0
- package/dist/chunks/types-DE2SnSbz.mjs.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.mjs +759 -0
- package/dist/index.mjs.map +1 -0
- package/dist/subpath/Arr.cjs +2 -0
- package/dist/subpath/Arr.cjs.map +1 -0
- package/dist/subpath/Arr.mjs +539 -0
- package/dist/subpath/Arr.mjs.map +1 -0
- package/dist/subpath/Concurrent.cjs +15 -0
- package/dist/subpath/Concurrent.cjs.map +1 -0
- package/dist/subpath/Concurrent.mjs +4044 -0
- package/dist/subpath/Concurrent.mjs.map +1 -0
- package/dist/subpath/FetchQ.cjs +2 -0
- package/dist/subpath/FetchQ.cjs.map +1 -0
- package/dist/subpath/FetchQ.mjs +519 -0
- package/dist/subpath/FetchQ.mjs.map +1 -0
- package/dist/subpath/Fit.cjs +2 -0
- package/dist/subpath/Fit.cjs.map +1 -0
- package/dist/subpath/Fit.mjs +914 -0
- package/dist/subpath/Fit.mjs.map +1 -0
- package/dist/subpath/Lazy.cjs +2 -0
- package/dist/subpath/Lazy.cjs.map +1 -0
- package/dist/subpath/Lazy.mjs +72 -0
- package/dist/subpath/Lazy.mjs.map +1 -0
- package/dist/subpath/Maps.cjs +2 -0
- package/dist/subpath/Maps.cjs.map +1 -0
- package/dist/subpath/Maps.mjs +123 -0
- package/dist/subpath/Maps.mjs.map +1 -0
- package/dist/subpath/Maybe.cjs +2 -0
- package/dist/subpath/Maybe.cjs.map +1 -0
- package/dist/subpath/Maybe.mjs +329 -0
- package/dist/subpath/Maybe.mjs.map +1 -0
- package/dist/subpath/Reactive.cjs +2 -0
- package/dist/subpath/Reactive.cjs.map +1 -0
- package/dist/subpath/Reactive.mjs +1204 -0
- package/dist/subpath/Reactive.mjs.map +1 -0
- package/dist/subpath/Reader.cjs +2 -0
- package/dist/subpath/Reader.cjs.map +1 -0
- package/dist/subpath/Reader.mjs +75 -0
- package/dist/subpath/Reader.mjs.map +1 -0
- package/dist/subpath/ReaderT.cjs +2 -0
- package/dist/subpath/ReaderT.cjs.map +1 -0
- package/dist/subpath/ReaderT.mjs +148 -0
- package/dist/subpath/ReaderT.mjs.map +1 -0
- package/dist/subpath/Resource.cjs +2 -0
- package/dist/subpath/Resource.cjs.map +1 -0
- package/dist/subpath/Resource.mjs +150 -0
- package/dist/subpath/Resource.mjs.map +1 -0
- package/dist/subpath/Result.cjs +2 -0
- package/dist/subpath/Result.cjs.map +1 -0
- package/dist/subpath/Result.mjs +337 -0
- package/dist/subpath/Result.mjs.map +1 -0
- package/dist/subpath/Sets.cjs +2 -0
- package/dist/subpath/Sets.cjs.map +1 -0
- package/dist/subpath/Sets.mjs +92 -0
- package/dist/subpath/Sets.mjs.map +1 -0
- package/dist/subpath/Str.cjs +2 -0
- package/dist/subpath/Str.cjs.map +1 -0
- package/dist/subpath/Str.mjs +114 -0
- package/dist/subpath/Str.mjs.map +1 -0
- package/dist/subpath/TxScope.cjs +2 -0
- package/dist/subpath/TxScope.cjs.map +1 -0
- package/dist/subpath/TxScope.mjs +138 -0
- package/dist/subpath/TxScope.mjs.map +1 -0
- package/dist/subpath/TypeTool.cjs +2 -0
- package/dist/subpath/TypeTool.cjs.map +1 -0
- package/dist/subpath/TypeTool.mjs +9 -0
- package/dist/subpath/TypeTool.mjs.map +1 -0
- package/dist/subpath/Utils.cjs +2 -0
- package/dist/subpath/Utils.cjs.map +1 -0
- package/dist/subpath/Utils.mjs +835 -0
- package/dist/subpath/Utils.mjs.map +1 -0
- package/dist/subpath/VirtualTime.cjs +2 -0
- package/dist/subpath/VirtualTime.cjs.map +1 -0
- package/dist/subpath/VirtualTime.mjs +1186 -0
- package/dist/subpath/VirtualTime.mjs.map +1 -0
- package/dist/types/Arr.d.ts +2 -0
- package/dist/types/Concurrent/Lock/condition_variable.d.ts +138 -0
- package/dist/types/Concurrent/Lock/mutex.d.ts +185 -0
- package/dist/types/Concurrent/Lock/rwlock.d.ts +253 -0
- package/dist/types/Concurrent/Lock/semaphore.d.ts +208 -0
- package/dist/types/Concurrent/Valve/__export__.d.ts +5 -0
- package/dist/types/Concurrent/Valve/circuit-breaker.d.ts +146 -0
- package/dist/types/Concurrent/Valve/leaky-bucket.d.ts +115 -0
- package/dist/types/Concurrent/Valve/sliding-window.d.ts +91 -0
- package/dist/types/Concurrent/Valve/token-bucket.d.ts +68 -0
- package/dist/types/Concurrent/__export__.d.ts +15 -0
- package/dist/types/Concurrent/barrier.d.ts +255 -0
- package/dist/types/Concurrent/channel.d.ts +239 -0
- package/dist/types/Concurrent/delay.d.ts +42 -0
- package/dist/types/Concurrent/ext/map.d.ts +82 -0
- package/dist/types/Concurrent/ext/other.d.ts +113 -0
- package/dist/types/Concurrent/ext/race.d.ts +31 -0
- package/dist/types/Concurrent/ext/some.d.ts +64 -0
- package/dist/types/Concurrent/limiter.d.ts +131 -0
- package/dist/types/Concurrent/scheduler.d.ts +171 -0
- package/dist/types/Concurrent/task-scope.d.ts +282 -0
- package/dist/types/Concurrent.d.ts +2 -0
- package/dist/types/Errors.d.ts +66 -0
- package/dist/types/FetchQ.d.ts +2 -0
- package/dist/types/Fit/__export__.d.ts +5 -0
- package/dist/types/Fit/base.d.ts +325 -0
- package/dist/types/Fit/parser.d.ts +110 -0
- package/dist/types/Fit/standard-schema.d.ts +127 -0
- package/dist/types/Fit/sugar.d.ts +274 -0
- package/dist/types/Fit/tool.d.ts +585 -0
- package/dist/types/Fit.d.ts +2 -0
- package/dist/types/Lazy.d.ts +2 -0
- package/dist/types/Maps.d.ts +2 -0
- package/dist/types/Maybe/__export__.d.ts +6 -0
- package/dist/types/Maybe/base.d.ts +62 -0
- package/dist/types/Maybe/consumers-async.d.ts +58 -0
- package/dist/types/Maybe/consumers.d.ts +63 -0
- package/dist/types/Maybe/operators-async.d.ts +145 -0
- package/dist/types/Maybe/operators.d.ts +177 -0
- package/dist/types/Maybe/types.d.ts +12 -0
- package/dist/types/Maybe.d.ts +2 -0
- package/dist/types/MockClock/Timeline.d.ts +392 -0
- package/dist/types/MockClock/TimerHandle.d.ts +159 -0
- package/dist/types/MockClock/TimerHeap.d.ts +21 -0
- package/dist/types/MockClock/VirtualTimeManager.d.ts +23 -0
- package/dist/types/MockClock/__export__.d.ts +104 -0
- package/dist/types/MockClock/hooks/__export__.d.ts +9 -0
- package/dist/types/MockClock/hooks/hookAbortSignal.d.ts +3 -0
- package/dist/types/MockClock/hooks/hookDate.d.ts +3 -0
- package/dist/types/MockClock/hooks/hookIntl.d.ts +3 -0
- package/dist/types/MockClock/hooks/hookMessageChannel.d.ts +3 -0
- package/dist/types/MockClock/hooks/hookMicrotasks.d.ts +3 -0
- package/dist/types/MockClock/hooks/hookOs.d.ts +3 -0
- package/dist/types/MockClock/hooks/hookPerformance.d.ts +3 -0
- package/dist/types/MockClock/hooks/hookProcess.d.ts +3 -0
- package/dist/types/MockClock/hooks/hookTimers.d.ts +3 -0
- package/dist/types/MockClock/types.d.ts +103 -0
- package/dist/types/Other/FetchQ.d.ts +320 -0
- package/dist/types/Other/deque.d.ts +59 -0
- package/dist/types/Other/disjointSet.d.ts +53 -0
- package/dist/types/Other/heap.d.ts +41 -0
- package/dist/types/Other/lazy.d.ts +127 -0
- package/dist/types/Other/queue.d.ts +42 -0
- package/dist/types/Other/secret.d.ts +111 -0
- package/dist/types/Other/stack.d.ts +40 -0
- package/dist/types/Reactive/__export__.d.ts +4 -0
- package/dist/types/Reactive/event_emitter.d.ts +195 -0
- package/dist/types/Reactive/flow-combination.d.ts +74 -0
- package/dist/types/Reactive/flow.d.ts +180 -0
- package/dist/types/Reactive/pace.d.ts +80 -0
- package/dist/types/Reactive.d.ts +2 -0
- package/dist/types/Reader/__export-readerT__.d.ts +4 -0
- package/dist/types/Reader/__export-reader__.d.ts +4 -0
- package/dist/types/Reader/local.d.ts +39 -0
- package/dist/types/Reader/reader-async.d.ts +84 -0
- package/dist/types/Reader/reader.d.ts +96 -0
- package/dist/types/Reader/readerT-async.d.ts +186 -0
- package/dist/types/Reader/readerT.d.ts +178 -0
- package/dist/types/Reader/types.d.ts +37 -0
- package/dist/types/Reader.d.ts +2 -0
- package/dist/types/ReaderT.d.ts +2 -0
- package/dist/types/Resource/TxScope-async.d.ts +86 -0
- package/dist/types/Resource/TxScope.d.ts +85 -0
- package/dist/types/Resource/__export-TxScope__.d.ts +2 -0
- package/dist/types/Resource/__export-resource__.d.ts +2 -0
- package/dist/types/Resource/resource-async.d.ts +79 -0
- package/dist/types/Resource/resource.d.ts +78 -0
- package/dist/types/Resource/types.d.ts +79 -0
- package/dist/types/Resource.d.ts +2 -0
- package/dist/types/Result/Consumers/branch-async.d.ts +77 -0
- package/dist/types/Result/Consumers/branch.d.ts +70 -0
- package/dist/types/Result/Consumers/inspect.d.ts +66 -0
- package/dist/types/Result/Operators/Async/combine-async.d.ts +69 -0
- package/dist/types/Result/Operators/Async/partition-async.d.ts +29 -0
- package/dist/types/Result/Operators/Async/reduce-async.d.ts +15 -0
- package/dist/types/Result/Operators/Async/transform-async.d.ts +90 -0
- package/dist/types/Result/Operators/combine.d.ts +60 -0
- package/dist/types/Result/Operators/flatten.d.ts +26 -0
- package/dist/types/Result/Operators/partition.d.ts +25 -0
- package/dist/types/Result/Operators/reduce.d.ts +12 -0
- package/dist/types/Result/Operators/transform.d.ts +70 -0
- package/dist/types/Result/__export__.d.ts +14 -0
- package/dist/types/Result/base.d.ts +115 -0
- package/dist/types/Result/types.d.ts +34 -0
- package/dist/types/Result.d.ts +2 -0
- package/dist/types/Sets.d.ts +2 -0
- package/dist/types/Str.d.ts +2 -0
- package/dist/types/TxScope.d.ts +2 -0
- package/dist/types/TypeTool.d.ts +2 -0
- package/dist/types/Utils/Array/__export__.d.ts +10 -0
- package/dist/types/Utils/Array/filtering.d.ts +89 -0
- package/dist/types/Utils/Array/flatten.d.ts +45 -0
- package/dist/types/Utils/Array/grouping.d.ts +44 -0
- package/dist/types/Utils/Array/iteration.d.ts +86 -0
- package/dist/types/Utils/Array/operators.d.ts +62 -0
- package/dist/types/Utils/Array/randomization.d.ts +76 -0
- package/dist/types/Utils/Array/set.d.ts +108 -0
- package/dist/types/Utils/Array/slice.d.ts +189 -0
- package/dist/types/Utils/Array/sorting.d.ts +55 -0
- package/dist/types/Utils/Array/zip.d.ts +93 -0
- package/dist/types/Utils/Functions/__export__.d.ts +5 -0
- package/dist/types/Utils/Functions/base.d.ts +157 -0
- package/dist/types/Utils/Functions/curry.d.ts +73 -0
- package/dist/types/Utils/Functions/debounce.d.ts +240 -0
- package/dist/types/Utils/Functions/defer.d.ts +43 -0
- package/dist/types/Utils/Functions/pipe.d.ts +205 -0
- package/dist/types/Utils/Map.d.ts +284 -0
- package/dist/types/Utils/Math.d.ts +225 -0
- package/dist/types/Utils/Object/__export__.d.ts +2 -0
- package/dist/types/Utils/Object/base.d.ts +131 -0
- package/dist/types/Utils/Object/clone.d.ts +81 -0
- package/dist/types/Utils/Predicates.d.ts +361 -0
- package/dist/types/Utils/Set.d.ts +105 -0
- package/dist/types/Utils/String.d.ts +217 -0
- package/dist/types/Utils/__export__.d.ts +9 -0
- package/dist/types/Utils/type-tool.d.ts +168 -0
- package/dist/types/Utils.d.ts +2 -0
- package/dist/types/VirtualTime.d.ts +2 -0
- package/dist/types/helper.d.ts +71 -0
- package/dist/types/index.d.ts +21 -0
- package/dist/types/unknown-error.d.ts +98 -0
- package/package.json +179 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
function u(e, n) {
|
|
2
|
+
const o = /* @__PURE__ */ new Map();
|
|
3
|
+
for (const [t, r] of e)
|
|
4
|
+
n(r, t) && o.set(t, r);
|
|
5
|
+
return o;
|
|
6
|
+
}
|
|
7
|
+
const l = (e, n) => {
|
|
8
|
+
const o = /* @__PURE__ */ new Map();
|
|
9
|
+
for (const [t, r] of e)
|
|
10
|
+
o.set(t, n(r, t));
|
|
11
|
+
return o;
|
|
12
|
+
}, f = (e, n) => {
|
|
13
|
+
const o = /* @__PURE__ */ new Map();
|
|
14
|
+
for (const [t, r] of e)
|
|
15
|
+
o.set(n(r, t), r);
|
|
16
|
+
return o;
|
|
17
|
+
}, a = (e, n) => {
|
|
18
|
+
for (const [o, t] of e)
|
|
19
|
+
if (n(t, o)) return o;
|
|
20
|
+
}, i = (e, n, o = (t, r) => t === r) => {
|
|
21
|
+
for (const t of e.values())
|
|
22
|
+
if (o(t, n)) return !0;
|
|
23
|
+
return !1;
|
|
24
|
+
}, v = (e, n, o) => {
|
|
25
|
+
let t = o;
|
|
26
|
+
for (const [r, s] of e)
|
|
27
|
+
t = n(t, s, r);
|
|
28
|
+
return t;
|
|
29
|
+
}, y = (e, n) => {
|
|
30
|
+
const o = {};
|
|
31
|
+
for (const [t, r] of e) {
|
|
32
|
+
const s = n(r, t);
|
|
33
|
+
o[s] = (o[s] || 0) + 1;
|
|
34
|
+
}
|
|
35
|
+
return o;
|
|
36
|
+
}, _ = (e, n) => {
|
|
37
|
+
const o = /* @__PURE__ */ new Map();
|
|
38
|
+
for (const [t, r] of e) {
|
|
39
|
+
const s = n(r, t);
|
|
40
|
+
let c = o.get(s);
|
|
41
|
+
c || (c = [], o.set(s, c)), c.push([t, r]);
|
|
42
|
+
}
|
|
43
|
+
return o;
|
|
44
|
+
}, k = (e, n) => {
|
|
45
|
+
const o = /* @__PURE__ */ new Map();
|
|
46
|
+
for (const t of n)
|
|
47
|
+
e.has(t) && o.set(t, e.get(t));
|
|
48
|
+
return o;
|
|
49
|
+
}, d = (e, n) => {
|
|
50
|
+
const o = new Map(e), t = n instanceof Set ? n : new Set(n);
|
|
51
|
+
for (const r of t)
|
|
52
|
+
o.delete(r);
|
|
53
|
+
return o;
|
|
54
|
+
}, p = (e, n) => {
|
|
55
|
+
for (const [o, t] of e)
|
|
56
|
+
n(t, o) || e.delete(o);
|
|
57
|
+
return e;
|
|
58
|
+
}, g = (e, n) => {
|
|
59
|
+
for (const [o, t] of e)
|
|
60
|
+
e.set(o, n(t, o));
|
|
61
|
+
return e;
|
|
62
|
+
}, w = (e, n) => {
|
|
63
|
+
for (const o of n)
|
|
64
|
+
e.delete(o);
|
|
65
|
+
return e;
|
|
66
|
+
}, M = (e, n) => {
|
|
67
|
+
const o = n instanceof Set ? n : new Set(n);
|
|
68
|
+
for (const t of e.keys())
|
|
69
|
+
o.has(t) || e.delete(t);
|
|
70
|
+
return e;
|
|
71
|
+
}, P = (e, n, o = (t, r) => r) => {
|
|
72
|
+
for (const [t, r] of n)
|
|
73
|
+
e.has(t) ? e.set(t, o(e.get(t), r, t)) : e.set(t, r);
|
|
74
|
+
return e;
|
|
75
|
+
}, I = (e, n, o) => {
|
|
76
|
+
if (e.has(n))
|
|
77
|
+
return e.get(n);
|
|
78
|
+
const t = o(n);
|
|
79
|
+
return e.set(n, t), t;
|
|
80
|
+
}, S = (e, n, o) => {
|
|
81
|
+
const t = e.get(n), r = o(t, n);
|
|
82
|
+
return e.set(n, r), e;
|
|
83
|
+
}, h = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
84
|
+
__proto__: null,
|
|
85
|
+
countBy: y,
|
|
86
|
+
filter: u,
|
|
87
|
+
filterInPlace: p,
|
|
88
|
+
findKey: a,
|
|
89
|
+
getOrSetInPlace: I,
|
|
90
|
+
groupBy: _,
|
|
91
|
+
hasValue: i,
|
|
92
|
+
mapKeys: f,
|
|
93
|
+
mapValues: l,
|
|
94
|
+
mapValuesInPlace: g,
|
|
95
|
+
mergeInPlace: P,
|
|
96
|
+
omit: d,
|
|
97
|
+
omitInPlace: w,
|
|
98
|
+
pick: k,
|
|
99
|
+
pickInPlace: M,
|
|
100
|
+
reduce: v,
|
|
101
|
+
updateInPlace: S
|
|
102
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
103
|
+
export {
|
|
104
|
+
h as M,
|
|
105
|
+
y as countBy,
|
|
106
|
+
u as filter,
|
|
107
|
+
p as filterInPlace,
|
|
108
|
+
a as findKey,
|
|
109
|
+
I as getOrSetInPlace,
|
|
110
|
+
_ as groupBy,
|
|
111
|
+
i as hasValue,
|
|
112
|
+
f as mapKeys,
|
|
113
|
+
l as mapValues,
|
|
114
|
+
g as mapValuesInPlace,
|
|
115
|
+
P as mergeInPlace,
|
|
116
|
+
d as omit,
|
|
117
|
+
w as omitInPlace,
|
|
118
|
+
k as pick,
|
|
119
|
+
M as pickInPlace,
|
|
120
|
+
v as reduce,
|
|
121
|
+
S as updateInPlace
|
|
122
|
+
};
|
|
123
|
+
//# sourceMappingURL=Maps.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Maps.mjs","sources":["../../src/Utils/Map.ts"],"sourcesContent":["// ============================================\r\n// ./src/Utils/Map.ts\r\n// ============================================\r\n\r\n/**\r\n * Filters a Map, keeping only entries that satisfy the predicate\r\n *\r\n * @template K - Key type\r\n * @template V - Value type\r\n * @template S - Narrowed value type (when using type guard predicate)\r\n * @param map - Map to filter\r\n * @param predicate - Function that returns true to keep entry, false to remove\r\n * @returns New Map with filtered entries\r\n * @remarks If the predicate is a type guard, returns Map<K, S>, otherwise Map<K, V>\r\n * @example\r\n * ```typescript\r\n * const m = new Map([['a', 1], ['b', 2], ['c', 3]]);\r\n * filter(m, (v) => v > 1); // Map([['b', 2], ['c', 3]])\r\n * ```\r\n */\r\nexport function filter<K, V, S extends V>(\r\n map: Map<K, V>,\r\n predicate: (value: V, key: K) => value is S,\r\n): Map<K, S>;\r\nexport function filter<K, V>(\r\n map: Map<K, V>,\r\n predicate: (value: V, key: K) => boolean,\r\n): Map<K, V>;\r\nexport function filter<K, V>(\r\n map: Map<K, V>,\r\n predicate: (value: V, key: K) => boolean,\r\n): Map<K, V> {\r\n const result = new Map<K, V>();\r\n for (const [key, value] of map) {\r\n if (predicate(value, key)) {\r\n result.set(key, value);\r\n }\r\n }\r\n return result;\r\n}\r\n\r\n/**\r\n * Creates a new Map with same keys but values transformed by iteratee\r\n *\r\n * @template K - Key type\r\n * @template V - Original value type\r\n * @template T - Transformed value type\r\n * @param map - Map to transform values of\r\n * @param iteratee - Function that transforms each value\r\n * @returns New Map with transformed values\r\n * @remarks Original Map is not modified\r\n * @example\r\n * ```typescript\r\n * const m = new Map([['a', 1], ['b', 2]]);\r\n * mapValues(m, v => v * 2); // Map([['a', 2], ['b', 4]])\r\n * ```\r\n */\r\nexport const mapValues = <K, V, T>(\r\n map: Map<K, V>,\r\n iteratee: (value: V, key: K) => T,\r\n): Map<K, T> => {\r\n const result = new Map<K, T>();\r\n for (const [key, value] of map) {\r\n result.set(key, iteratee(value, key));\r\n }\r\n return result;\r\n};\r\n\r\n/**\r\n * Creates a new Map with same values but keys transformed by iteratee\r\n *\r\n * @template K - Original key type\r\n * @template V - Value type\r\n * @template T - Transformed key type\r\n * @param map - Map to transform keys of\r\n * @param iteratee - Function that transforms each key\r\n * @returns New Map with transformed keys\r\n * @remarks Duplicate transformed keys will overwrite previous entries\r\n * @example\r\n * ```typescript\r\n * const m = new Map([[1, 'a'], [2, 'b']]);\r\n * mapKeys(m, (v, k) => `key-${k}`); // Map([['key-1', 'a'], ['key-2', 'b']])\r\n * ```\r\n */\r\nexport const mapKeys = <K, V, T>(\r\n map: Map<K, V>,\r\n iteratee: (value: V, key: K) => T,\r\n): Map<T, V> => {\r\n const result = new Map<T, V>();\r\n for (const [key, value] of map) {\r\n result.set(iteratee(value, key), value);\r\n }\r\n return result;\r\n};\r\n\r\n/**\r\n * Finds the first key that satisfies the predicate\r\n *\r\n * @template K - Key type\r\n * @template V - Value type\r\n * @param map - Map to search\r\n * @param predicate - Function that returns true for matching entry\r\n * @returns First matching key or undefined if none found\r\n * @remarks Iterates in insertion order, stops at first match\r\n * @example\r\n * ```typescript\r\n * const m = new Map([['a', 1], ['b', 2], ['c', 3]]);\r\n * findKey(m, v => v > 1); // 'b'\r\n * ```\r\n */\r\nexport const findKey = <K, V>(\r\n map: Map<K, V>,\r\n predicate: (value: V, key: K) => boolean,\r\n): K | undefined => {\r\n for (const [key, value] of map) {\r\n if (predicate(value, key)) return key;\r\n }\r\n return undefined;\r\n};\r\n\r\n/**\r\n * Checks if Map contains a value matching target_value using comparator\r\n *\r\n * @template K - Key type\r\n * @template V - Value type\r\n * @param map - Map to search\r\n * @param target_value - Value to search for\r\n * @param comparator - Optional comparison function (defaults to ===)\r\n * @returns True if matching value found, false otherwise\r\n * @remarks Uses linear search, O(n) time\r\n * @example\r\n * ```typescript\r\n * const m = new Map([['a', {id: 1}], ['b', {id: 2}]]);\r\n * hasValue(m, {id: 1}, (a, b) => a.id === b.id); // true\r\n * ```\r\n */\r\nexport const hasValue = <K, V>(\r\n map: Map<K, V>,\r\n target_value: V,\r\n comparator: (a: V, b: V) => boolean = (a, b) => a === b,\r\n): boolean => {\r\n for (const value of map.values()) {\r\n if (comparator(value, target_value)) return true;\r\n }\r\n return false;\r\n};\r\n\r\n/**\r\n * Reduces Map to a single value using iteratee function\r\n *\r\n * @template K - Key type\r\n * @template V - Value type\r\n * @template T - Accumulator type\r\n * @param map - Map to reduce\r\n * @param iteratee - Function that updates accumulator with each entry\r\n * @param initial_value - Starting accumulator value\r\n * @returns Final accumulator value\r\n * @remarks Iterates in insertion order\r\n * @example\r\n * ```typescript\r\n * const m = new Map([['a', 1], ['b', 2], ['c', 3]]);\r\n * reduce(m, (sum, v) => sum + v, 0); // 6\r\n * ```\r\n */\r\nexport const reduce = <K, V, T>(\r\n map: Map<K, V>,\r\n iteratee: (accumulator: T, value: V, key: K) => T,\r\n initial_value: T,\r\n): T => {\r\n let accumulator = initial_value;\r\n for (const [key, value] of map) {\r\n accumulator = iteratee(accumulator, value, key);\r\n }\r\n return accumulator;\r\n};\r\n\r\n/**\r\n * Groups Map entries by key derived from iteratee and counts occurrences\r\n *\r\n * @template K - Key type\r\n * @template V - Value type\r\n * @param map - Map to analyze\r\n * @param iteratee - Function that returns grouping key (string or number)\r\n * @returns Object with grouping keys as properties and counts as values\r\n * @remarks Keys are coerced to string for object property access\r\n * @example\r\n * ```typescript\r\n * const m = new Map([['a', 1], ['b', 2], ['c', 1]]);\r\n * countBy(m, v => v); // {1: 2, 2: 1}\r\n * ```\r\n */\r\nexport const countBy = <K, V>(\r\n map: Map<K, V>,\r\n iteratee: (value: V, key: K) => string | number,\r\n): Record<string | number, number> => {\r\n const result: Record<string | number, number> = {};\r\n for (const [key, value] of map) {\r\n const group_key = iteratee(value, key);\r\n result[group_key] = (result[group_key] || 0) + 1;\r\n }\r\n return result;\r\n};\r\n\r\n/**\r\n * Groups Map entries by key derived from iteratee\r\n *\r\n * @template K - Original key type\r\n * @template V - Value type\r\n * @template T - Grouping key type\r\n * @param map - Map to group\r\n * @param iteratee - Function that returns grouping key\r\n * @returns New Map with grouping keys and arrays of [K, V] entries\r\n * @remarks Each group contains original key-value pairs as arrays\r\n * @example\r\n * ```typescript\r\n * const m = new Map([['a', 1], ['b', 2], ['c', 1]]);\r\n * groupBy(m, v => v); // Map([[1, [['a', 1], ['c', 1]]], [2, [['b', 2]]]])\r\n * ```\r\n */\r\nexport const groupBy = <K, V, T>(\r\n map: Map<K, V>,\r\n iteratee: (value: V, key: K) => T,\r\n): Map<T, Array<[K, V]>> => {\r\n const result = new Map<T, Array<[K, V]>>();\r\n for (const [key, value] of map) {\r\n const group_key = iteratee(value, key);\r\n let group = result.get(group_key);\r\n if (!group) {\r\n group = [];\r\n result.set(group_key, group);\r\n }\r\n group.push([key, value]);\r\n }\r\n return result;\r\n};\r\n\r\n/**\r\n * Creates new Map with only specified keys\r\n *\r\n * @template K - Key type\r\n * @template V - Value type\r\n * @param map - Map to pick from\r\n * @param keys - Iterable of keys to include\r\n * @returns New Map with selected keys\r\n * @remarks Keys not present in original Map are silently ignored\r\n * @example\r\n * ```typescript\r\n * const m = new Map([['a', 1], ['b', 2], ['c', 3]]);\r\n * pick(m, ['a', 'c']); // Map([['a', 1], ['c', 3]])\r\n * ```\r\n */\r\nexport const pick = <K, V>(map: Map<K, V>, keys: Iterable<K>): Map<K, V> => {\r\n const result = new Map<K, V>();\r\n for (const key of keys) {\r\n if (map.has(key)) {\r\n result.set(key, map.get(key)!);\r\n }\r\n }\r\n return result;\r\n};\r\n\r\n/**\r\n * Creates new Map without specified keys\r\n *\r\n * @template K - Key type\r\n * @template V - Value type\r\n * @param map - Map to omit from\r\n * @param keys - Iterable of keys to exclude\r\n * @returns New Map without specified keys\r\n * @remarks Keys not present in original Map are silently ignored\r\n * @example\r\n * ```typescript\r\n * const m = new Map([['a', 1], ['b', 2], ['c', 3]]);\r\n * omit(m, ['b']); // Map([['a', 1], ['c', 3]])\r\n * ```\r\n */\r\nexport const omit = <K, V>(map: Map<K, V>, keys: Iterable<K>): Map<K, V> => {\r\n const result = new Map(map);\r\n const keys_to_delete = keys instanceof Set ? keys : new Set(keys);\r\n for (const key of keys_to_delete) {\r\n result.delete(key as K);\r\n }\r\n return result;\r\n};\r\n\r\n/**\r\n * Filters Map in-place, removing entries that don't satisfy predicate\r\n *\r\n * @template K - Key type\r\n * @template V - Value type\r\n * @param map - Map to filter (modified in-place)\r\n * @param predicate - Function that returns true to keep entry\r\n * @returns Same Map instance (mutated)\r\n * @remarks Modifies original Map, use filter() for immutable operation\r\n * @example\r\n * ```typescript\r\n * const m = new Map([['a', 1], ['b', 2], ['c', 3]]);\r\n * filterInPlace(m, v => v > 1); // m is now Map([['b', 2], ['c', 3]])\r\n * ```\r\n */\r\nexport const filterInPlace = <K, V>(\r\n map: Map<K, V>,\r\n predicate: (value: V, key: K) => boolean,\r\n): Map<K, V> => {\r\n for (const [key, value] of map) {\r\n if (!predicate(value, key)) {\r\n map.delete(key);\r\n }\r\n }\r\n return map;\r\n};\r\n\r\n/**\r\n * Transforms Map values in-place\r\n *\r\n * @template K - Key type\r\n * @template V - Value type\r\n * @param map - Map to transform (modified in-place)\r\n * @param iteratee - Function that transforms each value\r\n * @returns Same Map instance (mutated)\r\n * @remarks Modifies original Map, use mapValues() for immutable operation\r\n * @example\r\n * ```typescript\r\n * const m = new Map([['a', 1], ['b', 2]]);\r\n * mapValuesInPlace(m, v => v * 2); // m is now Map([['a', 2], ['b', 4]])\r\n * ```\r\n */\r\nexport const mapValuesInPlace = <K, V>(\r\n map: Map<K, V>,\r\n iteratee: (value: V, key: K) => V,\r\n): Map<K, V> => {\r\n for (const [key, value] of map) {\r\n map.set(key, iteratee(value, key));\r\n }\r\n return map;\r\n};\r\n\r\n/**\r\n * Removes specified keys from Map in-place\r\n *\r\n * @template K - Key type\r\n * @template V - Value type\r\n * @param map - Map to modify (modified in-place)\r\n * @param keys - Iterable of keys to remove\r\n * @returns Same Map instance (mutated)\r\n * @remarks Modifies original Map, use omit() for immutable operation\r\n * @example\r\n * ```typescript\r\n * const m = new Map([['a', 1], ['b', 2], ['c', 3]]);\r\n * omitInPlace(m, ['b']); // m is now Map([['a', 1], ['c', 3]])\r\n * ```\r\n */\r\nexport const omitInPlace = <K, V>(\r\n map: Map<K, V>,\r\n keys: Iterable<K>,\r\n): Map<K, V> => {\r\n for (const key of keys) {\r\n map.delete(key);\r\n }\r\n return map;\r\n};\r\n\r\n/**\r\n * Keeps only specified keys in Map in-place\r\n *\r\n * @template K - Key type\r\n * @template V - Value type\r\n * @param map - Map to modify (modified in-place)\r\n * @param keys - Iterable of keys to keep\r\n * @returns Same Map instance (mutated)\r\n * @remarks Modifies original Map, use pick() for immutable operation\r\n * @example\r\n * ```typescript\r\n * const m = new Map([['a', 1], ['b', 2], ['c', 3]]);\r\n * pickInPlace(m, ['a', 'c']); // m is now Map([['a', 1], ['c', 3]])\r\n * ```\r\n */\r\nexport const pickInPlace = <K, V>(\r\n map: Map<K, V>,\r\n keys: Iterable<K>,\r\n): Map<K, V> => {\r\n const keep_set = keys instanceof Set ? keys : new Set(keys);\r\n for (const key of map.keys()) {\r\n if (!keep_set.has(key)) {\r\n map.delete(key);\r\n }\r\n }\r\n return map;\r\n};\r\n\r\n/**\r\n * Merges source Map into target Map in-place\r\n *\r\n * @template K - Key type\r\n * @template V - Value type\r\n * @param target - Map to merge into (modified in-place)\r\n * @param source - Map to merge from\r\n * @param resolve_conflict - Function to resolve key conflicts (default: source wins)\r\n * @returns Same target Map instance (mutated)\r\n * @remarks Modifies target Map, source Map is not modified\r\n * @example\r\n * ```typescript\r\n * const t = new Map([['a', 1], ['b', 2]]);\r\n * const s = new Map([['b', 20], ['c', 3]]);\r\n * mergeInPlace(t, s); // t is now Map([['a', 1], ['b', 20], ['c', 3]])\r\n * ```\r\n */\r\nexport const mergeInPlace = <K, V>(\r\n target: Map<K, V>,\r\n source: Map<K, V>,\r\n resolve_conflict: (target_val: V, source_val: V, key: K) => V = (_t, s) => s,\r\n): Map<K, V> => {\r\n for (const [key, value] of source) {\r\n if (target.has(key)) {\r\n target.set(key, resolve_conflict(target.get(key)!, value, key));\r\n } else {\r\n target.set(key, value);\r\n }\r\n }\r\n return target;\r\n};\r\n\r\n/**\r\n * Gets value for key, setting it with default_factory if not present\r\n *\r\n * @template K - Key type\r\n * @template V - Value type\r\n * @param map - Map to access (modified in-place if key missing)\r\n * @param key - Key to get/set\r\n * @param default_factory - Function that creates default value when key missing\r\n * @returns Existing value or newly created default value\r\n * @remarks Modifies Map if key was not present (lazy initialization)\r\n * @example\r\n * ```typescript\r\n * const m = new Map([['a', 1]]);\r\n * getOrSetInPlace(m, 'b', () => 100); // Returns 100, m now has 'b': 100\r\n * ```\r\n */\r\nexport const getOrSetInPlace = <K, V>(\r\n map: Map<K, V>,\r\n key: K,\r\n default_factory: (key: K) => V,\r\n): V => {\r\n if (map.has(key)) {\r\n return map.get(key)!;\r\n }\r\n const new_value = default_factory(key);\r\n map.set(key, new_value);\r\n return new_value;\r\n};\r\n\r\n/**\r\n * Updates value for key using updater function\r\n *\r\n * @template K - Key type\r\n * @template V - Value type\r\n * @param map - Map to update (modified in-place)\r\n * @param key - Key to update\r\n * @param updater - Function that receives current value (or undefined) and returns new value\r\n * @returns Same Map instance (mutated)\r\n * @remarks Always sets the key, even if updater returns undefined (as value)\r\n * @example\r\n * ```typescript\r\n * const m = new Map([['a', 1]]);\r\n * updateInPlace(m, 'a', v => v ? v + 1 : 0); // m is now Map([['a', 2]])\r\n * ```\r\n */\r\nexport const updateInPlace = <K, V>(\r\n map: Map<K, V>,\r\n key: K,\r\n updater: (value: V | undefined, key: K) => V,\r\n): Map<K, V> => {\r\n const current_value = map.get(key);\r\n const next_value = updater(current_value, key);\r\n map.set(key, next_value);\r\n return map;\r\n};\r\n"],"names":["filter","map","predicate","result","key","value","mapValues","iteratee","mapKeys","findKey","hasValue","target_value","comparator","a","b","reduce","initial_value","accumulator","countBy","group_key","groupBy","group","pick","keys","omit","keys_to_delete","filterInPlace","mapValuesInPlace","omitInPlace","pickInPlace","keep_set","mergeInPlace","target","source","resolve_conflict","_t","s","getOrSetInPlace","default_factory","new_value","updateInPlace","updater","current_value","next_value"],"mappings":"AA4BO,SAASA,EACdC,GACAC,GACW;AACX,QAAMC,wBAAa,IAAA;AACnB,aAAW,CAACC,GAAKC,CAAK,KAAKJ;AACzB,IAAIC,EAAUG,GAAOD,CAAG,KACtBD,EAAO,IAAIC,GAAKC,CAAK;AAGzB,SAAOF;AACT;AAkBO,MAAMG,IAAY,CACvBL,GACAM,MACc;AACd,QAAMJ,wBAAa,IAAA;AACnB,aAAW,CAACC,GAAKC,CAAK,KAAKJ;AACzB,IAAAE,EAAO,IAAIC,GAAKG,EAASF,GAAOD,CAAG,CAAC;AAEtC,SAAOD;AACT,GAkBaK,IAAU,CACrBP,GACAM,MACc;AACd,QAAMJ,wBAAa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AK;AAGzB,SAAO2B;AACT,GAkBaK,IAAkB,CAC7BpC,GACAG,GACAkC,MACM;AACN,MAAIrC,EAAI,IAAIG,CAAG;AACb,WAAOH,EAAI,IAAIG,CAAG;AAEpB,QAAMmC,IAAYD,EAAgBlC,CAAG;AACrC,SAAAH,EAAI,IAAIG,GAAKmC,CAAS,GACfA;AACT,GAkBaC,IAAgB,CAC3BvC,GACAG,GACAqC,MACc;AACd,QAAMC,IAAgBzC,EAAI,IAAIG,CAAG,GAC3BuC,IAAaF,EAAQC,GAAetC,CAAG;AAC7C,SAAAH,EAAI,IAAIG,GAAKuC,CAAU,GAChB1C;AACT;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/base-BvHqpP_s.cjs"),a=require("../chunks/helper-tsqZMRHW.cjs"),m=(o,t,n)=>e.isSome(o)?t(o):n();function A(o,t,n){return e.isSome(o)?t(o):n?.()}function u(o,t,n){return e.isNone(o)?t():n?.(o)}const w=(o,t)=>(e.isSome(o)&&t(o),o),d=(o,t)=>(e.isNone(o)&&t(),o);function S(o,{fnSome:t=()=>{},fnNone:n=()=>{}}){return e.isSome(o)?t(o):n(),o}async function y(o,t,n,r){r?.throwIfAborted();const s=await o;if(e.isSome(s)){const c=await a.dynamicAwait(t(s,r));return r?.throwIfAborted(),c}else{const c=await a.dynamicAwait(n(r));return r?.throwIfAborted(),c}}async function h(o,t,n){const r=await o;return e.isSome(r)?await a.dynamicAwait(t(r)):n?await a.dynamicAwait(n()):void 0}async function p(o,t,n){const r=await o;return e.isNone(r)?await a.dynamicAwait(t()):n?await a.dynamicAwait(n(r)):void 0}async function l(o,t,n){n?.throwIfAborted();const r=await o;return n?.throwIfAborted(),e.isSome(r)&&(await a.dynamicAwait(t(r,n)),n?.throwIfAborted()),r}async function b(o,t,n){n?.throwIfAborted();const r=await o;return n?.throwIfAborted(),e.isNone(r)&&(await a.dynamicAwait(t(n)),n?.throwIfAborted()),r}async function I(o,{fnSome:t=()=>{},fnNone:n=()=>{}},r){r?.throwIfAborted();const s=await o;return r?.throwIfAborted(),e.isSome(s)?await a.dynamicAwait(t(s,r)):await a.dynamicAwait(n(r)),r?.throwIfAborted(),s}const N=(o,t)=>e.isSome(o)?e.Some(t(o)):e.None(),P=(o,t)=>e.isSome(o)?t(o):o,v=(o,t)=>e.isSome(o)&&e.isSome(t)?e.Some(o(t)):e.None(),_=(o,t)=>e.isSome(o)&&t(o)?o:e.None(),k=(o,t,n)=>e.isSome(o)&&t(o)?e.Some(n(o)):e.None(),z=(o,t)=>e.isSome(o)?t:e.None(),T=(o,t)=>e.isSome(o)?o:t,B=(o,t)=>e.isSome(o)?o:t(),F=(o,t,n)=>e.isSome(o)?n(o):t,R=(o,t)=>e.isSome(o)&&o===t,j=(o,t)=>e.isSome(o)&&e.isSome(t)?e.Some([o,t]):e.None(),M=(o,t,n)=>e.isSome(o)&&e.isSome(t)?e.Some(n(o,t)):e.None(),O=o=>o.every(e.isSome)?e.Some(o):e.None(),q=(o,t)=>{const n=[];for(let r=0;r<o.length;r++){const s=t(o[r],r);if(!e.isSome(s))return e.None();n.push(s)}return e.Some(n)},x=o=>{const t=[];let n=0;for(const r of o)e.isSome(r)?t.push(r):n++;return[t,n]},E=o=>{const t=[];for(const n of o)e.isSome(n)&&t.push(n);return t},W=o=>o.find(e.isSome)??e.None();function K(o,t,n){let r=t;for(const s of o){if(!e.isSome(s))return e.None();r=n(r,s)}return e.Some(r)}function C(o,t,n){const r=[t];let s=t;for(const c of o){if(!e.isSome(c))return e.None();s=n(s,c),r.push(s)}return e.Some(r)}const D=(o,t,n,r)=>{let s=t;for(const c of o)s=e.isSome(c)?n(s,c):r(s);return s},G=async(o,t,n)=>{n?.throwIfAborted();const[r,s]=await Promise.all([Promise.resolve(o),Promise.resolve(t)]);return n?.throwIfAborted(),e.isSome(r)&&e.isSome(s)?e.Some(await r(s)):e.None()},H=async(o,t,n)=>{n?.throwIfAborted();const r=await o;return n?.throwIfAborted(),e.isSome(r)?e.Some(await t(r)):e.None()},J=async(o,t,n,r)=>{r?.throwIfAborted();const s=await o;if(r?.throwIfAborted(),!e.isSome(s))return e.None();const c=await t(s);return r?.throwIfAborted(),c?e.Some(await n(s)):e.None()},L=async(o,t,n)=>{n?.throwIfAborted();const r=await o;return n?.throwIfAborted(),e.isSome(r)?t(r):e.None()},Q=async(o,t,n)=>{n?.throwIfAborted();const r=await o;if(n?.throwIfAborted(),!e.isSome(r))return e.None();const s=await t(r);return n?.throwIfAborted(),s?r:e.None()},U=async(o,t,n)=>{n?.throwIfAborted();const[r,s]=await Promise.all([Promise.resolve(o),Promise.resolve(t)]);return n?.throwIfAborted(),e.isSome(r)&&e.isSome(s)?e.Some([r,s]):e.None()},V=async(o,t,n,r)=>{r?.throwIfAborted();const s=await o;return r?.throwIfAborted(),e.isSome(s)?n(s):t},X=async(o,t,n)=>{n?.throwIfAborted();const r=await o;return n?.throwIfAborted(),e.isSome(r)?r:t()},Y=async(o,t,n)=>{n?.throwIfAborted();const r=await Promise.all(o.map(async(c,i)=>(n?.throwIfAborted(),await t(c,i))));n?.throwIfAborted();const s=[];for(const c of r){if(!e.isSome(c))return e.None();s.push(c)}return e.Some(s)},Z=async(o,t)=>{t?.throwIfAborted();const n=await Promise.all(o.map(r=>(t?.throwIfAborted(),Promise.resolve(r))));return t?.throwIfAborted(),n.every(e.isSome)?e.Some(n):e.None()},$=async(o,t)=>{t?.throwIfAborted();const n=await Promise.all(o.map(r=>(t?.throwIfAborted(),Promise.resolve(r))));t?.throwIfAborted();for(const r of n)if(e.isSome(r))return e.Some(r);return e.None()};async function g(o,t,n,r){r?.throwIfAborted();let s=t;const c=await Promise.all(o.map(i=>(r?.throwIfAborted(),Promise.resolve(i))));r?.throwIfAborted();for(const i of c){if(!e.isSome(i))return e.None();s=await n(s,i),r?.throwIfAborted()}return e.Some(s)}async function oo(o,t,n,r){r?.throwIfAborted();const s=await Promise.all(o.map(f=>(r?.throwIfAborted(),Promise.resolve(f))));r?.throwIfAborted();const c=[t];let i=t;for(const f of s){if(!e.isSome(f))return e.None();i=await n(i,f),r?.throwIfAborted(),c.push(i)}return e.Some(c)}const eo=async(o,t)=>{t?.throwIfAborted();const n=await Promise.all(o.map(r=>(t?.throwIfAborted(),Promise.resolve(r))));return t?.throwIfAborted(),n.filter(e.isSome)},to=async(o,t)=>{t?.throwIfAborted();const n=await Promise.all(o.map(c=>(t?.throwIfAborted(),Promise.resolve(c))));t?.throwIfAborted();const r=[];let s=0;for(const c of n)e.isSome(c)?r.push(c):s++;return[r,s]},ro=Object.freeze(Object.defineProperty({__proto__:null,None:e.None,Some:e.Some,all:O,allAsync:Z,and:z,andThen:P,andThenAsync:L,ap:v,apAsync:G,collectSomes:E,collectSomesAsync:eo,contains:R,filter:_,filterAsync:Q,firstSome:W,firstSomeAsync:$,fold:F,foldAsync:V,folds:D,fromFalsy:e.fromFalsy,fromNullable:e.fromNullable,ifNone:u,ifNoneAsync:p,ifSome:A,ifSomeAsync:h,isNone:e.isNone,isSome:e.isSome,map:N,mapAll:q,mapAllAsync:Y,mapAsync:H,mapIf:k,mapIfAsync:J,match:m,matchAsync:y,or:T,orElse:B,orElseAsync:X,partition:x,partitionAsync:to,peek:w,peekAsync:l,peekBoth:S,peekBothAsync:I,peekNone:d,peekNoneAsync:b,reduce:K,reduceAsync:g,scan:C,scanAsync:oo,toArray:e.toArray,toNullable:e.toNullable,toResult:e.toResult,transpose:e.transpose,zip:j,zipAsync:U,zipWith:M},Symbol.toStringTag,{value:"Module"}));exports.None=e.None;exports.Some=e.Some;exports.fromFalsy=e.fromFalsy;exports.fromNullable=e.fromNullable;exports.isNone=e.isNone;exports.isSome=e.isSome;exports.toArray=e.toArray;exports.toNullable=e.toNullable;exports.toResult=e.toResult;exports.transpose=e.transpose;exports.__export__=ro;exports.all=O;exports.allAsync=Z;exports.and=z;exports.andThen=P;exports.andThenAsync=L;exports.ap=v;exports.apAsync=G;exports.collectSomes=E;exports.collectSomesAsync=eo;exports.contains=R;exports.filter=_;exports.filterAsync=Q;exports.firstSome=W;exports.firstSomeAsync=$;exports.fold=F;exports.foldAsync=V;exports.folds=D;exports.ifNone=u;exports.ifNoneAsync=p;exports.ifSome=A;exports.ifSomeAsync=h;exports.map=N;exports.mapAll=q;exports.mapAllAsync=Y;exports.mapAsync=H;exports.mapIf=k;exports.mapIfAsync=J;exports.match=m;exports.matchAsync=y;exports.or=T;exports.orElse=B;exports.orElseAsync=X;exports.partition=x;exports.partitionAsync=to;exports.peek=w;exports.peekAsync=l;exports.peekBoth=S;exports.peekBothAsync=I;exports.peekNone=d;exports.peekNoneAsync=b;exports.reduce=K;exports.reduceAsync=g;exports.scan=C;exports.scanAsync=oo;exports.zip=j;exports.zipAsync=U;exports.zipWith=M;
|
|
2
|
+
//# sourceMappingURL=Maybe.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Maybe.cjs","sources":["../../src/Maybe/consumers.ts","../../src/Maybe/consumers-async.ts","../../src/Maybe/operators.ts","../../src/Maybe/operators-async.ts"],"sourcesContent":["// ========================================\r\n// ./src/Maybe/consumers.ts\r\n// ========================================\r\n\r\nimport {isNone, isSome} from './base';\r\nimport type {Maybe} from './types';\r\n\r\n// ========================================\r\n// 分支控制流\r\n// ========================================\r\n\r\n/**\r\n * Pattern matching for Maybe type\r\n * @param val - Maybe value to match\r\n * @param onSome - Callback for Some case\r\n * @param onNone - Callback for None case\r\n * @returns Result of the matched case\r\n */\r\nexport const match = <T, R>(\r\n val: Maybe<T>,\r\n onSome: (value: T) => R,\r\n onNone: () => R,\r\n): R => (isSome(val) ? onSome(val) : onNone());\r\n\r\n/**\r\n * Execute callback only if Maybe is Some\r\n * @param val - Maybe value to check\r\n * @param onSome - Callback for Some case\r\n * @returns Callback result or undefined\r\n */\r\nexport function ifSome<T, R1>(\r\n val: Maybe<T>,\r\n onSome: (value: T) => R1,\r\n): R1 | void;\r\n\r\n/**\r\n * Execute callback for Some, fallback for None\r\n * @param val - Maybe value to check\r\n * @param onSome - Callback for Some case\r\n * @param onElse - Fallback callback\r\n * @returns Result of either callback\r\n */\r\nexport function ifSome<T, R1, R2>(\r\n val: Maybe<T>,\r\n onSome: (value: T) => R1,\r\n onElse: () => R2,\r\n): R1 | R2;\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function ifSome<T, R1, R2>(\r\n val: Maybe<T>,\r\n onSome: (value: T) => R1,\r\n onElse?: () => R2,\r\n): R1 | R2 | void {\r\n return isSome(val) ? onSome(val) : onElse?.();\r\n}\r\n\r\n/**\r\n * Execute callback only if Maybe is None\r\n * @param val - Maybe value to check\r\n * @param onNone - Callback for None case\r\n * @returns Callback result or undefined\r\n */\r\nexport function ifNone<T, R1>(val: Maybe<T>, onNone: () => R1): R1 | void;\r\n\r\n/**\r\n * Execute callback for None, fallback for Some\r\n * @param val - Maybe value to check\r\n * @param onNone - Callback for None case\r\n * @param onElse - Fallback callback\r\n * @returns Result of either callback\r\n */\r\nexport function ifNone<T, R1, R2>(\r\n val: Maybe<T>,\r\n onNone: () => R1,\r\n onElse: (value: T) => R2,\r\n): R1 | R2;\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function ifNone<T, R1, R2>(\r\n val: Maybe<T>,\r\n onNone: () => R1,\r\n onElse?: (value: T) => R2,\r\n): R1 | R2 | void {\r\n return isNone(val) ? onNone() : onElse?.(val);\r\n}\r\n\r\n// ========================================\r\n// 副作用\r\n// ========================================\r\n\r\n/**\r\n * Peek at Some value without consuming\r\n * @param val - Maybe value to inspect\r\n * @param fn - Side effect callback\r\n * @returns Original Maybe value\r\n */\r\nexport const peek = <T>(val: Maybe<T>, fn: (v: T) => void): Maybe<T> => {\r\n if (isSome(val)) fn(val);\r\n return val;\r\n};\r\n\r\n/**\r\n * Peek at None case without consuming\r\n * @param val - Maybe value to inspect\r\n * @param fn - Side effect callback\r\n * @returns Original Maybe value\r\n */\r\nexport const peekNone = <T>(val: Maybe<T>, fn: () => void): Maybe<T> => {\r\n if (isNone(val)) fn();\r\n return val;\r\n};\r\n\r\n/**\r\n * Peek at both cases with separate callbacks\r\n * @param val - Maybe value to inspect\r\n * @param callbacks - Object with Some and None handlers\r\n * @returns Original Maybe value\r\n */\r\nexport function peekBoth<T>(\r\n val: Maybe<T>,\r\n {\r\n fnSome = () => {},\r\n fnNone = () => {},\r\n }: {\r\n fnSome?: (v: T) => void;\r\n fnNone?: () => void;\r\n },\r\n): Maybe<T> {\r\n if (isSome(val)) {\r\n fnSome(val);\r\n } else {\r\n fnNone();\r\n }\r\n\r\n return val;\r\n}\r\n","// ========================================\n// ./src/Maybe/consumers-async.ts\n// ========================================\n\nimport {isNone, isSome} from './base';\nimport type {AnyMaybe, Maybe} from './types';\nimport type {MaybePromise} from '../Utils/type-tool';\nimport {dynamicAwait} from '../helper';\n\n// ========================================\n// 分支控制流\n// ========================================\n\n/**\n * Asynchronously pattern matches on a Maybe value, executing the appropriate callback\n * @param val - The Maybe value or Promise of Maybe to match on\n * @param onSome - Callback executed when value is Some\n * @param onNone - Callback executed when value is None\n * @param signal - Optional AbortSignal for cancellation\n * @returns Promise resolving to the result of the executed callback\n */\nexport async function matchAsync<T, R>(\n val: AnyMaybe<T>,\n onSome: (value: T, signal?: AbortSignal) => MaybePromise<R>,\n onNone: (signal?: AbortSignal) => MaybePromise<R>,\n signal?: AbortSignal,\n): Promise<R> {\n signal?.throwIfAborted();\n const unwrapped = await val;\n\n if (isSome(unwrapped)) {\n const res = await dynamicAwait(onSome(unwrapped, signal));\n signal?.throwIfAborted();\n return res;\n } else {\n const res = await dynamicAwait(onNone(signal));\n signal?.throwIfAborted();\n return res;\n }\n}\n\n/**\n * Executes callback only if Maybe value is Some (single callback version)\n * @returns Promise resolving to callback result or undefined\n */\nexport async function ifSomeAsync<T, R1>(\n val: AnyMaybe<T>,\n onSome: (value: T) => MaybePromise<R1>,\n): Promise<R1 | void>;\n\n/**\n * Executes appropriate callback based on Maybe value (two callback version)\n * @returns Promise resolving to result of either callback\n */\nexport async function ifSomeAsync<T, R1, R2>(\n val: AnyMaybe<T>,\n onSome: (value: T) => MaybePromise<R1>,\n onElse: () => MaybePromise<R2>,\n): Promise<R1 | R2>;\n\n/**\n * Conditionally executes callback based on Maybe value\n * @param val - The Maybe value or Promise of Maybe to check\n * @param onSome - Callback executed for Some values\n * @param onElse - Optional callback executed for None values\n * @returns Promise resolving to callback result or undefined\n */\nexport async function ifSomeAsync<T, R1, R2 = void>(\n val: AnyMaybe<T>,\n onSome: (value: T) => MaybePromise<R1>,\n onElse?: () => MaybePromise<R2>,\n): Promise<R1 | R2 | void> {\n const unwrapped = await val;\n\n if (isSome(unwrapped)) {\n return await dynamicAwait(onSome(unwrapped));\n } else {\n if (onElse) {\n return await dynamicAwait(onElse());\n }\n return;\n }\n}\n\n/**\n * Executes callback only if Maybe value is None (single callback version)\n * @returns Promise resolving to callback result or undefined\n */\nexport async function ifNoneAsync<T, R1>(\n val: AnyMaybe<T>,\n onNone: () => MaybePromise<R1>,\n): Promise<R1 | void>;\n\n/**\n * Executes appropriate callback based on Maybe value (two callback version)\n * @returns Promise resolving to result of either callback\n */\nexport async function ifNoneAsync<T, R1, R2>(\n val: AnyMaybe<T>,\n onNone: () => MaybePromise<R1>,\n onElse: (value: T) => MaybePromise<R2>,\n): Promise<R1 | R2>;\n\n/**\n * Conditionally executes callback based on Maybe value\n * @param val - The Maybe value or Promise of Maybe to check\n * @param onNone - Callback executed for None values\n * @param onElse - Optional callback executed for Some values\n * @returns Promise resolving to callback result or undefined\n */\nexport async function ifNoneAsync<T, R1, R2 = void>(\n val: AnyMaybe<T>,\n onNone: () => MaybePromise<R1>,\n onElse?: (value: T) => MaybePromise<R2>,\n): Promise<R1 | R2 | void> {\n const unwrapped = await val;\n\n if (isNone(unwrapped)) {\n return await dynamicAwait(onNone());\n } else {\n if (onElse) {\n return await dynamicAwait(onElse(unwrapped));\n }\n return;\n }\n}\n\n// ========================================\n// 副作用\n// ========================================\n\n/**\n * Executes a side effect for Some values without modifying the Maybe\n * @param val - The Maybe value or Promise of Maybe to inspect\n * @param fn - Side effect function for Some values\n * @param signal - Optional AbortSignal for cancellation\n * @returns Promise resolving to the original Maybe value\n */\nexport async function peekAsync<T>(\n val: AnyMaybe<T>,\n fn: (v: T, signal?: AbortSignal) => MaybePromise<void>,\n signal?: AbortSignal,\n): Promise<Maybe<T>> {\n signal?.throwIfAborted();\n const unwrapped = await val;\n signal?.throwIfAborted();\n\n if (isSome(unwrapped)) {\n await dynamicAwait(fn(unwrapped, signal));\n signal?.throwIfAborted();\n }\n return unwrapped;\n}\n\n/**\n * Executes a side effect for None values without modifying the Maybe\n * @param val - The Maybe value or Promise of Maybe to inspect\n * @param fn - Side effect function for None values\n * @param signal - Optional AbortSignal for cancellation\n * @returns Promise resolving to the original Maybe value\n */\nexport async function peekNoneAsync<T>(\n val: AnyMaybe<T>,\n fn: (signal?: AbortSignal) => MaybePromise<void>,\n signal?: AbortSignal,\n): Promise<Maybe<T>> {\n signal?.throwIfAborted();\n const unwrapped = await val;\n signal?.throwIfAborted();\n\n if (isNone(unwrapped)) {\n await dynamicAwait(fn(signal));\n signal?.throwIfAborted();\n }\n return unwrapped;\n}\n\n/**\n * Executes side effects for both Some and None cases without modifying the Maybe\n * @param val - The Maybe value or Promise of Maybe to inspect\n * @param handlers - Object containing optional Some and None handlers\n * @param signal - Optional AbortSignal for cancellation\n * @returns Promise resolving to the original Maybe value\n */\nexport async function peekBothAsync<T>(\n val: AnyMaybe<T>,\n {\n fnSome = () => {},\n fnNone = () => {},\n }: {\n fnSome?: (v: T, signal?: AbortSignal) => MaybePromise<void>;\n fnNone?: (signal?: AbortSignal) => MaybePromise<void>;\n },\n signal?: AbortSignal,\n): Promise<Maybe<T>> {\n signal?.throwIfAborted();\n const unwrapped = await val;\n signal?.throwIfAborted();\n\n if (isSome(unwrapped)) {\n await dynamicAwait(fnSome(unwrapped, signal));\n } else {\n await dynamicAwait(fnNone(signal));\n }\n signal?.throwIfAborted();\n\n return unwrapped;\n}\n","// ========================================\r\n// ./src/Maybe/operators.ts\r\n// ========================================\r\nimport {isSome, None, Some} from './base';\r\nimport type {Maybe} from './types';\r\n\r\n// ========================================\r\n// 基础转换\r\n// ========================================\r\n\r\n/**\r\n * Transforms the contained value if Some, returns None otherwise.\r\n * @typeparam T - Original value type\r\n * @typeparam R - Result type\r\n * @param val - Maybe value\r\n * @param fn - Transformation function\r\n * @returns Maybe<R>\r\n */\r\nexport const map = <T, R>(val: Maybe<T>, fn: (value: T) => R): Maybe<R> =>\r\n isSome(val) ? Some(fn(val)) : None();\r\n\r\n/**\r\n * Chains computations that may fail. If Some, applies fn, otherwise returns None.\r\n * @typeparam T - Original value type\r\n * @typeparam R - Result type\r\n * @param val - Maybe value\r\n * @param fn - Function returning Maybe<R>\r\n * @returns Maybe<R>\r\n */\r\nexport const andThen = <T, R>(\r\n val: Maybe<T>,\r\n fn: (value: T) => Maybe<R>,\r\n): Maybe<R> => (isSome(val) ? fn(val) : val);\r\n\r\n/**\r\n * Applies a Maybe-wrapped function to a Maybe value.\r\n * @typeparam T - Input type\r\n * @typeparam R - Result type\r\n * @param fn_val - Maybe<(v: T) => R>\r\n * @param val - Maybe<T>\r\n * @returns Maybe<R>\r\n */\r\nexport const ap = <T, R>(\r\n fn_val: Maybe<(v: T) => R>,\r\n val: Maybe<T>,\r\n): Maybe<R> => (isSome(fn_val) && isSome(val) ? Some(fn_val(val)) : None());\r\n\r\n/**\r\n * Returns Some if value satisfies predicate, None otherwise.\r\n * @typeparam T - Value type\r\n * @param val - Maybe value\r\n * @param predicate - Filter condition\r\n * @returns Maybe<T>\r\n */\r\nexport const filter = <T>(\r\n val: Maybe<T>,\r\n predicate: (v: T) => boolean,\r\n): Maybe<T> => (isSome(val) && predicate(val) ? val : None());\r\n\r\n/**\r\n * Maps value if predicate passes, returns None otherwise.\r\n * @typeparam T - Original type\r\n * @typeparam R - Result type\r\n * @param val - Maybe value\r\n * @param predicate - Condition to check\r\n * @param fn - Transformation function\r\n * @returns Maybe<R>\r\n */\r\nexport const mapIf = <T, R>(\r\n val: Maybe<T>,\r\n predicate: (v: T) => boolean,\r\n fn: (v: T) => R,\r\n): Maybe<R> => (isSome(val) && predicate(val) ? Some(fn(val)) : None());\r\n\r\n// ========================================\r\n// 逻辑分支与聚合\r\n// ========================================\r\n\r\n/**\r\n * Returns other if val is Some, None otherwise.\r\n * @typeparam T - First type\r\n * @typeparam U - Second type\r\n * @param val - Maybe<T>\r\n * @param other - Maybe<U>\r\n * @returns Maybe<U>\r\n */\r\nexport const and = <T, U>(val: Maybe<T>, other: Maybe<U>): Maybe<U> =>\r\n isSome(val) ? other : None();\r\n\r\n/**\r\n * Returns first Some value, otherwise other.\r\n * @typeparam T - Value type\r\n * @param val - First Maybe\r\n * @param other - Fallback Maybe\r\n * @returns Maybe<T>\r\n */\r\nexport const or = <T>(val: Maybe<T>, other: Maybe<T>): Maybe<T> =>\r\n isSome(val) ? val : other;\r\n\r\n/**\r\n * Returns val if Some, otherwise calls fn for fallback.\r\n * @typeparam T - Value type\r\n * @param val - Maybe value\r\n * @param fn - Fallback supplier\r\n * @returns Maybe<T>\r\n */\r\nexport const orElse = <T>(val: Maybe<T>, fn: () => Maybe<T>): Maybe<T> =>\r\n isSome(val) ? val : fn();\r\n\r\n/**\r\n * Extracts value or returns default.\r\n * @typeparam T - Input type\r\n * @typeparam R - Output type\r\n * @param val - Maybe value\r\n * @param initial - Default value\r\n * @param onSome - Handler for Some case\r\n * @returns R\r\n */\r\nexport const fold = <T, R>(\r\n val: Maybe<T>,\r\n initial: R,\r\n onSome: (v: T) => R,\r\n): R => (isSome(val) ? onSome(val) : initial);\r\n\r\n/**\r\n * Checks if Maybe contains specific value.\r\n * @typeparam T - Value type\r\n * @param val - Maybe value\r\n * @param x - Value to compare\r\n * @returns boolean\r\n */\r\nexport const contains = <T>(val: Maybe<T>, x: T): boolean =>\r\n isSome(val) && val === x;\r\n\r\n// ========================================\r\n// 多元组合\r\n// ========================================\r\n\r\n/**\r\n * Combines two Maybes into tuple if both are Some.\r\n * @typeparam T - First type\r\n * @typeparam U - Second type\r\n * @param a - Maybe<T>\r\n * @param b - Maybe<U>\r\n * @returns Maybe<[T, U]>\r\n */\r\nexport const zip = <T, U>(a: Maybe<T>, b: Maybe<U>): Maybe<[T, U]> =>\r\n isSome(a) && isSome(b) ? Some([a, b] as [T, U]) : None();\r\n\r\n/**\r\n * Applies function to two Maybes if both are Some.\r\n * @typeparam T - First type\r\n * @typeparam U - Second type\r\n * @typeparam R - Result type\r\n * @param ma - Maybe<T>\r\n * @param mb - Maybe<U>\r\n * @param fn - Combining function\r\n * @returns Maybe<R>\r\n */\r\nexport const zipWith = <T, U, R>(\r\n ma: Maybe<T>,\r\n mb: Maybe<U>,\r\n fn: (a: T, b: U) => R,\r\n): Maybe<R> => (isSome(ma) && isSome(mb) ? Some(fn(ma, mb)) : None());\r\n\r\n// ========================================\r\n// 集合处理\r\n// ========================================\r\n\r\n/**\r\n * Returns array of all values if all are Some, None otherwise.\r\n * @typeparam T - Element type\r\n * @param vals - Array of Maybes\r\n * @returns Maybe<T[]>\r\n */\r\nexport const all = <T>(vals: readonly Maybe<T>[]): Maybe<T[]> =>\r\n vals.every(isSome) ? Some(vals as T[]) : None();\r\n\r\n/**\r\n * Maps array to Maybes, returns Some of results if all succeed.\r\n * @typeparam T - Input type\r\n * @typeparam U - Output type\r\n * @param items - Input array\r\n * @param fn - Mapping function\r\n * @returns Maybe<U[]>\r\n */\r\nexport const mapAll = <T, U>(\r\n items: readonly T[],\r\n fn: (it: T, i: number) => Maybe<U>,\r\n): Maybe<U[]> => {\r\n const results: U[] = [];\r\n for (let i = 0; i < items.length; i++) {\r\n const res = fn(items[i], i);\r\n if (!isSome(res)) return None();\r\n results.push(res);\r\n }\r\n return Some(results);\r\n};\r\n\r\n/**\r\n * Partitions array into Some values and None count.\r\n * @typeparam T - Element type\r\n * @param vals - Array of Maybes\r\n * @returns [T[], number] - [Some values, None count]\r\n */\r\nexport const partition = <T>(vals: readonly Maybe<T>[]): [T[], number] => {\r\n const somes: T[] = [];\r\n let none_count = 0;\r\n for (const v of vals) {\r\n if (isSome(v)) somes.push(v);\r\n else none_count++;\r\n }\r\n return [somes, none_count];\r\n};\r\n\r\n/**\r\n * Collects all Some values from array.\r\n * @typeparam T - Element type\r\n * @param vals - Array of Maybes\r\n * @returns T[] - Only Some values\r\n */\r\nexport const collectSomes = <T>(vals: readonly Maybe<T>[]): T[] => {\r\n const result: T[] = [];\r\n for (const v of vals) if (isSome(v)) result.push(v);\r\n return result;\r\n};\r\n\r\n/**\r\n * Returns first Some value in array, None if none found.\r\n * @typeparam T - Element type\r\n * @param vals - Array of Maybes\r\n * @returns Maybe<T>\r\n */\r\nexport const firstSome = <T>(vals: readonly Maybe<T>[]): Maybe<T> =>\r\n vals.find(isSome) ?? None();\r\n\r\n// ========================================\r\n// 高级规约\r\n// ========================================\r\n\r\n/**\r\n * Reduces array of Maybes. Returns None if any is None.\r\n * @typeparam T - Element type\r\n * @typeparam R - Result type\r\n * @param vals - Array of Maybes\r\n * @param initial - Initial value\r\n * @param reducer - Reduction function\r\n * @returns Maybe<R>\r\n */\r\nexport function reduce<T, R>(\r\n vals: readonly Maybe<T>[],\r\n initial: R,\r\n reducer: (acc: R, v: T) => R,\r\n): Maybe<R> {\r\n let acc = initial;\r\n for (const v of vals) {\r\n if (!isSome(v)) return None();\r\n acc = reducer(acc, v);\r\n }\r\n return Some(acc);\r\n}\r\n\r\n/**\r\n * Performs scan reduction. Returns None if any is None.\r\n * @typeparam T - Element type\r\n * @typeparam R - Result type\r\n * @param vals - Array of Maybes\r\n * @param initial - Initial value\r\n * @param scanner - Scanning function\r\n * @returns Maybe<R[]>\r\n */\r\nexport function scan<T, R>(\r\n vals: readonly Maybe<T>[],\r\n initial: R,\r\n scanner: (acc: R, v: T) => R,\r\n): Maybe<R[]> {\r\n const scanned: R[] = [initial];\r\n let acc = initial;\r\n for (const v of vals) {\r\n if (!isSome(v)) return None();\r\n acc = scanner(acc, v);\r\n scanned.push(acc);\r\n }\r\n return Some(scanned);\r\n}\r\n\r\n/**\r\n * Folds with separate handlers for Some/None.\r\n * @typeparam T - Element type\r\n * @typeparam R - Result type\r\n * @param vals - Array of Maybes\r\n * @param initial - Initial value\r\n * @param onSome - Handler for Some values\r\n * @param onNone - Handler for None values\r\n * @returns R\r\n */\r\nexport const folds = <T, R>(\r\n vals: readonly Maybe<T>[],\r\n initial: R,\r\n onSome: (acc: R, v: T) => R,\r\n onNone: (acc: R) => R,\r\n): R => {\r\n let acc = initial;\r\n for (const v of vals) acc = isSome(v) ? onSome(acc, v) : onNone(acc);\r\n return acc;\r\n};\r\n","// ========================================\r\n// ./src/Maybe/operators-async.ts\r\n// ========================================\r\nimport {isSome, None, Some} from './base';\r\nimport type {AnyMaybe, AsyncMaybe} from './types';\r\n\r\n// ========================================\r\n// 核心转换操作\r\n// ========================================\r\n\r\n/**\r\n * Applies async function from Maybe to async value.\r\n * @typeparam T - Input type\r\n * @typeparam R - Result type\r\n * @param fn_val - Maybe function\r\n * @param val - Maybe value\r\n * @param signal - Optional AbortSignal\r\n * @returns AsyncMaybe<R>\r\n */\r\nexport const apAsync = async <T, R>(\r\n fn_val: AnyMaybe<(v: T) => R | Promise<R>>,\r\n val: AnyMaybe<T>,\r\n signal?: AbortSignal,\r\n): AsyncMaybe<R> => {\r\n signal?.throwIfAborted();\r\n const [f, v] = await Promise.all([\r\n Promise.resolve(fn_val),\r\n Promise.resolve(val),\r\n ]);\r\n signal?.throwIfAborted();\r\n return isSome(f) && isSome(v) ? Some(await f(v)) : None();\r\n};\r\n\r\n/**\r\n * Transforms async Maybe value with async function.\r\n * @typeparam T - Input type\r\n * @typeparam R - Result type\r\n * @param val - Maybe value\r\n * @param fn - Async transformation function\r\n * @param signal - Optional AbortSignal\r\n * @returns AsyncMaybe<R>\r\n */\r\nexport const mapAsync = async <T, R>(\r\n val: AnyMaybe<T>,\r\n fn: (v: T) => R | Promise<R>,\r\n signal?: AbortSignal,\r\n): AsyncMaybe<R> => {\r\n signal?.throwIfAborted();\r\n const v = await val;\r\n signal?.throwIfAborted();\r\n return isSome(v) ? Some(await fn(v)) : None();\r\n};\r\n\r\n/**\r\n * Maps value only if predicate passes (async).\r\n * @typeparam T - Input type\r\n * @typeparam R - Result type\r\n * @param val - Maybe value\r\n * @param predicate - Async condition check\r\n * @param fn - Async transformation function\r\n * @param signal - Optional AbortSignal\r\n * @returns AsyncMaybe<R>\r\n */\r\nexport const mapIfAsync = async <T, R>(\r\n val: AnyMaybe<T>,\r\n predicate: (v: T) => boolean | Promise<boolean>,\r\n fn: (v: T) => R | Promise<R>,\r\n signal?: AbortSignal,\r\n): AsyncMaybe<R> => {\r\n signal?.throwIfAborted();\r\n const v = await val;\r\n signal?.throwIfAborted();\r\n if (!isSome(v)) return None();\r\n\r\n const shouldMap = await predicate(v);\r\n signal?.throwIfAborted();\r\n return shouldMap ? Some(await fn(v)) : None();\r\n};\r\n\r\n/**\r\n * Chains async computations that may fail.\r\n * @typeparam T - Input type\r\n * @typeparam R - Result type\r\n * @param val - Maybe value\r\n * @param fn - Async function returning Maybe\r\n * @param signal - Optional AbortSignal\r\n * @returns AsyncMaybe<R>\r\n */\r\nexport const andThenAsync = async <T, R>(\r\n val: AnyMaybe<T>,\r\n fn: (v: T) => AnyMaybe<R>,\r\n signal?: AbortSignal,\r\n): AsyncMaybe<R> => {\r\n signal?.throwIfAborted();\r\n const v = await val;\r\n signal?.throwIfAborted();\r\n return isSome(v) ? fn(v) : None();\r\n};\r\n\r\n/**\r\n * Filters async Maybe value with async predicate.\r\n * @typeparam T - Value type\r\n * @param val - Maybe value\r\n * @param predicate - Async filter condition\r\n * @param signal - Optional AbortSignal\r\n * @returns AsyncMaybe<T>\r\n */\r\nexport const filterAsync = async <T>(\r\n val: AnyMaybe<T>,\r\n predicate: (v: T) => boolean | Promise<boolean>,\r\n signal?: AbortSignal,\r\n): AsyncMaybe<T> => {\r\n signal?.throwIfAborted();\r\n const v = await val;\r\n signal?.throwIfAborted();\r\n if (!isSome(v)) return None();\r\n\r\n const shouldKeep = await predicate(v);\r\n signal?.throwIfAborted();\r\n return shouldKeep ? v : None();\r\n};\r\n\r\n// ========================================\r\n// 组合操作\r\n// ========================================\r\n\r\n/**\r\n * Zips two async Maybes into tuple if both are Some.\r\n * @typeparam T - First type\r\n * @typeparam U - Second type\r\n * @param a - First Maybe\r\n * @param b - Second Maybe\r\n * @param signal - Optional AbortSignal\r\n * @returns AsyncMaybe<[T, U]>\r\n */\r\nexport const zipAsync = async <T, U>(\r\n a: AnyMaybe<T>,\r\n b: AnyMaybe<U>,\r\n signal?: AbortSignal,\r\n): AsyncMaybe<[T, U]> => {\r\n signal?.throwIfAborted();\r\n const [ra, rb] = await Promise.all([Promise.resolve(a), Promise.resolve(b)]);\r\n signal?.throwIfAborted();\r\n return isSome(ra) && isSome(rb) ? Some([ra, rb]) : None();\r\n};\r\n\r\n// ========================================\r\n// 逻辑分支与错误处理\r\n// ========================================\r\n\r\n/**\r\n * Extracts value from async Maybe or returns default.\r\n * @typeparam T - Input type\r\n * @typeparam R - Result type\r\n * @param val - Maybe value\r\n * @param initial - Default value or Promise\r\n * @param onSome - Async handler for Some case\r\n * @param signal - Optional AbortSignal\r\n * @returns Promise<R>\r\n */\r\nexport const foldAsync = async <T, R>(\r\n val: AnyMaybe<T>,\r\n initial: R | Promise<R>,\r\n onSome: (v: T) => R | Promise<R>,\r\n signal?: AbortSignal,\r\n): Promise<R> => {\r\n signal?.throwIfAborted();\r\n const v = await val;\r\n signal?.throwIfAborted();\r\n return isSome(v) ? onSome(v) : initial;\r\n};\r\n\r\n/**\r\n * Returns value if Some, otherwise async fallback.\r\n * @typeparam T - Value type\r\n * @param val - Maybe value\r\n * @param fn - Async fallback supplier\r\n * @param signal - Optional AbortSignal\r\n * @returns AsyncMaybe<T>\r\n */\r\nexport const orElseAsync = async <T>(\r\n val: AnyMaybe<T>,\r\n fn: () => AnyMaybe<T>,\r\n signal?: AbortSignal,\r\n): AsyncMaybe<T> => {\r\n signal?.throwIfAborted();\r\n const v = await val;\r\n signal?.throwIfAborted();\r\n return isSome(v) ? v : fn();\r\n};\r\n\r\n// ========================================\r\n// 集合操作\r\n// ========================================\r\n\r\n/**\r\n * Maps array with async function, fails if any returns None.\r\n * @typeparam T - Input type\r\n * @typeparam R - Output type\r\n * @param items - Input array\r\n * @param fn - Async mapping function\r\n * @param signal - Optional AbortSignal\r\n * @returns AsyncMaybe<R[]>\r\n */\r\nexport const mapAllAsync = async <T, R>(\r\n items: readonly T[],\r\n fn: (it: T, i: number) => AnyMaybe<R>,\r\n signal?: AbortSignal,\r\n): AsyncMaybe<R[]> => {\r\n signal?.throwIfAborted();\r\n const results = await Promise.all(\r\n items.map(async (it, i) => {\r\n signal?.throwIfAborted();\r\n return await fn(it, i);\r\n }),\r\n );\r\n signal?.throwIfAborted();\r\n\r\n const final: R[] = [];\r\n for (const r of results) {\r\n if (!isSome(r)) return None();\r\n final.push(r);\r\n }\r\n return Some(final);\r\n};\r\n\r\n/**\r\n * Returns all async values if all are Some, None otherwise.\r\n * @typeparam T - Element type\r\n * @param vals - Array of async Maybes\r\n * @param signal - Optional AbortSignal\r\n * @returns AsyncMaybe<T[]>\r\n */\r\nexport const allAsync = async <T>(\r\n vals: readonly AnyMaybe<T>[],\r\n signal?: AbortSignal,\r\n): AsyncMaybe<T[]> => {\r\n signal?.throwIfAborted();\r\n const resolved = await Promise.all(\r\n vals.map((v) => {\r\n signal?.throwIfAborted();\r\n return Promise.resolve(v);\r\n }),\r\n );\r\n signal?.throwIfAborted();\r\n return resolved.every(isSome) ? Some(resolved as T[]) : None();\r\n};\r\n\r\n/**\r\n * Returns first Some value from async array, None if none found.\r\n * @typeparam T - Element type\r\n * @param vals - Array of async Maybes\r\n * @param signal - Optional AbortSignal\r\n * @returns AsyncMaybe<T>\r\n */\r\nexport const firstSomeAsync = async <T>(\r\n vals: readonly AnyMaybe<T>[],\r\n signal?: AbortSignal,\r\n): AsyncMaybe<T> => {\r\n signal?.throwIfAborted();\r\n const resolved = await Promise.all(\r\n vals.map((v) => {\r\n signal?.throwIfAborted();\r\n return Promise.resolve(v);\r\n }),\r\n );\r\n signal?.throwIfAborted();\r\n\r\n for (const v of resolved) {\r\n if (isSome(v)) return Some(v);\r\n }\r\n return None();\r\n};\r\n\r\n// ========================================\r\n// 规约与聚合\r\n// ========================================\r\n\r\n/**\r\n * Reduces array of async Maybes with async reducer.\r\n * @typeparam T - Element type\r\n * @typeparam R - Result type\r\n * @param vals - Array of async Maybes\r\n * @param initial - Initial value\r\n * @param reducer - Async reduction function\r\n * @param signal - Optional AbortSignal\r\n * @returns AsyncMaybe<R>\r\n */\r\nexport async function reduceAsync<T, R>(\r\n vals: readonly AnyMaybe<T>[],\r\n initial: R,\r\n reducer: (acc: R, v: T) => R | Promise<R>,\r\n signal?: AbortSignal,\r\n): AsyncMaybe<R> {\r\n signal?.throwIfAborted();\r\n let acc = initial;\r\n const resolved_vals = await Promise.all(\r\n vals.map((v) => {\r\n signal?.throwIfAborted();\r\n return Promise.resolve(v);\r\n }),\r\n );\r\n signal?.throwIfAborted();\r\n\r\n for (const v of resolved_vals) {\r\n if (!isSome(v)) return None();\r\n acc = await reducer(acc, v);\r\n signal?.throwIfAborted();\r\n }\r\n return Some(acc);\r\n}\r\n\r\n/**\r\n * Performs async scan reduction on array of async Maybes.\r\n * @typeparam T - Element type\r\n * @typeparam R - Result type\r\n * @param vals - Array of async Maybes\r\n * @param initial - Initial value\r\n * @param scanner - Async scanning function\r\n * @param signal - Optional AbortSignal\r\n * @returns AsyncMaybe<R[]>\r\n */\r\nexport async function scanAsync<T, R>(\r\n vals: readonly AnyMaybe<T>[],\r\n initial: R,\r\n scanner: (acc: R, v: T) => R | Promise<R>,\r\n signal?: AbortSignal,\r\n): AsyncMaybe<R[]> {\r\n signal?.throwIfAborted();\r\n const resolved = await Promise.all(\r\n vals.map((v) => {\r\n signal?.throwIfAborted();\r\n return Promise.resolve(v);\r\n }),\r\n );\r\n signal?.throwIfAborted();\r\n\r\n const scanned: R[] = [initial];\r\n let acc = initial;\r\n\r\n for (const v of resolved) {\r\n if (!isSome(v)) return None();\r\n acc = await scanner(acc, v);\r\n signal?.throwIfAborted();\r\n scanned.push(acc);\r\n }\r\n return Some(scanned);\r\n}\r\n\r\n// ========================================\r\n// 集合筛选与统计\r\n// ========================================\r\n\r\n/**\r\n * Collects all Some values from async array.\r\n * @typeparam T - Element type\r\n * @param vals - Array of async Maybes\r\n * @param signal - Optional AbortSignal\r\n * @returns Promise<T[]> - Only Some values\r\n */\r\nexport const collectSomesAsync = async <T>(\r\n vals: readonly AnyMaybe<T>[],\r\n signal?: AbortSignal,\r\n): Promise<T[]> => {\r\n signal?.throwIfAborted();\r\n const resolved = await Promise.all(\r\n vals.map((v) => {\r\n signal?.throwIfAborted();\r\n return Promise.resolve(v);\r\n }),\r\n );\r\n signal?.throwIfAborted();\r\n return resolved.filter(isSome) as T[];\r\n};\r\n\r\n/**\r\n * Partitions async array into Some values and None count.\r\n * @typeparam T - Element type\r\n * @param vals - Array of async Maybes\r\n * @param signal - Optional AbortSignal\r\n * @returns Promise<[T[], number]> - [Some values, None count]\r\n */\r\nexport const partitionAsync = async <T>(\r\n vals: readonly AnyMaybe<T>[],\r\n signal?: AbortSignal,\r\n): Promise<[T[], number]> => {\r\n signal?.throwIfAborted();\r\n const resolved = await Promise.all(\r\n vals.map((v) => {\r\n signal?.throwIfAborted();\r\n return Promise.resolve(v);\r\n }),\r\n );\r\n signal?.throwIfAborted();\r\n\r\n const somes: T[] = [];\r\n let none_count = 0;\r\n\r\n for (const v of resolved) {\r\n if (isSome(v)) somes.push(v);\r\n else none_count++;\r\n }\r\n\r\n return [somes, none_count];\r\n};\r\n"],"names":["match","val","onSome","onNone","isSome","ifSome","onElse","ifNone","isNone","peek","fn","peekNone","peekBoth","fnSome","fnNone","matchAsync","signal","unwrapped","res","dynamicAwait","ifSomeAsync","ifNoneAsync","peekAsync","peekNoneAsync","peekBothAsync","map","Some","None","andThen","ap","fn_val","filter","predicate","mapIf","and","other","or","orElse","fold","initial","contains","x","zip","a","b","zipWith","ma","mb","all","vals","mapAll","items","results","i","partition","somes","none_count","v","collectSomes","result","firstSome","reduce","reducer","acc","scan","scanner","scanned","folds","apAsync","f","mapAsync","mapIfAsync","shouldMap","andThenAsync","filterAsync","shouldKeep","zipAsync","ra","rb","foldAsync","orElseAsync","mapAllAsync","it","final","r","allAsync","resolved","firstSomeAsync","reduceAsync","resolved_vals","scanAsync","collectSomesAsync","partitionAsync"],"mappings":"0KAkBaA,EAAQ,CACnBC,EACAC,EACAC,IACOC,SAAOH,CAAG,EAAIC,EAAOD,CAAG,EAAIE,EAAA,EA6B9B,SAASE,EACdJ,EACAC,EACAI,EACgB,CAChB,OAAOF,EAAAA,OAAOH,CAAG,EAAIC,EAAOD,CAAG,EAAIK,IAAA,CACrC,CA0BO,SAASC,EACdN,EACAE,EACAG,EACgB,CAChB,OAAOE,EAAAA,OAAOP,CAAG,EAAIE,EAAA,EAAWG,IAASL,CAAG,CAC9C,CAYO,MAAMQ,EAAO,CAAIR,EAAeS,KACjCN,SAAOH,CAAG,GAAGS,EAAGT,CAAG,EAChBA,GASIU,EAAW,CAAIV,EAAeS,KACrCF,EAAAA,OAAOP,CAAG,GAAGS,EAAA,EACVT,GASF,SAASW,EACdX,EACA,CACE,OAAAY,EAAS,IAAM,CAAC,EAChB,OAAAC,EAAS,IAAM,CAAC,CAClB,EAIU,CACV,OAAIV,EAAAA,OAAOH,CAAG,EACZY,EAAOZ,CAAG,EAEVa,EAAA,EAGKb,CACT,CCvHA,eAAsBc,EACpBd,EACAC,EACAC,EACAa,EACY,CACZA,GAAQ,eAAA,EACR,MAAMC,EAAY,MAAMhB,EAExB,GAAIG,EAAAA,OAAOa,CAAS,EAAG,CACrB,MAAMC,EAAM,MAAMC,EAAAA,aAAajB,EAAOe,EAAWD,CAAM,CAAC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,GAAQ,eAAA,EAER,MAAMuC,EAAa,CAAA,EACnB,IAAIC,EAAa,EAEjB,UAAWC,KAAK6B,EACVlF,EAAAA,OAAOqD,CAAC,EAAGF,EAAM,KAAKE,CAAC,EACtBD,IAGP,MAAO,CAACD,EAAOC,CAAU,CAC3B"}
|
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import { i as n, a as d, S as a, N as f, f as i, b as h, t as b, c as I, d as p, e as y } from "../chunks/base-BpECeKwU.mjs";
|
|
2
|
+
import { d as u } from "../chunks/helper-BVabbpmX.mjs";
|
|
3
|
+
const m = (t, o, e) => n(t) ? o(t) : e();
|
|
4
|
+
function l(t, o, e) {
|
|
5
|
+
return n(t) ? o(t) : e?.();
|
|
6
|
+
}
|
|
7
|
+
function P(t, o, e) {
|
|
8
|
+
return d(t) ? o() : e?.(t);
|
|
9
|
+
}
|
|
10
|
+
const v = (t, o) => (n(t) && o(t), t), S = (t, o) => (d(t) && o(), t);
|
|
11
|
+
function _(t, {
|
|
12
|
+
fnSome: o = () => {
|
|
13
|
+
},
|
|
14
|
+
fnNone: e = () => {
|
|
15
|
+
}
|
|
16
|
+
}) {
|
|
17
|
+
return n(t) ? o(t) : e(), t;
|
|
18
|
+
}
|
|
19
|
+
async function N(t, o, e, r) {
|
|
20
|
+
r?.throwIfAborted();
|
|
21
|
+
const s = await t;
|
|
22
|
+
if (n(s)) {
|
|
23
|
+
const c = await u(o(s, r));
|
|
24
|
+
return r?.throwIfAborted(), c;
|
|
25
|
+
} else {
|
|
26
|
+
const c = await u(e(r));
|
|
27
|
+
return r?.throwIfAborted(), c;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
async function k(t, o, e) {
|
|
31
|
+
const r = await t;
|
|
32
|
+
return n(r) ? await u(o(r)) : e ? await u(e()) : void 0;
|
|
33
|
+
}
|
|
34
|
+
async function z(t, o, e) {
|
|
35
|
+
const r = await t;
|
|
36
|
+
return d(r) ? await u(o()) : e ? await u(e(r)) : void 0;
|
|
37
|
+
}
|
|
38
|
+
async function T(t, o, e) {
|
|
39
|
+
e?.throwIfAborted();
|
|
40
|
+
const r = await t;
|
|
41
|
+
return e?.throwIfAborted(), n(r) && (await u(o(r, e)), e?.throwIfAborted()), r;
|
|
42
|
+
}
|
|
43
|
+
async function j(t, o, e) {
|
|
44
|
+
e?.throwIfAborted();
|
|
45
|
+
const r = await t;
|
|
46
|
+
return e?.throwIfAborted(), d(r) && (await u(o(e)), e?.throwIfAborted()), r;
|
|
47
|
+
}
|
|
48
|
+
async function x(t, {
|
|
49
|
+
fnSome: o = () => {
|
|
50
|
+
},
|
|
51
|
+
fnNone: e = () => {
|
|
52
|
+
}
|
|
53
|
+
}, r) {
|
|
54
|
+
r?.throwIfAborted();
|
|
55
|
+
const s = await t;
|
|
56
|
+
return r?.throwIfAborted(), n(s) ? await u(o(s, r)) : await u(e(r)), r?.throwIfAborted(), s;
|
|
57
|
+
}
|
|
58
|
+
const B = (t, o) => n(t) ? a(o(t)) : f(), M = (t, o) => n(t) ? o(t) : t, O = (t, o) => n(t) && n(o) ? a(t(o)) : f(), F = (t, o) => n(t) && o(t) ? t : f(), K = (t, o, e) => n(t) && o(t) ? a(e(t)) : f(), R = (t, o) => n(t) ? o : f(), W = (t, o) => n(t) ? t : o, q = (t, o) => n(t) ? t : o(), C = (t, o, e) => n(t) ? e(t) : o, D = (t, o) => n(t) && t === o, E = (t, o) => n(t) && n(o) ? a([t, o]) : f(), G = (t, o, e) => n(t) && n(o) ? a(e(t, o)) : f(), H = (t) => t.every(n) ? a(t) : f(), J = (t, o) => {
|
|
59
|
+
const e = [];
|
|
60
|
+
for (let r = 0; r < t.length; r++) {
|
|
61
|
+
const s = o(t[r], r);
|
|
62
|
+
if (!n(s)) return f();
|
|
63
|
+
e.push(s);
|
|
64
|
+
}
|
|
65
|
+
return a(e);
|
|
66
|
+
}, L = (t) => {
|
|
67
|
+
const o = [];
|
|
68
|
+
let e = 0;
|
|
69
|
+
for (const r of t)
|
|
70
|
+
n(r) ? o.push(r) : e++;
|
|
71
|
+
return [o, e];
|
|
72
|
+
}, Q = (t) => {
|
|
73
|
+
const o = [];
|
|
74
|
+
for (const e of t) n(e) && o.push(e);
|
|
75
|
+
return o;
|
|
76
|
+
}, U = (t) => t.find(n) ?? f();
|
|
77
|
+
function V(t, o, e) {
|
|
78
|
+
let r = o;
|
|
79
|
+
for (const s of t) {
|
|
80
|
+
if (!n(s)) return f();
|
|
81
|
+
r = e(r, s);
|
|
82
|
+
}
|
|
83
|
+
return a(r);
|
|
84
|
+
}
|
|
85
|
+
function X(t, o, e) {
|
|
86
|
+
const r = [o];
|
|
87
|
+
let s = o;
|
|
88
|
+
for (const c of t) {
|
|
89
|
+
if (!n(c)) return f();
|
|
90
|
+
s = e(s, c), r.push(s);
|
|
91
|
+
}
|
|
92
|
+
return a(r);
|
|
93
|
+
}
|
|
94
|
+
const Y = (t, o, e, r) => {
|
|
95
|
+
let s = o;
|
|
96
|
+
for (const c of t) s = n(c) ? e(s, c) : r(s);
|
|
97
|
+
return s;
|
|
98
|
+
}, Z = async (t, o, e) => {
|
|
99
|
+
e?.throwIfAborted();
|
|
100
|
+
const [r, s] = await Promise.all([
|
|
101
|
+
Promise.resolve(t),
|
|
102
|
+
Promise.resolve(o)
|
|
103
|
+
]);
|
|
104
|
+
return e?.throwIfAborted(), n(r) && n(s) ? a(await r(s)) : f();
|
|
105
|
+
}, $ = async (t, o, e) => {
|
|
106
|
+
e?.throwIfAborted();
|
|
107
|
+
const r = await t;
|
|
108
|
+
return e?.throwIfAborted(), n(r) ? a(await o(r)) : f();
|
|
109
|
+
}, g = async (t, o, e, r) => {
|
|
110
|
+
r?.throwIfAborted();
|
|
111
|
+
const s = await t;
|
|
112
|
+
if (r?.throwIfAborted(), !n(s)) return f();
|
|
113
|
+
const c = await o(s);
|
|
114
|
+
return r?.throwIfAborted(), c ? a(await e(s)) : f();
|
|
115
|
+
}, tt = async (t, o, e) => {
|
|
116
|
+
e?.throwIfAborted();
|
|
117
|
+
const r = await t;
|
|
118
|
+
return e?.throwIfAborted(), n(r) ? o(r) : f();
|
|
119
|
+
}, ot = async (t, o, e) => {
|
|
120
|
+
e?.throwIfAborted();
|
|
121
|
+
const r = await t;
|
|
122
|
+
if (e?.throwIfAborted(), !n(r)) return f();
|
|
123
|
+
const s = await o(r);
|
|
124
|
+
return e?.throwIfAborted(), s ? r : f();
|
|
125
|
+
}, rt = async (t, o, e) => {
|
|
126
|
+
e?.throwIfAborted();
|
|
127
|
+
const [r, s] = await Promise.all([Promise.resolve(t), Promise.resolve(o)]);
|
|
128
|
+
return e?.throwIfAborted(), n(r) && n(s) ? a([r, s]) : f();
|
|
129
|
+
}, et = async (t, o, e, r) => {
|
|
130
|
+
r?.throwIfAborted();
|
|
131
|
+
const s = await t;
|
|
132
|
+
return r?.throwIfAborted(), n(s) ? e(s) : o;
|
|
133
|
+
}, nt = async (t, o, e) => {
|
|
134
|
+
e?.throwIfAborted();
|
|
135
|
+
const r = await t;
|
|
136
|
+
return e?.throwIfAborted(), n(r) ? r : o();
|
|
137
|
+
}, st = async (t, o, e) => {
|
|
138
|
+
e?.throwIfAborted();
|
|
139
|
+
const r = await Promise.all(
|
|
140
|
+
t.map(async (c, w) => (e?.throwIfAborted(), await o(c, w)))
|
|
141
|
+
);
|
|
142
|
+
e?.throwIfAborted();
|
|
143
|
+
const s = [];
|
|
144
|
+
for (const c of r) {
|
|
145
|
+
if (!n(c)) return f();
|
|
146
|
+
s.push(c);
|
|
147
|
+
}
|
|
148
|
+
return a(s);
|
|
149
|
+
}, ct = async (t, o) => {
|
|
150
|
+
o?.throwIfAborted();
|
|
151
|
+
const e = await Promise.all(
|
|
152
|
+
t.map((r) => (o?.throwIfAborted(), Promise.resolve(r)))
|
|
153
|
+
);
|
|
154
|
+
return o?.throwIfAborted(), e.every(n) ? a(e) : f();
|
|
155
|
+
}, ft = async (t, o) => {
|
|
156
|
+
o?.throwIfAborted();
|
|
157
|
+
const e = await Promise.all(
|
|
158
|
+
t.map((r) => (o?.throwIfAborted(), Promise.resolve(r)))
|
|
159
|
+
);
|
|
160
|
+
o?.throwIfAborted();
|
|
161
|
+
for (const r of e)
|
|
162
|
+
if (n(r)) return a(r);
|
|
163
|
+
return f();
|
|
164
|
+
};
|
|
165
|
+
async function at(t, o, e, r) {
|
|
166
|
+
r?.throwIfAborted();
|
|
167
|
+
let s = o;
|
|
168
|
+
const c = await Promise.all(
|
|
169
|
+
t.map((w) => (r?.throwIfAborted(), Promise.resolve(w)))
|
|
170
|
+
);
|
|
171
|
+
r?.throwIfAborted();
|
|
172
|
+
for (const w of c) {
|
|
173
|
+
if (!n(w)) return f();
|
|
174
|
+
s = await e(s, w), r?.throwIfAborted();
|
|
175
|
+
}
|
|
176
|
+
return a(s);
|
|
177
|
+
}
|
|
178
|
+
async function wt(t, o, e, r) {
|
|
179
|
+
r?.throwIfAborted();
|
|
180
|
+
const s = await Promise.all(
|
|
181
|
+
t.map((A) => (r?.throwIfAborted(), Promise.resolve(A)))
|
|
182
|
+
);
|
|
183
|
+
r?.throwIfAborted();
|
|
184
|
+
const c = [o];
|
|
185
|
+
let w = o;
|
|
186
|
+
for (const A of s) {
|
|
187
|
+
if (!n(A)) return f();
|
|
188
|
+
w = await e(w, A), r?.throwIfAborted(), c.push(w);
|
|
189
|
+
}
|
|
190
|
+
return a(c);
|
|
191
|
+
}
|
|
192
|
+
const ut = async (t, o) => {
|
|
193
|
+
o?.throwIfAborted();
|
|
194
|
+
const e = await Promise.all(
|
|
195
|
+
t.map((r) => (o?.throwIfAborted(), Promise.resolve(r)))
|
|
196
|
+
);
|
|
197
|
+
return o?.throwIfAborted(), e.filter(n);
|
|
198
|
+
}, dt = async (t, o) => {
|
|
199
|
+
o?.throwIfAborted();
|
|
200
|
+
const e = await Promise.all(
|
|
201
|
+
t.map((c) => (o?.throwIfAborted(), Promise.resolve(c)))
|
|
202
|
+
);
|
|
203
|
+
o?.throwIfAborted();
|
|
204
|
+
const r = [];
|
|
205
|
+
let s = 0;
|
|
206
|
+
for (const c of e)
|
|
207
|
+
n(c) ? r.push(c) : s++;
|
|
208
|
+
return [r, s];
|
|
209
|
+
}, ht = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
210
|
+
__proto__: null,
|
|
211
|
+
None: f,
|
|
212
|
+
Some: a,
|
|
213
|
+
all: H,
|
|
214
|
+
allAsync: ct,
|
|
215
|
+
and: R,
|
|
216
|
+
andThen: M,
|
|
217
|
+
andThenAsync: tt,
|
|
218
|
+
ap: O,
|
|
219
|
+
apAsync: Z,
|
|
220
|
+
collectSomes: Q,
|
|
221
|
+
collectSomesAsync: ut,
|
|
222
|
+
contains: D,
|
|
223
|
+
filter: F,
|
|
224
|
+
filterAsync: ot,
|
|
225
|
+
firstSome: U,
|
|
226
|
+
firstSomeAsync: ft,
|
|
227
|
+
fold: C,
|
|
228
|
+
foldAsync: et,
|
|
229
|
+
folds: Y,
|
|
230
|
+
fromFalsy: i,
|
|
231
|
+
fromNullable: h,
|
|
232
|
+
ifNone: P,
|
|
233
|
+
ifNoneAsync: z,
|
|
234
|
+
ifSome: l,
|
|
235
|
+
ifSomeAsync: k,
|
|
236
|
+
isNone: d,
|
|
237
|
+
isSome: n,
|
|
238
|
+
map: B,
|
|
239
|
+
mapAll: J,
|
|
240
|
+
mapAllAsync: st,
|
|
241
|
+
mapAsync: $,
|
|
242
|
+
mapIf: K,
|
|
243
|
+
mapIfAsync: g,
|
|
244
|
+
match: m,
|
|
245
|
+
matchAsync: N,
|
|
246
|
+
or: W,
|
|
247
|
+
orElse: q,
|
|
248
|
+
orElseAsync: nt,
|
|
249
|
+
partition: L,
|
|
250
|
+
partitionAsync: dt,
|
|
251
|
+
peek: v,
|
|
252
|
+
peekAsync: T,
|
|
253
|
+
peekBoth: _,
|
|
254
|
+
peekBothAsync: x,
|
|
255
|
+
peekNone: S,
|
|
256
|
+
peekNoneAsync: j,
|
|
257
|
+
reduce: V,
|
|
258
|
+
reduceAsync: at,
|
|
259
|
+
scan: X,
|
|
260
|
+
scanAsync: wt,
|
|
261
|
+
toArray: b,
|
|
262
|
+
toNullable: I,
|
|
263
|
+
toResult: p,
|
|
264
|
+
transpose: y,
|
|
265
|
+
zip: E,
|
|
266
|
+
zipAsync: rt,
|
|
267
|
+
zipWith: G
|
|
268
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
269
|
+
export {
|
|
270
|
+
f as None,
|
|
271
|
+
a as Some,
|
|
272
|
+
ht as _,
|
|
273
|
+
H as all,
|
|
274
|
+
ct as allAsync,
|
|
275
|
+
R as and,
|
|
276
|
+
M as andThen,
|
|
277
|
+
tt as andThenAsync,
|
|
278
|
+
O as ap,
|
|
279
|
+
Z as apAsync,
|
|
280
|
+
Q as collectSomes,
|
|
281
|
+
ut as collectSomesAsync,
|
|
282
|
+
D as contains,
|
|
283
|
+
F as filter,
|
|
284
|
+
ot as filterAsync,
|
|
285
|
+
U as firstSome,
|
|
286
|
+
ft as firstSomeAsync,
|
|
287
|
+
C as fold,
|
|
288
|
+
et as foldAsync,
|
|
289
|
+
Y as folds,
|
|
290
|
+
i as fromFalsy,
|
|
291
|
+
h as fromNullable,
|
|
292
|
+
P as ifNone,
|
|
293
|
+
z as ifNoneAsync,
|
|
294
|
+
l as ifSome,
|
|
295
|
+
k as ifSomeAsync,
|
|
296
|
+
d as isNone,
|
|
297
|
+
n as isSome,
|
|
298
|
+
B as map,
|
|
299
|
+
J as mapAll,
|
|
300
|
+
st as mapAllAsync,
|
|
301
|
+
$ as mapAsync,
|
|
302
|
+
K as mapIf,
|
|
303
|
+
g as mapIfAsync,
|
|
304
|
+
m as match,
|
|
305
|
+
N as matchAsync,
|
|
306
|
+
W as or,
|
|
307
|
+
q as orElse,
|
|
308
|
+
nt as orElseAsync,
|
|
309
|
+
L as partition,
|
|
310
|
+
dt as partitionAsync,
|
|
311
|
+
v as peek,
|
|
312
|
+
T as peekAsync,
|
|
313
|
+
_ as peekBoth,
|
|
314
|
+
x as peekBothAsync,
|
|
315
|
+
S as peekNone,
|
|
316
|
+
j as peekNoneAsync,
|
|
317
|
+
V as reduce,
|
|
318
|
+
at as reduceAsync,
|
|
319
|
+
X as scan,
|
|
320
|
+
wt as scanAsync,
|
|
321
|
+
b as toArray,
|
|
322
|
+
I as toNullable,
|
|
323
|
+
p as toResult,
|
|
324
|
+
y as transpose,
|
|
325
|
+
E as zip,
|
|
326
|
+
rt as zipAsync,
|
|
327
|
+
G as zipWith
|
|
328
|
+
};
|
|
329
|
+
//# sourceMappingURL=Maybe.mjs.map
|