@cloudflare/util-formatters 2.6.13 → 2.6.14

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/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.6.14](http://stash.cfops.it:7999/fe/stratus/compare/@cloudflare/util-formatters@2.6.13...@cloudflare/util-formatters@2.6.14) (2021-11-22)
7
+
8
+ **Note:** Version bump only for package @cloudflare/util-formatters
9
+
10
+
11
+
12
+
13
+
6
14
  ## [2.6.13](http://stash.cfops.it:7999/fe/stratus/compare/@cloudflare/util-formatters@2.6.10...@cloudflare/util-formatters@2.6.13) (2021-10-28)
7
15
 
8
16
 
@@ -41,7 +41,7 @@ export declare type CurrencyValue = number | string | undefined;
41
41
  export declare type CurrencyOptions = {
42
42
  locale: SupportedLocales;
43
43
  };
44
- export declare const formatCurrency: (value?: CurrencyValue, options?: CurrencyOptions) => string;
44
+ export declare const formatCurrency: (value?: CurrencyValue, options?: CurrencyOptions, minimumFractionDigits?: number, maximumFractionDigits?: number) => string;
45
45
  /**
46
46
  * @param {Number} number
47
47
  * @param {String} locale
package/es/formatters.js CHANGED
@@ -99,14 +99,13 @@ export const formatNumber = (number, locale = DEFAULT_LOCALE, abbreviate = false
99
99
  };
100
100
  export const formatCurrency = (value = 0, options = {
101
101
  locale: DEFAULT_LOCALE
102
- }) => {
102
+ }, minimumFractionDigits = 2, maximumFractionDigits = 2) => {
103
103
  return Number(value).toLocaleString(options.locale, {
104
104
  style: 'currency',
105
105
  // We should *always* display the currency that was billed in (USD).
106
106
  currency: DEFAULT_CURRENCY,
107
- // In the future—we can make these properties configurable.
108
- minimumFractionDigits: 2,
109
- maximumFractionDigits: 2
107
+ minimumFractionDigits,
108
+ maximumFractionDigits
110
109
  })
111
110
  /**
112
111
  * `Number.toLocaleString` with `style: 'currency'` behaves differently
package/lib/formatters.js CHANGED
@@ -131,13 +131,14 @@ var formatCurrency = function formatCurrency() {
131
131
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
132
132
  locale: DEFAULT_LOCALE
133
133
  };
134
+ var minimumFractionDigits = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 2;
135
+ var maximumFractionDigits = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 2;
134
136
  return Number(value).toLocaleString(options.locale, {
135
137
  style: 'currency',
136
138
  // We should *always* display the currency that was billed in (USD).
137
139
  currency: DEFAULT_CURRENCY,
138
- // In the future—we can make these properties configurable.
139
- minimumFractionDigits: 2,
140
- maximumFractionDigits: 2
140
+ minimumFractionDigits: minimumFractionDigits,
141
+ maximumFractionDigits: maximumFractionDigits
141
142
  })
142
143
  /**
143
144
  * `Number.toLocaleString` with `style: 'currency'` behaves differently
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudflare/util-formatters",
3
3
  "description": "",
4
- "version": "2.6.13",
4
+ "version": "2.6.14",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "lib/index.js",
7
7
  "module": "es/index.js",
@@ -21,5 +21,5 @@
21
21
  "d3-format": "^1.3.2",
22
22
  "moment": "^2.22.1"
23
23
  },
24
- "gitHead": "a1a7ca299c6676e5222e50aee57bc5beedb44882"
24
+ "gitHead": "569113c2ab73ce93969008d15ad9e6648d0d3ed0"
25
25
  }