This repository has been archived by the owner on Oct 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.js
64 lines (47 loc) · 1.53 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
const JsonDataEngine = require('./JsonDataEngine');
/**
* Test 1
*/
function putGetLogDelGetLog() {
const se1 = new JsonDataEngine();
se1.put('hi', { name: 'awesome-sauce' })
.then(() => se1.get('hi'))
.then((d) => console.log(d))
.then(() => se1.del('hi'))
.then(() => se1.get('hi'))
.then((d) => console.log(d))
.catch(console.error);
}
/**
* Tests 2,3
*/
function putFourSizeDelOneSize() {
const se2 = new JsonDataEngine();
console.log(se2.toString());
se2.put('foo_1', { name: 'FooBar One!' })
.then(() => se2.put('foo_2', { name: 'FooBar Two!' }))
.then(() => se2.put('foo_3', { name: 'FooBar Three!' }))
.then(() => se2.put('foo_4', { name: 'FooBar Four!' }))
.then(() => console.log(se2.toString()))
.then(() => console.log(se2.size))
.then(() => se2.del('foo_2'))
.then(() => console.log(se2.toString()))
.then(() => console.log(se2.size))
.catch(console.error)
.then(() => se2.put('foo_5', { name: 'FooBar Five!' }))
.then(() => se2.put('foo_6', { name: 'FooBar Six!' }))
.then(() => se2.put('foo_7', { name: 'FooBar Seven!' }))
.then(() => console.log(se2.toString()))
.then(() => console.log(se2.size))
.then(() => se2.del('foo_5'))
.then(() => console.log(se2.toString()))
.then(() => console.log(se2.size))
.catch(console.error)
.then(() => console.log('lucky for us, we can continue'))
.then(() => se2.del('foo_5'))
.then(() => console.log(se2.toString()))
.then(() => console.log(se2.size))
.catch(console.error)
}
//putGetLogDelGetLog();
putFourSizeDelOneSize();