@formatjs/ecma402-abstract 1.12.0 → 1.14.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/GetStringOrBooleanOption.d.ts +11 -0
- package/GetStringOrBooleanOption.d.ts.map +1 -0
- package/GetStringOrBooleanOption.js +35 -0
- package/NumberFormat/ApplyUnsignedRoundingMode.d.ts +3 -0
- package/NumberFormat/ApplyUnsignedRoundingMode.d.ts.map +1 -0
- package/NumberFormat/ApplyUnsignedRoundingMode.js +42 -0
- package/NumberFormat/CollapseNumberRange.d.ts +5 -0
- package/NumberFormat/CollapseNumberRange.d.ts.map +1 -0
- package/NumberFormat/CollapseNumberRange.js +10 -0
- package/NumberFormat/FormatApproximately.d.ts +8 -0
- package/NumberFormat/FormatApproximately.d.ts.map +1 -0
- package/NumberFormat/FormatApproximately.js +15 -0
- package/NumberFormat/FormatNumericRange.d.ts +8 -0
- package/NumberFormat/FormatNumericRange.d.ts.map +1 -0
- package/NumberFormat/FormatNumericRange.js +15 -0
- package/NumberFormat/FormatNumericRangeToParts.d.ts +8 -0
- package/NumberFormat/FormatNumericRangeToParts.d.ts.map +1 -0
- package/NumberFormat/FormatNumericRangeToParts.js +20 -0
- package/NumberFormat/GetUnsignedRoundingMode.d.ts +3 -0
- package/NumberFormat/GetUnsignedRoundingMode.d.ts.map +1 -0
- package/NumberFormat/GetUnsignedRoundingMode.js +32 -0
- package/NumberFormat/InitializeNumberFormat.d.ts.map +1 -1
- package/NumberFormat/InitializeNumberFormat.js +35 -4
- package/NumberFormat/PartitionNumberPattern.d.ts.map +1 -1
- package/NumberFormat/PartitionNumberPattern.js +14 -9
- package/NumberFormat/PartitionNumberRangePattern.d.ts +8 -0
- package/NumberFormat/PartitionNumberRangePattern.d.ts.map +1 -0
- package/NumberFormat/PartitionNumberRangePattern.js +36 -0
- package/NumberFormat/SetNumberFormatDigitOptions.d.ts.map +1 -1
- package/NumberFormat/SetNumberFormatDigitOptions.js +63 -18
- package/NumberFormat/format_to_parts.d.ts +2 -2
- package/NumberFormat/format_to_parts.d.ts.map +1 -1
- package/NumberFormat/format_to_parts.js +1 -1
- package/index.d.ts +8 -0
- package/index.d.ts.map +1 -1
- package/index.js +8 -0
- package/lib/GetStringOrBooleanOption.d.ts +11 -0
- package/lib/GetStringOrBooleanOption.d.ts.map +1 -0
- package/lib/GetStringOrBooleanOption.js +31 -0
- package/lib/NumberFormat/ApplyUnsignedRoundingMode.d.ts +3 -0
- package/lib/NumberFormat/ApplyUnsignedRoundingMode.d.ts.map +1 -0
- package/lib/NumberFormat/ApplyUnsignedRoundingMode.js +38 -0
- package/lib/NumberFormat/CollapseNumberRange.d.ts +5 -0
- package/lib/NumberFormat/CollapseNumberRange.d.ts.map +1 -0
- package/lib/NumberFormat/CollapseNumberRange.js +6 -0
- package/lib/NumberFormat/FormatApproximately.d.ts +8 -0
- package/lib/NumberFormat/FormatApproximately.d.ts.map +1 -0
- package/lib/NumberFormat/FormatApproximately.js +11 -0
- package/lib/NumberFormat/FormatNumericRange.d.ts +8 -0
- package/lib/NumberFormat/FormatNumericRange.d.ts.map +1 -0
- package/lib/NumberFormat/FormatNumericRange.js +11 -0
- package/lib/NumberFormat/FormatNumericRangeToParts.d.ts +8 -0
- package/lib/NumberFormat/FormatNumericRangeToParts.d.ts.map +1 -0
- package/lib/NumberFormat/FormatNumericRangeToParts.js +16 -0
- package/lib/NumberFormat/GetUnsignedRoundingMode.d.ts +3 -0
- package/lib/NumberFormat/GetUnsignedRoundingMode.d.ts.map +1 -0
- package/lib/NumberFormat/GetUnsignedRoundingMode.js +28 -0
- package/lib/NumberFormat/InitializeNumberFormat.d.ts.map +1 -1
- package/lib/NumberFormat/InitializeNumberFormat.js +35 -4
- package/lib/NumberFormat/PartitionNumberPattern.d.ts.map +1 -1
- package/lib/NumberFormat/PartitionNumberPattern.js +14 -9
- package/lib/NumberFormat/PartitionNumberRangePattern.d.ts +8 -0
- package/lib/NumberFormat/PartitionNumberRangePattern.d.ts.map +1 -0
- package/lib/NumberFormat/PartitionNumberRangePattern.js +32 -0
- package/lib/NumberFormat/SetNumberFormatDigitOptions.d.ts.map +1 -1
- package/lib/NumberFormat/SetNumberFormatDigitOptions.js +63 -18
- package/lib/NumberFormat/format_to_parts.d.ts +2 -2
- package/lib/NumberFormat/format_to_parts.d.ts.map +1 -1
- package/lib/NumberFormat/format_to_parts.js +1 -1
- package/lib/index.d.ts +8 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +8 -0
- package/lib/types/date-time.d.ts +3 -3
- package/lib/types/date-time.d.ts.map +1 -1
- package/lib/types/displaynames.d.ts +22 -3
- package/lib/types/displaynames.d.ts.map +1 -1
- package/lib/types/number.d.ts +25 -7
- package/lib/types/number.d.ts.map +1 -1
- package/package.json +1 -1
- package/types/date-time.d.ts +3 -3
- package/types/date-time.d.ts.map +1 -1
- package/types/displaynames.d.ts +22 -3
- package/types/displaynames.d.ts.map +1 -1
- package/types/number.d.ts +25 -7
- package/types/number.d.ts.map +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* https://tc39.es/ecma402/#sec-getstringorbooleanoption
|
|
3
|
+
* @param opts
|
|
4
|
+
* @param prop
|
|
5
|
+
* @param values
|
|
6
|
+
* @param trueValue
|
|
7
|
+
* @param falsyValue
|
|
8
|
+
* @param fallback
|
|
9
|
+
*/
|
|
10
|
+
export declare function GetStringOrBooleanOption<T extends object, K extends keyof T>(opts: T, prop: K, values: T[K][] | undefined, trueValue: T[K] | boolean, falsyValue: T[K] | boolean, fallback: T[K] | boolean): T[K] | boolean;
|
|
11
|
+
//# sourceMappingURL=GetStringOrBooleanOption.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GetStringOrBooleanOption.d.ts","sourceRoot":"","sources":["../GetStringOrBooleanOption.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,wBAAgB,wBAAwB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,CAAC,EAC1E,IAAI,EAAE,CAAC,EACP,IAAI,EAAE,CAAC,EACP,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,SAAS,EAC1B,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,EACzB,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,EAC1B,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,GACvB,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAyBhB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* https://tc39.es/ecma402/#sec-getstringorbooleanoption
|
|
3
|
+
* @param opts
|
|
4
|
+
* @param prop
|
|
5
|
+
* @param values
|
|
6
|
+
* @param trueValue
|
|
7
|
+
* @param falsyValue
|
|
8
|
+
* @param fallback
|
|
9
|
+
*/
|
|
10
|
+
import { ToString } from './262';
|
|
11
|
+
export function GetStringOrBooleanOption(opts, prop, values, trueValue, falsyValue, fallback) {
|
|
12
|
+
var value = opts[prop];
|
|
13
|
+
if (value === undefined) {
|
|
14
|
+
return fallback;
|
|
15
|
+
}
|
|
16
|
+
if (value === true) {
|
|
17
|
+
return trueValue;
|
|
18
|
+
}
|
|
19
|
+
var valueBoolean = Boolean(value);
|
|
20
|
+
if (valueBoolean === false) {
|
|
21
|
+
return falsyValue;
|
|
22
|
+
}
|
|
23
|
+
value = ToString(value);
|
|
24
|
+
if (value === 'true' || value === 'false') {
|
|
25
|
+
return fallback;
|
|
26
|
+
}
|
|
27
|
+
if ((values || []).indexOf(value) === -1) {
|
|
28
|
+
throw new RangeError("Invalid value ".concat(value));
|
|
29
|
+
}
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApplyUnsignedRoundingMode.d.ts","sourceRoot":"","sources":["../../NumberFormat/ApplyUnsignedRoundingMode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,wBAAwB,EAAC,MAAM,iBAAiB,CAAA;AAExD,wBAAgB,yBAAyB,CACvC,CAAC,EAAE,MAAM,EACT,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,oBAAoB,EAAE,wBAAwB,GAC7C,MAAM,CA8CR"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export function ApplyUnsignedRoundingMode(x, r1, r2, unsignedRoundingMode) {
|
|
2
|
+
if (x === r1)
|
|
3
|
+
return r1;
|
|
4
|
+
if (unsignedRoundingMode === undefined) {
|
|
5
|
+
throw new Error('unsignedRoundingMode is mandatory');
|
|
6
|
+
}
|
|
7
|
+
if (unsignedRoundingMode === 'zero') {
|
|
8
|
+
return r1;
|
|
9
|
+
}
|
|
10
|
+
if (unsignedRoundingMode === 'infinity') {
|
|
11
|
+
return r2;
|
|
12
|
+
}
|
|
13
|
+
var d1 = x - r1;
|
|
14
|
+
var d2 = r2 - x;
|
|
15
|
+
if (d1 < d2) {
|
|
16
|
+
return r1;
|
|
17
|
+
}
|
|
18
|
+
if (d2 < d1) {
|
|
19
|
+
return r2;
|
|
20
|
+
}
|
|
21
|
+
if (d1 !== d2) {
|
|
22
|
+
throw new Error('Unexpected error');
|
|
23
|
+
}
|
|
24
|
+
if (unsignedRoundingMode === 'half-zero') {
|
|
25
|
+
return r1;
|
|
26
|
+
}
|
|
27
|
+
if (unsignedRoundingMode === 'half-infinity') {
|
|
28
|
+
return r2;
|
|
29
|
+
}
|
|
30
|
+
if (unsignedRoundingMode !== 'half-even') {
|
|
31
|
+
throw new Error("Unexpected value for unsignedRoundingMode: ".concat(unsignedRoundingMode));
|
|
32
|
+
}
|
|
33
|
+
var cardinality = (r1 / (r2 - r1)) % 2;
|
|
34
|
+
if (cardinality === 0) {
|
|
35
|
+
return r1;
|
|
36
|
+
}
|
|
37
|
+
return r2;
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CollapseNumberRange.d.ts","sourceRoot":"","sources":["../../NumberFormat/CollapseNumberRange.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,KAE/C"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { NumberFormatInternal, NumberFormatPart } from '../types/number';
|
|
2
|
+
/**
|
|
3
|
+
* https://tc39.es/ecma402/#sec-formatapproximately
|
|
4
|
+
*/
|
|
5
|
+
export declare function FormatApproximately(numberFormat: Intl.NumberFormat, result: NumberFormatPart[], { getInternalSlots, }: {
|
|
6
|
+
getInternalSlots(nf: Intl.NumberFormat): NumberFormatInternal;
|
|
7
|
+
}): NumberFormatPart[];
|
|
8
|
+
//# sourceMappingURL=FormatApproximately.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormatApproximately.d.ts","sourceRoot":"","sources":["../../NumberFormat/FormatApproximately.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAE,gBAAgB,EAAC,MAAM,iBAAiB,CAAA;AAEtE;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,IAAI,CAAC,YAAY,EAC/B,MAAM,EAAE,gBAAgB,EAAE,EAC1B,EACE,gBAAgB,GACjB,EAAE;IACD,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,YAAY,GAAG,oBAAoB,CAAA;CAC9D,sBAWF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* https://tc39.es/ecma402/#sec-formatapproximately
|
|
3
|
+
*/
|
|
4
|
+
export function FormatApproximately(numberFormat, result, _a) {
|
|
5
|
+
var getInternalSlots = _a.getInternalSlots;
|
|
6
|
+
var internalSlots = getInternalSlots(numberFormat);
|
|
7
|
+
var symbols = internalSlots.dataLocaleData.numbers.symbols[internalSlots.numberingSystem];
|
|
8
|
+
var approximatelySign = symbols.approximatelySign;
|
|
9
|
+
result.push({ type: 'approximatelySign', value: approximatelySign });
|
|
10
|
+
return result;
|
|
11
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { NumberFormatInternal } from '../types/number';
|
|
2
|
+
/**
|
|
3
|
+
* https://tc39.es/ecma402/#sec-formatnumericrange
|
|
4
|
+
*/
|
|
5
|
+
export declare function FormatNumericRange(numberFormat: Intl.NumberFormat, x: number, y: number, { getInternalSlots, }: {
|
|
6
|
+
getInternalSlots(nf: Intl.NumberFormat): NumberFormatInternal;
|
|
7
|
+
}): string;
|
|
8
|
+
//# sourceMappingURL=FormatNumericRange.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormatNumericRange.d.ts","sourceRoot":"","sources":["../../NumberFormat/FormatNumericRange.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,iBAAiB,CAAA;AAGpD;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,IAAI,CAAC,YAAY,EAC/B,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,EACE,gBAAgB,GACjB,EAAE;IACD,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,YAAY,GAAG,oBAAoB,CAAA;CAC9D,UAOF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PartitionNumberRangePattern } from './PartitionNumberRangePattern';
|
|
2
|
+
/**
|
|
3
|
+
* https://tc39.es/ecma402/#sec-formatnumericrange
|
|
4
|
+
*/
|
|
5
|
+
export function FormatNumericRange(numberFormat, x, y, _a) {
|
|
6
|
+
var getInternalSlots = _a.getInternalSlots;
|
|
7
|
+
var parts = PartitionNumberRangePattern(numberFormat, x, y, {
|
|
8
|
+
getInternalSlots: getInternalSlots,
|
|
9
|
+
});
|
|
10
|
+
return parts.map(function (part) { return part.value; }).join('');
|
|
11
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { NumberFormatInternal, NumberRangeToParts } from '../types/number';
|
|
2
|
+
/**
|
|
3
|
+
* https://tc39.es/ecma402/#sec-formatnumericrangetoparts
|
|
4
|
+
*/
|
|
5
|
+
export declare function FormatNumericRangeToParts(numberFormat: Intl.NumberFormat, x: number, y: number, { getInternalSlots, }: {
|
|
6
|
+
getInternalSlots(nf: Intl.NumberFormat): NumberFormatInternal;
|
|
7
|
+
}): NumberRangeToParts[];
|
|
8
|
+
//# sourceMappingURL=FormatNumericRangeToParts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormatNumericRangeToParts.d.ts","sourceRoot":"","sources":["../../NumberFormat/FormatNumericRangeToParts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAE,kBAAkB,EAAC,MAAM,iBAAiB,CAAA;AAGxE;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,YAAY,EAAE,IAAI,CAAC,YAAY,EAC/B,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,EACE,gBAAgB,GACjB,EAAE;IACD,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,YAAY,GAAG,oBAAoB,CAAA;CAC9D,GACA,kBAAkB,EAAE,CAWtB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PartitionNumberRangePattern } from './PartitionNumberRangePattern';
|
|
2
|
+
/**
|
|
3
|
+
* https://tc39.es/ecma402/#sec-formatnumericrangetoparts
|
|
4
|
+
*/
|
|
5
|
+
export function FormatNumericRangeToParts(numberFormat, x, y, _a) {
|
|
6
|
+
var getInternalSlots = _a.getInternalSlots;
|
|
7
|
+
var parts = PartitionNumberRangePattern(numberFormat, x, y, {
|
|
8
|
+
getInternalSlots: getInternalSlots,
|
|
9
|
+
});
|
|
10
|
+
return parts.map(function (part, index) { return ({
|
|
11
|
+
type: part.type,
|
|
12
|
+
value: part.value,
|
|
13
|
+
source: part.source,
|
|
14
|
+
result: index.toString(),
|
|
15
|
+
}); });
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GetUnsignedRoundingMode.d.ts","sourceRoot":"","sources":["../../NumberFormat/GetUnsignedRoundingMode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAE,wBAAwB,EAAC,MAAM,iBAAiB,CAAA;AA0B1E,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,gBAAgB,EAC9B,UAAU,EAAE,OAAO,GAClB,wBAAwB,CAK1B"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var negativeMapping = {
|
|
2
|
+
ceil: 'zero',
|
|
3
|
+
floor: 'infinity',
|
|
4
|
+
expand: 'infinity',
|
|
5
|
+
trunc: 'zero',
|
|
6
|
+
halfCeil: 'half-zero',
|
|
7
|
+
halfFloor: 'half-infinity',
|
|
8
|
+
halfExpand: 'half-infinity',
|
|
9
|
+
halfTrunc: 'half-zero',
|
|
10
|
+
halfEven: 'half-even',
|
|
11
|
+
};
|
|
12
|
+
var positiveMapping = {
|
|
13
|
+
ceil: 'infinity',
|
|
14
|
+
floor: 'zero',
|
|
15
|
+
expand: 'infinity',
|
|
16
|
+
trunc: 'zero',
|
|
17
|
+
halfCeil: 'half-infinity',
|
|
18
|
+
halfFloor: 'half-zero',
|
|
19
|
+
halfExpand: 'half-infinity',
|
|
20
|
+
halfTrunc: 'half-zero',
|
|
21
|
+
halfEven: 'half-even',
|
|
22
|
+
};
|
|
23
|
+
export function GetUnsignedRoundingMode(roundingMode, isNegative) {
|
|
24
|
+
if (isNegative) {
|
|
25
|
+
return negativeMapping[roundingMode];
|
|
26
|
+
}
|
|
27
|
+
return positiveMapping[roundingMode];
|
|
28
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InitializeNumberFormat.d.ts","sourceRoot":"","sources":["../../NumberFormat/InitializeNumberFormat.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,8BAA8B,
|
|
1
|
+
{"version":3,"file":"InitializeNumberFormat.d.ts","sourceRoot":"","sources":["../../NumberFormat/InitializeNumberFormat.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,8BAA8B,EAE/B,MAAM,iBAAiB,CAAA;AAgBxB;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,EAAE,EAAE,IAAI,CAAC,YAAY,EACrB,OAAO,EAAE,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,EACnD,IAAI,EAAE,mBAAmB,GAAG,SAAS,EACrC,EACE,gBAAgB,EAChB,UAAU,EACV,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,EAChB,kBAAkB,GACnB,EAAE;IACD,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,YAAY,GAAG,oBAAoB,CAAA;IAC7D,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,8BAA8B,GAAG,SAAS,CAAC,CAAA;IACtE,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAC7B,oBAAoB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IAC3C,gBAAgB,IAAI,MAAM,CAAA;IAC1B,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC3C,qBAgLF"}
|
|
@@ -6,6 +6,11 @@ import { CurrencyDigits } from './CurrencyDigits';
|
|
|
6
6
|
import { SetNumberFormatDigitOptions } from './SetNumberFormatDigitOptions';
|
|
7
7
|
import { invariant } from '../utils';
|
|
8
8
|
import { CoerceOptionsToObject } from '../CoerceOptionsToObject';
|
|
9
|
+
import { GetNumberOption } from '../GetNumberOption';
|
|
10
|
+
import { GetStringOrBooleanOption } from '../GetStringOrBooleanOption';
|
|
11
|
+
var VALID_ROUND_INCREMENT_VALUES = [
|
|
12
|
+
1, 2, 5, 10, 20, 25, 50, 100, 200, 250, 500, 1000, 2000,
|
|
13
|
+
];
|
|
9
14
|
/**
|
|
10
15
|
* https://tc39.es/ecma402/#sec-initializenumberformat
|
|
11
16
|
*/
|
|
@@ -52,13 +57,39 @@ export function InitializeNumberFormat(nf, locales, opts, _a) {
|
|
|
52
57
|
var notation = GetOption(options, 'notation', 'string', ['standard', 'scientific', 'engineering', 'compact'], 'standard');
|
|
53
58
|
internalSlots.notation = notation;
|
|
54
59
|
SetNumberFormatDigitOptions(internalSlots, options, mnfdDefault, mxfdDefault, notation);
|
|
60
|
+
var roundingIncrement = GetNumberOption(options, 'roundingIncrement', 1, 5000, 1);
|
|
61
|
+
if (VALID_ROUND_INCREMENT_VALUES.indexOf(roundingIncrement) === -1) {
|
|
62
|
+
throw new RangeError("Invalid rounding increment value: ".concat(roundingIncrement, ".\nValid values are ").concat(VALID_ROUND_INCREMENT_VALUES, "."));
|
|
63
|
+
}
|
|
64
|
+
if (roundingIncrement !== 1 &&
|
|
65
|
+
internalSlots.roundingType !== 'fractionDigits') {
|
|
66
|
+
throw new TypeError("For roundingIncrement > 1 only fractionDigits is a valid roundingType");
|
|
67
|
+
}
|
|
68
|
+
if (roundingIncrement !== 1 &&
|
|
69
|
+
internalSlots.maximumFractionDigits !== internalSlots.minimumFractionDigits) {
|
|
70
|
+
throw new RangeError('With roundingIncrement > 1, maximumFractionDigits and minimumFractionDigits must be equal.');
|
|
71
|
+
}
|
|
72
|
+
internalSlots.roundingIncrement = roundingIncrement;
|
|
73
|
+
var trailingZeroDisplay = GetOption(options, 'trailingZeroDisplay', 'string', ['auto', 'stripIfInteger'], 'auto');
|
|
74
|
+
internalSlots.trailingZeroDisplay = trailingZeroDisplay;
|
|
55
75
|
var compactDisplay = GetOption(options, 'compactDisplay', 'string', ['short', 'long'], 'short');
|
|
76
|
+
var defaultUseGrouping = 'auto';
|
|
56
77
|
if (notation === 'compact') {
|
|
57
78
|
internalSlots.compactDisplay = compactDisplay;
|
|
79
|
+
defaultUseGrouping = 'min2';
|
|
58
80
|
}
|
|
59
|
-
|
|
60
|
-
internalSlots.
|
|
61
|
-
|
|
62
|
-
|
|
81
|
+
internalSlots.useGrouping = GetStringOrBooleanOption(options, 'useGrouping', ['min2', 'auto', 'always'], 'always', false, defaultUseGrouping);
|
|
82
|
+
internalSlots.signDisplay = GetOption(options, 'signDisplay', 'string', ['auto', 'never', 'always', 'exceptZero', 'negative'], 'auto');
|
|
83
|
+
internalSlots.roundingMode = GetOption(options, 'roundingMode', 'string', [
|
|
84
|
+
'ceil',
|
|
85
|
+
'floor',
|
|
86
|
+
'expand',
|
|
87
|
+
'trunc',
|
|
88
|
+
'halfCeil',
|
|
89
|
+
'halfFloor',
|
|
90
|
+
'halfExpand',
|
|
91
|
+
'halfTrunc',
|
|
92
|
+
'halfEven',
|
|
93
|
+
], 'halfExpand');
|
|
63
94
|
return nf;
|
|
64
95
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PartitionNumberPattern.d.ts","sourceRoot":"","sources":["../../NumberFormat/PartitionNumberPattern.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,iBAAiB,CAAA;AAMpD;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,IAAI,CAAC,YAAY,EAC/B,CAAC,EAAE,MAAM,EACT,EACE,gBAAgB,GACjB,EAAE;IACD,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,YAAY,GAAG,oBAAoB,CAAA;CAC9D,
|
|
1
|
+
{"version":3,"file":"PartitionNumberPattern.d.ts","sourceRoot":"","sources":["../../NumberFormat/PartitionNumberPattern.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,iBAAiB,CAAA;AAMpD;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,IAAI,CAAC,YAAY,EAC/B,CAAC,EAAE,MAAM,EACT,EACE,gBAAgB,GACjB,EAAE;IACD,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,YAAY,GAAG,oBAAoB,CAAA;CAC9D,gDA0EF"}
|
|
@@ -18,19 +18,24 @@ export function PartitionNumberPattern(numberFormat, x, _a) {
|
|
|
18
18
|
if (isNaN(x)) {
|
|
19
19
|
n = symbols.nan;
|
|
20
20
|
}
|
|
21
|
-
else if (
|
|
21
|
+
else if (x == Number.POSITIVE_INFINITY || x == Number.NEGATIVE_INFINITY) {
|
|
22
22
|
n = symbols.infinity;
|
|
23
23
|
}
|
|
24
24
|
else {
|
|
25
|
-
if (
|
|
26
|
-
x
|
|
25
|
+
if (!SameValue(x, -0)) {
|
|
26
|
+
if (!isFinite(x)) {
|
|
27
|
+
throw new Error('Input must be a mathematical value');
|
|
28
|
+
}
|
|
29
|
+
if (internalSlots.style == 'percent') {
|
|
30
|
+
x *= 100;
|
|
31
|
+
}
|
|
32
|
+
;
|
|
33
|
+
_b = ComputeExponent(numberFormat, x, {
|
|
34
|
+
getInternalSlots: getInternalSlots,
|
|
35
|
+
}), exponent = _b[0], magnitude = _b[1];
|
|
36
|
+
// Preserve more precision by doing multiplication when exponent is negative.
|
|
37
|
+
x = exponent < 0 ? x * Math.pow(10, -exponent) : x / Math.pow(10, exponent);
|
|
27
38
|
}
|
|
28
|
-
;
|
|
29
|
-
_b = ComputeExponent(numberFormat, x, {
|
|
30
|
-
getInternalSlots: getInternalSlots,
|
|
31
|
-
}), exponent = _b[0], magnitude = _b[1];
|
|
32
|
-
// Preserve more precision by doing multiplication when exponent is negative.
|
|
33
|
-
x = exponent < 0 ? x * Math.pow(10, -exponent) : x / Math.pow(10, exponent);
|
|
34
39
|
var formatNumberResult = FormatNumericToString(internalSlots, x);
|
|
35
40
|
n = formatNumberResult.formattedString;
|
|
36
41
|
x = formatNumberResult.roundedNumber;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { NumberFormatInternal, NumberFormatPart } from '../types/number';
|
|
2
|
+
/**
|
|
3
|
+
* https://tc39.es/ecma402/#sec-partitionnumberrangepattern
|
|
4
|
+
*/
|
|
5
|
+
export declare function PartitionNumberRangePattern(numberFormat: Intl.NumberFormat, x: number, y: number, { getInternalSlots, }: {
|
|
6
|
+
getInternalSlots(nf: Intl.NumberFormat): NumberFormatInternal;
|
|
7
|
+
}): NumberFormatPart[];
|
|
8
|
+
//# sourceMappingURL=PartitionNumberRangePattern.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PartitionNumberRangePattern.d.ts","sourceRoot":"","sources":["../../NumberFormat/PartitionNumberRangePattern.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAE,gBAAgB,EAAC,MAAM,iBAAiB,CAAA;AAKtE;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,YAAY,EAAE,IAAI,CAAC,YAAY,EAC/B,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,EACE,gBAAgB,GACjB,EAAE;IACD,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,YAAY,GAAG,oBAAoB,CAAA;CAC9D,sBAiCF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { PartitionNumberPattern } from './PartitionNumberPattern';
|
|
2
|
+
import { CollapseNumberRange } from './CollapseNumberRange';
|
|
3
|
+
import { FormatApproximately } from './FormatApproximately';
|
|
4
|
+
/**
|
|
5
|
+
* https://tc39.es/ecma402/#sec-partitionnumberrangepattern
|
|
6
|
+
*/
|
|
7
|
+
export function PartitionNumberRangePattern(numberFormat, x, y, _a) {
|
|
8
|
+
var getInternalSlots = _a.getInternalSlots;
|
|
9
|
+
if (isNaN(x) || isNaN(y)) {
|
|
10
|
+
throw new RangeError('Input must be a number');
|
|
11
|
+
}
|
|
12
|
+
var result = [];
|
|
13
|
+
var xResult = PartitionNumberPattern(numberFormat, x, { getInternalSlots: getInternalSlots });
|
|
14
|
+
var yResult = PartitionNumberPattern(numberFormat, y, { getInternalSlots: getInternalSlots });
|
|
15
|
+
if (xResult === yResult) {
|
|
16
|
+
return FormatApproximately(numberFormat, xResult, { getInternalSlots: getInternalSlots });
|
|
17
|
+
}
|
|
18
|
+
for (var _i = 0, xResult_1 = xResult; _i < xResult_1.length; _i++) {
|
|
19
|
+
var r = xResult_1[_i];
|
|
20
|
+
r.source = 'startRange';
|
|
21
|
+
}
|
|
22
|
+
result = result.concat(xResult);
|
|
23
|
+
var internalSlots = getInternalSlots(numberFormat);
|
|
24
|
+
var symbols = internalSlots.dataLocaleData.numbers.symbols[internalSlots.numberingSystem];
|
|
25
|
+
result.push({ type: 'literal', value: symbols.rangeSign, source: 'shared' });
|
|
26
|
+
for (var _b = 0, yResult_1 = yResult; _b < yResult_1.length; _b++) {
|
|
27
|
+
var r = yResult_1[_b];
|
|
28
|
+
r.source = 'endRange';
|
|
29
|
+
}
|
|
30
|
+
result = result.concat(yResult);
|
|
31
|
+
return CollapseNumberRange(result);
|
|
32
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SetNumberFormatDigitOptions.d.ts","sourceRoot":"","sources":["../../NumberFormat/SetNumberFormatDigitOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,8BAA8B,EAC/B,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"SetNumberFormatDigitOptions.d.ts","sourceRoot":"","sources":["../../NumberFormat/SetNumberFormatDigitOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,8BAA8B,EAC/B,MAAM,iBAAiB,CAAA;AAKxB;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,aAAa,EAAE,8BAA8B,EAC7C,IAAI,EAAE,wBAAwB,EAC9B,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,oBAAoB,QA2E/B"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { GetNumberOption } from '../GetNumberOption';
|
|
2
2
|
import { DefaultNumberOption } from '../DefaultNumberOption';
|
|
3
|
+
import { GetOption } from '../GetOption';
|
|
3
4
|
/**
|
|
4
5
|
* https://tc39.es/ecma402/#sec-setnfdigitoptions
|
|
5
6
|
*/
|
|
@@ -10,27 +11,71 @@ export function SetNumberFormatDigitOptions(internalSlots, opts, mnfdDefault, mx
|
|
|
10
11
|
var mnsd = opts.minimumSignificantDigits;
|
|
11
12
|
var mxsd = opts.maximumSignificantDigits;
|
|
12
13
|
internalSlots.minimumIntegerDigits = mnid;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
var roundingPriority = GetOption(opts, 'roundingPriority', 'string', ['auto', 'morePrecision', 'lessPrecision'], 'auto');
|
|
15
|
+
var hasSd = mnsd !== undefined || mxsd !== undefined;
|
|
16
|
+
var hasFd = mnfd !== undefined || mxfd !== undefined;
|
|
17
|
+
var needSd = true;
|
|
18
|
+
var needFd = true;
|
|
19
|
+
if (roundingPriority === 'auto') {
|
|
20
|
+
needSd = hasSd;
|
|
21
|
+
if (hasSd || (!hasFd && notation === 'compact')) {
|
|
22
|
+
needFd = false;
|
|
23
|
+
}
|
|
19
24
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
if (needSd) {
|
|
26
|
+
if (hasSd) {
|
|
27
|
+
mnsd = DefaultNumberOption(mnsd, 1, 21, 1);
|
|
28
|
+
mxsd = DefaultNumberOption(mxsd, mnsd, 21, 21);
|
|
29
|
+
internalSlots.minimumSignificantDigits = mnsd;
|
|
30
|
+
internalSlots.maximumSignificantDigits = mxsd;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
internalSlots.minimumSignificantDigits = 1;
|
|
34
|
+
internalSlots.maximumSignificantDigits = 21;
|
|
35
|
+
}
|
|
27
36
|
}
|
|
28
|
-
|
|
29
|
-
|
|
37
|
+
if (needFd) {
|
|
38
|
+
if (hasFd) {
|
|
39
|
+
// @ts-expect-error
|
|
40
|
+
mnfd = DefaultNumberOption(mnfd, 0, 20, undefined);
|
|
41
|
+
// @ts-expect-error
|
|
42
|
+
mxfd = DefaultNumberOption(mxfd, 0, 20, undefined);
|
|
43
|
+
if (mnfd === undefined) {
|
|
44
|
+
mnfd = Math.min(mnfdDefault, mxfd);
|
|
45
|
+
}
|
|
46
|
+
else if (mxfd === undefined) {
|
|
47
|
+
mxfd = Math.max(mxfdDefault, mnfd);
|
|
48
|
+
}
|
|
49
|
+
else if (mnfd > mxfd) {
|
|
50
|
+
throw new RangeError("Invalid range, ".concat(mnfd, " > ").concat(mxfd));
|
|
51
|
+
}
|
|
52
|
+
internalSlots.minimumFractionDigits = mnfd;
|
|
53
|
+
internalSlots.maximumFractionDigits = mxfd;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
internalSlots.minimumFractionDigits = mnfdDefault;
|
|
57
|
+
internalSlots.maximumFractionDigits = mxfdDefault;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (needSd || needFd) {
|
|
61
|
+
if (roundingPriority === 'morePrecision') {
|
|
62
|
+
internalSlots.roundingType = 'morePrecision';
|
|
63
|
+
}
|
|
64
|
+
else if (roundingPriority === 'lessPrecision') {
|
|
65
|
+
internalSlots.roundingType = 'lessPrecision';
|
|
66
|
+
}
|
|
67
|
+
else if (hasSd) {
|
|
68
|
+
internalSlots.roundingType = 'significantDigits';
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
internalSlots.roundingType = 'fractionDigits';
|
|
72
|
+
}
|
|
30
73
|
}
|
|
31
74
|
else {
|
|
32
|
-
internalSlots.roundingType = '
|
|
33
|
-
internalSlots.minimumFractionDigits =
|
|
34
|
-
internalSlots.maximumFractionDigits =
|
|
75
|
+
internalSlots.roundingType = 'morePrecision';
|
|
76
|
+
internalSlots.minimumFractionDigits = 0;
|
|
77
|
+
internalSlots.maximumFractionDigits = 0;
|
|
78
|
+
internalSlots.minimumSignificantDigits = 1;
|
|
79
|
+
internalSlots.maximumSignificantDigits = 2;
|
|
35
80
|
}
|
|
36
81
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NumberFormatOptionsStyle, NumberFormatOptionsNotation, NumberFormatOptionsCompactDisplay, NumberFormatOptionsCurrencyDisplay, NumberFormatOptionsCurrencySign, NumberFormatOptionsUnitDisplay, NumberFormatLocaleInternalData, NumberFormatPart } from '../types/number';
|
|
1
|
+
import { NumberFormatOptionsStyle, NumberFormatOptionsNotation, NumberFormatOptionsCompactDisplay, NumberFormatOptionsCurrencyDisplay, NumberFormatOptionsCurrencySign, NumberFormatOptionsUnitDisplay, NumberFormatLocaleInternalData, NumberFormatPart, UseGroupingType } from '../types/number';
|
|
2
2
|
interface NumberResult {
|
|
3
3
|
formattedString: string;
|
|
4
4
|
roundedNumber: number;
|
|
@@ -8,7 +8,7 @@ interface NumberResult {
|
|
|
8
8
|
}
|
|
9
9
|
export default function formatToParts(numberResult: NumberResult, data: NumberFormatLocaleInternalData, pl: Intl.PluralRules, options: {
|
|
10
10
|
numberingSystem: string;
|
|
11
|
-
useGrouping
|
|
11
|
+
useGrouping?: UseGroupingType;
|
|
12
12
|
style: NumberFormatOptionsStyle;
|
|
13
13
|
notation: NumberFormatOptionsNotation;
|
|
14
14
|
compactDisplay?: NumberFormatOptionsCompactDisplay;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format_to_parts.d.ts","sourceRoot":"","sources":["../../NumberFormat/format_to_parts.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,2BAA2B,EAC3B,iCAAiC,EACjC,kCAAkC,EAClC,+BAA+B,EAC/B,8BAA8B,EAC9B,8BAA8B,EAM9B,gBAAgB,
|
|
1
|
+
{"version":3,"file":"format_to_parts.d.ts","sourceRoot":"","sources":["../../NumberFormat/format_to_parts.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,2BAA2B,EAC3B,iCAAiC,EACjC,kCAAkC,EAClC,+BAA+B,EAC/B,8BAA8B,EAC9B,8BAA8B,EAM9B,gBAAgB,EAChB,eAAe,EAChB,MAAM,iBAAiB,CAAA;AAexB,UAAU,YAAY;IACpB,eAAe,EAAE,MAAM,CAAA;IACvB,aAAa,EAAE,MAAM,CAAA;IACrB,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IAEhB,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,CAAC,OAAO,UAAU,aAAa,CACnC,YAAY,EAAE,YAAY,EAC1B,IAAI,EAAE,8BAA8B,EACpC,EAAE,EAAE,IAAI,CAAC,WAAW,EACpB,OAAO,EAAE;IACP,eAAe,EAAE,MAAM,CAAA;IACvB,WAAW,CAAC,EAAE,eAAe,CAAA;IAC7B,KAAK,EAAE,wBAAwB,CAAA;IAE/B,QAAQ,EAAE,2BAA2B,CAAA;IAErC,cAAc,CAAC,EAAE,iCAAiC,CAAA;IAElD,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,eAAe,CAAC,EAAE,kCAAkC,CAAA;IACpD,YAAY,CAAC,EAAE,+BAA+B,CAAA;IAE9C,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,8BAA8B,CAAA;CAC7C,GACA,gBAAgB,EAAE,CAySpB"}
|
|
@@ -117,7 +117,7 @@ export default function formatToParts(numberResult, data, pl, options) {
|
|
|
117
117
|
// We only need to handle scientific and engineering notation here.
|
|
118
118
|
numberParts.push.apply(numberParts, paritionNumberIntoParts(symbols, numberResult, notation, exponent, numberingSystem,
|
|
119
119
|
// If compact number pattern exists, do not insert group separators.
|
|
120
|
-
!compactNumberPattern && options.useGrouping, decimalNumberPattern));
|
|
120
|
+
!compactNumberPattern && Boolean(options.useGrouping), decimalNumberPattern));
|
|
121
121
|
break;
|
|
122
122
|
}
|
|
123
123
|
case '-':
|
package/lib/index.d.ts
CHANGED
|
@@ -4,17 +4,25 @@ export * from './CoerceOptionsToObject';
|
|
|
4
4
|
export * from './GetNumberOption';
|
|
5
5
|
export * from './GetOption';
|
|
6
6
|
export * from './GetOptionsObject';
|
|
7
|
+
export * from './GetStringOrBooleanOption';
|
|
7
8
|
export * from './IsSanctionedSimpleUnitIdentifier';
|
|
8
9
|
export * from './IsValidTimeZoneName';
|
|
9
10
|
export * from './IsWellFormedCurrencyCode';
|
|
10
11
|
export * from './IsWellFormedUnitIdentifier';
|
|
12
|
+
export * from './NumberFormat/ApplyUnsignedRoundingMode';
|
|
13
|
+
export * from './NumberFormat/CollapseNumberRange';
|
|
11
14
|
export * from './NumberFormat/ComputeExponent';
|
|
12
15
|
export * from './NumberFormat/ComputeExponentForMagnitude';
|
|
13
16
|
export * from './NumberFormat/CurrencyDigits';
|
|
17
|
+
export * from './NumberFormat/FormatApproximately';
|
|
18
|
+
export * from './NumberFormat/FormatNumericRange';
|
|
19
|
+
export * from './NumberFormat/FormatNumericRangeToParts';
|
|
14
20
|
export * from './NumberFormat/FormatNumericToParts';
|
|
15
21
|
export * from './NumberFormat/FormatNumericToString';
|
|
22
|
+
export * from './NumberFormat/GetUnsignedRoundingMode';
|
|
16
23
|
export * from './NumberFormat/InitializeNumberFormat';
|
|
17
24
|
export * from './NumberFormat/PartitionNumberPattern';
|
|
25
|
+
export * from './NumberFormat/PartitionNumberRangePattern';
|
|
18
26
|
export * from './NumberFormat/SetNumberFormatDigitOptions';
|
|
19
27
|
export * from './NumberFormat/SetNumberFormatUnitOptions';
|
|
20
28
|
export * from './NumberFormat/ToRawFixed';
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA;AACxC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,yBAAyB,CAAA;AACvC,cAAc,mBAAmB,CAAA;AACjC,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,oCAAoC,CAAA;AAClD,cAAc,uBAAuB,CAAA;AACrC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,8BAA8B,CAAA;AAC5C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,4CAA4C,CAAA;AAC1D,cAAc,+BAA+B,CAAA;AAC7C,cAAc,qCAAqC,CAAA;AACnD,cAAc,sCAAsC,CAAA;AACpD,cAAc,uCAAuC,CAAA;AACrD,cAAc,uCAAuC,CAAA;AACrD,cAAc,4CAA4C,CAAA;AAC1D,cAAc,2CAA2C,CAAA;AACzD,cAAc,2BAA2B,CAAA;AACzC,cAAc,+BAA+B,CAAA;AAC7C,OAAO,EAAC,OAAO,IAAI,cAAc,EAAC,MAAM,gCAAgC,CAAA;AACxE,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,aAAa,EACb,eAAe,EACf,qBAAqB,EACrB,YAAY,EACZ,cAAc,GACf,MAAM,SAAS,CAAA;AAChB,YAAY,EAAC,WAAW,EAAC,MAAM,SAAS,CAAA;AAExC,OAAO,EAAC,wBAAwB,EAAC,MAAM,QAAQ,CAAA;AAC/C,cAAc,uBAAuB,CAAA;AACrC,cAAc,mBAAmB,CAAA;AACjC,cAAc,cAAc,CAAA;AAC5B,cAAc,sBAAsB,CAAA;AACpC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,sBAAsB,CAAA;AACpC,OAAO,EAAC,SAAS,EAAC,MAAM,SAAS,CAAA;AACjC,YAAY,EAAC,UAAU,EAAC,MAAM,cAAc,CAAA;AAC5C,cAAc,OAAO,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA;AACxC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,yBAAyB,CAAA;AACvC,cAAc,mBAAmB,CAAA;AACjC,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,oCAAoC,CAAA;AAClD,cAAc,uBAAuB,CAAA;AACrC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,8BAA8B,CAAA;AAC5C,cAAc,0CAA0C,CAAA;AACxD,cAAc,oCAAoC,CAAA;AAClD,cAAc,gCAAgC,CAAA;AAC9C,cAAc,4CAA4C,CAAA;AAC1D,cAAc,+BAA+B,CAAA;AAC7C,cAAc,oCAAoC,CAAA;AAClD,cAAc,mCAAmC,CAAA;AACjD,cAAc,0CAA0C,CAAA;AACxD,cAAc,qCAAqC,CAAA;AACnD,cAAc,sCAAsC,CAAA;AACpD,cAAc,wCAAwC,CAAA;AACtD,cAAc,uCAAuC,CAAA;AACrD,cAAc,uCAAuC,CAAA;AACrD,cAAc,4CAA4C,CAAA;AAC1D,cAAc,4CAA4C,CAAA;AAC1D,cAAc,2CAA2C,CAAA;AACzD,cAAc,2BAA2B,CAAA;AACzC,cAAc,+BAA+B,CAAA;AAC7C,OAAO,EAAC,OAAO,IAAI,cAAc,EAAC,MAAM,gCAAgC,CAAA;AACxE,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,aAAa,EACb,eAAe,EACf,qBAAqB,EACrB,YAAY,EACZ,cAAc,GACf,MAAM,SAAS,CAAA;AAChB,YAAY,EAAC,WAAW,EAAC,MAAM,SAAS,CAAA;AAExC,OAAO,EAAC,wBAAwB,EAAC,MAAM,QAAQ,CAAA;AAC/C,cAAc,uBAAuB,CAAA;AACrC,cAAc,mBAAmB,CAAA;AACjC,cAAc,cAAc,CAAA;AAC5B,cAAc,sBAAsB,CAAA;AACpC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,sBAAsB,CAAA;AACpC,OAAO,EAAC,SAAS,EAAC,MAAM,SAAS,CAAA;AACjC,YAAY,EAAC,UAAU,EAAC,MAAM,cAAc,CAAA;AAC5C,cAAc,OAAO,CAAA"}
|
package/lib/index.js
CHANGED
|
@@ -4,17 +4,25 @@ export * from './CoerceOptionsToObject';
|
|
|
4
4
|
export * from './GetNumberOption';
|
|
5
5
|
export * from './GetOption';
|
|
6
6
|
export * from './GetOptionsObject';
|
|
7
|
+
export * from './GetStringOrBooleanOption';
|
|
7
8
|
export * from './IsSanctionedSimpleUnitIdentifier';
|
|
8
9
|
export * from './IsValidTimeZoneName';
|
|
9
10
|
export * from './IsWellFormedCurrencyCode';
|
|
10
11
|
export * from './IsWellFormedUnitIdentifier';
|
|
12
|
+
export * from './NumberFormat/ApplyUnsignedRoundingMode';
|
|
13
|
+
export * from './NumberFormat/CollapseNumberRange';
|
|
11
14
|
export * from './NumberFormat/ComputeExponent';
|
|
12
15
|
export * from './NumberFormat/ComputeExponentForMagnitude';
|
|
13
16
|
export * from './NumberFormat/CurrencyDigits';
|
|
17
|
+
export * from './NumberFormat/FormatApproximately';
|
|
18
|
+
export * from './NumberFormat/FormatNumericRange';
|
|
19
|
+
export * from './NumberFormat/FormatNumericRangeToParts';
|
|
14
20
|
export * from './NumberFormat/FormatNumericToParts';
|
|
15
21
|
export * from './NumberFormat/FormatNumericToString';
|
|
22
|
+
export * from './NumberFormat/GetUnsignedRoundingMode';
|
|
16
23
|
export * from './NumberFormat/InitializeNumberFormat';
|
|
17
24
|
export * from './NumberFormat/PartitionNumberPattern';
|
|
25
|
+
export * from './NumberFormat/PartitionNumberRangePattern';
|
|
18
26
|
export * from './NumberFormat/SetNumberFormatDigitOptions';
|
|
19
27
|
export * from './NumberFormat/SetNumberFormatUnitOptions';
|
|
20
28
|
export * from './NumberFormat/ToRawFixed';
|
package/lib/types/date-time.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare type Formats = Pick<Intl.DateTimeFormatOptions, 'weekday' | 'era' | 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second' | 'timeZoneName'> & {
|
|
1
|
+
export declare type Formats = Pick<Intl.DateTimeFormatOptions, 'weekday' | 'era' | 'year' | 'month' | 'day' | 'dayPeriod' | 'hour' | 'minute' | 'second' | 'timeZoneName'> & {
|
|
2
2
|
fractionalSecondDigits?: 0 | 1 | 2;
|
|
3
3
|
hour12?: boolean;
|
|
4
4
|
pattern: string;
|
|
@@ -23,7 +23,7 @@ export interface IntlDateTimeFormatInternal {
|
|
|
23
23
|
hour: '2-digit' | 'numeric';
|
|
24
24
|
minute: '2-digit' | 'numeric';
|
|
25
25
|
second: '2-digit' | 'numeric';
|
|
26
|
-
timeZoneName: 'short' | 'long';
|
|
26
|
+
timeZoneName: 'short' | 'long' | 'shortOffset' | 'longOffset' | 'shortGeneric' | 'longGeneric';
|
|
27
27
|
fractionalSecondDigits?: 1 | 2 | 3;
|
|
28
28
|
hourCycle: string;
|
|
29
29
|
numberingSystem: string;
|
|
@@ -46,7 +46,7 @@ export declare enum RangePatternType {
|
|
|
46
46
|
shared = "shared",
|
|
47
47
|
endRange = "endRange"
|
|
48
48
|
}
|
|
49
|
-
export declare type TABLE_6 = 'weekday' | 'era' | 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second' | 'fractionalSecondDigits' | 'timeZoneName';
|
|
49
|
+
export declare type TABLE_6 = 'weekday' | 'era' | 'year' | 'month' | 'day' | 'dayPeriod' | 'hour' | 'minute' | 'second' | 'fractionalSecondDigits' | 'timeZoneName';
|
|
50
50
|
export declare type TABLE_2 = 'era' | 'year' | 'month' | 'day' | 'dayPeriod' | 'ampm' | 'hour' | 'minute' | 'second' | 'fractionalSecondDigits';
|
|
51
51
|
export declare type TimeZoneNameData = Record<string, {
|
|
52
52
|
long?: [string, string];
|