@ -120,7 +120,7 @@ function fromString(string, encoding) {
function fromObject ( obj ) {
function fromObject ( obj ) {
if ( obj instanceof Buffer ) {
if ( obj instanceof Buffer ) {
var b = allocate ( obj . length ) ;
const b = allocate ( obj . length ) ;
if ( b . length === 0 )
if ( b . length === 0 )
return b ;
return b ;
@ -130,9 +130,9 @@ function fromObject(obj) {
}
}
if ( Array . isArray ( obj ) ) {
if ( Array . isArray ( obj ) ) {
var length = obj . length ;
const length = obj . length ;
var b = allocate ( length ) ;
const b = allocate ( length ) ;
for ( var i = 0 ; i < length ; i ++ )
for ( let i = 0 ; i < length ; i ++ )
b [ i ] = obj [ i ] & 255 ;
b [ i ] = obj [ i ] & 255 ;
return b ;
return b ;
}
}
@ -146,13 +146,13 @@ function fromObject(obj) {
}
}
if ( obj . buffer instanceof ArrayBuffer || obj . length ) {
if ( obj . buffer instanceof ArrayBuffer || obj . length ) {
var length ;
let length ;
if ( typeof obj . length !== 'number' || obj . length !== obj . length )
if ( typeof obj . length !== 'number' || obj . length !== obj . length )
length = 0 ;
length = 0 ;
else
else
length = obj . length ;
length = obj . length ;
var b = allocate ( length ) ;
const b = allocate ( length ) ;
for ( var i = 0 ; i < length ; i ++ ) {
for ( let i = 0 ; i < length ; i ++ ) {
b [ i ] = obj [ i ] & 255 ;
b [ i ] = obj [ i ] & 255 ;
}
}
return b ;
return b ;
@ -160,8 +160,8 @@ function fromObject(obj) {
if ( obj . type === 'Buffer' && Array . isArray ( obj . data ) ) {
if ( obj . type === 'Buffer' && Array . isArray ( obj . data ) ) {
var array = obj . data ;
var array = obj . data ;
var b = allocate ( array . length ) ;
const b = allocate ( array . length ) ;
for ( var i = 0 ; i < array . length ; i ++ )
for ( let i = 0 ; i < array . length ; i ++ )
b [ i ] = array [ i ] & 255 ;
b [ i ] = array [ i ] & 255 ;
return b ;
return b ;
}
}
@ -226,7 +226,7 @@ Buffer.concat = function(list, length) {
if ( length === undefined ) {
if ( length === undefined ) {
length = 0 ;
length = 0 ;
for ( var i = 0 ; i < list . length ; i ++ )
for ( let i = 0 ; i < list . length ; i ++ )
length += list [ i ] . length ;
length += list [ i ] . length ;
} else {
} else {
length = length >>> 0 ;
length = length >>> 0 ;
@ -234,7 +234,7 @@ Buffer.concat = function(list, length) {
var buffer = new Buffer ( length ) ;
var buffer = new Buffer ( length ) ;
var pos = 0 ;
var pos = 0 ;
for ( var i = 0 ; i < list . length ; i ++ ) {
for ( let i = 0 ; i < list . length ; i ++ ) {
var buf = list [ i ] ;
var buf = list [ i ] ;
buf . copy ( buffer , pos ) ;
buf . copy ( buffer , pos ) ;
pos += buf . length ;
pos += buf . length ;
@ -396,10 +396,11 @@ function slowToString(encoding, start, end) {
Buffer . prototype . toString = function ( ) {
Buffer . prototype . toString = function ( ) {
let result ;
if ( arguments . length === 0 ) {
if ( arguments . length === 0 ) {
var result = this . utf8Slice ( 0 , this . length ) ;
result = this . utf8Slice ( 0 , this . length ) ;
} else {
} else {
var result = slowToString . apply ( this , arguments ) ;
result = slowToString . apply ( this , arguments ) ;
}
}
if ( result === undefined )
if ( result === undefined )
throw new Error ( 'toString failed' ) ;
throw new Error ( 'toString failed' ) ;