@@ -143,8 +143,9 @@ function Buffer(arg, encodingOrOffset, length) {
143
143
// Common case.
144
144
if ( typeof arg === 'number' ) {
145
145
if ( typeof encodingOrOffset === 'string' ) {
146
- throw new errors . TypeError ( 'ERR_INVALID_ARG_TYPE' , 'string' ,
147
- 'string' , arg ) ;
146
+ throw new errors . TypeError (
147
+ 'ERR_INVALID_ARG_TYPE' , 'string' , 'string' , arg
148
+ ) ;
148
149
}
149
150
return Buffer . alloc ( arg ) ;
150
151
}
@@ -172,13 +173,19 @@ Buffer.from = function(value, encodingOrOffset, length) {
172
173
if ( isAnyArrayBuffer ( value ) )
173
174
return fromArrayBuffer ( value , encodingOrOffset , length ) ;
174
175
175
- if ( value == null )
176
- throw new errors . TypeError ( 'ERR_INVALID_ARG_TYPE' , 'first argument' ,
177
- [ 'string' , 'buffer' , 'arrayBuffer' , 'array' , 'array-like object' ] , value ) ;
176
+ if ( value == null ) {
177
+ throw new errors . TypeError (
178
+ 'ERR_INVALID_ARG_TYPE' ,
179
+ 'first argument' ,
180
+ [ 'string' , 'buffer' , 'arrayBuffer' , 'array' , 'array-like object' ] ,
181
+ value
182
+ ) ;
183
+ }
178
184
179
185
if ( typeof value === 'number' )
180
- throw new errors . TypeError ( 'ERR_INVALID_ARG_TYPE' , 'value' , 'not number' ,
181
- value ) ;
186
+ throw new errors . TypeError (
187
+ 'ERR_INVALID_ARG_TYPE' , 'value' , 'not number' , value
188
+ ) ;
182
189
183
190
const valueOf = value . valueOf && value . valueOf ( ) ;
184
191
if ( valueOf != null && valueOf !== value )
@@ -194,8 +201,11 @@ Buffer.from = function(value, encodingOrOffset, length) {
194
201
length ) ;
195
202
}
196
203
197
- throw new errors . TypeError ( 'ERR_INVALID_ARG_TYPE' , 'first argument' ,
198
- [ 'string' , 'buffer' , 'arrayBuffer' , 'array' , 'array-like object' ] ) ;
204
+ throw new errors . TypeError (
205
+ 'ERR_INVALID_ARG_TYPE' ,
206
+ 'first argument' ,
207
+ [ 'string' , 'buffer' , 'arrayBuffer' , 'array' , 'array-like object' ]
208
+ ) ;
199
209
} ;
200
210
201
211
Object . setPrototypeOf ( Buffer , Uint8Array ) ;
@@ -397,8 +407,9 @@ Buffer.isBuffer = function isBuffer(b) {
397
407
398
408
Buffer . compare = function compare ( a , b ) {
399
409
if ( ! isUint8Array ( a ) || ! isUint8Array ( b ) ) {
400
- throw new errors . TypeError ( 'ERR_INVALID_ARG_TYPE' , [ 'buf1' , 'buf2' ] ,
401
- [ 'buffer' , 'uint8Array' ] ) ;
410
+ throw new errors . TypeError (
411
+ 'ERR_INVALID_ARG_TYPE' , [ 'buf1' , 'buf2' ] , [ 'buffer' , 'uint8Array' ]
412
+ ) ;
402
413
}
403
414
404
415
if ( a === b ) {
@@ -415,8 +426,9 @@ Buffer.isEncoding = function(encoding) {
415
426
} ;
416
427
Buffer [ internalUtil . kIsEncodingSymbol ] = Buffer . isEncoding ;
417
428
418
- const kConcatErr = new errors . TypeError ( 'ERR_INVALID_ARG_TYPE' , 'list' ,
419
- [ 'array' , 'buffer' , 'uint8Array' ] ) ;
429
+ const kConcatErr = new errors . TypeError (
430
+ 'ERR_INVALID_ARG_TYPE' , 'list' , [ 'array' , 'buffer' , 'uint8Array' ]
431
+ ) ;
420
432
421
433
Buffer . concat = function ( list , length ) {
422
434
var i ;
@@ -474,8 +486,9 @@ function byteLength(string, encoding) {
474
486
return string . byteLength ;
475
487
}
476
488
477
- throw new errors . TypeError ( 'ERR_INVALID_ARG_TYPE' , 'string' ,
478
- [ 'string' , 'buffer' , 'arrayBuffer' ] ) ;
489
+ throw new errors . TypeError (
490
+ 'ERR_INVALID_ARG_TYPE' , 'string' , [ 'string' , 'buffer' , 'arrayBuffer' ]
491
+ ) ;
479
492
}
480
493
481
494
const len = string . length ;
@@ -632,9 +645,11 @@ Buffer.prototype.toString = function(encoding, start, end) {
632
645
633
646
634
647
Buffer . prototype . equals = function equals ( b ) {
635
- if ( ! isUint8Array ( b ) )
636
- throw new errors . TypeError ( 'ERR_INVALID_ARG_TYPE' , 'otherBuffer' ,
637
- [ 'buffer' , 'uint8Array' ] ) ;
648
+ if ( ! isUint8Array ( b ) ) {
649
+ throw new errors . TypeError (
650
+ 'ERR_INVALID_ARG_TYPE' , 'otherBuffer' , [ 'buffer' , 'uint8Array' ]
651
+ ) ;
652
+ }
638
653
if ( this === b )
639
654
return true ;
640
655
@@ -658,9 +673,11 @@ Buffer.prototype.compare = function compare(target,
658
673
end ,
659
674
thisStart ,
660
675
thisEnd ) {
661
- if ( ! isUint8Array ( target ) )
662
- throw new errors . TypeError ( 'ERR_INVALID_ARG_TYPE' , 'target' ,
663
- [ 'buffer' , 'uint8Array' ] ) ;
676
+ if ( ! isUint8Array ( target ) ) {
677
+ throw new errors . TypeError (
678
+ 'ERR_INVALID_ARG_TYPE' , 'target' , [ 'buffer' , 'uint8Array' ]
679
+ ) ;
680
+ }
664
681
if ( arguments . length === 1 )
665
682
return compare_ ( this , target ) ;
666
683
@@ -739,8 +756,9 @@ function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
739
756
return binding . indexOfNumber ( buffer , val , byteOffset , dir ) ;
740
757
}
741
758
742
- throw new errors . TypeError ( 'ERR_INVALID_ARG_TYPE' , 'val' ,
743
- [ 'string' , 'buffer' , 'uint8Array' ] ) ;
759
+ throw new errors . TypeError (
760
+ 'ERR_INVALID_ARG_TYPE' , 'val' , [ 'string' , 'buffer' , 'uint8Array' ]
761
+ ) ;
744
762
}
745
763
746
764
@@ -878,8 +896,10 @@ Buffer.prototype.write = function(string, offset, length, encoding) {
878
896
// if someone is still calling the obsolete form of write(), tell them.
879
897
// we don't want eg buf.write("foo", "utf8", 10) to silently turn into
880
898
// buf.write("foo", "utf8"), so we can't ignore extra args
881
- throw new errors . Error ( 'ERR_NO_LONGER_SUPPORTED' ,
882
- 'Buffer.write(string, encoding, offset[, length])' ) ;
899
+ throw new errors . Error (
900
+ 'ERR_NO_LONGER_SUPPORTED' ,
901
+ 'Buffer.write(string, encoding, offset[, length])'
902
+ ) ;
883
903
}
884
904
885
905
if ( ! encoding ) return this . utf8Write ( string , offset , length ) ;
0 commit comments