@e280/stz 0.3.2 → 0.3.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/README.md +4 -4
- package/package.json +1 -1
- package/s/dig/test.ts +2 -2
- package/s/ok/fns/{need.ts → got.ts} +8 -2
- package/s/ok/index.ts +1 -1
- package/s/ok/test.ts +18 -18
- package/x/dig/test.js +2 -2
- package/x/dig/test.js.map +1 -1
- package/x/ok/fns/got.d.ts +9 -0
- package/x/ok/fns/{need.js → got.js} +7 -3
- package/x/ok/fns/got.js.map +1 -0
- package/x/ok/index.d.ts +1 -1
- package/x/ok/index.js +1 -1
- package/x/ok/index.js.map +1 -1
- package/x/ok/test.d.ts +3 -3
- package/x/ok/test.js +18 -18
- package/x/ok/test.js.map +1 -1
- package/x/ok/fns/need.d.ts +0 -5
- package/x/ok/fns/need.js.map +0 -1
package/README.md
CHANGED
|
@@ -344,15 +344,15 @@ rust-inspired pattern for explicit error handling instead of the usual js yolo v
|
|
|
344
344
|
// undefined
|
|
345
345
|
```
|
|
346
346
|
- there is also `getErr(result)`
|
|
347
|
-
- `
|
|
347
|
+
- `gotOk(result)` — get the value, or throw
|
|
348
348
|
```ts
|
|
349
|
-
|
|
349
|
+
gotOk(ok(123))
|
|
350
350
|
// 123
|
|
351
351
|
|
|
352
|
-
|
|
352
|
+
gotOk(err("containment lost"))
|
|
353
353
|
// throws Error("containment lost")
|
|
354
354
|
```
|
|
355
|
-
- there is also `
|
|
355
|
+
- there is also `gotErr(result)`
|
|
356
356
|
|
|
357
357
|
|
|
358
358
|
|
package/package.json
CHANGED
package/s/dig/test.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
|
|
2
2
|
import {suite, expect, assert} from "@e280/science"
|
|
3
3
|
import {dig} from "./dig.js"
|
|
4
|
-
import {
|
|
4
|
+
import {gotOk} from "../ok/index.js"
|
|
5
5
|
|
|
6
6
|
const check = (t: any, path: (string | number)[]) => ({
|
|
7
7
|
ok: (value: any) => async() => {
|
|
8
8
|
const result = dig(t, path)
|
|
9
|
-
expect(
|
|
9
|
+
expect(gotOk(result)).is(value)
|
|
10
10
|
},
|
|
11
11
|
err: (e: any) => async() => {
|
|
12
12
|
const result = dig(t, path)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type {Result} from "../types/result.js"
|
|
3
3
|
|
|
4
4
|
/** return ok value, otherwise throw error */
|
|
5
|
-
export function
|
|
5
|
+
export function gotOk<Value, E>(result: Result<Value, E>): Value {
|
|
6
6
|
if (result.ok)
|
|
7
7
|
return result.value
|
|
8
8
|
|
|
@@ -19,8 +19,14 @@ export function needOk<Value, E>(result: Result<Value, E>): Value {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
/** return error, otherwise throw error */
|
|
22
|
-
export function
|
|
22
|
+
export function gotErr<E>(result: Result<unknown, E>): E {
|
|
23
23
|
if (result.ok) throw new Error("didn't get needed error")
|
|
24
24
|
return result.error
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
/** @deprecated renamed to `gotOk` */
|
|
28
|
+
export const needOk = gotOk
|
|
29
|
+
|
|
30
|
+
/** @deprecated renamed to `gotErr` */
|
|
31
|
+
export const needErr = gotErr
|
|
32
|
+
|
package/s/ok/index.ts
CHANGED
package/s/ok/test.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import {expect, suite, test} from "@e280/science"
|
|
3
3
|
import {thrown} from "../thrown.js"
|
|
4
|
-
import {ok, err, getOk,
|
|
4
|
+
import {ok, err, getOk, gotOk, gotErr, getErr, resultify, Err, resultifyAsync} from "./index.js"
|
|
5
5
|
|
|
6
6
|
export default suite({
|
|
7
7
|
"ok": test(async() => {
|
|
@@ -26,43 +26,43 @@ export default suite({
|
|
|
26
26
|
expect(getErr(ok(123))).is(undefined)
|
|
27
27
|
}),
|
|
28
28
|
|
|
29
|
-
"
|
|
30
|
-
expect(
|
|
31
|
-
expect(() =>
|
|
29
|
+
"gotOk": test(async() => {
|
|
30
|
+
expect(gotOk(ok(123))).is(123)
|
|
31
|
+
expect(() => gotOk(err("nope"))).throws()
|
|
32
32
|
}),
|
|
33
33
|
|
|
34
|
-
"
|
|
35
|
-
expect(
|
|
36
|
-
expect(() =>
|
|
34
|
+
"gotErr": test(async() => {
|
|
35
|
+
expect(gotErr(err("nope"))).is("nope")
|
|
36
|
+
expect(() => gotErr(ok(123))).throws()
|
|
37
37
|
}),
|
|
38
38
|
|
|
39
39
|
"resultify": test(async() => {
|
|
40
|
-
expect(
|
|
40
|
+
expect(gotOk(resultify(() => 123)())).is(123)
|
|
41
41
|
expect(resultify(() => {throw new Error("rofl")})().ok).is(false)
|
|
42
|
-
expect(
|
|
42
|
+
expect(gotErr(resultify(() => {throw new Error("rofl")})() as Err<Error>).message).is("rofl")
|
|
43
43
|
}),
|
|
44
44
|
|
|
45
45
|
"resultifyAsync": test(async() => {
|
|
46
|
-
expect(
|
|
46
|
+
expect(gotOk(await resultifyAsync(async() => 123)())).is(123)
|
|
47
47
|
expect((await resultifyAsync(async() => {throw new Error("rofl")})()).ok).is(false)
|
|
48
|
-
expect(
|
|
48
|
+
expect(gotErr(await resultifyAsync(async() => {throw new Error("rofl")})() as Err<Error>).message).is("rofl")
|
|
49
49
|
}),
|
|
50
50
|
|
|
51
|
-
"
|
|
51
|
+
"gotOk error handling": {
|
|
52
52
|
"rethrows errors": test(async() => {
|
|
53
53
|
const error = new TypeError()
|
|
54
|
-
expect(() =>
|
|
55
|
-
expect(thrown(() =>
|
|
54
|
+
expect(() => gotOk(err(error))).throws(TypeError)
|
|
55
|
+
expect(thrown(() => gotOk(err(error)))).is(error)
|
|
56
56
|
}),
|
|
57
57
|
|
|
58
58
|
"upgrades strings to errors": test(async() => {
|
|
59
|
-
expect(() =>
|
|
60
|
-
expect(thrown(() =>
|
|
59
|
+
expect(() => gotOk(err("nope"))).throws(Error)
|
|
60
|
+
expect(thrown(() => gotOk(err("nope"))).message).is("nope")
|
|
61
61
|
}),
|
|
62
62
|
|
|
63
63
|
"everything else is unknown": test(async() => {
|
|
64
|
-
expect(() =>
|
|
65
|
-
expect(thrown(() =>
|
|
64
|
+
expect(() => gotOk(err({code: 234}))).throws(Error)
|
|
65
|
+
expect(thrown(() => gotOk(err({code: 234}))).message).is("unknown")
|
|
66
66
|
}),
|
|
67
67
|
},
|
|
68
68
|
})
|
package/x/dig/test.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { suite, expect, assert } from "@e280/science";
|
|
2
2
|
import { dig } from "./dig.js";
|
|
3
|
-
import {
|
|
3
|
+
import { gotOk } from "../ok/index.js";
|
|
4
4
|
const check = (t, path) => ({
|
|
5
5
|
ok: (value) => async () => {
|
|
6
6
|
const result = dig(t, path);
|
|
7
|
-
expect(
|
|
7
|
+
expect(gotOk(result)).is(value);
|
|
8
8
|
},
|
|
9
9
|
err: (e) => async () => {
|
|
10
10
|
const result = dig(t, path);
|
package/x/dig/test.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test.js","sourceRoot":"","sources":["../../s/dig/test.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAC,MAAM,eAAe,CAAA;AACnD,OAAO,EAAC,GAAG,EAAC,MAAM,UAAU,CAAA;AAC5B,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"test.js","sourceRoot":"","sources":["../../s/dig/test.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAC,MAAM,eAAe,CAAA;AACnD,OAAO,EAAC,GAAG,EAAC,MAAM,UAAU,CAAA;AAC5B,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAA;AAEpC,MAAM,KAAK,GAAG,CAAC,CAAM,EAAE,IAAyB,EAAE,EAAE,CAAC,CAAC;IACrD,EAAE,EAAE,CAAC,KAAU,EAAE,EAAE,CAAC,KAAK,IAAG,E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C;IAExB,2BAA2B,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,GAAG,CAAC,CAAC;SAClD,GAAG,CAAC,iBAAiB,CAAC;IAExB,uBAAuB,EAAE,KAAK,CAAC,EAAC,CAAC,EAAE,CAAC,EAAC,EAAE,CAAC,GAAG,CAAC,CAAC;SAC3C,GAAG,CAAC,WAAW,CAAC;IAElB,uBAAuB,EAAE,KAAK,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;SAC7C,GAAG,CAAC,WAAW,CAAC;IAElB,wBAAwB,EAAE,KAAK,CAAC,EAAC,CAAC,EAAE,CAAC,EAAC,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;SACjD,GAAG,CAAC,iBAAiB,CAAC;IAExB,kBAAkB,EAAE,KAAK,CAAC,EAAC,CAAC,EAAE,EAAE,EAAC,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;SAC5C,GAAG,CAAC,WAAW,CAAC;CAClB,CAAC,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Result } from "../types/result.js";
|
|
2
|
+
/** return ok value, otherwise throw error */
|
|
3
|
+
export declare function gotOk<Value, E>(result: Result<Value, E>): Value;
|
|
4
|
+
/** return error, otherwise throw error */
|
|
5
|
+
export declare function gotErr<E>(result: Result<unknown, E>): E;
|
|
6
|
+
/** @deprecated renamed to `gotOk` */
|
|
7
|
+
export declare const needOk: typeof gotOk;
|
|
8
|
+
/** @deprecated renamed to `gotErr` */
|
|
9
|
+
export declare const needErr: typeof gotErr;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** return ok value, otherwise throw error */
|
|
2
|
-
export function
|
|
2
|
+
export function gotOk(result) {
|
|
3
3
|
if (result.ok)
|
|
4
4
|
return result.value;
|
|
5
5
|
const { error } = result;
|
|
@@ -11,9 +11,13 @@ export function needOk(result) {
|
|
|
11
11
|
throw new Error("unknown");
|
|
12
12
|
}
|
|
13
13
|
/** return error, otherwise throw error */
|
|
14
|
-
export function
|
|
14
|
+
export function gotErr(result) {
|
|
15
15
|
if (result.ok)
|
|
16
16
|
throw new Error("didn't get needed error");
|
|
17
17
|
return result.error;
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
/** @deprecated renamed to `gotOk` */
|
|
20
|
+
export const needOk = gotOk;
|
|
21
|
+
/** @deprecated renamed to `gotErr` */
|
|
22
|
+
export const needErr = gotErr;
|
|
23
|
+
//# sourceMappingURL=got.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"got.js","sourceRoot":"","sources":["../../../s/ok/fns/got.ts"],"names":[],"mappings":"AAGA,6CAA6C;AAC7C,MAAM,UAAU,KAAK,CAAW,MAAwB;IACvD,IAAI,MAAM,CAAC,EAAE;QACZ,OAAO,MAAM,CAAC,KAAK,CAAA;IAEpB,MAAM,EAAC,KAAK,EAAC,GAAG,MAAM,CAAA;IAEtB,IAAI,KAAK,YAAY,KAAK;QACzB,MAAM,KAAK,CAAA;SAEP,IAAI,OAAO,KAAK,KAAK,QAAQ;QACjC,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAA;;QAGtB,MAAM,IAAI,KAAK,CAAC,SAAS,CAAC,CAAA;AAC5B,CAAC;AAED,0CAA0C;AAC1C,MAAM,UAAU,MAAM,CAAI,MAA0B;IACnD,IAAI,MAAM,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;IACzD,OAAO,MAAM,CAAC,KAAK,CAAA;AACpB,CAAC;AAED,qCAAqC;AACrC,MAAM,CAAC,MAAM,MAAM,GAAG,KAAK,CAAA;AAE3B,sCAAsC;AACtC,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAA"}
|
package/x/ok/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export * from "./fns/attempt.js";
|
|
|
2
2
|
export * from "./fns/ok.js";
|
|
3
3
|
export * from "./fns/err.js";
|
|
4
4
|
export * from "./fns/get.js";
|
|
5
|
-
export * from "./fns/
|
|
5
|
+
export * from "./fns/got.js";
|
|
6
6
|
export * from "./types/ok.js";
|
|
7
7
|
export * from "./types/err.js";
|
|
8
8
|
export * from "./types/result.js";
|
package/x/ok/index.js
CHANGED
|
@@ -2,7 +2,7 @@ export * from "./fns/attempt.js";
|
|
|
2
2
|
export * from "./fns/ok.js";
|
|
3
3
|
export * from "./fns/err.js";
|
|
4
4
|
export * from "./fns/get.js";
|
|
5
|
-
export * from "./fns/
|
|
5
|
+
export * from "./fns/got.js";
|
|
6
6
|
export * from "./types/ok.js";
|
|
7
7
|
export * from "./types/err.js";
|
|
8
8
|
export * from "./types/result.js";
|
package/x/ok/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../s/ok/index.ts"],"names":[],"mappings":"AACA,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../s/ok/index.ts"],"names":[],"mappings":"AACA,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAE5B,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA"}
|
package/x/ok/test.d.ts
CHANGED
|
@@ -3,11 +3,11 @@ declare const _default: {
|
|
|
3
3
|
err: import("@e280/science").Test;
|
|
4
4
|
getOk: import("@e280/science").Test;
|
|
5
5
|
getErr: import("@e280/science").Test;
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
gotOk: import("@e280/science").Test;
|
|
7
|
+
gotErr: import("@e280/science").Test;
|
|
8
8
|
resultify: import("@e280/science").Test;
|
|
9
9
|
resultifyAsync: import("@e280/science").Test;
|
|
10
|
-
"
|
|
10
|
+
"gotOk error handling": {
|
|
11
11
|
"rethrows errors": import("@e280/science").Test;
|
|
12
12
|
"upgrades strings to errors": import("@e280/science").Test;
|
|
13
13
|
"everything else is unknown": import("@e280/science").Test;
|
package/x/ok/test.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { expect, suite, test } from "@e280/science";
|
|
2
2
|
import { thrown } from "../thrown.js";
|
|
3
|
-
import { ok, err, getOk,
|
|
3
|
+
import { ok, err, getOk, gotOk, gotErr, getErr, resultify, resultifyAsync } from "./index.js";
|
|
4
4
|
export default suite({
|
|
5
5
|
"ok": test(async () => {
|
|
6
6
|
expect(ok(123).ok).is(true);
|
|
@@ -20,37 +20,37 @@ export default suite({
|
|
|
20
20
|
expect(getErr(err("nope"))).is("nope");
|
|
21
21
|
expect(getErr(ok(123))).is(undefined);
|
|
22
22
|
}),
|
|
23
|
-
"
|
|
24
|
-
expect(
|
|
25
|
-
expect(() =>
|
|
23
|
+
"gotOk": test(async () => {
|
|
24
|
+
expect(gotOk(ok(123))).is(123);
|
|
25
|
+
expect(() => gotOk(err("nope"))).throws();
|
|
26
26
|
}),
|
|
27
|
-
"
|
|
28
|
-
expect(
|
|
29
|
-
expect(() =>
|
|
27
|
+
"gotErr": test(async () => {
|
|
28
|
+
expect(gotErr(err("nope"))).is("nope");
|
|
29
|
+
expect(() => gotErr(ok(123))).throws();
|
|
30
30
|
}),
|
|
31
31
|
"resultify": test(async () => {
|
|
32
|
-
expect(
|
|
32
|
+
expect(gotOk(resultify(() => 123)())).is(123);
|
|
33
33
|
expect(resultify(() => { throw new Error("rofl"); })().ok).is(false);
|
|
34
|
-
expect(
|
|
34
|
+
expect(gotErr(resultify(() => { throw new Error("rofl"); })()).message).is("rofl");
|
|
35
35
|
}),
|
|
36
36
|
"resultifyAsync": test(async () => {
|
|
37
|
-
expect(
|
|
37
|
+
expect(gotOk(await resultifyAsync(async () => 123)())).is(123);
|
|
38
38
|
expect((await resultifyAsync(async () => { throw new Error("rofl"); })()).ok).is(false);
|
|
39
|
-
expect(
|
|
39
|
+
expect(gotErr(await resultifyAsync(async () => { throw new Error("rofl"); })()).message).is("rofl");
|
|
40
40
|
}),
|
|
41
|
-
"
|
|
41
|
+
"gotOk error handling": {
|
|
42
42
|
"rethrows errors": test(async () => {
|
|
43
43
|
const error = new TypeError();
|
|
44
|
-
expect(() =>
|
|
45
|
-
expect(thrown(() =>
|
|
44
|
+
expect(() => gotOk(err(error))).throws(TypeError);
|
|
45
|
+
expect(thrown(() => gotOk(err(error)))).is(error);
|
|
46
46
|
}),
|
|
47
47
|
"upgrades strings to errors": test(async () => {
|
|
48
|
-
expect(() =>
|
|
49
|
-
expect(thrown(() =>
|
|
48
|
+
expect(() => gotOk(err("nope"))).throws(Error);
|
|
49
|
+
expect(thrown(() => gotOk(err("nope"))).message).is("nope");
|
|
50
50
|
}),
|
|
51
51
|
"everything else is unknown": test(async () => {
|
|
52
|
-
expect(() =>
|
|
53
|
-
expect(thrown(() =>
|
|
52
|
+
expect(() => gotOk(err({ code: 234 }))).throws(Error);
|
|
53
|
+
expect(thrown(() => gotOk(err({ code: 234 }))).message).is("unknown");
|
|
54
54
|
}),
|
|
55
55
|
},
|
|
56
56
|
});
|
package/x/ok/test.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test.js","sourceRoot":"","sources":["../../s/ok/test.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAC,MAAM,eAAe,CAAA;AACjD,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAA;AACnC,OAAO,EAAC,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"test.js","sourceRoot":"","sources":["../../s/ok/test.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAC,MAAM,eAAe,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AC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;YAC9C,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAA;QAC5D,CAAC,CAAC;QAEF,4BAA4B,EAAE,IAAI,CAAC,KAAK,IAAG,EAAE;YAC5C,MAAM,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,EAAC,IAAI,EAAE,GAAG,EAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;YACnD,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,EAAC,IAAI,EAAE,GAAG,EAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,CAAA;QACpE,CAAC,CAAC;KACF;CACD,CAAC,CAAA"}
|
package/x/ok/fns/need.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { Result } from "../types/result.js";
|
|
2
|
-
/** return ok value, otherwise throw error */
|
|
3
|
-
export declare function needOk<Value, E>(result: Result<Value, E>): Value;
|
|
4
|
-
/** return error, otherwise throw error */
|
|
5
|
-
export declare function needErr<E>(result: Result<unknown, E>): E;
|
package/x/ok/fns/need.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"need.js","sourceRoot":"","sources":["../../../s/ok/fns/need.ts"],"names":[],"mappings":"AAGA,6CAA6C;AAC7C,MAAM,UAAU,MAAM,CAAW,MAAwB;IACxD,IAAI,MAAM,CAAC,EAAE;QACZ,OAAO,MAAM,CAAC,KAAK,CAAA;IAEpB,MAAM,EAAC,KAAK,EAAC,GAAG,MAAM,CAAA;IAEtB,IAAI,KAAK,YAAY,KAAK;QACzB,MAAM,KAAK,CAAA;SAEP,IAAI,OAAO,KAAK,KAAK,QAAQ;QACjC,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAA;;QAGtB,MAAM,IAAI,KAAK,CAAC,SAAS,CAAC,CAAA;AAC5B,CAAC;AAED,0CAA0C;AAC1C,MAAM,UAAU,OAAO,CAAI,MAA0B;IACpD,IAAI,MAAM,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;IACzD,OAAO,MAAM,CAAC,KAAK,CAAA;AACpB,CAAC"}
|