-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
67 lines (54 loc) · 1.8 KB
/
test.js
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
const { MappingMap, MappingObj } = require("..");
const log = require("logging-pretty").default();
const run = (state, cn) => {
state.set(`num`, 2);
if (state.get(`num`) == 2) {
log.success(`[${cn}] [1/13] operation .set()`);
log.success(`[${cn}] [2/13] operation .get()`);
}
const entries = state.entries();
const entriesValue =
entries?.next === undefined ? entries[0] : entries.next().value;
if (entriesValue[0] == `num` && entriesValue[1] == 2) {
log.success(`[${cn}] [3/13] operation .entries()`);
}
state.forEach((v, k) => {
if (v == 2 && k == `num`) {
log.success(`[${cn}] [4/13] operation .forEach()`);
}
});
const keys = state.keys();
const keysValue = keys?.next === undefined ? keys : keys.next().value;
if (keysValue == `num`) {
log.success(`[${cn}] [5/13] operation .keys()`);
}
const values = state.values();
const valuesValue = values?.next === undefined ? values : values.next().value;
if (valuesValue == 2) {
log.success(`[${cn}] [6/13] operation .values()`);
}
if (typeof state.jsonObject() == `object`) {
log.success(`[${cn}] [7/13] operation .jsonObject()`);
}
if (typeof state.jsonString() == `string`) {
log.success(`[${cn}] [8/13] operation .jsonString()`);
}
if (state[`size`] == 1) {
log.success(`[${cn}] [9/13] operation .size`);
}
state[`state`];
log.success(`[${cn}] [10/13] operation .state`);
state.delete(`num`);
if (state.has(`num`) === false) {
log.success(`[${cn}] [11/13] operation .delete()`);
log.success(`[${cn}] [12/13] operation .has()`);
}
state.set(`num`, 3);
state.clear();
if (state[`size`] == 0) {
log.success(`[${cn}] [13/13] operation .clear()`);
}
log.info(`-----------> done`);
};
run(new MappingMap(), `MappingMap`);
run(new MappingObj(), `MappingObj`);