Skip to content

Commit e42f3d7

Browse files
committed
Merge tag 'v2.0.32' into loctusjs.sprintf
Release v2.0.32
2 parents 6104c40 + 10c5d32 commit e42f3d7

File tree

6 files changed

+28
-44
lines changed

6 files changed

+28
-44
lines changed

LICENSE

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
1-
Copyright (c) 2007-2016 Kevin van Zonneveld (https://kvz.io)
2-
and Contributors (https://locutus.io/authors)
1+
Copyright (c) 2007-2024 Kevin van Zonneveld (https://kvz.io) and Contributors (https://locutus.io/authors)
32

4-
Permission is hereby granted, free of charge, to any person obtaining a copy of
5-
this software and associated documentation files (the "Software"), to deal in
6-
the Software without restriction, including without limitation the rights to
7-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8-
of the Software, and to permit persons to whom the Software is furnished to do
9-
so, subject to the following conditions:
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
4+
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
5+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
6+
persons to whom the Software is furnished to do so, subject to the following conditions:
107

11-
The above copyright notice and this permission notice shall be included in all
12-
copies or substantial portions of the Software.
8+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
9+
Software.
1310

14-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20-
SOFTWARE.
11+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12+
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
13+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
14+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
{
22
"name": "locutus.sprintf",
3-
"version": "2.0.14-code-lts.2",
3+
"version": "2.0.32-code-lts.2",
44
"license": "MIT",
55
"description": "Locutus sprintf and vsprintf for browsers and node",
6-
"homepage": "https://locutus.io/php/strings/sprintf/",
76
"author": "Kevin van Zonneveld <[email protected]>",
87
"keywords": [
98
"php",
109
"js",
1110
"locutus",
1211
"sprintf"
1312
],
13+
"homepage": "https://locutus.io/php/strings/sprintf/",
1414
"bugs": {
1515
"url": "https://github.com/code-lts/locutus.sprintf/issues",
1616
"email": "[email protected]"
@@ -24,4 +24,4 @@
2424
},
2525
"readmeFilename": "README.md",
2626
"main": "src/php/index.js"
27-
}
27+
}

src/php/strings/sprintf.browser.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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 @@ function sprintf () {
6161
if (!chr) {
6262
chr = ' '
6363
}
64-
var 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 @@ 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 @@ 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 @@ 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

src/php/strings/sprintf.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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

src/php/strings/vsprintf.browser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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

src/php/strings/vsprintf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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

0 commit comments

Comments
 (0)