@antti5/ship-tool-common 1.0.8 → 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.
Files changed (2) hide show
  1. package/lib/Util.js +17 -2
  2. package/package.json +2 -2
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' : 'negative'
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
- const localized = number.toLocaleString(locale, options);
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] === '-' ?
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antti5/ship-tool-common",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "description": "Ship Tool common utils and library code",
5
5
  "repository": {
6
6
  "type": "git",
@@ -12,7 +12,7 @@
12
12
  "bin": {
13
13
  "curl_time": "bin/curl_time",
14
14
  "jpretty": "bin/jpretty",
15
- "repot": "bin/repot",
15
+ "repos": "bin/repos",
16
16
  "tag": "bin/tag"
17
17
  },
18
18
  "exports": {