forked from AssemblyScript/assemblyscript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharraybuffer.ts
More file actions
40 lines (22 loc) · 682 Bytes
/
arraybuffer.ts
File metadata and controls
40 lines (22 loc) · 682 Bytes
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
import "allocator/arena";
var buffer = new ArrayBuffer(8);
assert(buffer.byteLength == 8);
var sliced = buffer.slice();
assert(sliced.byteLength == 8);
assert(sliced.data != buffer.data);
assert(sliced !== buffer);
sliced = buffer.slice(1);
assert(sliced.byteLength == 7);
sliced = buffer.slice(-1);
assert(sliced.byteLength == 1);
sliced = buffer.slice(1, 3);
assert(sliced.byteLength == 2);
sliced = buffer.slice(1, -1);
assert(sliced.byteLength == 6);
sliced = buffer.slice(-3, -1);
assert(sliced.byteLength == 2);
sliced = buffer.slice(-4, 42);
assert(sliced.byteLength == 4);
sliced = buffer.slice(42);
assert(sliced.byteLength == 0);
assert(sliced != null);