uint8arraylist 1.1.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/src/index.d.ts +49 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +191 -14
- package/dist/src/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +250 -19
package/README.md
CHANGED
package/dist/src/index.d.ts
CHANGED
|
@@ -1,14 +1,60 @@
|
|
|
1
|
+
declare type Appendable = Uint8ArrayList | Uint8Array;
|
|
1
2
|
export declare class Uint8ArrayList implements Iterable<Uint8Array> {
|
|
2
3
|
private bufs;
|
|
3
4
|
length: number;
|
|
4
|
-
constructor(...data:
|
|
5
|
+
constructor(...data: Appendable[]);
|
|
5
6
|
[Symbol.iterator](): Generator<Uint8Array, void, undefined>;
|
|
6
|
-
|
|
7
|
+
get byteLength(): number;
|
|
8
|
+
/**
|
|
9
|
+
* Add one or more `bufs` to this Uint8ArrayList
|
|
10
|
+
*/
|
|
11
|
+
append(...bufs: Appendable[]): void;
|
|
12
|
+
/**
|
|
13
|
+
* Add all `bufs` to this Uint8ArrayList
|
|
14
|
+
*/
|
|
15
|
+
appendAll(bufs: Appendable[]): void;
|
|
16
|
+
/**
|
|
17
|
+
* Read the value at `index`
|
|
18
|
+
*/
|
|
7
19
|
get(index: number): number;
|
|
20
|
+
/**
|
|
21
|
+
* Set the value at `index` to `value`
|
|
22
|
+
*/
|
|
23
|
+
set(index: number, value: number): void;
|
|
24
|
+
/**
|
|
25
|
+
* Copy bytes from `buf` to the index specified by `offset`
|
|
26
|
+
*/
|
|
27
|
+
write(buf: Appendable, offset?: number): void;
|
|
8
28
|
/**
|
|
9
29
|
* Remove bytes from the front of the pool
|
|
10
30
|
*/
|
|
11
31
|
consume(bytes: number): void;
|
|
12
|
-
|
|
32
|
+
slice(beginInclusive?: number, endExclusive?: number): Uint8Array;
|
|
33
|
+
subarray(beginInclusive?: number, endExclusive?: number): Uint8ArrayList;
|
|
34
|
+
_subList(beginInclusive?: number, endExclusive?: number): {
|
|
35
|
+
bufs: Uint8Array[];
|
|
36
|
+
length: number;
|
|
37
|
+
};
|
|
38
|
+
getInt8(byteOffset: number): number;
|
|
39
|
+
setInt8(byteOffset: number, value: number): void;
|
|
40
|
+
getInt16(byteOffset: number, littleEndian?: boolean): number;
|
|
41
|
+
setInt16(byteOffset: number, value: number, littleEndian?: boolean): void;
|
|
42
|
+
getInt32(byteOffset: number, littleEndian?: boolean): number;
|
|
43
|
+
setInt32(byteOffset: number, value: number, littleEndian?: boolean): void;
|
|
44
|
+
getBigInt64(byteOffset: number, littleEndian?: boolean): BigInt;
|
|
45
|
+
setBigInt64(byteOffset: number, value: bigint, littleEndian?: boolean): void;
|
|
46
|
+
getUint8(byteOffset: number): number;
|
|
47
|
+
setUint8(byteOffset: number, value: number): void;
|
|
48
|
+
getUint16(byteOffset: number, littleEndian?: boolean): number;
|
|
49
|
+
setUint16(byteOffset: number, value: number, littleEndian?: boolean): void;
|
|
50
|
+
getUint32(byteOffset: number, littleEndian?: boolean): number;
|
|
51
|
+
setUint32(byteOffset: number, value: number, littleEndian?: boolean): void;
|
|
52
|
+
getBigUint64(byteOffset: number, littleEndian?: boolean): BigInt;
|
|
53
|
+
setBigUint64(byteOffset: number, value: bigint, littleEndian?: boolean): void;
|
|
54
|
+
getFloat32(byteOffset: number, littleEndian?: boolean): number;
|
|
55
|
+
setFloat32(byteOffset: number, value: number, littleEndian?: boolean): void;
|
|
56
|
+
getFloat64(byteOffset: number, littleEndian?: boolean): number;
|
|
57
|
+
setFloat64(byteOffset: number, value: number, littleEndian?: boolean): void;
|
|
13
58
|
}
|
|
59
|
+
export {};
|
|
14
60
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA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,EAAE,YAAY,CAAC,EAAE,OAAO,GAAG,IAAI;IAQ9E,UAAU,CAAE,UAAU,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,OAAO,GAAG,MAAM;IAO/D,UAAU,CAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,OAAO,GAAG,IAAI;IAQ5E,UAAU,CAAE,UAAU,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,OAAO,GAAG,MAAM;IAO/D,UAAU,CAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,OAAO,GAAG,IAAI;CAO7E"}
|
package/dist/src/index.js
CHANGED
|
@@ -1,34 +1,84 @@
|
|
|
1
1
|
import { concat } from 'uint8arrays';
|
|
2
|
+
function findBufAndOffset(bufs, index, totalLength) {
|
|
3
|
+
if (index == null || index < 0 || index >= totalLength) {
|
|
4
|
+
throw new RangeError('index is out of bounds');
|
|
5
|
+
}
|
|
6
|
+
let offset = 0;
|
|
7
|
+
for (const buf of bufs) {
|
|
8
|
+
const bufEnd = offset + buf.byteLength;
|
|
9
|
+
if (index < bufEnd) {
|
|
10
|
+
return {
|
|
11
|
+
buf,
|
|
12
|
+
index: index - offset
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
offset = bufEnd;
|
|
16
|
+
}
|
|
17
|
+
throw new RangeError('index is out of bounds');
|
|
18
|
+
}
|
|
2
19
|
export class Uint8ArrayList {
|
|
3
20
|
constructor(...data) {
|
|
4
21
|
this.bufs = [];
|
|
5
22
|
this.length = 0;
|
|
6
|
-
this.
|
|
23
|
+
this.appendAll(data);
|
|
7
24
|
}
|
|
8
25
|
*[Symbol.iterator]() {
|
|
9
26
|
yield* this.bufs;
|
|
10
27
|
}
|
|
28
|
+
get byteLength() {
|
|
29
|
+
return this.length;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Add one or more `bufs` to this Uint8ArrayList
|
|
33
|
+
*/
|
|
11
34
|
append(...bufs) {
|
|
35
|
+
this.appendAll(bufs);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Add all `bufs` to this Uint8ArrayList
|
|
39
|
+
*/
|
|
40
|
+
appendAll(bufs) {
|
|
12
41
|
let length = 0;
|
|
13
42
|
for (const buf of bufs) {
|
|
14
|
-
|
|
15
|
-
|
|
43
|
+
if (buf instanceof Uint8Array) {
|
|
44
|
+
length += buf.byteLength;
|
|
45
|
+
this.bufs.push(buf);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
length += buf.length;
|
|
49
|
+
this.bufs = this.bufs.concat(buf.bufs);
|
|
50
|
+
}
|
|
16
51
|
}
|
|
17
52
|
this.length += length;
|
|
18
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Read the value at `index`
|
|
56
|
+
*/
|
|
19
57
|
get(index) {
|
|
20
|
-
|
|
21
|
-
|
|
58
|
+
const res = findBufAndOffset(this.bufs, index, this.length);
|
|
59
|
+
return res.buf[res.index];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Set the value at `index` to `value`
|
|
63
|
+
*/
|
|
64
|
+
set(index, value) {
|
|
65
|
+
const res = findBufAndOffset(this.bufs, index, this.length);
|
|
66
|
+
res.buf[res.index] = value;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Copy bytes from `buf` to the index specified by `offset`
|
|
70
|
+
*/
|
|
71
|
+
write(buf, offset = 0) {
|
|
72
|
+
if (buf instanceof Uint8Array) {
|
|
73
|
+
for (let i = 0; i < buf.length; i++) {
|
|
74
|
+
this.set(offset + i, buf[i]);
|
|
75
|
+
}
|
|
22
76
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (index < bufEnd) {
|
|
27
|
-
return buf[index - offset];
|
|
77
|
+
else {
|
|
78
|
+
for (let i = 0; i < buf.length; i++) {
|
|
79
|
+
this.set(offset + i, buf.get(i));
|
|
28
80
|
}
|
|
29
|
-
offset = bufEnd;
|
|
30
81
|
}
|
|
31
|
-
throw new RangeError('index is out of bounds');
|
|
32
82
|
}
|
|
33
83
|
/**
|
|
34
84
|
* Remove bytes from the front of the pool
|
|
@@ -53,11 +103,28 @@ export class Uint8ArrayList {
|
|
|
53
103
|
}
|
|
54
104
|
}
|
|
55
105
|
}
|
|
56
|
-
|
|
106
|
+
slice(beginInclusive, endExclusive) {
|
|
107
|
+
const { bufs, length } = this._subList(beginInclusive, endExclusive);
|
|
108
|
+
return concat(bufs, length);
|
|
109
|
+
}
|
|
110
|
+
subarray(beginInclusive, endExclusive) {
|
|
111
|
+
const { bufs } = this._subList(beginInclusive, endExclusive);
|
|
112
|
+
const list = new Uint8ArrayList();
|
|
113
|
+
list.appendAll(bufs);
|
|
114
|
+
return list;
|
|
115
|
+
}
|
|
116
|
+
_subList(beginInclusive, endExclusive) {
|
|
117
|
+
if (beginInclusive == null && endExclusive == null) {
|
|
118
|
+
return { bufs: this.bufs, length: this.length };
|
|
119
|
+
}
|
|
120
|
+
beginInclusive = beginInclusive ?? 0;
|
|
57
121
|
endExclusive = endExclusive ?? (this.length > 0 ? this.length : 0);
|
|
58
122
|
if (beginInclusive < 0 || endExclusive > this.length) {
|
|
59
123
|
throw new RangeError('index out of bounds');
|
|
60
124
|
}
|
|
125
|
+
if (beginInclusive === endExclusive) {
|
|
126
|
+
return { bufs: [], length: 0 };
|
|
127
|
+
}
|
|
61
128
|
const bufs = [];
|
|
62
129
|
let offset = 0;
|
|
63
130
|
for (const buf of this.bufs) {
|
|
@@ -90,7 +157,117 @@ export class Uint8ArrayList {
|
|
|
90
157
|
break;
|
|
91
158
|
}
|
|
92
159
|
}
|
|
93
|
-
return
|
|
160
|
+
return { bufs, length: endExclusive - beginInclusive };
|
|
161
|
+
}
|
|
162
|
+
getInt8(byteOffset) {
|
|
163
|
+
const buf = this.slice(byteOffset, byteOffset + 1);
|
|
164
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
165
|
+
return view.getInt8(0);
|
|
166
|
+
}
|
|
167
|
+
setInt8(byteOffset, value) {
|
|
168
|
+
const buf = new Uint8Array(1);
|
|
169
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
170
|
+
view.setInt8(0, value);
|
|
171
|
+
this.write(buf, byteOffset);
|
|
172
|
+
}
|
|
173
|
+
getInt16(byteOffset, littleEndian) {
|
|
174
|
+
const buf = this.slice(byteOffset, byteOffset + 2);
|
|
175
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
176
|
+
return view.getInt16(0, littleEndian);
|
|
177
|
+
}
|
|
178
|
+
setInt16(byteOffset, value, littleEndian) {
|
|
179
|
+
const buf = new Uint8Array(2);
|
|
180
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
181
|
+
view.setInt16(0, value, littleEndian);
|
|
182
|
+
this.write(buf, byteOffset);
|
|
183
|
+
}
|
|
184
|
+
getInt32(byteOffset, littleEndian) {
|
|
185
|
+
const buf = this.slice(byteOffset, byteOffset + 4);
|
|
186
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
187
|
+
return view.getInt32(0, littleEndian);
|
|
188
|
+
}
|
|
189
|
+
setInt32(byteOffset, value, littleEndian) {
|
|
190
|
+
const buf = new Uint8Array(4);
|
|
191
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
192
|
+
view.setInt32(0, value, littleEndian);
|
|
193
|
+
this.write(buf, byteOffset);
|
|
194
|
+
}
|
|
195
|
+
getBigInt64(byteOffset, littleEndian) {
|
|
196
|
+
const buf = this.slice(byteOffset, byteOffset + 8);
|
|
197
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
198
|
+
return view.getBigInt64(0, littleEndian);
|
|
199
|
+
}
|
|
200
|
+
setBigInt64(byteOffset, value, littleEndian) {
|
|
201
|
+
const buf = new Uint8Array(8);
|
|
202
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
203
|
+
view.setBigInt64(0, value, littleEndian);
|
|
204
|
+
this.write(buf, byteOffset);
|
|
205
|
+
}
|
|
206
|
+
getUint8(byteOffset) {
|
|
207
|
+
const buf = this.slice(byteOffset, byteOffset + 1);
|
|
208
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
209
|
+
return view.getUint8(0);
|
|
210
|
+
}
|
|
211
|
+
setUint8(byteOffset, value) {
|
|
212
|
+
const buf = new Uint8Array(1);
|
|
213
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
214
|
+
view.setUint8(0, value);
|
|
215
|
+
this.write(buf, byteOffset);
|
|
216
|
+
}
|
|
217
|
+
getUint16(byteOffset, littleEndian) {
|
|
218
|
+
const buf = this.slice(byteOffset, byteOffset + 2);
|
|
219
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
220
|
+
return view.getUint16(0, littleEndian);
|
|
221
|
+
}
|
|
222
|
+
setUint16(byteOffset, value, littleEndian) {
|
|
223
|
+
const buf = new Uint8Array(2);
|
|
224
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
225
|
+
view.setUint16(0, value, littleEndian);
|
|
226
|
+
this.write(buf, byteOffset);
|
|
227
|
+
}
|
|
228
|
+
getUint32(byteOffset, littleEndian) {
|
|
229
|
+
const buf = this.slice(byteOffset, byteOffset + 4);
|
|
230
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
231
|
+
return view.getUint32(0, littleEndian);
|
|
232
|
+
}
|
|
233
|
+
setUint32(byteOffset, value, littleEndian) {
|
|
234
|
+
const buf = new Uint8Array(4);
|
|
235
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
236
|
+
view.setUint32(0, value, littleEndian);
|
|
237
|
+
this.write(buf, byteOffset);
|
|
238
|
+
}
|
|
239
|
+
getBigUint64(byteOffset, littleEndian) {
|
|
240
|
+
const buf = this.slice(byteOffset, byteOffset + 8);
|
|
241
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
242
|
+
return view.getBigUint64(0, littleEndian);
|
|
243
|
+
}
|
|
244
|
+
setBigUint64(byteOffset, value, littleEndian) {
|
|
245
|
+
const buf = new Uint8Array(8);
|
|
246
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
247
|
+
view.setBigUint64(0, value, littleEndian);
|
|
248
|
+
this.write(buf, byteOffset);
|
|
249
|
+
}
|
|
250
|
+
getFloat32(byteOffset, littleEndian) {
|
|
251
|
+
const buf = this.slice(byteOffset, byteOffset + 4);
|
|
252
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
253
|
+
return view.getFloat32(0, littleEndian);
|
|
254
|
+
}
|
|
255
|
+
setFloat32(byteOffset, value, littleEndian) {
|
|
256
|
+
const buf = new Uint8Array(4);
|
|
257
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
258
|
+
view.setFloat32(0, value, littleEndian);
|
|
259
|
+
this.write(buf, byteOffset);
|
|
260
|
+
}
|
|
261
|
+
getFloat64(byteOffset, littleEndian) {
|
|
262
|
+
const buf = this.slice(byteOffset, byteOffset + 8);
|
|
263
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
264
|
+
return view.getFloat64(0, littleEndian);
|
|
265
|
+
}
|
|
266
|
+
setFloat64(byteOffset, value, littleEndian) {
|
|
267
|
+
const buf = new Uint8Array(8);
|
|
268
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
269
|
+
view.setFloat64(0, value, littleEndian);
|
|
270
|
+
this.write(buf, byteOffset);
|
|
94
271
|
}
|
|
95
272
|
}
|
|
96
273
|
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js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Y,CAAC,CAAA;QAEvC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,UAAU,CAAC,CAAA;IAC7B,CAAC;CACF"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,49 +1,106 @@
|
|
|
1
1
|
import { concat } from 'uint8arrays'
|
|
2
2
|
|
|
3
|
+
type Appendable = Uint8ArrayList | Uint8Array
|
|
4
|
+
|
|
5
|
+
function findBufAndOffset (bufs: Uint8Array[], index: number, totalLength: number) {
|
|
6
|
+
if (index == null || index < 0 || index >= totalLength) {
|
|
7
|
+
throw new RangeError('index is out of bounds')
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
let offset = 0
|
|
11
|
+
|
|
12
|
+
for (const buf of bufs) {
|
|
13
|
+
const bufEnd = offset + buf.byteLength
|
|
14
|
+
|
|
15
|
+
if (index < bufEnd) {
|
|
16
|
+
return {
|
|
17
|
+
buf,
|
|
18
|
+
index: index - offset
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
offset = bufEnd
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
throw new RangeError('index is out of bounds')
|
|
26
|
+
}
|
|
27
|
+
|
|
3
28
|
export class Uint8ArrayList implements Iterable<Uint8Array> {
|
|
4
29
|
private bufs: Uint8Array[]
|
|
5
30
|
public length: number
|
|
6
31
|
|
|
7
|
-
constructor (...data:
|
|
32
|
+
constructor (...data: Appendable[]) {
|
|
8
33
|
this.bufs = []
|
|
9
34
|
this.length = 0
|
|
10
35
|
|
|
11
|
-
this.
|
|
36
|
+
this.appendAll(data)
|
|
12
37
|
}
|
|
13
38
|
|
|
14
39
|
* [Symbol.iterator] () {
|
|
15
40
|
yield * this.bufs
|
|
16
41
|
}
|
|
17
42
|
|
|
18
|
-
|
|
43
|
+
get byteLength () {
|
|
44
|
+
return this.length
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Add one or more `bufs` to this Uint8ArrayList
|
|
49
|
+
*/
|
|
50
|
+
append (...bufs: Appendable[]) {
|
|
51
|
+
this.appendAll(bufs)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Add all `bufs` to this Uint8ArrayList
|
|
56
|
+
*/
|
|
57
|
+
appendAll (bufs: Appendable[]) {
|
|
19
58
|
let length = 0
|
|
20
59
|
|
|
21
60
|
for (const buf of bufs) {
|
|
22
|
-
|
|
23
|
-
|
|
61
|
+
if (buf instanceof Uint8Array) {
|
|
62
|
+
length += buf.byteLength
|
|
63
|
+
this.bufs.push(buf)
|
|
64
|
+
} else {
|
|
65
|
+
length += buf.length
|
|
66
|
+
this.bufs = this.bufs.concat(buf.bufs)
|
|
67
|
+
}
|
|
24
68
|
}
|
|
25
69
|
|
|
26
70
|
this.length += length
|
|
27
71
|
}
|
|
28
72
|
|
|
73
|
+
/**
|
|
74
|
+
* Read the value at `index`
|
|
75
|
+
*/
|
|
29
76
|
get (index: number) {
|
|
30
|
-
|
|
31
|
-
throw new RangeError('index is out of bounds')
|
|
32
|
-
}
|
|
77
|
+
const res = findBufAndOffset(this.bufs, index, this.length)
|
|
33
78
|
|
|
34
|
-
|
|
79
|
+
return res.buf[res.index]
|
|
80
|
+
}
|
|
35
81
|
|
|
36
|
-
|
|
37
|
-
|
|
82
|
+
/**
|
|
83
|
+
* Set the value at `index` to `value`
|
|
84
|
+
*/
|
|
85
|
+
set (index: number, value: number) {
|
|
86
|
+
const res = findBufAndOffset(this.bufs, index, this.length)
|
|
38
87
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
88
|
+
res.buf[res.index] = value
|
|
89
|
+
}
|
|
42
90
|
|
|
43
|
-
|
|
91
|
+
/**
|
|
92
|
+
* Copy bytes from `buf` to the index specified by `offset`
|
|
93
|
+
*/
|
|
94
|
+
write (buf: Appendable, offset: number = 0) {
|
|
95
|
+
if (buf instanceof Uint8Array) {
|
|
96
|
+
for (let i = 0; i < buf.length; i++) {
|
|
97
|
+
this.set(offset + i, buf[i])
|
|
98
|
+
}
|
|
99
|
+
} else {
|
|
100
|
+
for (let i = 0; i < buf.length; i++) {
|
|
101
|
+
this.set(offset + i, buf.get(i))
|
|
102
|
+
}
|
|
44
103
|
}
|
|
45
|
-
|
|
46
|
-
throw new RangeError('index is out of bounds')
|
|
47
104
|
}
|
|
48
105
|
|
|
49
106
|
/**
|
|
@@ -71,13 +128,37 @@ export class Uint8ArrayList implements Iterable<Uint8Array> {
|
|
|
71
128
|
}
|
|
72
129
|
}
|
|
73
130
|
|
|
74
|
-
|
|
131
|
+
slice (beginInclusive?: number, endExclusive?: number) {
|
|
132
|
+
const { bufs, length } = this._subList(beginInclusive, endExclusive)
|
|
133
|
+
|
|
134
|
+
return concat(bufs, length)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
subarray (beginInclusive?: number, endExclusive?: number) {
|
|
138
|
+
const { bufs } = this._subList(beginInclusive, endExclusive)
|
|
139
|
+
|
|
140
|
+
const list = new Uint8ArrayList()
|
|
141
|
+
list.appendAll(bufs)
|
|
142
|
+
|
|
143
|
+
return list
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
_subList (beginInclusive?: number, endExclusive?: number) {
|
|
147
|
+
if (beginInclusive == null && endExclusive == null) {
|
|
148
|
+
return { bufs: this.bufs, length: this.length }
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
beginInclusive = beginInclusive ?? 0
|
|
75
152
|
endExclusive = endExclusive ?? (this.length > 0 ? this.length : 0)
|
|
76
153
|
|
|
77
154
|
if (beginInclusive < 0 || endExclusive > this.length) {
|
|
78
155
|
throw new RangeError('index out of bounds')
|
|
79
156
|
}
|
|
80
157
|
|
|
158
|
+
if (beginInclusive === endExclusive) {
|
|
159
|
+
return { bufs: [], length: 0 }
|
|
160
|
+
}
|
|
161
|
+
|
|
81
162
|
const bufs: Uint8Array[] = []
|
|
82
163
|
let offset = 0
|
|
83
164
|
|
|
@@ -119,6 +200,156 @@ export class Uint8ArrayList implements Iterable<Uint8Array> {
|
|
|
119
200
|
}
|
|
120
201
|
}
|
|
121
202
|
|
|
122
|
-
return
|
|
203
|
+
return { bufs, length: endExclusive - beginInclusive }
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
getInt8 (byteOffset: number): number {
|
|
207
|
+
const buf = this.slice(byteOffset, byteOffset + 1)
|
|
208
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
209
|
+
|
|
210
|
+
return view.getInt8(0)
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
setInt8 (byteOffset: number, value: number): void {
|
|
214
|
+
const buf = new Uint8Array(1)
|
|
215
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
216
|
+
view.setInt8(0, value)
|
|
217
|
+
|
|
218
|
+
this.write(buf, byteOffset)
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
getInt16 (byteOffset: number, littleEndian?: boolean): number {
|
|
222
|
+
const buf = this.slice(byteOffset, byteOffset + 2)
|
|
223
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
224
|
+
|
|
225
|
+
return view.getInt16(0, littleEndian)
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
setInt16 (byteOffset: number, value: number, littleEndian?: boolean): void {
|
|
229
|
+
const buf = new Uint8Array(2)
|
|
230
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
231
|
+
view.setInt16(0, value, littleEndian)
|
|
232
|
+
|
|
233
|
+
this.write(buf, byteOffset)
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
getInt32 (byteOffset: number, littleEndian?: boolean): number {
|
|
237
|
+
const buf = this.slice(byteOffset, byteOffset + 4)
|
|
238
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
239
|
+
|
|
240
|
+
return view.getInt32(0, littleEndian)
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
setInt32 (byteOffset: number, value: number, littleEndian?: boolean): void {
|
|
244
|
+
const buf = new Uint8Array(4)
|
|
245
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
246
|
+
view.setInt32(0, value, littleEndian)
|
|
247
|
+
|
|
248
|
+
this.write(buf, byteOffset)
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
getBigInt64 (byteOffset: number, littleEndian?: boolean): BigInt {
|
|
252
|
+
const buf = this.slice(byteOffset, byteOffset + 8)
|
|
253
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
254
|
+
|
|
255
|
+
return view.getBigInt64(0, littleEndian)
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
setBigInt64 (byteOffset: number, value: bigint, littleEndian?: boolean): void {
|
|
259
|
+
const buf = new Uint8Array(8)
|
|
260
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
261
|
+
view.setBigInt64(0, value, littleEndian)
|
|
262
|
+
|
|
263
|
+
this.write(buf, byteOffset)
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
getUint8 (byteOffset: number): number {
|
|
267
|
+
const buf = this.slice(byteOffset, byteOffset + 1)
|
|
268
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
269
|
+
|
|
270
|
+
return view.getUint8(0)
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
setUint8 (byteOffset: number, value: number): void {
|
|
274
|
+
const buf = new Uint8Array(1)
|
|
275
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
276
|
+
view.setUint8(0, value)
|
|
277
|
+
|
|
278
|
+
this.write(buf, byteOffset)
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
getUint16 (byteOffset: number, littleEndian?: boolean): number {
|
|
282
|
+
const buf = this.slice(byteOffset, byteOffset + 2)
|
|
283
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
284
|
+
|
|
285
|
+
return view.getUint16(0, littleEndian)
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
setUint16 (byteOffset: number, value: number, littleEndian?: boolean): void {
|
|
289
|
+
const buf = new Uint8Array(2)
|
|
290
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
291
|
+
view.setUint16(0, value, littleEndian)
|
|
292
|
+
|
|
293
|
+
this.write(buf, byteOffset)
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
getUint32 (byteOffset: number, littleEndian?: boolean): number {
|
|
297
|
+
const buf = this.slice(byteOffset, byteOffset + 4)
|
|
298
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
299
|
+
|
|
300
|
+
return view.getUint32(0, littleEndian)
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
setUint32 (byteOffset: number, value: number, littleEndian?: boolean): void {
|
|
304
|
+
const buf = new Uint8Array(4)
|
|
305
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
306
|
+
view.setUint32(0, value, littleEndian)
|
|
307
|
+
|
|
308
|
+
this.write(buf, byteOffset)
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
getBigUint64 (byteOffset: number, littleEndian?: boolean): BigInt {
|
|
312
|
+
const buf = this.slice(byteOffset, byteOffset + 8)
|
|
313
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
314
|
+
|
|
315
|
+
return view.getBigUint64(0, littleEndian)
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
setBigUint64 (byteOffset: number, value: bigint, littleEndian?: boolean): void {
|
|
319
|
+
const buf = new Uint8Array(8)
|
|
320
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
321
|
+
view.setBigUint64(0, value, littleEndian)
|
|
322
|
+
|
|
323
|
+
this.write(buf, byteOffset)
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
getFloat32 (byteOffset: number, littleEndian?: boolean): number {
|
|
327
|
+
const buf = this.slice(byteOffset, byteOffset + 4)
|
|
328
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
329
|
+
|
|
330
|
+
return view.getFloat32(0, littleEndian)
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
setFloat32 (byteOffset: number, value: number, littleEndian?: boolean): void {
|
|
334
|
+
const buf = new Uint8Array(4)
|
|
335
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
336
|
+
view.setFloat32(0, value, littleEndian)
|
|
337
|
+
|
|
338
|
+
this.write(buf, byteOffset)
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
getFloat64 (byteOffset: number, littleEndian?: boolean): number {
|
|
342
|
+
const buf = this.slice(byteOffset, byteOffset + 8)
|
|
343
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
344
|
+
|
|
345
|
+
return view.getFloat64(0, littleEndian)
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
setFloat64 (byteOffset: number, value: number, littleEndian?: boolean): void {
|
|
349
|
+
const buf = new Uint8Array(8)
|
|
350
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
351
|
+
view.setFloat64(0, value, littleEndian)
|
|
352
|
+
|
|
353
|
+
this.write(buf, byteOffset)
|
|
123
354
|
}
|
|
124
355
|
}
|