-
Notifications
You must be signed in to change notification settings - Fork 29.9k
/
bl-tests.ts
110 lines (92 loc) · 2.64 KB
/
bl-tests.ts
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
import BufferListStream = require("bl");
import BufferList = require("bl/BufferList");
var bls: BufferListStream;
var buffer: Buffer;
var offset: number;
var num: number;
var str: string;
BufferListStream.isBufferList({});
// has Duplex methods
bls.pause();
bls.resume();
var bl = new BufferList();
// is assignable
bl = bls.duplicate();
// is not assignable as it lacks the Duplex methods
var bls2: BufferListStream;
bls2 = bl; // $ExpectError
// does not have Duplex methods
bl.pause(); // $ExpectError
bl.resume(); // $ExpectError
bl.append(buffer);
bl.append(bl);
bl.append(bls);
bls = new BufferListStream();
bls = new BufferListStream(bls);
bls = new BufferListStream([bls]);
bls = new BufferListStream(Buffer.from("asdf"));
bls = new BufferListStream([Buffer.from("asdf")]);
bls = new BufferListStream("hi");
bls.append(buffer);
bls.append(bl);
bls.append(bls);
num = bls.length;
num = bls.get(num);
buffer = bls.slice(num, num);
buffer = bls.slice(num);
buffer = bls.slice();
bls.shallowSlice(0, 1).shallowSlice();
bls.copy(buffer, num, num, num);
bls.copy(buffer, num, num);
bls.copy(buffer, num);
bls.copy(buffer);
bls = bls.duplicate();
bls.consume();
bls.consume(num);
str = bls.toString(str, num, num);
str = bls.toString(str, num);
str = bls.toString(str);
str = bls.toString();
bls.indexOf("foo", 0, "hex") === 1;
bls.indexOf(Buffer.from("foo")) === 1;
bls.indexOf(4) === 1;
bls.indexOf(bls) === 1;
bls.indexOf(new Uint8Array([1, 3, 4])) === 2;
bls.indexOf(bl) === 0;
bl.indexOf(bls) === 0;
num = bls.readDoubleBE(offset);
num = bls.readDoubleBE(offset);
num = bls.readDoubleLE(offset);
num = bls.readDoubleLE(offset);
num = bls.readFloatBE(offset);
num = bls.readFloatBE(offset);
num = bls.readFloatLE(offset);
num = bls.readFloatLE(offset);
num = bls.readInt32BE(offset);
num = bls.readInt32BE(offset);
num = bls.readInt32LE(offset);
num = bls.readInt32LE(offset);
num = bls.readUInt32BE(offset);
num = bls.readUInt32BE(offset);
num = bls.readUInt32LE(offset);
num = bls.readUInt32LE(offset);
num = bls.readInt16BE(offset);
num = bls.readInt16BE(offset);
num = bls.readInt16LE(offset);
num = bls.readInt16LE(offset);
num = bls.readUInt16BE(offset);
num = bls.readUInt16BE(offset);
num = bls.readUInt16LE(offset);
num = bls.readUInt16LE(offset);
num = bls.readInt8(offset);
num = bls.readInt8(offset);
num = bls.readUInt8(offset);
num = bls.readUInt8(offset);
num = bls.readIntBE(offset);
num = bls.readIntLE(offset);
num = bls.readUIntBE(offset);
num = bls.readUIntLE(offset);
BufferListStream.isBufferList(bls); // $ExpectTrue
BufferListStream.isBufferList({}); // $ExpectFalse
BufferList.isBufferList(bl); // $ExpectTrue
BufferList.isBufferList({}); // $ExpectFalse