-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathscratch.nnb
More file actions
172 lines (172 loc) · 7.32 KB
/
scratch.nnb
File metadata and controls
172 lines (172 loc) · 7.32 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
{
"cells": [
{
"language": "typescript",
"source": [
"function create(x: number) {\n\treturn { print() { console.log(x); } };\n}\n\nlet x = create(10);\nlet y = create(11);\n\nx.print();\ny.print();\nconsole.log(x.print === y.print);"
],
"outputs": [
{
"items": [
{
"mime": "application/vnd.code.notebook.stdout",
"value": [
"10",
"11",
"false",
""
]
}
]
}
]
},
{
"language": "typescript",
"source": [
"{\n\tconst buffer = new ArrayBuffer(16);\n\tconst view = new DataView(buffer, 0, 4);\n\tview.getInt32(16);\n}"
],
"outputs": [
{
"items": [
{
"mime": "application/vnd.code.notebook.error",
"value": {
"name": "RangeError",
"message": "Offset is outside the bounds of the DataView",
"stack": " at DataView.getInt32 (<anonymous>)\n at <Cell 2> [4, 14]\n at <Cell 2> [8, 46]\n at Script.runInContext (node:vm:135:12)\n at Script.runInNewContext (node:vm:140:17)\n at Object.runInNewContext (node:vm:292:38)\n at C (/home/dirkb/.vscode-server-insiders/extensions/donjayamanne.typescript-notebook-2.0.6/out/extension/server/index.js:2:113345)\n at t.execCode (/home/dirkb/.vscode-server-insiders/extensions/donjayamanne.typescript-notebook-2.0.6/out/extension/server/index.js:2:114312)\n at k.<anonymous> (/home/dirkb/.vscode-server-insiders/extensions/donjayamanne.typescript-notebook-2.0.6/out/extension/server/index.js:2:142156)\n at k.emit (node:events:514:28)"
}
}
]
}
]
},
{
"language": "typescript",
"source": [
"const ab = new ArrayBuffer(1024);\nconst ib = new Int32Array(ab, 256, 2);\nconsole.log(ib.byteOffset);\nconsole.log(ib.byteLength);"
],
"outputs": [
{
"items": [
{
"mime": "application/vnd.code.notebook.stdout",
"value": [
"256",
"8",
""
]
}
]
}
]
},
{
"language": "typescript",
"source": [
"const buffer = new ArrayBuffer(4);\n\nconst array = new Uint32Array(buffer);\narray[0] = 305419896;\n\nconst bytes = new Uint8Array(buffer);\n\nfor (const byte of bytes) {\n\tconsole.log(byte.toString(16));\n}\n"
],
"outputs": [
{
"items": [
{
"mime": "application/vnd.code.notebook.stdout",
"value": [
"78",
"56",
"34",
"12",
""
]
}
]
}
]
},
{
"language": "typescript",
"source": [
"Math.ceil( 7451 / 8) * 8;"
],
"outputs": [
{
"items": [
{
"mime": "text/plain",
"value": [
"\u001b[33m7456\u001b[39m"
]
}
]
}
]
},
{
"language": "typescript",
"source": [
"const sbuffer = new SharedArrayBuffer(1024);\nconst view = new DataView(sbuffer);\nconst p = { a: 305419896, b: 305419896, c: 305419896, d: 305419896 };\nconst start = Date.now();\nfor (let i = 0; i < 10000000; i++) {\n\tview.setUint32(0, p.a);\n\tview.setUint32(4, p.b);\n\tview.setUint32(8, p.c);\n\tview.setUint32(12, p.d);\n}\nconsole.log(Date.now() - start);"
],
"outputs": [
{
"items": [
{
"mime": "application/vnd.code.notebook.stdout",
"value": [
"5021",
""
]
}
]
}
]
},
{
"language": "typescript",
"source": [
"const param = { a: 305419896, b: 305419896, c: 305419896, d: 305419896, e: 'dirk' };\nconst start2 = Date.now();\nfor (let i = 0; i < 10000000; i++) {\n\tJSON.stringify(param);\n}\nconsole.log(Date.now() - start2);"
],
"outputs": [
{
"items": [
{
"mime": "application/vnd.code.notebook.stdout",
"value": [
"3655",
""
]
}
]
}
]
},
{
"language": "typescript",
"source": [
"try {\n\tthrow new Error(10);\n} catch (e) {\n\tconsole.log(e.stack);\n}"
],
"outputs": [
{
"items": [
{
"mime": "application/vnd.code.notebook.stdout",
"value": [
"Error: 10",
" at <Cell 8> [2, 7]",
" at <Cell 8> [9, 46]",
" at Script.runInContext (node:vm:148:12)",
" at Script.runInNewContext (node:vm:153:17)",
" at Object.runInNewContext (node:vm:309:38)",
" at C (/home/dirkb/.vscode-server-insiders/extensions/donjayamanne.typescript-notebook-2.0.6/out/extension/server/index.js:2:113345)",
" at t.execCode (/home/dirkb/.vscode-server-insiders/extensions/donjayamanne.typescript-notebook-2.0.6/out/extension/server/index.js:2:114312)",
" at k.<anonymous> (/home/dirkb/.vscode-server-insiders/extensions/donjayamanne.typescript-notebook-2.0.6/out/extension/server/index.js:2:142156)",
" at k.emit (node:events:519:28)",
" at k.emit (node:domain:488:12)",
""
]
}
]
}
]
}
]
}