@formatjs/intl-numberformat 8.14.5 → 8.15.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/README.md +1 -1
- package/lib/src/core.js +8 -3
- package/lib/src/types.d.ts +6 -5
- package/package.json +7 -6
- package/polyfill.iife.js +2850 -298
- package/src/core.js +8 -3
- package/src/types.d.ts +6 -5
- package/index.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/polyfill-force.js.map +0 -1
- package/lib/polyfill.js.map +0 -1
- package/lib/should-polyfill.js.map +0 -1
- package/lib/src/core.js.map +0 -1
- package/lib/src/currency-digits.generated.js.map +0 -1
- package/lib/src/get_internal_slots.js.map +0 -1
- package/lib/src/numbering-systems.generated.js.map +0 -1
- package/lib/src/to_locale_string.js.map +0 -1
- package/lib/src/types.js.map +0 -1
- package/lib/supported-locales.generated.js.map +0 -1
- package/polyfill-force.js.map +0 -1
- package/polyfill.js.map +0 -1
- package/should-polyfill.js.map +0 -1
- package/src/core.js.map +0 -1
- package/src/currency-digits.generated.js.map +0 -1
- package/src/get_internal_slots.js.map +0 -1
- package/src/numbering-systems.generated.js.map +0 -1
- package/src/to_locale_string.js.map +0 -1
- package/src/types.js.map +0 -1
- package/supported-locales.generated.js.map +0 -1
package/README.md
CHANGED
package/lib/src/core.js
CHANGED
|
@@ -2,6 +2,7 @@ import { CanonicalizeLocaleList, FormatNumericRange, FormatNumericRangeToParts,
|
|
|
2
2
|
import { currencyDigitsData } from './currency-digits.generated';
|
|
3
3
|
import { numberingSystemNames } from './numbering-systems.generated';
|
|
4
4
|
// eslint-disable-next-line import/no-cycle
|
|
5
|
+
import Decimal from 'decimal.js';
|
|
5
6
|
import getInternalSlots from './get_internal_slots';
|
|
6
7
|
var RESOLVED_OPTIONS_KEYS = [
|
|
7
8
|
'locale',
|
|
@@ -57,10 +58,14 @@ function formatToParts(x) {
|
|
|
57
58
|
});
|
|
58
59
|
}
|
|
59
60
|
function formatRange(start, end) {
|
|
60
|
-
return FormatNumericRange(this, start, end, {
|
|
61
|
+
return FormatNumericRange(this, toNumeric(start), toNumeric(end), {
|
|
62
|
+
getInternalSlots: getInternalSlots,
|
|
63
|
+
});
|
|
61
64
|
}
|
|
62
65
|
function formatRangeToParts(start, end) {
|
|
63
|
-
return FormatNumericRangeToParts(this, start, end, {
|
|
66
|
+
return FormatNumericRangeToParts(this, toNumeric(start), toNumeric(end), {
|
|
67
|
+
getInternalSlots: getInternalSlots,
|
|
68
|
+
});
|
|
64
69
|
}
|
|
65
70
|
try {
|
|
66
71
|
Object.defineProperty(formatToParts, 'name', {
|
|
@@ -208,7 +213,7 @@ NumberFormat.getDefaultLocale = function () {
|
|
|
208
213
|
NumberFormat.polyfilled = true;
|
|
209
214
|
function toNumeric(val) {
|
|
210
215
|
if (typeof val === 'bigint') {
|
|
211
|
-
return val;
|
|
216
|
+
return new Decimal(val.toString());
|
|
212
217
|
}
|
|
213
218
|
return ToNumber(val);
|
|
214
219
|
}
|
package/lib/src/types.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { NumberFormatLocaleInternalData,
|
|
1
|
+
import { NumberFormatLocaleInternalData, NumberFormatOptions, NumberFormatPart, NumberRangeToParts, RawNumberLocaleData, ResolvedNumberFormatOptions } from '@formatjs/ecma402-abstract';
|
|
2
|
+
import Decimal from 'decimal.js';
|
|
2
3
|
export interface NumberFormat {
|
|
3
4
|
resolvedOptions(): ResolvedNumberFormatOptions;
|
|
4
|
-
formatToParts(x: number): NumberFormatPart[];
|
|
5
|
-
format(x: number): string;
|
|
6
|
-
formatRange(start: number, end: number): string;
|
|
7
|
-
formatRangeToParts(start: number, end: number): NumberRangeToParts[];
|
|
5
|
+
formatToParts(x: number | bigint | Decimal): NumberFormatPart[];
|
|
6
|
+
format(x: number | bigint | Decimal): string;
|
|
7
|
+
formatRange(start: number | bigint | Decimal, end: number | bigint | Decimal): string;
|
|
8
|
+
formatRangeToParts(start: number | bigint | Decimal, end: number | bigint | Decimal): NumberRangeToParts[];
|
|
8
9
|
}
|
|
9
10
|
export interface NumberFormatConstructor {
|
|
10
11
|
new (locales?: string | string[], options?: NumberFormatOptions): NumberFormat;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formatjs/intl-numberformat",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.15.0",
|
|
4
4
|
"description": "Ponyfill for ES2020 Intl.NumberFormat",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"polyfill",
|
|
@@ -22,14 +22,15 @@
|
|
|
22
22
|
"url": "git+https://github.com/formatjs/formatjs.git"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
+
"decimal.js": "10",
|
|
25
26
|
"tslib": "2",
|
|
26
|
-
"@formatjs/
|
|
27
|
-
"@formatjs/
|
|
27
|
+
"@formatjs/ecma402-abstract": "2.3.0",
|
|
28
|
+
"@formatjs/intl-localematcher": "0.5.9"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
|
-
"@formatjs/intl-
|
|
31
|
-
"@formatjs/intl-locale": "4.2.
|
|
32
|
-
"@formatjs/intl-
|
|
31
|
+
"@formatjs/intl-pluralrules": "5.4.0",
|
|
32
|
+
"@formatjs/intl-locale": "4.2.7",
|
|
33
|
+
"@formatjs/intl-getcanonicallocales": "2.5.4"
|
|
33
34
|
},
|
|
34
35
|
"bugs": {
|
|
35
36
|
"url": "https://github.com/formatjs/formatjs/issues"
|