@@ -102,7 +102,7 @@ const constants = Object.defineProperties({}, {
102
102
} ) ;
103
103
104
104
Buffer . poolSize = 8 * 1024 ;
105
- var poolSize , poolOffset , allocPool ;
105
+ let poolSize , poolOffset , allocPool ;
106
106
107
107
setupBufferJS ( Buffer . prototype , bindingObj ) ;
108
108
@@ -221,7 +221,7 @@ Buffer.from = function from(value, encodingOrOffset, length) {
221
221
if ( valueOf !== null && valueOf !== undefined && valueOf !== value )
222
222
return Buffer . from ( valueOf , encodingOrOffset , length ) ;
223
223
224
- var b = fromObject ( value ) ;
224
+ const b = fromObject ( value ) ;
225
225
if ( b )
226
226
return b ;
227
227
@@ -307,13 +307,10 @@ Buffer.allocUnsafeSlow = function allocUnsafeSlow(size) {
307
307
// If --zero-fill-buffers command line argument is set, a zero-filled
308
308
// buffer is returned.
309
309
function SlowBuffer ( length ) {
310
- const len = + length ;
311
- // eslint-disable-next-line eqeqeq
312
- if ( len != length )
313
- length = 0 ;
314
- else
315
- assertSize ( len ) ;
316
- return createUnsafeBuffer ( len ) ;
310
+ if ( typeof length !== 'number' )
311
+ length = + length ;
312
+ assertSize ( length ) ;
313
+ return createUnsafeBuffer ( length ) ;
317
314
}
318
315
319
316
Object . setPrototypeOf ( SlowBuffer . prototype , Uint8Array . prototype ) ;
@@ -326,7 +323,7 @@ function allocate(size) {
326
323
if ( size < ( Buffer . poolSize >>> 1 ) ) {
327
324
if ( size > ( poolSize - poolOffset ) )
328
325
createPool ( ) ;
329
- var b = new FastBuffer ( allocPool , poolOffset , size ) ;
326
+ const b = new FastBuffer ( allocPool , poolOffset , size ) ;
330
327
poolOffset += size ;
331
328
alignPool ( ) ;
332
329
return b ;
@@ -335,7 +332,7 @@ function allocate(size) {
335
332
}
336
333
337
334
function fromString ( string , encoding ) {
338
- var length ;
335
+ let length ;
339
336
if ( typeof encoding !== 'string' || encoding . length === 0 ) {
340
337
if ( string . length === 0 )
341
338
return new FastBuffer ( ) ;
@@ -354,7 +351,7 @@ function fromString(string, encoding) {
354
351
355
352
if ( length > ( poolSize - poolOffset ) )
356
353
createPool ( ) ;
357
- var b = new FastBuffer ( allocPool , poolOffset , length ) ;
354
+ let b = new FastBuffer ( allocPool , poolOffset , length ) ;
358
355
const actual = b . write ( string , encoding ) ;
359
356
if ( actual !== length ) {
360
357
// byteLength() may overestimate. That's a rare case, though.
@@ -456,7 +453,7 @@ Buffer.isEncoding = function isEncoding(encoding) {
456
453
Buffer [ kIsEncodingSymbol ] = Buffer . isEncoding ;
457
454
458
455
Buffer . concat = function concat ( list , length ) {
459
- var i ;
456
+ let i ;
460
457
if ( ! Array . isArray ( list ) ) {
461
458
throw new ERR_INVALID_ARG_TYPE (
462
459
'list' , [ 'Array' , 'Buffer' , 'Uint8Array' ] , list ) ;
@@ -473,10 +470,10 @@ Buffer.concat = function concat(list, length) {
473
470
length = length >>> 0 ;
474
471
}
475
472
476
- var buffer = Buffer . allocUnsafe ( length ) ;
477
- var pos = 0 ;
473
+ const buffer = Buffer . allocUnsafe ( length ) ;
474
+ let pos = 0 ;
478
475
for ( i = 0 ; i < list . length ; i ++ ) {
479
- var buf = list [ i ] ;
476
+ const buf = list [ i ] ;
480
477
if ( ! isUint8Array ( buf ) ) {
481
478
// TODO(BridgeAR): This should not be of type ERR_INVALID_ARG_TYPE.
482
479
// Instead, find the proper error code for this.
@@ -791,7 +788,7 @@ function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
791
788
}
792
789
793
790
function slowIndexOf ( buffer , val , byteOffset , encoding , dir ) {
794
- var loweredCase = false ;
791
+ let loweredCase = false ;
795
792
for ( ; ; ) {
796
793
switch ( encoding ) {
797
794
case 'utf8' :
@@ -926,7 +923,7 @@ Buffer.prototype.write = function write(string, offset, length, encoding) {
926
923
length = undefined ;
927
924
}
928
925
929
- var remaining = this . length - offset ;
926
+ const remaining = this . length - offset ;
930
927
if ( length === undefined || length > remaining )
931
928
length = remaining ;
932
929
0 commit comments