@@ -59,6 +59,8 @@ function boundsError(value, length, type) {
59
59
60
60
// Read integers.
61
61
function readUIntLE ( offset , byteLength ) {
62
+ if ( offset === undefined )
63
+ throw new ERR_INVALID_ARG_TYPE ( 'offset' , 'number' , offset ) ;
62
64
if ( byteLength === 6 )
63
65
return readUInt48LE ( this , offset ) ;
64
66
if ( byteLength === 5 )
@@ -69,7 +71,7 @@ function readUIntLE(offset, byteLength) {
69
71
return this . readUInt32LE ( offset ) ;
70
72
if ( byteLength === 2 )
71
73
return this . readUInt16LE ( offset ) ;
72
- if ( byteLength === 1 || byteLength === undefined )
74
+ if ( byteLength === 1 )
73
75
return this . readUInt8 ( offset ) ;
74
76
75
77
boundsError ( byteLength , 6 , 'byteLength' ) ;
@@ -146,6 +148,8 @@ function readUInt8(offset = 0) {
146
148
}
147
149
148
150
function readUIntBE ( offset , byteLength ) {
151
+ if ( offset === undefined )
152
+ throw new ERR_INVALID_ARG_TYPE ( 'offset' , 'number' , offset ) ;
149
153
if ( byteLength === 6 )
150
154
return readUInt48BE ( this , offset ) ;
151
155
if ( byteLength === 5 )
@@ -156,7 +160,7 @@ function readUIntBE(offset, byteLength) {
156
160
return this . readUInt32BE ( offset ) ;
157
161
if ( byteLength === 2 )
158
162
return this . readUInt16BE ( offset ) ;
159
- if ( byteLength === 1 || byteLength === undefined )
163
+ if ( byteLength === 1 )
160
164
return this . readUInt8 ( offset ) ;
161
165
162
166
boundsError ( byteLength , 6 , 'byteLength' ) ;
@@ -224,6 +228,8 @@ function readUInt16BE(offset = 0) {
224
228
}
225
229
226
230
function readIntLE ( offset , byteLength ) {
231
+ if ( offset === undefined )
232
+ throw new ERR_INVALID_ARG_TYPE ( 'offset' , 'number' , offset ) ;
227
233
if ( byteLength === 6 )
228
234
return readInt48LE ( this , offset ) ;
229
235
if ( byteLength === 5 )
@@ -234,7 +240,7 @@ function readIntLE(offset, byteLength) {
234
240
return this . readInt32LE ( offset ) ;
235
241
if ( byteLength === 2 )
236
242
return this . readInt16LE ( offset ) ;
237
- if ( byteLength === 1 || byteLength === undefined )
243
+ if ( byteLength === 1 )
238
244
return this . readInt8 ( offset ) ;
239
245
240
246
boundsError ( byteLength , 6 , 'byteLength' ) ;
@@ -314,6 +320,8 @@ function readInt8(offset = 0) {
314
320
}
315
321
316
322
function readIntBE ( offset , byteLength ) {
323
+ if ( offset === undefined )
324
+ throw new ERR_INVALID_ARG_TYPE ( 'offset' , 'number' , offset ) ;
317
325
if ( byteLength === 6 )
318
326
return readInt48BE ( this , offset ) ;
319
327
if ( byteLength === 5 )
@@ -324,7 +332,7 @@ function readIntBE(offset, byteLength) {
324
332
return this . readInt32BE ( offset ) ;
325
333
if ( byteLength === 2 )
326
334
return this . readInt16BE ( offset ) ;
327
- if ( byteLength === 1 || byteLength === undefined )
335
+ if ( byteLength === 1 )
328
336
return this . readInt8 ( offset ) ;
329
337
330
338
boundsError ( byteLength , 6 , 'byteLength' ) ;
@@ -460,7 +468,7 @@ function readDoubleForwards(offset = 0) {
460
468
}
461
469
462
470
// Write integers.
463
- function writeUIntLE ( value , offset = 0 , byteLength ) {
471
+ function writeUIntLE ( value , offset , byteLength ) {
464
472
if ( byteLength === 6 )
465
473
return writeU_Int48LE ( this , value , offset , 0 , 0xffffffffffff ) ;
466
474
if ( byteLength === 5 )
@@ -471,7 +479,7 @@ function writeUIntLE(value, offset = 0, byteLength) {
471
479
return writeU_Int32LE ( this , value , offset , 0 , 0xffffffff ) ;
472
480
if ( byteLength === 2 )
473
481
return writeU_Int16LE ( this , value , offset , 0 , 0xffff ) ;
474
- if ( byteLength === 1 || byteLength === undefined )
482
+ if ( byteLength === 1 )
475
483
return writeU_Int8 ( this , value , offset , 0 , 0xff ) ;
476
484
477
485
boundsError ( byteLength , 6 , 'byteLength' ) ;
@@ -571,7 +579,7 @@ function writeUInt8(value, offset = 0) {
571
579
return writeU_Int8 ( this , value , offset , 0 , 0xff ) ;
572
580
}
573
581
574
- function writeUIntBE ( value , offset = 0 , byteLength ) {
582
+ function writeUIntBE ( value , offset , byteLength ) {
575
583
if ( byteLength === 6 )
576
584
return writeU_Int48BE ( this , value , offset , 0 , 0xffffffffffffff ) ;
577
585
if ( byteLength === 5 )
@@ -582,7 +590,7 @@ function writeUIntBE(value, offset = 0, byteLength) {
582
590
return writeU_Int32BE ( this , value , offset , 0 , 0xffffffff ) ;
583
591
if ( byteLength === 2 )
584
592
return writeU_Int16BE ( this , value , offset , 0 , 0xffff ) ;
585
- if ( byteLength === 1 || byteLength === undefined )
593
+ if ( byteLength === 1 )
586
594
return writeU_Int8 ( this , value , offset , 0 , 0xff ) ;
587
595
588
596
boundsError ( byteLength , 6 , 'byteLength' ) ;
@@ -663,7 +671,7 @@ function writeUInt16BE(value, offset = 0) {
663
671
return writeU_Int16BE ( this , value , offset , 0 , 0xffffffff ) ;
664
672
}
665
673
666
- function writeIntLE ( value , offset = 0 , byteLength ) {
674
+ function writeIntLE ( value , offset , byteLength ) {
667
675
if ( byteLength === 6 )
668
676
return writeU_Int48LE ( this , value , offset , - 0x800000000000 , 0x7fffffffffff ) ;
669
677
if ( byteLength === 5 )
@@ -674,7 +682,7 @@ function writeIntLE(value, offset = 0, byteLength) {
674
682
return writeU_Int32LE ( this , value , offset , - 0x80000000 , 0x7fffffff ) ;
675
683
if ( byteLength === 2 )
676
684
return writeU_Int16LE ( this , value , offset , - 0x8000 , 0x7fff ) ;
677
- if ( byteLength === 1 || byteLength === undefined )
685
+ if ( byteLength === 1 )
678
686
return writeU_Int8 ( this , value , offset , - 0x80 , 0x7f ) ;
679
687
680
688
boundsError ( byteLength , 6 , 'byteLength' ) ;
@@ -692,7 +700,7 @@ function writeInt8(value, offset = 0) {
692
700
return writeU_Int8 ( this , value , offset , - 0x80 , 0x7f ) ;
693
701
}
694
702
695
- function writeIntBE ( value , offset = 0 , byteLength ) {
703
+ function writeIntBE ( value , offset , byteLength ) {
696
704
if ( byteLength === 6 )
697
705
return writeU_Int48BE ( this , value , offset , - 0x800000000000 , 0x7fffffffffff ) ;
698
706
if ( byteLength === 5 )
@@ -703,7 +711,7 @@ function writeIntBE(value, offset = 0, byteLength) {
703
711
return writeU_Int32BE ( this , value , offset , - 0x80000000 , 0x7fffffff ) ;
704
712
if ( byteLength === 2 )
705
713
return writeU_Int16BE ( this , value , offset , - 0x8000 , 0x7fff ) ;
706
- if ( byteLength === 1 || byteLength === undefined )
714
+ if ( byteLength === 1 )
707
715
return writeU_Int8 ( this , value , offset , - 0x80 , 0x7f ) ;
708
716
709
717
boundsError ( byteLength , 6 , 'byteLength' ) ;
0 commit comments