-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.html
55 lines (55 loc) · 1.23 KB
/
test.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>bson.js tester</title>
</head>
<body>
<h1>BSON</h1>
<p>See your console.</p>
<script src="bson-browser.js"></script>
<script>
var test = {
中文属性名:null,
"2:3":undefined,
复杂嵌套:{
number:1024,
array: [{},20,"3",true,false,null,undefined],
str: "可以正常处理\"符号",
}
};
// for(let i=0;i<2000;++i) test[i] = i*2;
var
bson独有功能= {
arwfunc: (n)=> n**2,
func: function() {
var feat = "不怕换行符,不怕各种转义和编程符号";
var test = `比如换行符
和转义符号\\a\"`
return feat + "," + test
},
bigint: 1024n,
cls: class {
constructor(r) {
this.r = r;
}
get s() {return this.r + " from prototype"}
},
file: new Uint8Array(0xff)
}
j=JSON.stringify(test);
b=BSON.gen(test)
console.time("j")
for(let i=0;i<1000;++i)
JSON.parse(j);
console.timeEnd("j")
console.log(b);
console.time("b")
for(let i=0;i<1000;++i)
BSON.parse(b)
console.timeEnd("b")
// open(URL.createObjectURL(new Blob([BSON.gen(test)],{type:"text/plain;charset=utf8"})));
</script>
</body>
</html>