extended-buffer 6.0.2 → 6.0.5

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.
@@ -1,19 +1,19 @@
1
1
  /// <reference types="node" />
2
2
  import { ExtendedBufferOptions } from './ExtendedBufferOptions';
3
3
  export declare class ExtendedBuffer {
4
- _maxBufferLength: number;
5
4
  _pointer: number;
6
- _pointerStart: number;
7
5
  _pointerEnd: number;
6
+ _pointerStart: number;
8
7
  _nativeBuffer: Buffer;
8
+ _maxBufferLength: number;
9
9
  constructor(options?: ExtendedBufferOptions);
10
- static readonly maxSize: number;
10
+ static get maxSize(): number;
11
11
  static concat<T extends ExtendedBuffer>(this: new (options?: ExtendedBufferOptions) => T, list: ExtendedBuffer[], totalLength?: number): T;
12
12
  static zigZagEncode32(value: number): number;
13
13
  static zigZagDecode32(value: number): number;
14
- readonly length: number;
15
- readonly nativeLength: number;
16
- readonly buffer: Buffer;
14
+ get length(): number;
15
+ get nativeLength(): number;
16
+ get buffer(): Buffer;
17
17
  _initEmptyBuffer(): this;
18
18
  clean(): this;
19
19
  getFreeSpaceStart(): number;
@@ -53,6 +53,9 @@ export declare class ExtendedBuffer {
53
53
  writeDoubleBE(value: number, unshift?: boolean, noAssert?: boolean): this;
54
54
  writeDoubleLE(value: number, unshift?: boolean, noAssert?: boolean): this;
55
55
  writeVarInt32(value: number, unshift?: boolean): this;
56
+ readBuffer(size: number): this;
57
+ readBuffer(size: number, asNative: false, bufferOptions?: ExtendedBufferOptions): this;
58
+ readBuffer(size: number, asNative: true, bufferOptions?: ExtendedBufferOptions): Buffer;
56
59
  readBuffer(size: number, asNative?: boolean, bufferOptions?: ExtendedBufferOptions): this | Buffer;
57
60
  readString(size: number, encoding?: string): string;
58
61
  readIntBE(byteLength: number, noAssert?: boolean): number;
@@ -1,23 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var buffer_1 = require("buffer");
4
- var ExtendedBuffer = (function () {
5
- function ExtendedBuffer(options) {
6
- if (options === void 0) { options = {}; }
7
- this._maxBufferLength = options.maxBufferLength || buffer_1.kMaxLength;
3
+ exports.ExtendedBuffer = void 0;
4
+ const buffer_1 = require("buffer");
5
+ class ExtendedBuffer {
6
+ constructor(options) {
7
+ var _a;
8
+ this._maxBufferLength = (_a = options === null || options === void 0 ? void 0 : options.maxBufferLength) !== null && _a !== void 0 ? _a : (1024 * 1024);
8
9
  this._initEmptyBuffer();
9
10
  }
10
- Object.defineProperty(ExtendedBuffer, "maxSize", {
11
- get: function () {
12
- return buffer_1.kMaxLength;
13
- },
14
- enumerable: true,
15
- configurable: true
16
- });
17
- ExtendedBuffer.concat = function (list, totalLength) {
18
- var buffer = new this;
19
- var listLength = list.length;
20
- for (var i = 0; i < listLength; ++i) {
11
+ static get maxSize() {
12
+ return buffer_1.kMaxLength;
13
+ }
14
+ static concat(list, totalLength) {
15
+ let buffer = new this;
16
+ let listLength = list.length;
17
+ for (let i = 0; i < listLength; ++i) {
21
18
  buffer.writeBuffer(list[i], false);
22
19
  if (undefined !== totalLength && buffer.length >= totalLength) {
23
20
  buffer._pointerEnd = buffer._pointerStart + totalLength;
@@ -25,84 +22,74 @@ var ExtendedBuffer = (function () {
25
22
  }
26
23
  }
27
24
  return buffer;
28
- };
29
- ExtendedBuffer.zigZagEncode32 = function (value) {
25
+ }
26
+ static zigZagEncode32(value) {
30
27
  return (((value |= 0) << 1) ^ (value >> 31)) >>> 0;
31
- };
32
- ExtendedBuffer.zigZagDecode32 = function (value) {
28
+ }
29
+ static zigZagDecode32(value) {
33
30
  return ((value >>> 1) ^ -(value & 1)) | 0;
34
- };
35
- Object.defineProperty(ExtendedBuffer.prototype, "length", {
36
- get: function () {
37
- return this._pointerEnd - this._pointerStart;
38
- },
39
- enumerable: true,
40
- configurable: true
41
- });
42
- Object.defineProperty(ExtendedBuffer.prototype, "nativeLength", {
43
- get: function () {
44
- return this._nativeBuffer.length;
45
- },
46
- enumerable: true,
47
- configurable: true
48
- });
49
- Object.defineProperty(ExtendedBuffer.prototype, "buffer", {
50
- get: function () {
51
- return this._nativeBuffer.slice(this._pointerStart, this._pointerEnd);
52
- },
53
- enumerable: true,
54
- configurable: true
55
- });
56
- ExtendedBuffer.prototype._initEmptyBuffer = function () {
31
+ }
32
+ get length() {
33
+ return this._pointerEnd - this._pointerStart;
34
+ }
35
+ get nativeLength() {
36
+ return this._nativeBuffer.length;
37
+ }
38
+ get buffer() {
39
+ return this._nativeBuffer.slice(this._pointerStart, this._pointerEnd);
40
+ }
41
+ _initEmptyBuffer() {
42
+ if (this._maxBufferLength > buffer_1.kMaxLength) {
43
+ throw new RangeError(`"_maxBufferLength" cannot be more than ${buffer_1.kMaxLength} bytes`);
44
+ }
57
45
  this._pointerStart = this._pointerEnd = Math.floor(this._maxBufferLength / 2);
58
46
  this._nativeBuffer = buffer_1.Buffer.allocUnsafe ? buffer_1.Buffer.allocUnsafe(this._maxBufferLength) : new buffer_1.Buffer(this._maxBufferLength);
59
47
  this._pointer = 0;
60
48
  return this;
61
- };
62
- ExtendedBuffer.prototype.clean = function () {
49
+ }
50
+ clean() {
63
51
  return this._initEmptyBuffer();
64
- };
65
- ExtendedBuffer.prototype.getFreeSpaceStart = function () {
52
+ }
53
+ getFreeSpaceStart() {
66
54
  return this._pointerStart;
67
- };
68
- ExtendedBuffer.prototype.getFreeSpaceEnd = function () {
55
+ }
56
+ getFreeSpaceEnd() {
69
57
  return this._nativeBuffer.length - this._pointerEnd;
70
- };
71
- ExtendedBuffer.prototype.getFreeSpace = function () {
58
+ }
59
+ getFreeSpace() {
72
60
  return this.getFreeSpaceStart() + this.getFreeSpaceEnd();
73
- };
74
- ExtendedBuffer.prototype.allocStart = function (byteLength) {
61
+ }
62
+ allocStart(byteLength) {
75
63
  if (byteLength > this.getFreeSpaceStart()) {
76
64
  if (byteLength > this.getFreeSpace()) {
77
65
  throw new RangeError('Not enough free space');
78
66
  }
79
- var offset = Math.floor((this.getFreeSpace() - byteLength) / 2) + byteLength - this._pointerStart;
67
+ const offset = Math.floor((this.getFreeSpace() - byteLength) / 2) + byteLength - this._pointerStart;
80
68
  this._nativeBuffer.copy(this._nativeBuffer, this._pointerStart + offset, this._pointerStart, this._pointerEnd);
81
69
  this._pointerStart += offset;
82
70
  this._pointerEnd += offset;
83
71
  }
84
72
  return this;
85
- };
86
- ExtendedBuffer.prototype.allocEnd = function (byteLength) {
73
+ }
74
+ allocEnd(byteLength) {
87
75
  if (byteLength > this.getFreeSpaceEnd()) {
88
76
  if (byteLength > this.getFreeSpace()) {
89
77
  throw new RangeError('Not enough free space');
90
78
  }
91
- var offset = this._nativeBuffer.length - Math.floor((this.getFreeSpace() - byteLength) / 2) - byteLength - this._pointerEnd;
79
+ let offset = this._nativeBuffer.length - Math.floor((this.getFreeSpace() - byteLength) / 2) - byteLength - this._pointerEnd;
92
80
  this._nativeBuffer.copy(this._nativeBuffer, this._pointerStart + offset, this._pointerStart, this._pointerEnd);
93
81
  this._pointerStart += offset;
94
82
  this._pointerEnd += offset;
95
83
  }
96
84
  return this;
97
- };
98
- ExtendedBuffer.prototype.getReadableSize = function () {
85
+ }
86
+ getReadableSize() {
99
87
  return this._pointerEnd - this._pointerStart - this._pointer;
100
- };
101
- ExtendedBuffer.prototype.getWritableSize = function () {
88
+ }
89
+ getWritableSize() {
102
90
  return this.getFreeSpace();
103
- };
104
- ExtendedBuffer.prototype._writeNativeBuffer = function (buffer, unshift) {
105
- if (unshift === void 0) { unshift = false; }
91
+ }
92
+ _writeNativeBuffer(buffer, unshift) {
106
93
  if (unshift) {
107
94
  this.allocStart(buffer.length);
108
95
  this._pointerStart -= buffer.length;
@@ -114,61 +101,53 @@ var ExtendedBuffer = (function () {
114
101
  this._pointerEnd += buffer.length;
115
102
  }
116
103
  return this;
117
- };
118
- ExtendedBuffer.prototype.gc = function () {
104
+ }
105
+ gc() {
119
106
  if (this._pointer > 0) {
120
- var payload = this._nativeBuffer.slice(this._pointerStart + this._pointer, this._pointerEnd);
107
+ let payload = this._nativeBuffer.slice(this._pointerStart + this._pointer, this._pointerEnd);
121
108
  return this._initEmptyBuffer()._writeNativeBuffer(payload, false);
122
109
  }
123
110
  return this;
124
- };
125
- ExtendedBuffer.prototype.nodeGc = function () {
111
+ }
112
+ nodeGc() {
126
113
  global.gc && global.gc();
127
114
  return this;
128
- };
129
- ExtendedBuffer.prototype.setPointer = function (pointer) {
130
- if (pointer >= 0 && pointer <= this.length) {
131
- this._pointer = pointer;
132
- }
133
- else {
134
- this._pointer = pointer < 0 ? 0 : this.length;
115
+ }
116
+ setPointer(pointer) {
117
+ if (pointer < 0 || pointer > this.length) {
118
+ throw new RangeError('Pointer out of range');
135
119
  }
120
+ this._pointer = pointer;
136
121
  return this;
137
- };
138
- ExtendedBuffer.prototype.getPointer = function () {
122
+ }
123
+ getPointer() {
139
124
  return this._pointer;
140
- };
141
- ExtendedBuffer.prototype.offset = function (offset) {
125
+ }
126
+ offset(offset) {
142
127
  return this.setPointer(this._pointer + offset);
143
- };
144
- ExtendedBuffer.prototype.isReadable = function (byteLength) {
145
- if (byteLength === void 0) { byteLength = 1; }
128
+ }
129
+ isReadable(byteLength = 1) {
146
130
  byteLength = byteLength < 1 ? 1 : byteLength;
147
131
  return this.getReadableSize() >= byteLength;
148
- };
149
- ExtendedBuffer.prototype.isWritable = function (byteLength) {
150
- if (byteLength === void 0) { byteLength = 1; }
132
+ }
133
+ isWritable(byteLength = 1) {
151
134
  byteLength = byteLength < 1 ? 1 : byteLength;
152
135
  return this.getFreeSpace() >= byteLength;
153
- };
154
- ExtendedBuffer.prototype.toString = function (encoding, start, end) {
136
+ }
137
+ toString(encoding, start, end) {
155
138
  return this.buffer.toString(encoding, start, end);
156
- };
157
- ExtendedBuffer.prototype.writeBuffer = function (value, unshift) {
158
- if (unshift === void 0) { unshift = false; }
139
+ }
140
+ writeBuffer(value, unshift) {
159
141
  if (value instanceof buffer_1.Buffer) {
160
142
  return this._writeNativeBuffer(value, unshift);
161
143
  }
162
- else if (value instanceof ExtendedBuffer) {
144
+ if (value instanceof ExtendedBuffer) {
163
145
  return this._writeNativeBuffer(value.buffer, unshift);
164
146
  }
165
- else {
166
- throw new TypeError('"value" is incorrect buffer');
167
- }
168
- };
169
- ExtendedBuffer.prototype.writeString = function (string, encoding, unshift) {
170
- if (unshift === void 0) { unshift = false; }
171
- var byteLength = buffer_1.Buffer.byteLength(string, encoding);
147
+ throw new TypeError('"value" is incorrect buffer');
148
+ }
149
+ writeString(string, encoding, unshift) {
150
+ let byteLength = buffer_1.Buffer.byteLength(string, encoding);
172
151
  if (unshift) {
173
152
  this.allocStart(byteLength);
174
153
  this._pointerStart -= byteLength;
@@ -180,10 +159,8 @@ var ExtendedBuffer = (function () {
180
159
  this._pointerEnd += byteLength;
181
160
  }
182
161
  return this;
183
- };
184
- ExtendedBuffer.prototype.writeIntBE = function (value, byteLength, unshift, noAssert) {
185
- if (unshift === void 0) { unshift = false; }
186
- if (noAssert === void 0) { noAssert = false; }
162
+ }
163
+ writeIntBE(value, byteLength, unshift, noAssert) {
187
164
  if (unshift) {
188
165
  this.allocStart(byteLength);
189
166
  this._pointerStart -= byteLength;
@@ -195,10 +172,8 @@ var ExtendedBuffer = (function () {
195
172
  this._pointerEnd += byteLength;
196
173
  }
197
174
  return this;
198
- };
199
- ExtendedBuffer.prototype.writeIntLE = function (value, byteLength, unshift, noAssert) {
200
- if (unshift === void 0) { unshift = false; }
201
- if (noAssert === void 0) { noAssert = false; }
175
+ }
176
+ writeIntLE(value, byteLength, unshift, noAssert) {
202
177
  if (unshift) {
203
178
  this.allocStart(byteLength);
204
179
  this._pointerStart -= byteLength;
@@ -210,10 +185,8 @@ var ExtendedBuffer = (function () {
210
185
  this._pointerEnd += byteLength;
211
186
  }
212
187
  return this;
213
- };
214
- ExtendedBuffer.prototype.writeUIntBE = function (value, byteLength, unshift, noAssert) {
215
- if (unshift === void 0) { unshift = false; }
216
- if (noAssert === void 0) { noAssert = false; }
188
+ }
189
+ writeUIntBE(value, byteLength, unshift, noAssert) {
217
190
  if (unshift) {
218
191
  this.allocStart(byteLength);
219
192
  this._pointerStart -= byteLength;
@@ -225,10 +198,8 @@ var ExtendedBuffer = (function () {
225
198
  this._pointerEnd += byteLength;
226
199
  }
227
200
  return this;
228
- };
229
- ExtendedBuffer.prototype.writeUIntLE = function (value, byteLength, unshift, noAssert) {
230
- if (unshift === void 0) { unshift = false; }
231
- if (noAssert === void 0) { noAssert = false; }
201
+ }
202
+ writeUIntLE(value, byteLength, unshift, noAssert) {
232
203
  if (unshift) {
233
204
  this.allocStart(byteLength);
234
205
  this._pointerStart -= byteLength;
@@ -240,60 +211,38 @@ var ExtendedBuffer = (function () {
240
211
  this._pointerEnd += byteLength;
241
212
  }
242
213
  return this;
243
- };
244
- ExtendedBuffer.prototype.writeInt8 = function (value, unshift, noAssert) {
245
- if (unshift === void 0) { unshift = false; }
246
- if (noAssert === void 0) { noAssert = false; }
214
+ }
215
+ writeInt8(value, unshift, noAssert) {
247
216
  return this.writeIntBE(value, 1, unshift, noAssert);
248
- };
249
- ExtendedBuffer.prototype.writeUInt8 = function (value, unshift, noAssert) {
250
- if (unshift === void 0) { unshift = false; }
251
- if (noAssert === void 0) { noAssert = false; }
217
+ }
218
+ writeUInt8(value, unshift, noAssert) {
252
219
  return this.writeUIntBE(value, 1, unshift, noAssert);
253
- };
254
- ExtendedBuffer.prototype.writeInt16BE = function (value, unshift, noAssert) {
255
- if (unshift === void 0) { unshift = false; }
256
- if (noAssert === void 0) { noAssert = false; }
220
+ }
221
+ writeInt16BE(value, unshift, noAssert) {
257
222
  return this.writeIntBE(value, 2, unshift, noAssert);
258
- };
259
- ExtendedBuffer.prototype.writeInt16LE = function (value, unshift, noAssert) {
260
- if (unshift === void 0) { unshift = false; }
261
- if (noAssert === void 0) { noAssert = false; }
223
+ }
224
+ writeInt16LE(value, unshift, noAssert) {
262
225
  return this.writeIntLE(value, 2, unshift, noAssert);
263
- };
264
- ExtendedBuffer.prototype.writeUInt16BE = function (value, unshift, noAssert) {
265
- if (unshift === void 0) { unshift = false; }
266
- if (noAssert === void 0) { noAssert = false; }
226
+ }
227
+ writeUInt16BE(value, unshift, noAssert) {
267
228
  return this.writeUIntBE(value, 2, unshift, noAssert);
268
- };
269
- ExtendedBuffer.prototype.writeUInt16LE = function (value, unshift, noAssert) {
270
- if (unshift === void 0) { unshift = false; }
271
- if (noAssert === void 0) { noAssert = false; }
229
+ }
230
+ writeUInt16LE(value, unshift, noAssert) {
272
231
  return this.writeUIntLE(value, 2, unshift, noAssert);
273
- };
274
- ExtendedBuffer.prototype.writeInt32BE = function (value, unshift, noAssert) {
275
- if (unshift === void 0) { unshift = false; }
276
- if (noAssert === void 0) { noAssert = false; }
232
+ }
233
+ writeInt32BE(value, unshift, noAssert) {
277
234
  return this.writeIntBE(value, 4, unshift, noAssert);
278
- };
279
- ExtendedBuffer.prototype.writeInt32LE = function (value, unshift, noAssert) {
280
- if (unshift === void 0) { unshift = false; }
281
- if (noAssert === void 0) { noAssert = false; }
235
+ }
236
+ writeInt32LE(value, unshift, noAssert) {
282
237
  return this.writeIntLE(value, 4, unshift, noAssert);
283
- };
284
- ExtendedBuffer.prototype.writeUInt32BE = function (value, unshift, noAssert) {
285
- if (unshift === void 0) { unshift = false; }
286
- if (noAssert === void 0) { noAssert = false; }
238
+ }
239
+ writeUInt32BE(value, unshift, noAssert) {
287
240
  return this.writeUIntBE(value, 4, unshift, noAssert);
288
- };
289
- ExtendedBuffer.prototype.writeUInt32LE = function (value, unshift, noAssert) {
290
- if (unshift === void 0) { unshift = false; }
291
- if (noAssert === void 0) { noAssert = false; }
241
+ }
242
+ writeUInt32LE(value, unshift, noAssert) {
292
243
  return this.writeUIntLE(value, 4, unshift, noAssert);
293
- };
294
- ExtendedBuffer.prototype.writeFloatBE = function (value, unshift, noAssert) {
295
- if (unshift === void 0) { unshift = false; }
296
- if (noAssert === void 0) { noAssert = false; }
244
+ }
245
+ writeFloatBE(value, unshift, noAssert) {
297
246
  if (unshift) {
298
247
  this.allocStart(4);
299
248
  this._pointerStart -= 4;
@@ -305,10 +254,8 @@ var ExtendedBuffer = (function () {
305
254
  this._pointerEnd += 4;
306
255
  }
307
256
  return this;
308
- };
309
- ExtendedBuffer.prototype.writeFloatLE = function (value, unshift, noAssert) {
310
- if (unshift === void 0) { unshift = false; }
311
- if (noAssert === void 0) { noAssert = false; }
257
+ }
258
+ writeFloatLE(value, unshift, noAssert) {
312
259
  if (unshift) {
313
260
  this.allocStart(4);
314
261
  this._pointerStart -= 4;
@@ -320,10 +267,8 @@ var ExtendedBuffer = (function () {
320
267
  this._pointerEnd += 4;
321
268
  }
322
269
  return this;
323
- };
324
- ExtendedBuffer.prototype.writeDoubleBE = function (value, unshift, noAssert) {
325
- if (unshift === void 0) { unshift = false; }
326
- if (noAssert === void 0) { noAssert = false; }
270
+ }
271
+ writeDoubleBE(value, unshift, noAssert) {
327
272
  if (unshift) {
328
273
  this.allocStart(8);
329
274
  this._pointerStart -= 8;
@@ -335,10 +280,8 @@ var ExtendedBuffer = (function () {
335
280
  this._pointerEnd += 8;
336
281
  }
337
282
  return this;
338
- };
339
- ExtendedBuffer.prototype.writeDoubleLE = function (value, unshift, noAssert) {
340
- if (unshift === void 0) { unshift = false; }
341
- if (noAssert === void 0) { noAssert = false; }
283
+ }
284
+ writeDoubleLE(value, unshift, noAssert) {
342
285
  if (unshift) {
343
286
  this.allocStart(8);
344
287
  this._pointerStart -= 8;
@@ -350,13 +293,12 @@ var ExtendedBuffer = (function () {
350
293
  this._pointerEnd += 8;
351
294
  }
352
295
  return this;
353
- };
354
- ExtendedBuffer.prototype.writeVarInt32 = function (value, unshift) {
355
- if (unshift === void 0) { unshift = false; }
296
+ }
297
+ writeVarInt32(value, unshift) {
356
298
  value >>>= 0;
357
- var b;
299
+ let b;
358
300
  if (unshift) {
359
- var buffer = new ExtendedBuffer({
301
+ let buffer = new ExtendedBuffer({
360
302
  maxBufferLength: 10
361
303
  });
362
304
  while (value >= 0x80) {
@@ -373,106 +315,86 @@ var ExtendedBuffer = (function () {
373
315
  value >>>= 7;
374
316
  }
375
317
  return this.writeUIntBE(value, 1);
376
- };
377
- ExtendedBuffer.prototype.readBuffer = function (size, asNative, bufferOptions) {
378
- if (asNative === void 0) { asNative = false; }
379
- if (bufferOptions === void 0) { bufferOptions = {}; }
380
- var buffer = this._nativeBuffer.slice(this._pointerStart + this._pointer, this._pointerStart + this._pointer + size);
318
+ }
319
+ readBuffer(size, asNative, bufferOptions) {
320
+ let buffer = this._nativeBuffer.slice(this._pointerStart + this._pointer, this._pointerStart + this._pointer + size);
381
321
  this._pointer += size;
382
- var ThisClass = this.constructor;
322
+ const ThisClass = this.constructor;
383
323
  if (asNative) {
384
324
  return buffer_1.Buffer.from ? buffer_1.Buffer.from(buffer) : new buffer_1.Buffer(buffer);
385
325
  }
386
326
  return (new ThisClass(bufferOptions))._writeNativeBuffer(buffer, false);
387
- };
388
- ExtendedBuffer.prototype.readString = function (size, encoding) {
327
+ }
328
+ readString(size, encoding) {
389
329
  this._pointer += size;
390
330
  return this._nativeBuffer.toString(encoding, this._pointerStart + this._pointer - size, this._pointerStart + this._pointer);
391
- };
392
- ExtendedBuffer.prototype.readIntBE = function (byteLength, noAssert) {
393
- if (noAssert === void 0) { noAssert = false; }
331
+ }
332
+ readIntBE(byteLength, noAssert) {
394
333
  this._pointer += byteLength;
395
334
  return this._nativeBuffer.readIntBE(this._pointerStart + this._pointer - byteLength, byteLength, noAssert);
396
- };
397
- ExtendedBuffer.prototype.readIntLE = function (byteLength, noAssert) {
398
- if (noAssert === void 0) { noAssert = false; }
335
+ }
336
+ readIntLE(byteLength, noAssert) {
399
337
  this._pointer += byteLength;
400
338
  return this._nativeBuffer.readIntLE(this._pointerStart + this._pointer - byteLength, byteLength, noAssert);
401
- };
402
- ExtendedBuffer.prototype.readUIntBE = function (byteLength, noAssert) {
403
- if (noAssert === void 0) { noAssert = false; }
339
+ }
340
+ readUIntBE(byteLength, noAssert) {
404
341
  this._pointer += byteLength;
405
342
  return this._nativeBuffer.readUIntBE(this._pointerStart + this._pointer - byteLength, byteLength, noAssert);
406
- };
407
- ExtendedBuffer.prototype.readUIntLE = function (byteLength, noAssert) {
408
- if (noAssert === void 0) { noAssert = false; }
343
+ }
344
+ readUIntLE(byteLength, noAssert) {
409
345
  this._pointer += byteLength;
410
346
  return this._nativeBuffer.readUIntLE(this._pointerStart + this._pointer - byteLength, byteLength, noAssert);
411
- };
412
- ExtendedBuffer.prototype.readInt8 = function (noAssert) {
413
- if (noAssert === void 0) { noAssert = false; }
347
+ }
348
+ readInt8(noAssert) {
414
349
  return this.readIntBE(1, noAssert);
415
- };
416
- ExtendedBuffer.prototype.readUInt8 = function (noAssert) {
417
- if (noAssert === void 0) { noAssert = false; }
350
+ }
351
+ readUInt8(noAssert) {
418
352
  return this.readUIntBE(1, noAssert);
419
- };
420
- ExtendedBuffer.prototype.readInt16BE = function (noAssert) {
421
- if (noAssert === void 0) { noAssert = false; }
353
+ }
354
+ readInt16BE(noAssert) {
422
355
  return this.readIntBE(2, noAssert);
423
- };
424
- ExtendedBuffer.prototype.readInt16LE = function (noAssert) {
425
- if (noAssert === void 0) { noAssert = false; }
356
+ }
357
+ readInt16LE(noAssert) {
426
358
  return this.readIntLE(2, noAssert);
427
- };
428
- ExtendedBuffer.prototype.readUInt16BE = function (noAssert) {
429
- if (noAssert === void 0) { noAssert = false; }
359
+ }
360
+ readUInt16BE(noAssert) {
430
361
  return this.readUIntBE(2, noAssert);
431
- };
432
- ExtendedBuffer.prototype.readUInt16LE = function (noAssert) {
433
- if (noAssert === void 0) { noAssert = false; }
362
+ }
363
+ readUInt16LE(noAssert) {
434
364
  return this.readUIntLE(2, noAssert);
435
- };
436
- ExtendedBuffer.prototype.readInt32BE = function (noAssert) {
437
- if (noAssert === void 0) { noAssert = false; }
365
+ }
366
+ readInt32BE(noAssert) {
438
367
  return this.readIntBE(4, noAssert);
439
- };
440
- ExtendedBuffer.prototype.readInt32LE = function (noAssert) {
441
- if (noAssert === void 0) { noAssert = false; }
368
+ }
369
+ readInt32LE(noAssert) {
442
370
  return this.readIntLE(4, noAssert);
443
- };
444
- ExtendedBuffer.prototype.readUInt32BE = function (noAssert) {
445
- if (noAssert === void 0) { noAssert = false; }
371
+ }
372
+ readUInt32BE(noAssert) {
446
373
  return this.readUIntBE(4, noAssert);
447
- };
448
- ExtendedBuffer.prototype.readUInt32LE = function (noAssert) {
449
- if (noAssert === void 0) { noAssert = false; }
374
+ }
375
+ readUInt32LE(noAssert) {
450
376
  return this.readUIntLE(4, noAssert);
451
- };
452
- ExtendedBuffer.prototype.readFloatBE = function (noAssert) {
453
- if (noAssert === void 0) { noAssert = false; }
377
+ }
378
+ readFloatBE(noAssert) {
454
379
  this._pointer += 4;
455
380
  return this._nativeBuffer.readFloatBE(this._pointerStart + this._pointer - 4, noAssert);
456
- };
457
- ExtendedBuffer.prototype.readFloatLE = function (noAssert) {
458
- if (noAssert === void 0) { noAssert = false; }
381
+ }
382
+ readFloatLE(noAssert) {
459
383
  this._pointer += 4;
460
384
  return this._nativeBuffer.readFloatLE(this._pointerStart + this._pointer - 4, noAssert);
461
- };
462
- ExtendedBuffer.prototype.readDoubleBE = function (noAssert) {
463
- if (noAssert === void 0) { noAssert = false; }
385
+ }
386
+ readDoubleBE(noAssert) {
464
387
  this._pointer += 8;
465
388
  return this._nativeBuffer.readDoubleBE(this._pointerStart + this._pointer - 8, noAssert);
466
- };
467
- ExtendedBuffer.prototype.readDoubleLE = function (noAssert) {
468
- if (noAssert === void 0) { noAssert = false; }
389
+ }
390
+ readDoubleLE(noAssert) {
469
391
  this._pointer += 8;
470
392
  return this._nativeBuffer.readDoubleLE(this._pointerStart + this._pointer - 8, noAssert);
471
- };
472
- ExtendedBuffer.prototype.readVarInt32 = function () {
473
- var c = 0;
474
- var value = 0 >>> 0;
475
- var b;
393
+ }
394
+ readVarInt32() {
395
+ let c = 0;
396
+ let value = 0 >>> 0;
397
+ let b;
476
398
  do {
477
399
  b = this.readUIntBE(1);
478
400
  if (c < 5) {
@@ -481,12 +403,12 @@ var ExtendedBuffer = (function () {
481
403
  ++c;
482
404
  } while ((b & 0x80) !== 0);
483
405
  return value | 0;
484
- };
485
- ExtendedBuffer.prototype.isReadableVarInt32 = function () {
486
- var c = 0;
487
- var value = 0 >>> 0;
488
- var b;
489
- var oldPointer = this._pointer;
406
+ }
407
+ isReadableVarInt32() {
408
+ let c = 0;
409
+ let value = 0 >>> 0;
410
+ let b;
411
+ let oldPointer = this._pointer;
490
412
  do {
491
413
  if (!this.isReadable(1)) {
492
414
  this._pointer = oldPointer;
@@ -500,7 +422,6 @@ var ExtendedBuffer = (function () {
500
422
  } while ((b & 0x80) !== 0);
501
423
  this._pointer = oldPointer;
502
424
  return true;
503
- };
504
- return ExtendedBuffer;
505
- }());
425
+ }
426
+ }
506
427
  exports.ExtendedBuffer = ExtendedBuffer;
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExtendedBuffer = void 0;
3
4
  var ExtendedBuffer_1 = require("./ExtendedBuffer");
4
- exports.ExtendedBuffer = ExtendedBuffer_1.ExtendedBuffer;
5
+ Object.defineProperty(exports, "ExtendedBuffer", { enumerable: true, get: function () { return ExtendedBuffer_1.ExtendedBuffer; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "extended-buffer",
3
- "version": "6.0.2",
3
+ "version": "6.0.5",
4
4
  "engineStrict": true,
5
5
  "description": "Node JS extended Buffer",
6
6
  "main": "./dist/index.js",
@@ -29,6 +29,6 @@
29
29
  "chai": "^4.1.2",
30
30
  "mocha": "^4.0.1",
31
31
  "nyc": "^11.3.0",
32
- "typescript": "^3.3.4000"
32
+ "typescript": "^4.7.2"
33
33
  }
34
34
  }