extended-buffer 7.1.0 → 7.1.2
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 +1 -1
- package/dist/ExtendedBuffer.js +8 -22
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/ExtendedBuffer.js
CHANGED
|
@@ -41,6 +41,12 @@ class ExtendedBuffer {
|
|
|
41
41
|
this.initExtendedBuffer();
|
|
42
42
|
}
|
|
43
43
|
createInstance(options) {
|
|
44
|
+
options = Object.assign({
|
|
45
|
+
capacity: this._capacity,
|
|
46
|
+
capacityStep: this._capacityStep,
|
|
47
|
+
nativeAllocSlow: this._nativeAllocSlow,
|
|
48
|
+
nativeReallocSlow: this._nativeReallocSlow
|
|
49
|
+
}, options !== null && options !== void 0 ? options : {});
|
|
44
50
|
const ThisClass = this.constructor;
|
|
45
51
|
return new ThisClass(options);
|
|
46
52
|
}
|
|
@@ -200,7 +206,6 @@ class ExtendedBuffer {
|
|
|
200
206
|
}
|
|
201
207
|
writeIntBE(value, size, unshift) {
|
|
202
208
|
utils.assertInteger(value);
|
|
203
|
-
utils.assertUnsignedInteger(size);
|
|
204
209
|
utils.assertIntegerSize(size);
|
|
205
210
|
if (unshift) {
|
|
206
211
|
this.allocStart(size);
|
|
@@ -216,7 +221,6 @@ class ExtendedBuffer {
|
|
|
216
221
|
}
|
|
217
222
|
writeIntLE(value, size, unshift) {
|
|
218
223
|
utils.assertInteger(value);
|
|
219
|
-
utils.assertUnsignedInteger(size);
|
|
220
224
|
utils.assertIntegerSize(size);
|
|
221
225
|
if (unshift) {
|
|
222
226
|
this.allocStart(size);
|
|
@@ -232,7 +236,6 @@ class ExtendedBuffer {
|
|
|
232
236
|
}
|
|
233
237
|
writeUIntBE(value, size, unshift) {
|
|
234
238
|
utils.assertUnsignedInteger(value);
|
|
235
|
-
utils.assertUnsignedInteger(size);
|
|
236
239
|
utils.assertIntegerSize(size);
|
|
237
240
|
if (unshift) {
|
|
238
241
|
this.allocStart(size);
|
|
@@ -248,7 +251,6 @@ class ExtendedBuffer {
|
|
|
248
251
|
}
|
|
249
252
|
writeUIntLE(value, size, unshift) {
|
|
250
253
|
utils.assertUnsignedInteger(value);
|
|
251
|
-
utils.assertUnsignedInteger(size);
|
|
252
254
|
utils.assertIntegerSize(size);
|
|
253
255
|
if (unshift) {
|
|
254
256
|
this.allocStart(size);
|
|
@@ -349,20 +351,8 @@ class ExtendedBuffer {
|
|
|
349
351
|
if (!this.isReadable(size)) {
|
|
350
352
|
throw new errors_1.ExtendedBufferRangeError('SIZE_OUT_OF_RANGE');
|
|
351
353
|
}
|
|
352
|
-
|
|
353
|
-
const
|
|
354
|
-
if (asNative) {
|
|
355
|
-
result = buffer_1.Buffer.from(buffer);
|
|
356
|
-
}
|
|
357
|
-
else {
|
|
358
|
-
bufferOptions = Object.assign({
|
|
359
|
-
capacity: this._capacity,
|
|
360
|
-
capacityStep: this._capacityStep,
|
|
361
|
-
nativeAllocSlow: this._nativeAllocSlow,
|
|
362
|
-
nativeReallocSlow: this._nativeReallocSlow
|
|
363
|
-
}, bufferOptions !== null && bufferOptions !== void 0 ? bufferOptions : {});
|
|
364
|
-
result = this.createInstance(bufferOptions).writeNativeBuffer(buffer);
|
|
365
|
-
}
|
|
354
|
+
const nativeBuffer = utils.nativeBufferSubarray(this._nativeBuffer, this.nativePointer(), this.nativePointer() + size);
|
|
355
|
+
const result = asNative ? buffer_1.Buffer.from(nativeBuffer) : this.createInstance(bufferOptions).writeNativeBuffer(nativeBuffer);
|
|
366
356
|
this.offset(size);
|
|
367
357
|
return result;
|
|
368
358
|
}
|
|
@@ -376,7 +366,6 @@ class ExtendedBuffer {
|
|
|
376
366
|
return result;
|
|
377
367
|
}
|
|
378
368
|
readIntBE(size) {
|
|
379
|
-
utils.assertUnsignedInteger(size);
|
|
380
369
|
utils.assertIntegerSize(size);
|
|
381
370
|
if (!this.isReadable(size)) {
|
|
382
371
|
throw new errors_1.ExtendedBufferRangeError('SIZE_OUT_OF_RANGE');
|
|
@@ -386,7 +375,6 @@ class ExtendedBuffer {
|
|
|
386
375
|
return result;
|
|
387
376
|
}
|
|
388
377
|
readIntLE(size) {
|
|
389
|
-
utils.assertUnsignedInteger(size);
|
|
390
378
|
utils.assertIntegerSize(size);
|
|
391
379
|
if (!this.isReadable(size)) {
|
|
392
380
|
throw new errors_1.ExtendedBufferRangeError('SIZE_OUT_OF_RANGE');
|
|
@@ -396,7 +384,6 @@ class ExtendedBuffer {
|
|
|
396
384
|
return result;
|
|
397
385
|
}
|
|
398
386
|
readUIntBE(size) {
|
|
399
|
-
utils.assertUnsignedInteger(size);
|
|
400
387
|
utils.assertIntegerSize(size);
|
|
401
388
|
if (!this.isReadable(size)) {
|
|
402
389
|
throw new errors_1.ExtendedBufferRangeError('SIZE_OUT_OF_RANGE');
|
|
@@ -406,7 +393,6 @@ class ExtendedBuffer {
|
|
|
406
393
|
return result;
|
|
407
394
|
}
|
|
408
395
|
readUIntLE(size) {
|
|
409
|
-
utils.assertUnsignedInteger(size);
|
|
410
396
|
utils.assertIntegerSize(size);
|
|
411
397
|
if (!this.isReadable(size)) {
|
|
412
398
|
throw new errors_1.ExtendedBufferRangeError('SIZE_OUT_OF_RANGE');
|