@@ -312,7 +312,8 @@ function strEscape(str) {
312
312
313
313
let result = '' ;
314
314
let last = 0 ;
315
- for ( var i = 0 ; i < str . length ; i ++ ) {
315
+ const lastIndex = str . length ;
316
+ for ( let i = 0 ; i < lastIndex ; i ++ ) {
316
317
const point = str . charCodeAt ( i ) ;
317
318
if ( point === singleQuote || point === 92 || point < 32 ) {
318
319
if ( last === i ) {
@@ -324,7 +325,7 @@ function strEscape(str) {
324
325
}
325
326
}
326
327
327
- if ( last !== i ) {
328
+ if ( last !== lastIndex ) {
328
329
result += str . slice ( last ) ;
329
330
}
330
331
return addQuotes ( result , singleQuote ) ;
@@ -1059,10 +1060,11 @@ function formatPrimitive(fn, value, ctx) {
1059
1060
if ( matches . length > 1 ) {
1060
1061
const indent = ' ' . repeat ( ctx . indentationLvl ) ;
1061
1062
let res = `${ fn ( strEscape ( matches [ 0 ] ) , 'string' ) } +\n` ;
1062
- for ( var i = 1 ; i < matches . length - 1 ; i ++ ) {
1063
+ const lastIndex = matches . length - 1 ;
1064
+ for ( let i = 1 ; i < lastIndex ; i ++ ) {
1063
1065
res += `${ indent } ${ fn ( strEscape ( matches [ i ] ) , 'string' ) } +\n` ;
1064
1066
}
1065
- res += `${ indent } ${ fn ( strEscape ( matches [ i ] ) , 'string' ) } ` ;
1067
+ res += `${ indent } ${ fn ( strEscape ( matches [ lastIndex ] ) , 'string' ) } ` ;
1066
1068
return res ;
1067
1069
}
1068
1070
}
@@ -1185,10 +1187,10 @@ function formatTypedArray(ctx, value, recurseTimes) {
1185
1187
const elementFormatter = value . length > 0 && typeof value [ 0 ] === 'number' ?
1186
1188
formatNumber :
1187
1189
formatBigInt ;
1188
- for ( var i = 0 ; i < maxLength ; ++ i )
1190
+ for ( let i = 0 ; i < maxLength ; ++ i )
1189
1191
output [ i ] = elementFormatter ( ctx . stylize , value [ i ] ) ;
1190
1192
if ( remaining > 0 ) {
1191
- output [ i ] = `... ${ remaining } more item${ remaining > 1 ? 's' : '' } ` ;
1193
+ output [ maxLength ] = `... ${ remaining } more item${ remaining > 1 ? 's' : '' } ` ;
1192
1194
}
1193
1195
if ( ctx . showHidden ) {
1194
1196
// .buffer goes last, it's not a primitive like the others.
0 commit comments