@antti5/ship-tool-common 1.0.9 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Util.js +17 -2
- package/package.json +1 -1
package/lib/Util.js
CHANGED
|
@@ -259,7 +259,7 @@ class Util {
|
|
|
259
259
|
const options = {
|
|
260
260
|
/* Add thousand separators if value is big/small enough */
|
|
261
261
|
useGrouping: Math.abs(number) >= separatorMin,
|
|
262
|
-
signDisplay: signed ? 'exceptZero' : '
|
|
262
|
+
signDisplay: signed ? 'exceptZero' : 'auto'
|
|
263
263
|
};
|
|
264
264
|
|
|
265
265
|
if (decimals instanceof Array) {
|
|
@@ -271,7 +271,22 @@ class Util {
|
|
|
271
271
|
}
|
|
272
272
|
|
|
273
273
|
/* Localized to string */
|
|
274
|
-
|
|
274
|
+
let localized = number.toLocaleString(locale, options);
|
|
275
|
+
|
|
276
|
+
/* Remove negative zero.
|
|
277
|
+
|
|
278
|
+
Note: This could be achieved with signDisplay = 'negative' above, however Firefox only
|
|
279
|
+
supports it from version 116. At the time of writing Vite build target is Firefox 114,
|
|
280
|
+
however there does not appear to be a polyfill.
|
|
281
|
+
|
|
282
|
+
Firefox 115 support is relatively important because it is the most recent version
|
|
283
|
+
supported on Windows 7.
|
|
284
|
+
|
|
285
|
+
Without signDisplay = 'negative', a common case is that a number is rounded to at most
|
|
286
|
+
one decimal, in which case -0.04 rounds to -0. */
|
|
287
|
+
|
|
288
|
+
if (localized === '-0')
|
|
289
|
+
localized = '0';
|
|
275
290
|
|
|
276
291
|
/* Finally, replace possible hyphen-minus with a minus sign */
|
|
277
292
|
return localized[0] === '-' ?
|