11/**
2- * Copyright (c) 2007-2016 Kevin van Zonneveld (https://kvz.io)
2+ * Copyright (c) 2007-2024 Kevin van Zonneveld (https://kvz.io)
33 * and Contributors (https://locutus.io/authors)
44 *
55 * Permission is hereby granted, free of charge, to any person obtaining a copy of
@@ -61,7 +61,7 @@ module.exports = function sprintf () {
6161 if ( ! chr ) {
6262 chr = ' '
6363 }
64- const padding = ( str . length >= len ) ? '' : new Array ( 1 + len - str . length >>> 0 ) . join ( chr )
64+ const padding = str . length >= len ? '' : new Array ( ( 1 + len - str . length ) >>> 0 ) . join ( chr )
6565 return leftJustify ? str + padding : padding + str
6666 }
6767
@@ -72,11 +72,7 @@ module.exports = function sprintf () {
7272 // on the left side
7373 // keep sign (+ or -) in front
7474 if ( ! leftJustify && padChar === '0' ) {
75- value = [
76- value . slice ( 0 , prefix . length ) ,
77- _pad ( '' , diff , '0' , true ) ,
78- value . slice ( prefix . length )
79- ] . join ( '' )
75+ value = [ value . slice ( 0 , prefix . length ) , _pad ( '' , diff , '0' , true ) , value . slice ( prefix . length ) ] . join ( '' )
8076 } else {
8177 value = _pad ( value , minWidth , padChar , leftJustify )
8278 }
@@ -145,7 +141,7 @@ module.exports = function sprintf () {
145141 }
146142
147143 if ( ! precision ) {
148- precision = ( specifier === 'd' ) ? 0 : 'fFeE' . indexOf ( specifier ) > - 1 ? 6 : undefined
144+ precision = specifier === 'd' ? 0 : 'fFeE' . indexOf ( specifier ) > - 1 ? 6 : undefined
149145 } else {
150146 precision = + precision
151147 }
@@ -174,15 +170,14 @@ module.exports = function sprintf () {
174170 case 'x' :
175171 return _formatBaseX ( value , 16 , leftJustify , minWidth , precision , padChar )
176172 case 'X' :
177- return _formatBaseX ( value , 16 , leftJustify , minWidth , precision , padChar )
178- . toUpperCase ( )
173+ return _formatBaseX ( value , 16 , leftJustify , minWidth , precision , padChar ) . toUpperCase ( )
179174 case 'u' :
180175 return _formatBaseX ( value , 10 , leftJustify , minWidth , precision , padChar )
181176 case 'i' :
182177 case 'd' :
183178 number = + value || 0
184179 // Plain Math.round doesn't just truncate
185- number = Math . round ( number - number % 1 )
180+ number = Math . round ( number - ( number % 1 ) )
186181 prefix = number < 0 ? '-' : positiveNumberPrefix
187182 value = prefix + _pad ( String ( Math . abs ( number ) ) , precision , '0' , false )
188183
0 commit comments