@osimatic/helpers-js 1.1.19 → 1.1.20

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/number.js +9 -9
  2. package/package.json +1 -1
package/number.js CHANGED
@@ -1,29 +1,29 @@
1
1
  class NumberFormatter {
2
2
  static getDecimalFormatter(locale, digits = 2) {
3
3
  this.decimalFormatter = this.decimalFormatter || {};
4
- if (typeof this.decimalFormatter[locale] == 'undefined') {
5
- this.decimalFormatter[locale] = new Intl.NumberFormat(locale, { minimumFractionDigits: digits, maximumFractionDigits: digits });
4
+ if (typeof this.decimalFormatter[locale+digits] == 'undefined') {
5
+ this.decimalFormatter[locale+digits] = new Intl.NumberFormat(locale, { minimumFractionDigits: digits, maximumFractionDigits: digits });
6
6
  }
7
7
 
8
- return this.decimalFormatter[locale];
8
+ return this.decimalFormatter[locale+digits];
9
9
  }
10
10
 
11
11
  static getCurrencyFormatter(locale, currency, digits = 2) {
12
12
  this.currencyFormatter = this.currencyFormatter || {};
13
- if (typeof this.currencyFormatter[currency+locale] == 'undefined') {
14
- this.currencyFormatter[currency+locale] = new Intl.NumberFormat(locale, { minimumFractionDigits: digits, maximumFractionDigits: digits, style: 'currency', currency });
13
+ if (typeof this.currencyFormatter[locale+currency+digits] == 'undefined') {
14
+ this.currencyFormatter[locale+currency+digits] = new Intl.NumberFormat(locale, { minimumFractionDigits: digits, maximumFractionDigits: digits, style: 'currency', currency });
15
15
  }
16
16
 
17
- return this.currencyFormatter[currency+locale];
17
+ return this.currencyFormatter[locale+currency+digits];
18
18
  }
19
19
 
20
20
  static getPercentFormatter(locale, digits = 2) {
21
21
  this.percentFormatter = this.percentFormatter || {};
22
- if (typeof this.percentFormatter[locale] == 'undefined') {
23
- this.percentFormatter[locale] = new Intl.NumberFormat(locale, { minimumFractionDigits: digits, maximumFractionDigits: digits, style: 'percent' });
22
+ if (typeof this.percentFormatter[locale+digits] == 'undefined') {
23
+ this.percentFormatter[locale+digits] = new Intl.NumberFormat(locale, { minimumFractionDigits: digits, maximumFractionDigits: digits, style: 'percent' });
24
24
  }
25
25
 
26
- return this.percentFormatter[locale];
26
+ return this.percentFormatter[locale+digits];
27
27
  }
28
28
  }
29
29
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osimatic/helpers-js",
3
- "version": "1.1.19",
3
+ "version": "1.1.20",
4
4
  "main": "main.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"