-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
92 lines (67 loc) · 2.5 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
const KBstorage = require('.//BrowserScript//KBstorage.js')
const MyStorage = new KBstorage();
{
// code for demo project
let exp = "{ \"cid\" : \"7E1D8D6609499A1A5FB67C6B9E7DD34CF7C6C4355259115FC7161F47266F5F3C\" }";
// get information for requested expression
let inCache = MyStorage.ExpressionInCache(JSON.parse(exp));
console.log(exp + ", InCache " + inCache);
// expecting array of expressions or empty array if error or exp has no inner expressions
let exp_array = MyStorage.ParseExpression(exp);
for ( var i in exp_array )
{
let inCache = MyStorage.ExpressionInCache(exp_array[i]);
console.log(JSON.stringify(exp_array[i]) + ", InCache " + inCache);
}
while( 0 != exp_array.length )
{
let new_exp_array = new Array();
for ( var i in exp_array )
{
let str_exp = JSON.stringify(exp_array[i]);
let exp = MyStorage.ParseExpression(str_exp);
for ( var j in exp )
{
new_exp_array.push(exp[j]);
let inCache = MyStorage.ExpressionInCache(exp[j]);
console.log(JSON.stringify(exp[j]) + ", InCache " + inCache);
}
}
exp_array = new_exp_array;
}
}
{
let expression = "{ \"cid\" : \"7E1D8D6609499A1A5FB67C6B9E7DD34CF7C6C4355259115FC7161F47266F5F3C\" }";
MyStorage.GetData(expression).then( data => {
console.log("-------------- first --------------");
console.log(expression);
if ( null == data )
{
console.log("Empty data");
}
else
{
console.log("MIME " + data["MIME"]);
console.log("size " + data["size"]);
console.log(data);
}
});
}
{
let expression = "{ \"exec\" : { \"wasm\" : { \"cid\" : \"_wasm_concat_\" }, \"arg1\" : { \"cid\" : \"2CF24DBA5FB0A30E26E83B2AC5B9E29E1B161E5C1FA7425E73043362938B9824\" }, \"arg2\" : { \"cid\" : \"B493D48364AFE44D11C0165CF470A4164D1E2609911EF998BE868D46ADE3DE4E\" } } }";
MyStorage.GetData(expression).then( data => {
console.log("-------------- second --------------");
console.log(expression);
if ( null == data )
{
console.log("Empty data");
}
else
{
console.log("second");
console.log("MIME " + data["MIME"]);
console.log("size " + data["size"]);
console.log(data);
}
});
}