@vanyamate/sec 0.3.1-batch-beta.1 → 0.3.1-batch-beta.3
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/index.cjs +1 -1
- package/dist/index.js +62 -73
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let d=0,A=new Map;const S=()=>d+=1,k=()=>{d-=1,m()&&B()},m=()=>d==0,p=(o,n)=>{S(),A.set(o,n),queueMicrotask(k)},B=()=>{A.forEach(o=>o()),A.clear()},a=function(o,n){o&&n()},w=function(o,n={enabled:!0,instantListenerExecution:!1}){const c=new Set;let l=o,{enabled:s=!0,instantListenerExecution:f=!1}=n;const e={on:(r,t,i)=>(t==="onBefore"?r.onBefore((...u)=>a(s,()=>e.set(i(o,{args:u})))):t==="onSuccess"?r.onSuccess((u,...b)=>a(s,()=>e.set(i(o,{result:u,args:b})))):t==="onError"?r.onError((u,...b)=>a(s,()=>e.set(i(o,{error:u,args:b})))):r.onFinally((...u)=>a(s,()=>e.set(i(o,{args:u})))),e),get(){return o},set(r){o=r,p(this,()=>{l!=o&&(l=o,c.forEach(t=>t(o)))})},subscribe(r){return c.add(r),f&&r(o),()=>c.delete(r)},enableOn(r,t){return r.subscribe(()=>{s=!0,t!==void 0&&e.set(t)}),e},disableOn(r,t){return r.subscribe(()=>{s=!1,t!==void 0&&e.set(t)}),e}};return e},h=function(){return{afterAll:[],beforeAll:[],other:[]}},y=function(o){const n=h(),c=h(),l=h(),s=h(),f=async function(...e){return n.beforeAll.forEach(r=>r(...e)),n.other.forEach(r=>r(...e)),n.afterAll.forEach(r=>r(...e)),o(...e).then(r=>(c.beforeAll.forEach(t=>t(r,...e)),c.other.forEach(t=>t(r,...e)),c.afterAll.forEach(t=>t(r,...e)),r)).catch(r=>{throw l.beforeAll.forEach(t=>t(r,...e)),l.other.forEach(t=>t(r,...e)),l.afterAll.forEach(t=>t(r,...e)),r}).finally(()=>{s.beforeAll.forEach(r=>r(...e)),s.other.forEach(r=>r(...e)),s.afterAll.forEach(r=>r(...e))})};return f.onBefore=(e,r)=>{switch(r){case"beforeAll":n.beforeAll.push(e);break;case"afterAll":n.afterAll.push(e);break;default:n.other.push(e)}},f.onSuccess=(e,r)=>{switch(r){case"beforeAll":c.beforeAll.push(e);break;case"afterAll":c.afterAll.push(e);break;default:c.other.push(e)}},f.onError=(e,r)=>{switch(r){case"beforeAll":l.beforeAll.push(e);break;case"afterAll":l.afterAll.push(e);break;default:l.other.push(e)}},f.onFinally=(e,r)=>{switch(r){case"beforeAll":s.beforeAll.push(e);break;case"afterAll":s.afterAll.push(e);break;default:s.other.push(e)}},f},C=function(o,n,c=!0){let l=n(o);const s=new Set;o.forEach(e=>{e.subscribe(()=>{a(c,()=>{p(f,()=>{l=n(o),s.forEach(r=>r(l))})})})});const f={on:()=>{throw new Error("Cannot call 'on' on combined store")},get(){return l},set(){throw new Error("Cannot call 'set' on combined store")},subscribe(e){return s.add(e),e(l),()=>s.delete(e)},enableOn(e){return e.subscribe(()=>c=!0),f},disableOn(e){return e.subscribe(()=>c=!1),f}};return f},F=function(o){const n=[],c={on:(l,s)=>(l==="onBefore"?s.onBefore(()=>n.forEach(f=>f()),o):l==="onSuccess"?s.onSuccess(()=>n.forEach(f=>f()),o):l==="onError"?s.onError(()=>n.forEach(f=>f()),o):s.onFinally(()=>n.forEach(f=>f()),o),c),subscribe:l=>{n.push(l)}};return c},E=function(o){return()=>o},O=function(o){const n=w(!1);return o.forEach(c=>{n.on(c,"onBefore",E(!0)),n.on(c,"onFinally",E(!1))}),n},L=function(){return(o,{result:n})=>n};exports.combine=C;exports.effect=y;exports.enableCheck=a;exports.marker=F;exports.pending=O;exports.result=L;exports.store=w;exports.to=E;
|
package/dist/index.js
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
let
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
},
|
|
5
|
-
|
|
6
|
-
},
|
|
1
|
+
let E = 0, A = /* @__PURE__ */ new Map();
|
|
2
|
+
const w = () => E += 1, B = () => {
|
|
3
|
+
E -= 1, S() && k();
|
|
4
|
+
}, S = () => E == 0, d = (o, n) => {
|
|
5
|
+
w(), A.set(o, n), queueMicrotask(B);
|
|
6
|
+
}, k = () => {
|
|
7
7
|
A.forEach((o) => o()), A.clear();
|
|
8
|
-
},
|
|
8
|
+
}, a = function(o, n) {
|
|
9
9
|
o && n();
|
|
10
|
-
},
|
|
10
|
+
}, C = function(o, n = { enabled: !0, instantListenerExecution: !1 }) {
|
|
11
11
|
const c = /* @__PURE__ */ new Set();
|
|
12
|
-
let l, { enabled:
|
|
12
|
+
let l = o, { enabled: s = !0, instantListenerExecution: f = !1 } = n;
|
|
13
13
|
const e = {
|
|
14
|
-
on: (r,
|
|
15
|
-
(...u) =>
|
|
16
|
-
|
|
14
|
+
on: (r, t, h) => (t === "onBefore" ? r.onBefore(
|
|
15
|
+
(...u) => a(
|
|
16
|
+
s,
|
|
17
17
|
() => e.set(
|
|
18
|
-
|
|
18
|
+
h(o, { args: u })
|
|
19
19
|
)
|
|
20
20
|
)
|
|
21
|
-
) :
|
|
22
|
-
(u, ...b) =>
|
|
23
|
-
|
|
21
|
+
) : t === "onSuccess" ? r.onSuccess(
|
|
22
|
+
(u, ...b) => a(
|
|
23
|
+
s,
|
|
24
24
|
() => e.set(
|
|
25
|
-
|
|
25
|
+
h(o, {
|
|
26
26
|
result: u,
|
|
27
27
|
args: b
|
|
28
28
|
})
|
|
29
29
|
)
|
|
30
30
|
)
|
|
31
|
-
) :
|
|
32
|
-
(u, ...b) =>
|
|
33
|
-
|
|
31
|
+
) : t === "onError" ? r.onError(
|
|
32
|
+
(u, ...b) => a(
|
|
33
|
+
s,
|
|
34
34
|
() => e.set(
|
|
35
|
-
|
|
35
|
+
h(o, {
|
|
36
36
|
error: u,
|
|
37
37
|
args: b
|
|
38
38
|
})
|
|
39
39
|
)
|
|
40
40
|
)
|
|
41
41
|
) : r.onFinally(
|
|
42
|
-
(...u) =>
|
|
43
|
-
|
|
42
|
+
(...u) => a(
|
|
43
|
+
s,
|
|
44
44
|
() => e.set(
|
|
45
|
-
|
|
45
|
+
h(o, { args: u })
|
|
46
46
|
)
|
|
47
47
|
)
|
|
48
48
|
), e),
|
|
@@ -50,47 +50,38 @@ const E = () => d += 1, p = () => {
|
|
|
50
50
|
return o;
|
|
51
51
|
},
|
|
52
52
|
set(r) {
|
|
53
|
-
o = r,
|
|
54
|
-
l != o && (l = o, c.forEach((
|
|
55
|
-
}
|
|
53
|
+
o = r, d(this, () => {
|
|
54
|
+
l != o && (l = o, c.forEach((t) => t(o)));
|
|
55
|
+
});
|
|
56
56
|
},
|
|
57
57
|
subscribe(r) {
|
|
58
58
|
return c.add(r), f && r(o), () => c.delete(r);
|
|
59
59
|
},
|
|
60
|
-
enableOn(r,
|
|
60
|
+
enableOn(r, t) {
|
|
61
61
|
return r.subscribe(() => {
|
|
62
|
-
|
|
63
|
-
p(), e.set(s);
|
|
64
|
-
}));
|
|
62
|
+
s = !0, t !== void 0 && e.set(t);
|
|
65
63
|
}), e;
|
|
66
64
|
},
|
|
67
|
-
disableOn(r,
|
|
65
|
+
disableOn(r, t) {
|
|
68
66
|
return r.subscribe(() => {
|
|
69
|
-
|
|
70
|
-
p(), e.set(s);
|
|
71
|
-
}));
|
|
67
|
+
s = !1, t !== void 0 && e.set(t);
|
|
72
68
|
}), e;
|
|
73
69
|
}
|
|
74
70
|
};
|
|
75
71
|
return e;
|
|
76
|
-
},
|
|
72
|
+
}, i = function() {
|
|
77
73
|
return {
|
|
78
74
|
afterAll: [],
|
|
79
75
|
beforeAll: [],
|
|
80
76
|
other: []
|
|
81
77
|
};
|
|
82
78
|
}, m = function(o) {
|
|
83
|
-
const n =
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
t.beforeAll.forEach((r) => r(...e)), t.other.forEach((r) => r(...e)), t.afterAll.forEach((r) => r(...e));
|
|
90
|
-
});
|
|
91
|
-
} finally {
|
|
92
|
-
p();
|
|
93
|
-
}
|
|
79
|
+
const n = i(), c = i(), l = i(), s = i(), f = async function(...e) {
|
|
80
|
+
return n.beforeAll.forEach((r) => r(...e)), n.other.forEach((r) => r(...e)), n.afterAll.forEach((r) => r(...e)), o(...e).then((r) => (c.beforeAll.forEach((t) => t(r, ...e)), c.other.forEach((t) => t(r, ...e)), c.afterAll.forEach((t) => t(r, ...e)), r)).catch((r) => {
|
|
81
|
+
throw l.beforeAll.forEach((t) => t(r, ...e)), l.other.forEach((t) => t(r, ...e)), l.afterAll.forEach((t) => t(r, ...e)), r;
|
|
82
|
+
}).finally(() => {
|
|
83
|
+
s.beforeAll.forEach((r) => r(...e)), s.other.forEach((r) => r(...e)), s.afterAll.forEach((r) => r(...e));
|
|
84
|
+
});
|
|
94
85
|
};
|
|
95
86
|
return f.onBefore = (e, r) => {
|
|
96
87
|
switch (r) {
|
|
@@ -128,23 +119,24 @@ const E = () => d += 1, p = () => {
|
|
|
128
119
|
}, f.onFinally = (e, r) => {
|
|
129
120
|
switch (r) {
|
|
130
121
|
case "beforeAll":
|
|
131
|
-
|
|
122
|
+
s.beforeAll.push(e);
|
|
132
123
|
break;
|
|
133
124
|
case "afterAll":
|
|
134
|
-
|
|
125
|
+
s.afterAll.push(e);
|
|
135
126
|
break;
|
|
136
127
|
default:
|
|
137
|
-
|
|
128
|
+
s.other.push(e);
|
|
138
129
|
}
|
|
139
130
|
}, f;
|
|
140
|
-
},
|
|
141
|
-
console.log("Combine", o, n, c);
|
|
131
|
+
}, y = function(o, n, c = !0) {
|
|
142
132
|
let l = n(o);
|
|
143
|
-
const
|
|
133
|
+
const s = /* @__PURE__ */ new Set();
|
|
144
134
|
o.forEach((e) => {
|
|
145
135
|
e.subscribe(() => {
|
|
146
|
-
|
|
147
|
-
|
|
136
|
+
a(c, () => {
|
|
137
|
+
d(f, () => {
|
|
138
|
+
l = n(o), s.forEach((r) => r(l));
|
|
139
|
+
});
|
|
148
140
|
});
|
|
149
141
|
});
|
|
150
142
|
});
|
|
@@ -159,10 +151,7 @@ const E = () => d += 1, p = () => {
|
|
|
159
151
|
throw new Error("Cannot call 'set' on combined store");
|
|
160
152
|
},
|
|
161
153
|
subscribe(e) {
|
|
162
|
-
return
|
|
163
|
-
const r = t.indexOf(e);
|
|
164
|
-
~r && t.splice(r, 1);
|
|
165
|
-
};
|
|
154
|
+
return s.add(e), e(l), () => s.delete(e);
|
|
166
155
|
},
|
|
167
156
|
enableOn(e) {
|
|
168
157
|
return e.subscribe(() => c = !0), f;
|
|
@@ -172,31 +161,31 @@ const E = () => d += 1, p = () => {
|
|
|
172
161
|
}
|
|
173
162
|
};
|
|
174
163
|
return f;
|
|
175
|
-
},
|
|
164
|
+
}, F = function(o) {
|
|
176
165
|
const n = [], c = {
|
|
177
|
-
on: (l,
|
|
166
|
+
on: (l, s) => (l === "onBefore" ? s.onBefore(() => n.forEach((f) => f()), o) : l === "onSuccess" ? s.onSuccess(() => n.forEach((f) => f()), o) : l === "onError" ? s.onError(() => n.forEach((f) => f()), o) : s.onFinally(() => n.forEach((f) => f()), o), c),
|
|
178
167
|
subscribe: (l) => {
|
|
179
168
|
n.push(l);
|
|
180
169
|
}
|
|
181
170
|
};
|
|
182
171
|
return c;
|
|
183
|
-
},
|
|
172
|
+
}, p = function(o) {
|
|
184
173
|
return () => o;
|
|
185
|
-
},
|
|
186
|
-
const n =
|
|
174
|
+
}, x = function(o) {
|
|
175
|
+
const n = C(!1);
|
|
187
176
|
return o.forEach((c) => {
|
|
188
|
-
n.on(c, "onBefore",
|
|
177
|
+
n.on(c, "onBefore", p(!0)), n.on(c, "onFinally", p(!1));
|
|
189
178
|
}), n;
|
|
190
|
-
},
|
|
179
|
+
}, L = function() {
|
|
191
180
|
return (o, { result: n }) => n;
|
|
192
181
|
};
|
|
193
182
|
export {
|
|
194
|
-
|
|
183
|
+
y as combine,
|
|
195
184
|
m as effect,
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
185
|
+
a as enableCheck,
|
|
186
|
+
F as marker,
|
|
187
|
+
x as pending,
|
|
188
|
+
L as result,
|
|
189
|
+
C as store,
|
|
190
|
+
p as to
|
|
202
191
|
};
|