uint8arraylist 2.1.2 → 2.3.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/dist/src/index.d.ts +17 -4
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +119 -57
- package/dist/src/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +130 -59
package/dist/src/index.d.ts
CHANGED
|
@@ -10,13 +10,21 @@ export declare class Uint8ArrayList implements Iterable<Uint8Array> {
|
|
|
10
10
|
[Symbol.iterator](): Generator<Uint8Array, void, undefined>;
|
|
11
11
|
get byteLength(): number;
|
|
12
12
|
/**
|
|
13
|
-
* Add one or more `bufs` to this Uint8ArrayList
|
|
13
|
+
* Add one or more `bufs` to the end of this Uint8ArrayList
|
|
14
14
|
*/
|
|
15
15
|
append(...bufs: Appendable[]): void;
|
|
16
16
|
/**
|
|
17
|
-
* Add all `bufs` to this Uint8ArrayList
|
|
17
|
+
* Add all `bufs` to the end of this Uint8ArrayList
|
|
18
18
|
*/
|
|
19
19
|
appendAll(bufs: Appendable[]): void;
|
|
20
|
+
/**
|
|
21
|
+
* Add one or more `bufs` to the start of this Uint8ArrayList
|
|
22
|
+
*/
|
|
23
|
+
prepend(...bufs: Appendable[]): void;
|
|
24
|
+
/**
|
|
25
|
+
* Add all `bufs` to the start of this Uint8ArrayList
|
|
26
|
+
*/
|
|
27
|
+
prependAll(bufs: Appendable[]): void;
|
|
20
28
|
/**
|
|
21
29
|
* Read the value at `index`
|
|
22
30
|
*/
|
|
@@ -41,14 +49,14 @@ export declare class Uint8ArrayList implements Iterable<Uint8Array> {
|
|
|
41
49
|
*/
|
|
42
50
|
slice(beginInclusive?: number, endExclusive?: number): Uint8Array;
|
|
43
51
|
/**
|
|
44
|
-
* Returns a
|
|
52
|
+
* Returns a alloc from the given start and end element index.
|
|
45
53
|
*
|
|
46
54
|
* In the best case where the data extracted comes from a single Uint8Array
|
|
47
55
|
* internally this is a no-copy operation otherwise it is a copy operation.
|
|
48
56
|
*/
|
|
49
57
|
subarray(beginInclusive?: number, endExclusive?: number): Uint8Array;
|
|
50
58
|
/**
|
|
51
|
-
* Returns a
|
|
59
|
+
* Returns a allocList from the given start and end element index.
|
|
52
60
|
*
|
|
53
61
|
* This is a no-copy operation.
|
|
54
62
|
*/
|
|
@@ -75,6 +83,11 @@ export declare class Uint8ArrayList implements Iterable<Uint8Array> {
|
|
|
75
83
|
getFloat64(byteOffset: number, littleEndian?: boolean): number;
|
|
76
84
|
setFloat64(byteOffset: number, value: number, littleEndian?: boolean): void;
|
|
77
85
|
equals(other: any): other is Uint8ArrayList;
|
|
86
|
+
/**
|
|
87
|
+
* Create a Uint8ArrayList from a pre-existing list of Uint8Arrays. Use this
|
|
88
|
+
* method if you know the total size of all the Uint8Arrays ahead of time.
|
|
89
|
+
*/
|
|
90
|
+
static fromUint8Arrays(bufs: Uint8Array[], length?: number): Uint8ArrayList;
|
|
78
91
|
}
|
|
79
92
|
export {};
|
|
80
93
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAMA,aAAK,UAAU,GAAG,cAAc,GAAG,UAAU,CAAA;AAyB7C;;GAEG;AACH,wBAAgB,gBAAgB,CAAE,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,cAAc,CAErE;AAED,qBAAa,cAAe,YAAW,QAAQ,CAAC,UAAU,CAAC;IACzD,OAAO,CAAC,IAAI,CAAc;IACnB,MAAM,EAAE,MAAM,CAAA;gBAER,GAAG,IAAI,EAAE,UAAU,EAAE;IAYhC,CAAC,MAAM,CAAC,QAAQ,CAAC;IAInB,IAAI,UAAU,WAEb;IAED;;OAEG;IACH,MAAM,CAAE,GAAG,IA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AY,CAAC,EAAE,OAAO,GAAG,IAAI;IAQ5E,MAAM,CAAE,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,cAAc;IAsB5C;;;OAGG;IACH,MAAM,CAAC,eAAe,CAAE,IAAI,EAAE,UAAU,EAAE,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,cAAc;CAY7E"}
|
package/dist/src/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { concat } from 'uint8arrays/concat';
|
|
2
2
|
import { equals } from 'uint8arrays/equals';
|
|
3
|
+
import { allocUnsafe, alloc } from 'uint8arrays/alloc';
|
|
3
4
|
const symbol = Symbol.for('@achingbrain/uint8arraylist');
|
|
4
|
-
function findBufAndOffset(bufs, index
|
|
5
|
-
if (index == null || index < 0
|
|
5
|
+
function findBufAndOffset(bufs, index) {
|
|
6
|
+
if (index == null || index < 0) {
|
|
6
7
|
throw new RangeError('index is out of bounds');
|
|
7
8
|
}
|
|
8
9
|
let offset = 0;
|
|
@@ -30,7 +31,9 @@ export class Uint8ArrayList {
|
|
|
30
31
|
Object.defineProperty(this, symbol, { value: true });
|
|
31
32
|
this.bufs = [];
|
|
32
33
|
this.length = 0;
|
|
33
|
-
|
|
34
|
+
if (data.length > 0) {
|
|
35
|
+
this.appendAll(data);
|
|
36
|
+
}
|
|
34
37
|
}
|
|
35
38
|
*[Symbol.iterator]() {
|
|
36
39
|
yield* this.bufs;
|
|
@@ -39,13 +42,13 @@ export class Uint8ArrayList {
|
|
|
39
42
|
return this.length;
|
|
40
43
|
}
|
|
41
44
|
/**
|
|
42
|
-
* Add one or more `bufs` to this Uint8ArrayList
|
|
45
|
+
* Add one or more `bufs` to the end of this Uint8ArrayList
|
|
43
46
|
*/
|
|
44
47
|
append(...bufs) {
|
|
45
48
|
this.appendAll(bufs);
|
|
46
49
|
}
|
|
47
50
|
/**
|
|
48
|
-
* Add all `bufs` to this Uint8ArrayList
|
|
51
|
+
* Add all `bufs` to the end of this Uint8ArrayList
|
|
49
52
|
*/
|
|
50
53
|
appendAll(bufs) {
|
|
51
54
|
let length = 0;
|
|
@@ -55,8 +58,8 @@ export class Uint8ArrayList {
|
|
|
55
58
|
this.bufs.push(buf);
|
|
56
59
|
}
|
|
57
60
|
else if (isUint8ArrayList(buf)) {
|
|
58
|
-
length += buf.
|
|
59
|
-
this.bufs
|
|
61
|
+
length += buf.byteLength;
|
|
62
|
+
this.bufs.push(...buf.bufs);
|
|
60
63
|
}
|
|
61
64
|
else {
|
|
62
65
|
throw new Error('Could not append value, must be an Uint8Array or a Uint8ArrayList');
|
|
@@ -64,18 +67,44 @@ export class Uint8ArrayList {
|
|
|
64
67
|
}
|
|
65
68
|
this.length += length;
|
|
66
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Add one or more `bufs` to the start of this Uint8ArrayList
|
|
72
|
+
*/
|
|
73
|
+
prepend(...bufs) {
|
|
74
|
+
this.prependAll(bufs);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Add all `bufs` to the start of this Uint8ArrayList
|
|
78
|
+
*/
|
|
79
|
+
prependAll(bufs) {
|
|
80
|
+
let length = 0;
|
|
81
|
+
for (const buf of bufs.reverse()) {
|
|
82
|
+
if (buf instanceof Uint8Array) {
|
|
83
|
+
length += buf.byteLength;
|
|
84
|
+
this.bufs.unshift(buf);
|
|
85
|
+
}
|
|
86
|
+
else if (isUint8ArrayList(buf)) {
|
|
87
|
+
length += buf.byteLength;
|
|
88
|
+
this.bufs.unshift(...buf.bufs);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
throw new Error('Could not prepend value, must be an Uint8Array or a Uint8ArrayList');
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
this.length += length;
|
|
95
|
+
}
|
|
67
96
|
/**
|
|
68
97
|
* Read the value at `index`
|
|
69
98
|
*/
|
|
70
99
|
get(index) {
|
|
71
|
-
const res = findBufAndOffset(this.bufs, index
|
|
100
|
+
const res = findBufAndOffset(this.bufs, index);
|
|
72
101
|
return res.buf[res.index];
|
|
73
102
|
}
|
|
74
103
|
/**
|
|
75
104
|
* Set the value at `index` to `value`
|
|
76
105
|
*/
|
|
77
106
|
set(index, value) {
|
|
78
|
-
const res = findBufAndOffset(this.bufs, index
|
|
107
|
+
const res = findBufAndOffset(this.bufs, index);
|
|
79
108
|
res.buf[res.index] = value;
|
|
80
109
|
}
|
|
81
110
|
/**
|
|
@@ -130,7 +159,7 @@ export class Uint8ArrayList {
|
|
|
130
159
|
return concat(bufs, length);
|
|
131
160
|
}
|
|
132
161
|
/**
|
|
133
|
-
* Returns a
|
|
162
|
+
* Returns a alloc from the given start and end element index.
|
|
134
163
|
*
|
|
135
164
|
* In the best case where the data extracted comes from a single Uint8Array
|
|
136
165
|
* internally this is a no-copy operation otherwise it is a copy operation.
|
|
@@ -143,22 +172,21 @@ export class Uint8ArrayList {
|
|
|
143
172
|
return concat(bufs, length);
|
|
144
173
|
}
|
|
145
174
|
/**
|
|
146
|
-
* Returns a
|
|
175
|
+
* Returns a allocList from the given start and end element index.
|
|
147
176
|
*
|
|
148
177
|
* This is a no-copy operation.
|
|
149
178
|
*/
|
|
150
179
|
sublist(beginInclusive, endExclusive) {
|
|
151
|
-
const { bufs } = this._subList(beginInclusive, endExclusive);
|
|
180
|
+
const { bufs, length } = this._subList(beginInclusive, endExclusive);
|
|
152
181
|
const list = new Uint8ArrayList();
|
|
153
|
-
list.
|
|
182
|
+
list.length = length;
|
|
183
|
+
// don't loop, just set the bufs
|
|
184
|
+
list.bufs = bufs;
|
|
154
185
|
return list;
|
|
155
186
|
}
|
|
156
187
|
_subList(beginInclusive, endExclusive) {
|
|
157
|
-
if (beginInclusive == null && endExclusive == null) {
|
|
158
|
-
return { bufs: this.bufs, length: this.length };
|
|
159
|
-
}
|
|
160
188
|
beginInclusive = beginInclusive ?? 0;
|
|
161
|
-
endExclusive = endExclusive ??
|
|
189
|
+
endExclusive = endExclusive ?? this.length;
|
|
162
190
|
if (beginInclusive < 0) {
|
|
163
191
|
beginInclusive = this.length + beginInclusive;
|
|
164
192
|
}
|
|
@@ -166,151 +194,172 @@ export class Uint8ArrayList {
|
|
|
166
194
|
endExclusive = this.length + endExclusive;
|
|
167
195
|
}
|
|
168
196
|
if (beginInclusive < 0 || endExclusive > this.length) {
|
|
169
|
-
throw new RangeError('index out of bounds');
|
|
197
|
+
throw new RangeError('index is out of bounds');
|
|
170
198
|
}
|
|
171
199
|
if (beginInclusive === endExclusive) {
|
|
172
200
|
return { bufs: [], length: 0 };
|
|
173
201
|
}
|
|
202
|
+
if (beginInclusive === 0 && endExclusive === this.length) {
|
|
203
|
+
return { bufs: this.bufs, length: this.length };
|
|
204
|
+
}
|
|
174
205
|
const bufs = [];
|
|
175
206
|
let offset = 0;
|
|
176
|
-
for (
|
|
207
|
+
for (let i = 0; i < this.bufs.length; i++) {
|
|
208
|
+
const buf = this.bufs[i];
|
|
177
209
|
const bufStart = offset;
|
|
178
210
|
const bufEnd = bufStart + buf.byteLength;
|
|
179
|
-
|
|
180
|
-
const sliceEndsInBuf = endExclusive > bufStart && endExclusive <= bufEnd;
|
|
181
|
-
const bufInSlice = beginInclusive < bufStart && endExclusive >= bufEnd;
|
|
211
|
+
// for next loop
|
|
182
212
|
offset = bufEnd;
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
startIndex = beginInclusive - bufStart;
|
|
187
|
-
endIndex = buf.byteLength;
|
|
213
|
+
if (beginInclusive >= bufEnd) {
|
|
214
|
+
// start after this buf
|
|
215
|
+
continue;
|
|
188
216
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
217
|
+
const sliceStartInBuf = beginInclusive >= bufStart && beginInclusive < bufEnd;
|
|
218
|
+
const sliceEndsInBuf = endExclusive > bufStart && endExclusive <= bufEnd;
|
|
219
|
+
if (sliceStartInBuf && sliceEndsInBuf) {
|
|
220
|
+
// slice is wholly contained within this buffer
|
|
221
|
+
if (beginInclusive === bufStart && endExclusive === bufEnd) {
|
|
222
|
+
// requested whole buffer
|
|
223
|
+
bufs.push(buf);
|
|
224
|
+
break;
|
|
193
225
|
}
|
|
226
|
+
// requested part of buffer
|
|
227
|
+
const start = beginInclusive - bufStart;
|
|
228
|
+
bufs.push(buf.subarray(start, start + (endExclusive - beginInclusive)));
|
|
229
|
+
break;
|
|
194
230
|
}
|
|
195
|
-
if (
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
231
|
+
if (sliceStartInBuf) {
|
|
232
|
+
// slice starts in this buffer
|
|
233
|
+
if (beginInclusive === 0) {
|
|
234
|
+
// requested whole buffer
|
|
235
|
+
bufs.push(buf);
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
// requested part of buffer
|
|
239
|
+
bufs.push(buf.subarray(beginInclusive - bufStart));
|
|
240
|
+
continue;
|
|
201
241
|
}
|
|
202
242
|
if (sliceEndsInBuf) {
|
|
243
|
+
if (endExclusive === bufEnd) {
|
|
244
|
+
// requested whole buffer
|
|
245
|
+
bufs.push(buf);
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
248
|
+
// requested part of buffer
|
|
249
|
+
bufs.push(buf.subarray(0, endExclusive - bufStart));
|
|
203
250
|
break;
|
|
204
251
|
}
|
|
252
|
+
// slice started before this buffer and ends after it
|
|
253
|
+
bufs.push(buf);
|
|
205
254
|
}
|
|
206
255
|
return { bufs, length: endExclusive - beginInclusive };
|
|
207
256
|
}
|
|
208
257
|
getInt8(byteOffset) {
|
|
209
|
-
const buf = this.
|
|
258
|
+
const buf = this.subarray(byteOffset, byteOffset + 1);
|
|
210
259
|
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
211
260
|
return view.getInt8(0);
|
|
212
261
|
}
|
|
213
262
|
setInt8(byteOffset, value) {
|
|
214
|
-
const buf =
|
|
263
|
+
const buf = allocUnsafe(1);
|
|
215
264
|
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
216
265
|
view.setInt8(0, value);
|
|
217
266
|
this.write(buf, byteOffset);
|
|
218
267
|
}
|
|
219
268
|
getInt16(byteOffset, littleEndian) {
|
|
220
|
-
const buf = this.
|
|
269
|
+
const buf = this.subarray(byteOffset, byteOffset + 2);
|
|
221
270
|
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
222
271
|
return view.getInt16(0, littleEndian);
|
|
223
272
|
}
|
|
224
273
|
setInt16(byteOffset, value, littleEndian) {
|
|
225
|
-
const buf =
|
|
274
|
+
const buf = alloc(2);
|
|
226
275
|
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
227
276
|
view.setInt16(0, value, littleEndian);
|
|
228
277
|
this.write(buf, byteOffset);
|
|
229
278
|
}
|
|
230
279
|
getInt32(byteOffset, littleEndian) {
|
|
231
|
-
const buf = this.
|
|
280
|
+
const buf = this.subarray(byteOffset, byteOffset + 4);
|
|
232
281
|
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
233
282
|
return view.getInt32(0, littleEndian);
|
|
234
283
|
}
|
|
235
284
|
setInt32(byteOffset, value, littleEndian) {
|
|
236
|
-
const buf =
|
|
285
|
+
const buf = alloc(4);
|
|
237
286
|
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
238
287
|
view.setInt32(0, value, littleEndian);
|
|
239
288
|
this.write(buf, byteOffset);
|
|
240
289
|
}
|
|
241
290
|
getBigInt64(byteOffset, littleEndian) {
|
|
242
|
-
const buf = this.
|
|
291
|
+
const buf = this.subarray(byteOffset, byteOffset + 8);
|
|
243
292
|
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
244
293
|
return view.getBigInt64(0, littleEndian);
|
|
245
294
|
}
|
|
246
295
|
setBigInt64(byteOffset, value, littleEndian) {
|
|
247
|
-
const buf =
|
|
296
|
+
const buf = alloc(8);
|
|
248
297
|
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
249
298
|
view.setBigInt64(0, value, littleEndian);
|
|
250
299
|
this.write(buf, byteOffset);
|
|
251
300
|
}
|
|
252
301
|
getUint8(byteOffset) {
|
|
253
|
-
const buf = this.
|
|
302
|
+
const buf = this.subarray(byteOffset, byteOffset + 1);
|
|
254
303
|
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
255
304
|
return view.getUint8(0);
|
|
256
305
|
}
|
|
257
306
|
setUint8(byteOffset, value) {
|
|
258
|
-
const buf =
|
|
307
|
+
const buf = allocUnsafe(1);
|
|
259
308
|
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
260
309
|
view.setUint8(0, value);
|
|
261
310
|
this.write(buf, byteOffset);
|
|
262
311
|
}
|
|
263
312
|
getUint16(byteOffset, littleEndian) {
|
|
264
|
-
const buf = this.
|
|
313
|
+
const buf = this.subarray(byteOffset, byteOffset + 2);
|
|
265
314
|
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
266
315
|
return view.getUint16(0, littleEndian);
|
|
267
316
|
}
|
|
268
317
|
setUint16(byteOffset, value, littleEndian) {
|
|
269
|
-
const buf =
|
|
318
|
+
const buf = alloc(2);
|
|
270
319
|
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
271
320
|
view.setUint16(0, value, littleEndian);
|
|
272
321
|
this.write(buf, byteOffset);
|
|
273
322
|
}
|
|
274
323
|
getUint32(byteOffset, littleEndian) {
|
|
275
|
-
const buf = this.
|
|
324
|
+
const buf = this.subarray(byteOffset, byteOffset + 4);
|
|
276
325
|
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
277
326
|
return view.getUint32(0, littleEndian);
|
|
278
327
|
}
|
|
279
328
|
setUint32(byteOffset, value, littleEndian) {
|
|
280
|
-
const buf =
|
|
329
|
+
const buf = alloc(4);
|
|
281
330
|
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
282
331
|
view.setUint32(0, value, littleEndian);
|
|
283
332
|
this.write(buf, byteOffset);
|
|
284
333
|
}
|
|
285
334
|
getBigUint64(byteOffset, littleEndian) {
|
|
286
|
-
const buf = this.
|
|
335
|
+
const buf = this.subarray(byteOffset, byteOffset + 8);
|
|
287
336
|
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
288
337
|
return view.getBigUint64(0, littleEndian);
|
|
289
338
|
}
|
|
290
339
|
setBigUint64(byteOffset, value, littleEndian) {
|
|
291
|
-
const buf =
|
|
340
|
+
const buf = alloc(8);
|
|
292
341
|
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
293
342
|
view.setBigUint64(0, value, littleEndian);
|
|
294
343
|
this.write(buf, byteOffset);
|
|
295
344
|
}
|
|
296
345
|
getFloat32(byteOffset, littleEndian) {
|
|
297
|
-
const buf = this.
|
|
346
|
+
const buf = this.subarray(byteOffset, byteOffset + 4);
|
|
298
347
|
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
299
348
|
return view.getFloat32(0, littleEndian);
|
|
300
349
|
}
|
|
301
350
|
setFloat32(byteOffset, value, littleEndian) {
|
|
302
|
-
const buf =
|
|
351
|
+
const buf = alloc(4);
|
|
303
352
|
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
304
353
|
view.setFloat32(0, value, littleEndian);
|
|
305
354
|
this.write(buf, byteOffset);
|
|
306
355
|
}
|
|
307
356
|
getFloat64(byteOffset, littleEndian) {
|
|
308
|
-
const buf = this.
|
|
357
|
+
const buf = this.subarray(byteOffset, byteOffset + 8);
|
|
309
358
|
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
310
359
|
return view.getFloat64(0, littleEndian);
|
|
311
360
|
}
|
|
312
361
|
setFloat64(byteOffset, value, littleEndian) {
|
|
313
|
-
const buf =
|
|
362
|
+
const buf = alloc(8);
|
|
314
363
|
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
315
364
|
view.setFloat64(0, value, littleEndian);
|
|
316
365
|
this.write(buf, byteOffset);
|
|
@@ -332,5 +381,18 @@ export class Uint8ArrayList {
|
|
|
332
381
|
}
|
|
333
382
|
return true;
|
|
334
383
|
}
|
|
384
|
+
/**
|
|
385
|
+
* Create a Uint8ArrayList from a pre-existing list of Uint8Arrays. Use this
|
|
386
|
+
* method if you know the total size of all the Uint8Arrays ahead of time.
|
|
387
|
+
*/
|
|
388
|
+
static fromUint8Arrays(bufs, length) {
|
|
389
|
+
const list = new Uint8ArrayList();
|
|
390
|
+
list.bufs = bufs;
|
|
391
|
+
if (length == null) {
|
|
392
|
+
length = bufs.reduce((acc, curr) => acc + curr.byteLength, 0);
|
|
393
|
+
}
|
|
394
|
+
list.length = length;
|
|
395
|
+
return list;
|
|
396
|
+
}
|
|
335
397
|
}
|
|
336
398
|
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAE3C,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAA;AAIxD,SAAS,gBAAgB,CAAE,IAAkB,EAAE,KAAa,EAAE,WAAmB;IAC/E,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,IAAI,WAAW,EAAE;QACtD,MAAM,IAAI,UAAU,CAAC,wBAAwB,CAAC,CAAA;KAC/C;IAED,IAAI,MAAM,GAAG,CAAC,CAAA;IAEd,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;QACtB,MAAM,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC,UAAU,CAAA;QAEtC,IAAI,KAAK,GAAG,MAAM,EAAE;YAClB,OAAO;gBACL,GAAG;gBACH,KAAK,EAAE,KAAK,GAAG,MA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CACF"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { concat } from 'uint8arrays/concat'
|
|
2
2
|
import { equals } from 'uint8arrays/equals'
|
|
3
|
+
import { allocUnsafe, alloc } from 'uint8arrays/alloc'
|
|
3
4
|
|
|
4
5
|
const symbol = Symbol.for('@achingbrain/uint8arraylist')
|
|
5
6
|
|
|
6
7
|
type Appendable = Uint8ArrayList | Uint8Array
|
|
7
8
|
|
|
8
|
-
function findBufAndOffset (bufs: Uint8Array[], index: number
|
|
9
|
-
if (index == null || index < 0
|
|
9
|
+
function findBufAndOffset (bufs: Uint8Array[], index: number) {
|
|
10
|
+
if (index == null || index < 0) {
|
|
10
11
|
throw new RangeError('index is out of bounds')
|
|
11
12
|
}
|
|
12
13
|
|
|
@@ -46,7 +47,9 @@ export class Uint8ArrayList implements Iterable<Uint8Array> {
|
|
|
46
47
|
this.bufs = []
|
|
47
48
|
this.length = 0
|
|
48
49
|
|
|
49
|
-
|
|
50
|
+
if (data.length > 0) {
|
|
51
|
+
this.appendAll(data)
|
|
52
|
+
}
|
|
50
53
|
}
|
|
51
54
|
|
|
52
55
|
* [Symbol.iterator] () {
|
|
@@ -58,14 +61,14 @@ export class Uint8ArrayList implements Iterable<Uint8Array> {
|
|
|
58
61
|
}
|
|
59
62
|
|
|
60
63
|
/**
|
|
61
|
-
* Add one or more `bufs` to this Uint8ArrayList
|
|
64
|
+
* Add one or more `bufs` to the end of this Uint8ArrayList
|
|
62
65
|
*/
|
|
63
66
|
append (...bufs: Appendable[]) {
|
|
64
67
|
this.appendAll(bufs)
|
|
65
68
|
}
|
|
66
69
|
|
|
67
70
|
/**
|
|
68
|
-
* Add all `bufs` to this Uint8ArrayList
|
|
71
|
+
* Add all `bufs` to the end of this Uint8ArrayList
|
|
69
72
|
*/
|
|
70
73
|
appendAll (bufs: Appendable[]) {
|
|
71
74
|
let length = 0
|
|
@@ -75,8 +78,8 @@ export class Uint8ArrayList implements Iterable<Uint8Array> {
|
|
|
75
78
|
length += buf.byteLength
|
|
76
79
|
this.bufs.push(buf)
|
|
77
80
|
} else if (isUint8ArrayList(buf)) {
|
|
78
|
-
length += buf.
|
|
79
|
-
this.bufs
|
|
81
|
+
length += buf.byteLength
|
|
82
|
+
this.bufs.push(...buf.bufs)
|
|
80
83
|
} else {
|
|
81
84
|
throw new Error('Could not append value, must be an Uint8Array or a Uint8ArrayList')
|
|
82
85
|
}
|
|
@@ -85,11 +88,39 @@ export class Uint8ArrayList implements Iterable<Uint8Array> {
|
|
|
85
88
|
this.length += length
|
|
86
89
|
}
|
|
87
90
|
|
|
91
|
+
/**
|
|
92
|
+
* Add one or more `bufs` to the start of this Uint8ArrayList
|
|
93
|
+
*/
|
|
94
|
+
prepend (...bufs: Appendable[]) {
|
|
95
|
+
this.prependAll(bufs)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Add all `bufs` to the start of this Uint8ArrayList
|
|
100
|
+
*/
|
|
101
|
+
prependAll (bufs: Appendable[]) {
|
|
102
|
+
let length = 0
|
|
103
|
+
|
|
104
|
+
for (const buf of bufs.reverse()) {
|
|
105
|
+
if (buf instanceof Uint8Array) {
|
|
106
|
+
length += buf.byteLength
|
|
107
|
+
this.bufs.unshift(buf)
|
|
108
|
+
} else if (isUint8ArrayList(buf)) {
|
|
109
|
+
length += buf.byteLength
|
|
110
|
+
this.bufs.unshift(...buf.bufs)
|
|
111
|
+
} else {
|
|
112
|
+
throw new Error('Could not prepend value, must be an Uint8Array or a Uint8ArrayList')
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
this.length += length
|
|
117
|
+
}
|
|
118
|
+
|
|
88
119
|
/**
|
|
89
120
|
* Read the value at `index`
|
|
90
121
|
*/
|
|
91
122
|
get (index: number) {
|
|
92
|
-
const res = findBufAndOffset(this.bufs, index
|
|
123
|
+
const res = findBufAndOffset(this.bufs, index)
|
|
93
124
|
|
|
94
125
|
return res.buf[res.index]
|
|
95
126
|
}
|
|
@@ -98,7 +129,7 @@ export class Uint8ArrayList implements Iterable<Uint8Array> {
|
|
|
98
129
|
* Set the value at `index` to `value`
|
|
99
130
|
*/
|
|
100
131
|
set (index: number, value: number) {
|
|
101
|
-
const res = findBufAndOffset(this.bufs, index
|
|
132
|
+
const res = findBufAndOffset(this.bufs, index)
|
|
102
133
|
|
|
103
134
|
res.buf[res.index] = value
|
|
104
135
|
}
|
|
@@ -158,7 +189,7 @@ export class Uint8ArrayList implements Iterable<Uint8Array> {
|
|
|
158
189
|
}
|
|
159
190
|
|
|
160
191
|
/**
|
|
161
|
-
* Returns a
|
|
192
|
+
* Returns a alloc from the given start and end element index.
|
|
162
193
|
*
|
|
163
194
|
* In the best case where the data extracted comes from a single Uint8Array
|
|
164
195
|
* internally this is a no-copy operation otherwise it is a copy operation.
|
|
@@ -174,26 +205,24 @@ export class Uint8ArrayList implements Iterable<Uint8Array> {
|
|
|
174
205
|
}
|
|
175
206
|
|
|
176
207
|
/**
|
|
177
|
-
* Returns a
|
|
208
|
+
* Returns a allocList from the given start and end element index.
|
|
178
209
|
*
|
|
179
210
|
* This is a no-copy operation.
|
|
180
211
|
*/
|
|
181
212
|
sublist (beginInclusive?: number, endExclusive?: number): Uint8ArrayList {
|
|
182
|
-
const { bufs } = this._subList(beginInclusive, endExclusive)
|
|
213
|
+
const { bufs, length } = this._subList(beginInclusive, endExclusive)
|
|
183
214
|
|
|
184
215
|
const list = new Uint8ArrayList()
|
|
185
|
-
list.
|
|
216
|
+
list.length = length
|
|
217
|
+
// don't loop, just set the bufs
|
|
218
|
+
list.bufs = bufs
|
|
186
219
|
|
|
187
220
|
return list
|
|
188
221
|
}
|
|
189
222
|
|
|
190
223
|
private _subList (beginInclusive?: number, endExclusive?: number) {
|
|
191
|
-
if (beginInclusive == null && endExclusive == null) {
|
|
192
|
-
return { bufs: this.bufs, length: this.length }
|
|
193
|
-
}
|
|
194
|
-
|
|
195
224
|
beginInclusive = beginInclusive ?? 0
|
|
196
|
-
endExclusive = endExclusive ??
|
|
225
|
+
endExclusive = endExclusive ?? this.length
|
|
197
226
|
|
|
198
227
|
if (beginInclusive < 0) {
|
|
199
228
|
beginInclusive = this.length + beginInclusive
|
|
@@ -204,66 +233,91 @@ export class Uint8ArrayList implements Iterable<Uint8Array> {
|
|
|
204
233
|
}
|
|
205
234
|
|
|
206
235
|
if (beginInclusive < 0 || endExclusive > this.length) {
|
|
207
|
-
throw new RangeError('index out of bounds')
|
|
236
|
+
throw new RangeError('index is out of bounds')
|
|
208
237
|
}
|
|
209
238
|
|
|
210
239
|
if (beginInclusive === endExclusive) {
|
|
211
240
|
return { bufs: [], length: 0 }
|
|
212
241
|
}
|
|
213
242
|
|
|
243
|
+
if (beginInclusive === 0 && endExclusive === this.length) {
|
|
244
|
+
return { bufs: this.bufs, length: this.length }
|
|
245
|
+
}
|
|
246
|
+
|
|
214
247
|
const bufs: Uint8Array[] = []
|
|
215
248
|
let offset = 0
|
|
216
249
|
|
|
217
|
-
for (
|
|
250
|
+
for (let i = 0; i < this.bufs.length; i++) {
|
|
251
|
+
const buf = this.bufs[i]
|
|
218
252
|
const bufStart = offset
|
|
219
253
|
const bufEnd = bufStart + buf.byteLength
|
|
220
|
-
const sliceStartInBuf = beginInclusive >= bufStart && beginInclusive < bufEnd
|
|
221
|
-
const sliceEndsInBuf = endExclusive > bufStart && endExclusive <= bufEnd
|
|
222
|
-
const bufInSlice = beginInclusive < bufStart && endExclusive >= bufEnd
|
|
223
|
-
offset = bufEnd
|
|
224
254
|
|
|
225
|
-
|
|
226
|
-
|
|
255
|
+
// for next loop
|
|
256
|
+
offset = bufEnd
|
|
227
257
|
|
|
228
|
-
if (
|
|
229
|
-
|
|
230
|
-
|
|
258
|
+
if (beginInclusive >= bufEnd) {
|
|
259
|
+
// start after this buf
|
|
260
|
+
continue
|
|
231
261
|
}
|
|
232
262
|
|
|
233
|
-
|
|
234
|
-
|
|
263
|
+
const sliceStartInBuf = beginInclusive >= bufStart && beginInclusive < bufEnd
|
|
264
|
+
const sliceEndsInBuf = endExclusive > bufStart && endExclusive <= bufEnd
|
|
235
265
|
|
|
236
|
-
|
|
237
|
-
|
|
266
|
+
if (sliceStartInBuf && sliceEndsInBuf) {
|
|
267
|
+
// slice is wholly contained within this buffer
|
|
268
|
+
if (beginInclusive === bufStart && endExclusive === bufEnd) {
|
|
269
|
+
// requested whole buffer
|
|
270
|
+
bufs.push(buf)
|
|
271
|
+
break
|
|
238
272
|
}
|
|
239
|
-
}
|
|
240
273
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
274
|
+
// requested part of buffer
|
|
275
|
+
const start = beginInclusive - bufStart
|
|
276
|
+
bufs.push(buf.subarray(start, start + (endExclusive - beginInclusive)))
|
|
277
|
+
break
|
|
244
278
|
}
|
|
245
279
|
|
|
246
|
-
if (
|
|
247
|
-
|
|
280
|
+
if (sliceStartInBuf) {
|
|
281
|
+
// slice starts in this buffer
|
|
282
|
+
if (beginInclusive === 0) {
|
|
283
|
+
// requested whole buffer
|
|
284
|
+
bufs.push(buf)
|
|
285
|
+
continue
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// requested part of buffer
|
|
289
|
+
bufs.push(buf.subarray(beginInclusive - bufStart))
|
|
290
|
+
continue
|
|
248
291
|
}
|
|
249
292
|
|
|
250
293
|
if (sliceEndsInBuf) {
|
|
294
|
+
if (endExclusive === bufEnd) {
|
|
295
|
+
// requested whole buffer
|
|
296
|
+
bufs.push(buf)
|
|
297
|
+
break
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// requested part of buffer
|
|
301
|
+
bufs.push(buf.subarray(0, endExclusive - bufStart))
|
|
251
302
|
break
|
|
252
303
|
}
|
|
304
|
+
|
|
305
|
+
// slice started before this buffer and ends after it
|
|
306
|
+
bufs.push(buf)
|
|
253
307
|
}
|
|
254
308
|
|
|
255
309
|
return { bufs, length: endExclusive - beginInclusive }
|
|
256
310
|
}
|
|
257
311
|
|
|
258
312
|
getInt8 (byteOffset: number): number {
|
|
259
|
-
const buf = this.
|
|
313
|
+
const buf = this.subarray(byteOffset, byteOffset + 1)
|
|
260
314
|
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
261
315
|
|
|
262
316
|
return view.getInt8(0)
|
|
263
317
|
}
|
|
264
318
|
|
|
265
319
|
setInt8 (byteOffset: number, value: number): void {
|
|
266
|
-
const buf =
|
|
320
|
+
const buf = allocUnsafe(1)
|
|
267
321
|
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
268
322
|
view.setInt8(0, value)
|
|
269
323
|
|
|
@@ -271,14 +325,14 @@ export class Uint8ArrayList implements Iterable<Uint8Array> {
|
|
|
271
325
|
}
|
|
272
326
|
|
|
273
327
|
getInt16 (byteOffset: number, littleEndian?: boolean): number {
|
|
274
|
-
const buf = this.
|
|
328
|
+
const buf = this.subarray(byteOffset, byteOffset + 2)
|
|
275
329
|
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
276
330
|
|
|
277
331
|
return view.getInt16(0, littleEndian)
|
|
278
332
|
}
|
|
279
333
|
|
|
280
334
|
setInt16 (byteOffset: number, value: number, littleEndian?: boolean): void {
|
|
281
|
-
const buf =
|
|
335
|
+
const buf = alloc(2)
|
|
282
336
|
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
283
337
|
view.setInt16(0, value, littleEndian)
|
|
284
338
|
|
|
@@ -286,14 +340,14 @@ export class Uint8ArrayList implements Iterable<Uint8Array> {
|
|
|
286
340
|
}
|
|
287
341
|
|
|
288
342
|
getInt32 (byteOffset: number, littleEndian?: boolean): number {
|
|
289
|
-
const buf = this.
|
|
343
|
+
const buf = this.subarray(byteOffset, byteOffset + 4)
|
|
290
344
|
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
291
345
|
|
|
292
346
|
return view.getInt32(0, littleEndian)
|
|
293
347
|
}
|
|
294
348
|
|
|
295
349
|
setInt32 (byteOffset: number, value: number, littleEndian?: boolean): void {
|
|
296
|
-
const buf =
|
|
350
|
+
const buf = alloc(4)
|
|
297
351
|
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
298
352
|
view.setInt32(0, value, littleEndian)
|
|
299
353
|
|
|
@@ -301,14 +355,14 @@ export class Uint8ArrayList implements Iterable<Uint8Array> {
|
|
|
301
355
|
}
|
|
302
356
|
|
|
303
357
|
getBigInt64 (byteOffset: number, littleEndian?: boolean): bigint {
|
|
304
|
-
const buf = this.
|
|
358
|
+
const buf = this.subarray(byteOffset, byteOffset + 8)
|
|
305
359
|
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
306
360
|
|
|
307
361
|
return view.getBigInt64(0, littleEndian)
|
|
308
362
|
}
|
|
309
363
|
|
|
310
364
|
setBigInt64 (byteOffset: number, value: bigint, littleEndian?: boolean): void {
|
|
311
|
-
const buf =
|
|
365
|
+
const buf = alloc(8)
|
|
312
366
|
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
313
367
|
view.setBigInt64(0, value, littleEndian)
|
|
314
368
|
|
|
@@ -316,14 +370,14 @@ export class Uint8ArrayList implements Iterable<Uint8Array> {
|
|
|
316
370
|
}
|
|
317
371
|
|
|
318
372
|
getUint8 (byteOffset: number): number {
|
|
319
|
-
const buf = this.
|
|
373
|
+
const buf = this.subarray(byteOffset, byteOffset + 1)
|
|
320
374
|
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
321
375
|
|
|
322
376
|
return view.getUint8(0)
|
|
323
377
|
}
|
|
324
378
|
|
|
325
379
|
setUint8 (byteOffset: number, value: number): void {
|
|
326
|
-
const buf =
|
|
380
|
+
const buf = allocUnsafe(1)
|
|
327
381
|
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
328
382
|
view.setUint8(0, value)
|
|
329
383
|
|
|
@@ -331,14 +385,14 @@ export class Uint8ArrayList implements Iterable<Uint8Array> {
|
|
|
331
385
|
}
|
|
332
386
|
|
|
333
387
|
getUint16 (byteOffset: number, littleEndian?: boolean): number {
|
|
334
|
-
const buf = this.
|
|
388
|
+
const buf = this.subarray(byteOffset, byteOffset + 2)
|
|
335
389
|
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
336
390
|
|
|
337
391
|
return view.getUint16(0, littleEndian)
|
|
338
392
|
}
|
|
339
393
|
|
|
340
394
|
setUint16 (byteOffset: number, value: number, littleEndian?: boolean): void {
|
|
341
|
-
const buf =
|
|
395
|
+
const buf = alloc(2)
|
|
342
396
|
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
343
397
|
view.setUint16(0, value, littleEndian)
|
|
344
398
|
|
|
@@ -346,14 +400,14 @@ export class Uint8ArrayList implements Iterable<Uint8Array> {
|
|
|
346
400
|
}
|
|
347
401
|
|
|
348
402
|
getUint32 (byteOffset: number, littleEndian?: boolean): number {
|
|
349
|
-
const buf = this.
|
|
403
|
+
const buf = this.subarray(byteOffset, byteOffset + 4)
|
|
350
404
|
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
351
405
|
|
|
352
406
|
return view.getUint32(0, littleEndian)
|
|
353
407
|
}
|
|
354
408
|
|
|
355
409
|
setUint32 (byteOffset: number, value: number, littleEndian?: boolean): void {
|
|
356
|
-
const buf =
|
|
410
|
+
const buf = alloc(4)
|
|
357
411
|
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
358
412
|
view.setUint32(0, value, littleEndian)
|
|
359
413
|
|
|
@@ -361,14 +415,14 @@ export class Uint8ArrayList implements Iterable<Uint8Array> {
|
|
|
361
415
|
}
|
|
362
416
|
|
|
363
417
|
getBigUint64 (byteOffset: number, littleEndian?: boolean): bigint {
|
|
364
|
-
const buf = this.
|
|
418
|
+
const buf = this.subarray(byteOffset, byteOffset + 8)
|
|
365
419
|
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
366
420
|
|
|
367
421
|
return view.getBigUint64(0, littleEndian)
|
|
368
422
|
}
|
|
369
423
|
|
|
370
424
|
setBigUint64 (byteOffset: number, value: bigint, littleEndian?: boolean): void {
|
|
371
|
-
const buf =
|
|
425
|
+
const buf = alloc(8)
|
|
372
426
|
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
373
427
|
view.setBigUint64(0, value, littleEndian)
|
|
374
428
|
|
|
@@ -376,14 +430,14 @@ export class Uint8ArrayList implements Iterable<Uint8Array> {
|
|
|
376
430
|
}
|
|
377
431
|
|
|
378
432
|
getFloat32 (byteOffset: number, littleEndian?: boolean): number {
|
|
379
|
-
const buf = this.
|
|
433
|
+
const buf = this.subarray(byteOffset, byteOffset + 4)
|
|
380
434
|
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
381
435
|
|
|
382
436
|
return view.getFloat32(0, littleEndian)
|
|
383
437
|
}
|
|
384
438
|
|
|
385
439
|
setFloat32 (byteOffset: number, value: number, littleEndian?: boolean): void {
|
|
386
|
-
const buf =
|
|
440
|
+
const buf = alloc(4)
|
|
387
441
|
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
388
442
|
view.setFloat32(0, value, littleEndian)
|
|
389
443
|
|
|
@@ -391,14 +445,14 @@ export class Uint8ArrayList implements Iterable<Uint8Array> {
|
|
|
391
445
|
}
|
|
392
446
|
|
|
393
447
|
getFloat64 (byteOffset: number, littleEndian?: boolean): number {
|
|
394
|
-
const buf = this.
|
|
448
|
+
const buf = this.subarray(byteOffset, byteOffset + 8)
|
|
395
449
|
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
396
450
|
|
|
397
451
|
return view.getFloat64(0, littleEndian)
|
|
398
452
|
}
|
|
399
453
|
|
|
400
454
|
setFloat64 (byteOffset: number, value: number, littleEndian?: boolean): void {
|
|
401
|
-
const buf =
|
|
455
|
+
const buf = alloc(8)
|
|
402
456
|
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
403
457
|
view.setFloat64(0, value, littleEndian)
|
|
404
458
|
|
|
@@ -426,4 +480,21 @@ export class Uint8ArrayList implements Iterable<Uint8Array> {
|
|
|
426
480
|
|
|
427
481
|
return true
|
|
428
482
|
}
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* Create a Uint8ArrayList from a pre-existing list of Uint8Arrays. Use this
|
|
486
|
+
* method if you know the total size of all the Uint8Arrays ahead of time.
|
|
487
|
+
*/
|
|
488
|
+
static fromUint8Arrays (bufs: Uint8Array[], length?: number): Uint8ArrayList {
|
|
489
|
+
const list = new Uint8ArrayList()
|
|
490
|
+
list.bufs = bufs
|
|
491
|
+
|
|
492
|
+
if (length == null) {
|
|
493
|
+
length = bufs.reduce((acc, curr) => acc + curr.byteLength, 0)
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
list.length = length
|
|
497
|
+
|
|
498
|
+
return list
|
|
499
|
+
}
|
|
429
500
|
}
|