@automattic/number-formatters 1.0.17 → 1.1.0

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
@@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
6
6
 
7
+ ## [1.1.0] - 2026-02-23
8
+ ### Added
9
+ - `getCurrencyObject`: Add `floatValue` property to currency object. [#47203]
10
+
11
+ ## [1.0.18] - 2026-02-18
12
+ ### Changed
13
+ - Set `.repository.url` in `package.json` to the mirror repo rather than the monorepo. [#47149]
14
+
7
15
  ## [1.0.17] - 2026-02-12
8
16
  ### Changed
9
17
  - Update package dependencies. [#47099]
@@ -101,6 +109,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
101
109
  - Initial release
102
110
  - Basic number formatting functionality
103
111
 
112
+ [1.1.0]: https://github.com/Automattic/number-formatters/compare/1.0.18...1.1.0
113
+ [1.0.18]: https://github.com/Automattic/number-formatters/compare/1.0.17...1.0.18
104
114
  [1.0.17]: https://github.com/Automattic/number-formatters/compare/1.0.16...1.0.17
105
115
  [1.0.16]: https://github.com/Automattic/number-formatters/compare/1.0.15...1.0.16
106
116
  [1.0.15]: https://github.com/Automattic/number-formatters/compare/1.0.14...1.0.15
@@ -317,6 +317,7 @@ const getCurrencyObject = ({ number, browserSafeLocale, currency, stripZeros, is
317
317
  integer,
318
318
  fraction,
319
319
  hasNonZeroFraction,
320
+ floatValue: numberAsFloat,
320
321
  };
321
322
  };
322
323
  exports.getCurrencyObject = getCurrencyObject;
@@ -312,6 +312,7 @@ const getCurrencyObject = ({ number, browserSafeLocale, currency, stripZeros, is
312
312
  integer,
313
313
  fraction,
314
314
  hasNonZeroFraction,
315
+ floatValue: numberAsFloat,
315
316
  };
316
317
  };
317
318
  export { numberFormatCurrency, getCurrencyObject };
@@ -103,6 +103,16 @@ export interface CurrencyObject {
103
103
  * True if the formatted number has a non-0 decimal part.
104
104
  */
105
105
  hasNonZeroFraction: boolean;
106
+ /**
107
+ * The raw floating-point version of the number prepared for formatting,
108
+ * after unit conversion and precision scaling.
109
+ *
110
+ * For non-decimal currencies (eg: JPY) this will actually be an integer.
111
+ * Otherwise it will likely be a floating-point number. Be careful with this!
112
+ * It should not be used for math if possible because of floating-point
113
+ * rounding issues! Use the smallest unit instead.
114
+ */
115
+ floatValue: number;
106
116
  }
107
117
  export type FormatNumber = (number: number, options?: Omit<NumberFormatParams, 'browserSafeLocale'>) => string;
108
118
  export type FormatCurrency = (number: number, currency: string, options?: Omit<NumberFormatCurrencyParams, 'number' | 'currency' | 'browserSafeLocale' | 'geoLocation'>) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/number-formatters",
3
- "version": "1.0.17",
3
+ "version": "1.1.0",
4
4
  "description": "Number formatting utilities",
5
5
  "homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/number-formatters/#readme",
6
6
  "bugs": {
@@ -8,8 +8,7 @@
8
8
  },
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "https://github.com/Automattic/jetpack.git",
12
- "directory": "projects/js-packages/number-formatters"
11
+ "url": "git+https://github.com/Automattic/number-formatters.git"
13
12
  },
14
13
  "license": "GPL-2.0-or-later",
15
14
  "author": "Automattic",
@@ -389,6 +389,7 @@ const getCurrencyObject = ( {
389
389
  integer,
390
390
  fraction,
391
391
  hasNonZeroFraction,
392
+ floatValue: numberAsFloat,
392
393
  };
393
394
  };
394
395
 
package/src/types.ts CHANGED
@@ -118,6 +118,17 @@ export interface CurrencyObject {
118
118
  * True if the formatted number has a non-0 decimal part.
119
119
  */
120
120
  hasNonZeroFraction: boolean;
121
+
122
+ /**
123
+ * The raw floating-point version of the number prepared for formatting,
124
+ * after unit conversion and precision scaling.
125
+ *
126
+ * For non-decimal currencies (eg: JPY) this will actually be an integer.
127
+ * Otherwise it will likely be a floating-point number. Be careful with this!
128
+ * It should not be used for math if possible because of floating-point
129
+ * rounding issues! Use the smallest unit instead.
130
+ */
131
+ floatValue: number;
121
132
  }
122
133
 
123
134
  export type FormatNumber = (