@qrvey/utils 1.2.0 → 1.2.1

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.
@@ -35,8 +35,8 @@ function formatAbbreviated(num, decimals) {
35
35
  const absValue = Math.abs(num);
36
36
  const exp = Math.floor(Math.log10(absValue));
37
37
  if (exp < 0 && exp >= -3)
38
- return decimals ? num.toFixed(decimals) : num;
39
- return (0, d3_1.format)(num > -100 && num < 100 ? '' : '.3s')(num);
38
+ return num.toFixed(decimals === 0 ? 2 : decimals);
39
+ return (0, d3_1.format)(num > -100 && num < 100 ? '.' + (decimals + 2) + 'n' : '.3s')(num);
40
40
  }
41
41
  exports.formatAbbreviated = formatAbbreviated;
42
42
  function formatNumber(num, outputFormat, _config) {
@@ -28,8 +28,8 @@ export function formatAbbreviated(num, decimals) {
28
28
  const absValue = Math.abs(num);
29
29
  const exp = Math.floor(Math.log10(absValue));
30
30
  if (exp < 0 && exp >= -3)
31
- return decimals ? num.toFixed(decimals) : num;
32
- return d3Format(num > -100 && num < 100 ? '' : '.3s')(num);
31
+ return num.toFixed(decimals === 0 ? 2 : decimals);
32
+ return d3Format(num > -100 && num < 100 ? '.' + (decimals + 2) + 'n' : '.3s')(num);
33
33
  }
34
34
  function formatNumber(num, outputFormat, _config) {
35
35
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qrvey/utils",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Helper, Utils for all Qrvey Projects",
5
5
  "homepage": "https://bitbucket.org/qrvey/qrvey_utils/wiki/Home",
6
6
  "main": "dist/index.js",
@@ -31,9 +31,9 @@ export function formatAbbreviated(num, decimals) {
31
31
  const exp = Math.floor(Math.log10(absValue));
32
32
 
33
33
  if (exp < 0 && exp >= -3)
34
- return decimals ? num.toFixed(decimals) : num;
34
+ return num.toFixed(decimals === 0 ? 2 : decimals);
35
35
 
36
- return d3Format(num > -100 && num < 100 ? '' : '.3s')(num);
36
+ return d3Format(num > -100 && num < 100 ? '.' + (decimals + 2) + 'n' : '.3s')(num);
37
37
  }
38
38
 
39
39
  function formatNumber(num, outputFormat, _config?) {
@@ -65,7 +65,7 @@ describe('Testing format util', function () {
65
65
 
66
66
  test("Format Number Abbreviated", ()=>{
67
67
  const numberFormasted = formatAbbreviated(4.419, 0);
68
- expect(numberFormasted).toEqual("4.419");
68
+ expect(numberFormasted).toEqual("4.4");
69
69
  })
70
70
 
71
71
  });