-
Notifications
You must be signed in to change notification settings - Fork 77
/
SerializeTest.ts
71 lines (60 loc) · 1.48 KB
/
SerializeTest.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import {Serializable, Transient} from "../..";
import {BitSet} from "../../common/util/BitSet";
class A {
paraA = "aaa";
random = parseInt((Math.random() * 10000).toFixed());
b: B;
}
class B {
paraB = 123;
random = parseInt((Math.random() * 10000).toFixed());
a: A;
}
@Serializable()
class C {
@Transient()
private transientF = "test transient";
private a: A;
private b: B;
bitSet: BitSet;
paramNum = 12;
paramBoolean = true;
paramString = "test";
paramObj = {
aa: null,
bb: null,
bitSet: null
};
paramArray: any[] = [
1,
"2",
false
];
private testLambda = () => true;
testFun() {
return "test";
}
constructor() {
this.a = new A();
this.b = new B();
this.a.b = this.b;
this.b.a = this.a;
this.bitSet = new BitSet(2 << 10);
this.bitSet.set(8, 1);
this.bitSet.set(16, 1);
this.paramObj.aa = this.a;
this.paramObj.bb = this.b;
this.paramObj.bitSet = this.bitSet;
this.paramArray.push(this.a);
this.paramArray.push(this.b);
this.paramArray.push(this.bitSet);
}
}
(async () => {
const c = new C();
// await SerializableUtil.serializeToFile(c, "c.txt");
// const cFromFile = await SerializableUtil.deserializeFromFile("c.txt");
// console.log(cFromFile);
// console.log(cFromFile.testLambda());
// console.log(cFromFile.testFun());
})();