@adviser/cement 0.0.3 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- package/index.d.ts +2 -0
- package/index.d.ts.map +1 -1
- package/index.js +2 -0
- package/index.js.map +1 -1
- package/option.d.ts +25 -0
- package/option.d.ts.map +1 -0
- package/option.js +53 -0
- package/option.js.map +1 -0
- package/package.json +6 -6
- package/result.d.ts +31 -0
- package/result.d.ts.map +1 -0
- package/result.js +69 -0
- package/result.js.map +1 -0
- package/result.test.d.ts +2 -0
- package/result.test.d.ts.map +1 -0
- package/result.test.js +39 -0
- package/result.test.js.map +1 -0
package/index.d.ts
CHANGED
package/index.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,QAAQ,CAAC;AACvB,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,QAAQ,CAAC;AACvB,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC"}
|
package/index.js
CHANGED
@@ -24,4 +24,6 @@ __exportStar(require("./sys_abstraction"), exports);
|
|
24
24
|
__exportStar(require("./time"), exports);
|
25
25
|
__exportStar(require("./test/log_collector"), exports);
|
26
26
|
__exportStar(require("./test/mock_logger"), exports);
|
27
|
+
__exportStar(require("./result"), exports);
|
28
|
+
__exportStar(require("./option"), exports);
|
27
29
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,sDAAoC;AACpC,sDAAoC;AACpC,gDAA8B;AAC9B,2CAAyB;AACzB,yDAAuC;AACvC,oDAAkC;AAClC,yCAAuB;AACvB,uDAAqC;AACrC,qDAAmC"}
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,sDAAoC;AACpC,sDAAoC;AACpC,gDAA8B;AAC9B,2CAAyB;AACzB,yDAAuC;AACvC,oDAAkC;AAClC,yCAAuB;AACvB,uDAAqC;AACrC,qDAAmC;AACnC,2CAAyB;AACzB,2CAAyB"}
|
package/option.d.ts
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
export declare abstract class Option<T> {
|
2
|
+
static Some<T>(t: T): Option<T>;
|
3
|
+
static None<T>(): Option<T>;
|
4
|
+
static Is<T>(t: unknown): t is Option<T>;
|
5
|
+
IsNone(): boolean;
|
6
|
+
IsSome(): boolean;
|
7
|
+
Unwrap(): T;
|
8
|
+
abstract is_none(): boolean;
|
9
|
+
abstract is_some(): boolean;
|
10
|
+
abstract unwrap(): T;
|
11
|
+
}
|
12
|
+
export declare class Some<T> extends Option<T> {
|
13
|
+
private _t;
|
14
|
+
constructor(_t: T);
|
15
|
+
is_none(): boolean;
|
16
|
+
is_some(): boolean;
|
17
|
+
unwrap(): T;
|
18
|
+
}
|
19
|
+
export declare class None<T> extends Option<T> {
|
20
|
+
is_none(): boolean;
|
21
|
+
is_some(): boolean;
|
22
|
+
unwrap(): T;
|
23
|
+
}
|
24
|
+
export type WithoutOption<T> = T extends Option<infer U> ? U : T;
|
25
|
+
//# sourceMappingURL=option.d.ts.map
|
package/option.d.ts.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"option.d.ts","sourceRoot":"","sources":["../src/option.ts"],"names":[],"mappings":"AAAA,8BAAsB,MAAM,CAAC,CAAC;IAC5B,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;IAI/B,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC;IAI3B,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC;IAIxC,MAAM,IAAI,OAAO;IAIjB,MAAM,IAAI,OAAO;IAGjB,MAAM,IAAI,CAAC;IAIX,QAAQ,CAAC,OAAO,IAAI,OAAO;IAC3B,QAAQ,CAAC,OAAO,IAAI,OAAO;IAC3B,QAAQ,CAAC,MAAM,IAAI,CAAC;CACrB;AAED,qBAAa,IAAI,CAAC,CAAC,CAAE,SAAQ,MAAM,CAAC,CAAC,CAAC;IACpC,OAAO,CAAC,EAAE,CAAI;gBACF,EAAE,EAAE,CAAC;IAKjB,OAAO,IAAI,OAAO;IAGlB,OAAO,IAAI,OAAO;IAGlB,MAAM,IAAI,CAAC;CAGZ;AAED,qBAAa,IAAI,CAAC,CAAC,CAAE,SAAQ,MAAM,CAAC,CAAC,CAAC;IACpC,OAAO,IAAI,OAAO;IAGlB,OAAO,IAAI,OAAO;IAGlB,MAAM,IAAI,CAAC;CAGZ;AAED,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC"}
|
package/option.js
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.None = exports.Some = exports.Option = void 0;
|
4
|
+
class Option {
|
5
|
+
static Some(t) {
|
6
|
+
return new Some(t);
|
7
|
+
}
|
8
|
+
static None() {
|
9
|
+
return new None();
|
10
|
+
}
|
11
|
+
static Is(t) {
|
12
|
+
return t instanceof Option;
|
13
|
+
}
|
14
|
+
IsNone() {
|
15
|
+
return this.is_none();
|
16
|
+
}
|
17
|
+
IsSome() {
|
18
|
+
return this.is_some();
|
19
|
+
}
|
20
|
+
Unwrap() {
|
21
|
+
return this.unwrap();
|
22
|
+
}
|
23
|
+
}
|
24
|
+
exports.Option = Option;
|
25
|
+
class Some extends Option {
|
26
|
+
constructor(_t) {
|
27
|
+
super();
|
28
|
+
this._t = _t;
|
29
|
+
}
|
30
|
+
is_none() {
|
31
|
+
return false;
|
32
|
+
}
|
33
|
+
is_some() {
|
34
|
+
return true;
|
35
|
+
}
|
36
|
+
unwrap() {
|
37
|
+
return this._t;
|
38
|
+
}
|
39
|
+
}
|
40
|
+
exports.Some = Some;
|
41
|
+
class None extends Option {
|
42
|
+
is_none() {
|
43
|
+
return true;
|
44
|
+
}
|
45
|
+
is_some() {
|
46
|
+
return false;
|
47
|
+
}
|
48
|
+
unwrap() {
|
49
|
+
throw new Error("None.unwrap");
|
50
|
+
}
|
51
|
+
}
|
52
|
+
exports.None = None;
|
53
|
+
//# sourceMappingURL=option.js.map
|
package/option.js.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"option.js","sourceRoot":"","sources":["../src/option.ts"],"names":[],"mappings":";;;AAAA,MAAsB,MAAM;IAC1B,MAAM,CAAC,IAAI,CAAI,CAAI;QACjB,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;IACrB,CAAC;IAED,MAAM,CAAC,IAAI;QACT,OAAO,IAAI,IAAI,EAAE,CAAC;IACpB,CAAC;IAED,MAAM,CAAC,EAAE,CAAI,CAAU;QACrB,OAAO,CAAC,YAAY,MAAM,CAAC;IAC7B,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC;IACD,MAAM;QACJ,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;IACvB,CAAC;CAKF;AA3BD,wBA2BC;AAED,MAAa,IAAQ,SAAQ,MAAS;IAEpC,YAAY,EAAK;QACf,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;IAED,OAAO;QACL,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO;QACL,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM;QACJ,OAAO,IAAI,CAAC,EAAE,CAAC;IACjB,CAAC;CACF;AAhBD,oBAgBC;AAED,MAAa,IAAQ,SAAQ,MAAS;IACpC,OAAO;QACL,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO;QACL,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM;QACJ,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC;IACjC,CAAC;CACF;AAVD,oBAUC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@adviser/cement",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.5",
|
4
4
|
"description": "better try/catch/finally handling",
|
5
5
|
"main": "index.js",
|
6
6
|
"keywords": [],
|
@@ -11,13 +11,13 @@
|
|
11
11
|
},
|
12
12
|
"homepage": "https://github.com/mabels/cement#readme",
|
13
13
|
"devDependencies": {
|
14
|
-
"@types/jest": "^29.5.
|
15
|
-
"@types/node": "^20.11.
|
16
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
17
|
-
"@typescript-eslint/parser": "^6.
|
14
|
+
"@types/jest": "^29.5.12",
|
15
|
+
"@types/node": "^20.11.16",
|
16
|
+
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
17
|
+
"@typescript-eslint/parser": "^6.21.0",
|
18
18
|
"eslint": "^8.56.0",
|
19
19
|
"jest": "^29.7.0",
|
20
|
-
"prettier": "^3.2.
|
20
|
+
"prettier": "^3.2.5",
|
21
21
|
"ts-jest": "^29.1.2",
|
22
22
|
"ts-node": "^10.9.2",
|
23
23
|
"typescript": "^5.3.3"
|
package/result.d.ts
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
export declare abstract class Result<T, E = Error> {
|
2
|
+
static Ok<T>(t: T): Result<T, Error>;
|
3
|
+
static Err<T extends Error = Error>(t: T | string): Result<never, T>;
|
4
|
+
static Is<T>(t: unknown): t is Result<T>;
|
5
|
+
isOk(): boolean;
|
6
|
+
isErr(): boolean;
|
7
|
+
Ok(): T;
|
8
|
+
Err(): E;
|
9
|
+
abstract is_ok(): boolean;
|
10
|
+
abstract is_err(): boolean;
|
11
|
+
abstract unwrap(): T;
|
12
|
+
abstract unwrap_err(): E;
|
13
|
+
}
|
14
|
+
export declare class ResultOK<T> extends Result<T, Error> {
|
15
|
+
private _t;
|
16
|
+
constructor(t: T);
|
17
|
+
is_ok(): boolean;
|
18
|
+
is_err(): boolean;
|
19
|
+
unwrap_err(): Error;
|
20
|
+
unwrap(): T;
|
21
|
+
}
|
22
|
+
export declare class ResultError<T extends Error> extends Result<never, T> {
|
23
|
+
private _error;
|
24
|
+
constructor(t: T);
|
25
|
+
is_ok(): boolean;
|
26
|
+
is_err(): boolean;
|
27
|
+
unwrap(): never;
|
28
|
+
unwrap_err(): T;
|
29
|
+
}
|
30
|
+
export type WithoutResult<T> = T extends Result<infer U> ? U : T;
|
31
|
+
//# sourceMappingURL=result.d.ts.map
|
package/result.d.ts.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../src/result.ts"],"names":[],"mappings":"AAAA,8BAAsB,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK;IACvC,MAA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69 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.ResultError = exports.ResultOK = exports.Result = void 0;
|
4
|
+
class Result {
|
5
|
+
static Ok(t) {
|
6
|
+
return new ResultOK(t);
|
7
|
+
}
|
8
|
+
static Err(t) {
|
9
|
+
if (typeof t === "string") {
|
10
|
+
return new ResultError(new Error(t));
|
11
|
+
}
|
12
|
+
return new ResultError(t);
|
13
|
+
}
|
14
|
+
static Is(t) {
|
15
|
+
return t instanceof Result;
|
16
|
+
}
|
17
|
+
isOk() {
|
18
|
+
return this.is_ok();
|
19
|
+
}
|
20
|
+
isErr() {
|
21
|
+
return this.is_err();
|
22
|
+
}
|
23
|
+
Ok() {
|
24
|
+
return this.unwrap();
|
25
|
+
}
|
26
|
+
Err() {
|
27
|
+
return this.unwrap_err();
|
28
|
+
}
|
29
|
+
}
|
30
|
+
exports.Result = Result;
|
31
|
+
class ResultOK extends Result {
|
32
|
+
constructor(t) {
|
33
|
+
super();
|
34
|
+
this._t = t;
|
35
|
+
}
|
36
|
+
is_ok() {
|
37
|
+
return true;
|
38
|
+
}
|
39
|
+
is_err() {
|
40
|
+
return false;
|
41
|
+
}
|
42
|
+
unwrap_err() {
|
43
|
+
throw new Error("Result is Ok");
|
44
|
+
}
|
45
|
+
unwrap() {
|
46
|
+
return this._t;
|
47
|
+
}
|
48
|
+
}
|
49
|
+
exports.ResultOK = ResultOK;
|
50
|
+
class ResultError extends Result {
|
51
|
+
constructor(t) {
|
52
|
+
super();
|
53
|
+
this._error = t;
|
54
|
+
}
|
55
|
+
is_ok() {
|
56
|
+
return false;
|
57
|
+
}
|
58
|
+
is_err() {
|
59
|
+
return true;
|
60
|
+
}
|
61
|
+
unwrap() {
|
62
|
+
throw new Error(`Result is Err: ${this._error}`);
|
63
|
+
}
|
64
|
+
unwrap_err() {
|
65
|
+
return this._error;
|
66
|
+
}
|
67
|
+
}
|
68
|
+
exports.ResultError = ResultError;
|
69
|
+
//# sourceMappingURL=result.js.map
|
package/result.js.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"result.js","sourceRoot":"","sources":["../src/result.ts"],"names":[],"mappings":";;;AAAA,MAAsB,MAAM;IAC1B,MAAM,CAAC,EAAE,CAAI,CAAI;QACf,OAAO,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC;IACzB,CAAC;IACD,MAAM,CAAC,GAAG,CAA0B,CAAa;QAC/C,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;YAC1B,OAAO,IAAI,WAAW,CAAC,IAAI,KAAK,CAAC,CAAC,CAAM,CAAC,CAAC;QAC5C,CAAC;QACD,OAAO,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IACD,MAAM,CAAC,EAAE,CAAI,CAAU;QACrB,OAAO,CAAC,YAAY,MAAM,CAAC;IAC7B,CAAC;IAED,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;IACD,KAAK;QACH,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;IACvB,CAAC;IAED,EAAE;QACA,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;IACvB,CAAC;IACD,GAAG;QACD,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC;IAC3B,CAAC;CAMF;AAhCD,wBAgCC;AAED,MAAa,QAAY,SAAQ,MAAgB;IAE/C,YAAY,CAAI;QACd,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;IACd,CAAC;IACD,KAAK;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM;QACJ,OAAO,KAAK,CAAC;IACf,CAAC;IACD,UAAU;QACR,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC;IAClC,CAAC;IACD,MAAM;QACJ,OAAO,IAAI,CAAC,EAAE,CAAC;IACjB,CAAC;CACF;AAlBD,4BAkBC;AAED,MAAa,WAA6B,SAAQ,MAAgB;IAEhE,YAAY,CAAI;QACd,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAClB,CAAC;IACD,KAAK;QACH,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM;QACJ,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM;QACJ,MAAM,IAAI,KAAK,CAAC,kBAAkB,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IACnD,CAAC;IACD,UAAU;QACR,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF;AAlBD,kCAkBC"}
|
package/result.test.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"result.test.d.ts","sourceRoot":"","sources":["../src/result.test.ts"],"names":[],"mappings":""}
|
package/result.test.js
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const result_1 = require("./result");
|
4
|
+
it("ResultOk", () => {
|
5
|
+
const result = result_1.Result.Ok(1);
|
6
|
+
expect(result.isOk()).toBe(true);
|
7
|
+
expect(result.is_ok()).toBe(true);
|
8
|
+
expect(result.Ok()).toBe(1);
|
9
|
+
expect(result.unwrap()).toBe(1);
|
10
|
+
expect(result.isErr()).toBe(false);
|
11
|
+
expect(result.is_err()).toBe(false);
|
12
|
+
expect(() => result.Err()).toThrow();
|
13
|
+
expect(() => result.unwrap_err()).toThrow();
|
14
|
+
});
|
15
|
+
it("ResultErr", () => {
|
16
|
+
const result = result_1.Result.Err("xxx");
|
17
|
+
expect(result.isOk()).toBe(false);
|
18
|
+
expect(result.is_ok()).toBe(false);
|
19
|
+
expect(result.Err().message).toEqual("xxx");
|
20
|
+
expect(result.unwrap_err().message).toBe("xxx");
|
21
|
+
expect(result.isErr()).toBe(true);
|
22
|
+
expect(result.is_err()).toBe(true);
|
23
|
+
expect(() => result.Ok()).toThrow();
|
24
|
+
expect(() => result.unwrap()).toThrow();
|
25
|
+
});
|
26
|
+
class xResult {
|
27
|
+
}
|
28
|
+
it("is Result", () => {
|
29
|
+
expect(result_1.Result.Is(result_1.Result.Ok(1))).toBe(true);
|
30
|
+
expect(result_1.Result.Is(result_1.Result.Err("xxx"))).toEqual(true);
|
31
|
+
expect(result_1.Result.Is(new xResult())).toBe(false);
|
32
|
+
});
|
33
|
+
it("WithoutResult", () => {
|
34
|
+
const result = result_1.Result.Ok({ a: 1 });
|
35
|
+
const a1 = {};
|
36
|
+
a1.a = 1;
|
37
|
+
expect(a1.a).toEqual(1);
|
38
|
+
});
|
39
|
+
//# sourceMappingURL=result.test.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"result.test.js","sourceRoot":"","sources":["../src/result.test.ts"],"names":[],"mappings":";;AAAA,qCAAiD;AAEjD,EAAE,CAAC,UAAU,EAAE,GAAG,EAAE;IAClB,MAAM,MAAM,GAAG,eAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC5B,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC5B,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAEhC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACnC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACpC,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;IACrC,MAAM,CAAC,G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