@formatjs/intl-utils
Advanced tools
Comparing version 2.0.3 to 2.0.4
@@ -6,2 +6,13 @@ # Change Log | ||
## [2.0.4](https://github.com/formatjs/formatjs/compare/@formatjs/intl-utils@2.0.3...@formatjs/intl-utils@2.0.4) (2020-01-09) | ||
### Bug Fixes | ||
* **@formatjs/intl-utils:** fix setNumberFormatDigitOptions ([cb21c1f](https://github.com/formatjs/formatjs/commit/cb21c1f7abcb32040ffc5108c37734e2fd43c117)) | ||
## [2.0.3](https://github.com/formatjs/formatjs/compare/@formatjs/intl-utils@2.0.2...@formatjs/intl-utils@2.0.3) (2020-01-08) | ||
@@ -8,0 +19,0 @@ |
@@ -19,2 +19,3 @@ import { LDMLPluralRule } from './plural-rules-types'; | ||
maximumFractionDigits?: number; | ||
notation?: NumberFormatNotation; | ||
} | ||
@@ -21,0 +22,0 @@ export declare enum InternalSlotToken { |
@@ -1,2 +0,2 @@ | ||
import { NumberFormatDigitInternalSlots, NumberFormatDigitOptions, NumberFormatNotation } from './number-types'; | ||
import { NumberFormatDigitInternalSlots, NumberFormatDigitOptions } from './number-types'; | ||
/** | ||
@@ -57,3 +57,3 @@ * https://tc39.es/ecma262/#sec-toobject | ||
* https://tc39.es/proposal-unified-intl-numberformat/section11/numberformat_diff_out.html#sec-setnfdigitoptions | ||
* @param pl | ||
* @param intlObj | ||
* @param opts | ||
@@ -63,3 +63,3 @@ * @param mnfdDefault | ||
*/ | ||
export declare function setNumberFormatDigitOptions<TObject extends object, TInternalSlots extends NumberFormatDigitInternalSlots>(internalSlotMap: WeakMap<TObject, TInternalSlots>, pl: TObject, opts: NumberFormatDigitOptions, mnfdDefault: number, mxfdDefault: number, notation: NumberFormatNotation): void; | ||
export declare function setNumberFormatDigitOptions<TObject extends object, TInternalSlots extends NumberFormatDigitInternalSlots>(internalSlotMap: WeakMap<TObject, TInternalSlots>, intlObj: TObject, opts: NumberFormatDigitOptions, mnfdDefault: number, mxfdDefault: number): void; | ||
export declare function objectIs(x: any, y: any): boolean; |
@@ -166,3 +166,3 @@ "use strict"; | ||
* https://tc39.es/proposal-unified-intl-numberformat/section11/numberformat_diff_out.html#sec-setnfdigitoptions | ||
* @param pl | ||
* @param intlObj | ||
* @param opts | ||
@@ -172,3 +172,3 @@ * @param mnfdDefault | ||
*/ | ||
function setNumberFormatDigitOptions(internalSlotMap, pl, opts, mnfdDefault, mxfdDefault, notation) { | ||
function setNumberFormatDigitOptions(internalSlotMap, intlObj, opts, mnfdDefault, mxfdDefault) { | ||
var mnid = getNumberOption(opts, 'minimumIntegerDigits', 1, 21, 1); | ||
@@ -179,25 +179,25 @@ var mnfd = opts.minimumFractionDigits; | ||
var mxsd = opts.maximumSignificantDigits; | ||
setInternalSlot(internalSlotMap, pl, 'minimumIntegerDigits', mnid); | ||
setInternalSlot(internalSlotMap, intlObj, 'minimumIntegerDigits', mnid); | ||
if (mnsd !== undefined || mxsd !== undefined) { | ||
setInternalSlot(internalSlotMap, pl, 'roundingType', 'significantDigits'); | ||
setInternalSlot(internalSlotMap, intlObj, 'roundingType', 'significantDigits'); | ||
mnsd = defaultNumberOption(mnsd, 1, 21, 1); | ||
mxsd = defaultNumberOption(mxsd, mnsd, 21, 21); | ||
setInternalSlot(internalSlotMap, pl, 'minimumSignificantDigits', mnsd); | ||
setInternalSlot(internalSlotMap, pl, 'maximumSignificantDigits', mxsd); | ||
setInternalSlot(internalSlotMap, intlObj, 'minimumSignificantDigits', mnsd); | ||
setInternalSlot(internalSlotMap, intlObj, 'maximumSignificantDigits', mxsd); | ||
} | ||
else if (mnfd !== undefined || mxfd !== undefined) { | ||
setInternalSlot(internalSlotMap, pl, 'roundingType', 'fractionDigits'); | ||
setInternalSlot(internalSlotMap, intlObj, 'roundingType', 'fractionDigits'); | ||
mnfd = defaultNumberOption(mnfd, 0, 20, mnfdDefault); | ||
var mxfdActualDefault = Math.max(mnfd, mxfdDefault); | ||
mxfd = defaultNumberOption(mxfd, mnfd, 20, mxfdActualDefault); | ||
setInternalSlot(internalSlotMap, pl, 'minimumFractionDigits', mnfd); | ||
setInternalSlot(internalSlotMap, pl, 'maximumFractionDigits', mxfd); | ||
setInternalSlot(internalSlotMap, intlObj, 'minimumFractionDigits', mnfd); | ||
setInternalSlot(internalSlotMap, intlObj, 'maximumFractionDigits', mxfd); | ||
} | ||
else if (notation === 'compact') { | ||
setInternalSlot(internalSlotMap, pl, 'roundingType', 'compactRounding'); | ||
else if (getInternalSlot(internalSlotMap, intlObj, 'notation') === 'compact') { | ||
setInternalSlot(internalSlotMap, intlObj, 'roundingType', 'compactRounding'); | ||
} | ||
else { | ||
setInternalSlot(internalSlotMap, pl, 'roundingType', 'fractionDigits'); | ||
setInternalSlot(internalSlotMap, pl, 'minimumFractionDigits', mnfdDefault); | ||
setInternalSlot(internalSlotMap, pl, 'maximumFractionDigits', mxfdDefault); | ||
setInternalSlot(internalSlotMap, intlObj, 'roundingType', 'fractionDigits'); | ||
setInternalSlot(internalSlotMap, intlObj, 'minimumFractionDigits', mnfdDefault); | ||
setInternalSlot(internalSlotMap, intlObj, 'maximumFractionDigits', mxfdDefault); | ||
} | ||
@@ -204,0 +204,0 @@ } |
@@ -192,2 +192,3 @@ | ||
maximumFractionDigits?: number; | ||
notation?: NumberFormatNotation; | ||
} | ||
@@ -342,3 +343,3 @@ | ||
* https://tc39.es/proposal-unified-intl-numberformat/section11/numberformat_diff_out.html#sec-setnfdigitoptions | ||
* @param pl | ||
* @param intlObj | ||
* @param opts | ||
@@ -348,3 +349,3 @@ * @param mnfdDefault | ||
*/ | ||
export declare function setNumberFormatDigitOptions<TObject extends object, TInternalSlots extends NumberFormatDigitInternalSlots>(internalSlotMap: WeakMap<TObject, TInternalSlots>, pl: TObject, opts: NumberFormatDigitOptions, mnfdDefault: number, mxfdDefault: number, notation: NumberFormatNotation): void; | ||
export declare function setNumberFormatDigitOptions<TObject extends object, TInternalSlots extends NumberFormatDigitInternalSlots>(internalSlotMap: WeakMap<TObject, TInternalSlots>, intlObj: TObject, opts: NumberFormatDigitOptions, mnfdDefault: number, mxfdDefault: number): void; | ||
@@ -351,0 +352,0 @@ export declare interface SignDisplayPattern { |
@@ -19,2 +19,3 @@ import { LDMLPluralRule } from './plural-rules-types'; | ||
maximumFractionDigits?: number; | ||
notation?: NumberFormatNotation; | ||
} | ||
@@ -21,0 +22,0 @@ export declare enum InternalSlotToken { |
@@ -1,2 +0,2 @@ | ||
import { NumberFormatDigitInternalSlots, NumberFormatDigitOptions, NumberFormatNotation } from './number-types'; | ||
import { NumberFormatDigitInternalSlots, NumberFormatDigitOptions } from './number-types'; | ||
/** | ||
@@ -57,3 +57,3 @@ * https://tc39.es/ecma262/#sec-toobject | ||
* https://tc39.es/proposal-unified-intl-numberformat/section11/numberformat_diff_out.html#sec-setnfdigitoptions | ||
* @param pl | ||
* @param intlObj | ||
* @param opts | ||
@@ -63,3 +63,3 @@ * @param mnfdDefault | ||
*/ | ||
export declare function setNumberFormatDigitOptions<TObject extends object, TInternalSlots extends NumberFormatDigitInternalSlots>(internalSlotMap: WeakMap<TObject, TInternalSlots>, pl: TObject, opts: NumberFormatDigitOptions, mnfdDefault: number, mxfdDefault: number, notation: NumberFormatNotation): void; | ||
export declare function setNumberFormatDigitOptions<TObject extends object, TInternalSlots extends NumberFormatDigitInternalSlots>(internalSlotMap: WeakMap<TObject, TInternalSlots>, intlObj: TObject, opts: NumberFormatDigitOptions, mnfdDefault: number, mxfdDefault: number): void; | ||
export declare function objectIs(x: any, y: any): boolean; |
@@ -152,3 +152,3 @@ import aliases from './aliases'; | ||
* https://tc39.es/proposal-unified-intl-numberformat/section11/numberformat_diff_out.html#sec-setnfdigitoptions | ||
* @param pl | ||
* @param intlObj | ||
* @param opts | ||
@@ -158,3 +158,3 @@ * @param mnfdDefault | ||
*/ | ||
export function setNumberFormatDigitOptions(internalSlotMap, pl, opts, mnfdDefault, mxfdDefault, notation) { | ||
export function setNumberFormatDigitOptions(internalSlotMap, intlObj, opts, mnfdDefault, mxfdDefault) { | ||
var mnid = getNumberOption(opts, 'minimumIntegerDigits', 1, 21, 1); | ||
@@ -165,25 +165,25 @@ var mnfd = opts.minimumFractionDigits; | ||
var mxsd = opts.maximumSignificantDigits; | ||
setInternalSlot(internalSlotMap, pl, 'minimumIntegerDigits', mnid); | ||
setInternalSlot(internalSlotMap, intlObj, 'minimumIntegerDigits', mnid); | ||
if (mnsd !== undefined || mxsd !== undefined) { | ||
setInternalSlot(internalSlotMap, pl, 'roundingType', 'significantDigits'); | ||
setInternalSlot(internalSlotMap, intlObj, 'roundingType', 'significantDigits'); | ||
mnsd = defaultNumberOption(mnsd, 1, 21, 1); | ||
mxsd = defaultNumberOption(mxsd, mnsd, 21, 21); | ||
setInternalSlot(internalSlotMap, pl, 'minimumSignificantDigits', mnsd); | ||
setInternalSlot(internalSlotMap, pl, 'maximumSignificantDigits', mxsd); | ||
setInternalSlot(internalSlotMap, intlObj, 'minimumSignificantDigits', mnsd); | ||
setInternalSlot(internalSlotMap, intlObj, 'maximumSignificantDigits', mxsd); | ||
} | ||
else if (mnfd !== undefined || mxfd !== undefined) { | ||
setInternalSlot(internalSlotMap, pl, 'roundingType', 'fractionDigits'); | ||
setInternalSlot(internalSlotMap, intlObj, 'roundingType', 'fractionDigits'); | ||
mnfd = defaultNumberOption(mnfd, 0, 20, mnfdDefault); | ||
var mxfdActualDefault = Math.max(mnfd, mxfdDefault); | ||
mxfd = defaultNumberOption(mxfd, mnfd, 20, mxfdActualDefault); | ||
setInternalSlot(internalSlotMap, pl, 'minimumFractionDigits', mnfd); | ||
setInternalSlot(internalSlotMap, pl, 'maximumFractionDigits', mxfd); | ||
setInternalSlot(internalSlotMap, intlObj, 'minimumFractionDigits', mnfd); | ||
setInternalSlot(internalSlotMap, intlObj, 'maximumFractionDigits', mxfd); | ||
} | ||
else if (notation === 'compact') { | ||
setInternalSlot(internalSlotMap, pl, 'roundingType', 'compactRounding'); | ||
else if (getInternalSlot(internalSlotMap, intlObj, 'notation') === 'compact') { | ||
setInternalSlot(internalSlotMap, intlObj, 'roundingType', 'compactRounding'); | ||
} | ||
else { | ||
setInternalSlot(internalSlotMap, pl, 'roundingType', 'fractionDigits'); | ||
setInternalSlot(internalSlotMap, pl, 'minimumFractionDigits', mnfdDefault); | ||
setInternalSlot(internalSlotMap, pl, 'maximumFractionDigits', mxfdDefault); | ||
setInternalSlot(internalSlotMap, intlObj, 'roundingType', 'fractionDigits'); | ||
setInternalSlot(internalSlotMap, intlObj, 'minimumFractionDigits', mnfdDefault); | ||
setInternalSlot(internalSlotMap, intlObj, 'maximumFractionDigits', mxfdDefault); | ||
} | ||
@@ -190,0 +190,0 @@ } |
{ | ||
"name": "@formatjs/intl-utils", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"description": "Smartly determine best unit for relative time format", | ||
@@ -38,3 +38,3 @@ "keywords": [ | ||
"license": "MIT", | ||
"gitHead": "f6fec1144ba47dce65e4b604155be83ee373fe25" | ||
"gitHead": "a7842673d8ad205171ad7c8cb8bb2f318b427c0c" | ||
} |
@@ -31,2 +31,3 @@ import {LDMLPluralRule} from './plural-rules-types'; | ||
maximumFractionDigits?: number; | ||
notation?: NumberFormatNotation; | ||
} | ||
@@ -33,0 +34,0 @@ |
@@ -7,3 +7,2 @@ import aliases from './aliases'; | ||
NumberFormatDigitOptions, | ||
NumberFormatNotation, | ||
} from './number-types'; | ||
@@ -230,3 +229,3 @@ | ||
* https://tc39.es/proposal-unified-intl-numberformat/section11/numberformat_diff_out.html#sec-setnfdigitoptions | ||
* @param pl | ||
* @param intlObj | ||
* @param opts | ||
@@ -241,7 +240,6 @@ * @param mnfdDefault | ||
internalSlotMap: WeakMap<TObject, TInternalSlots>, | ||
pl: TObject, | ||
intlObj: TObject, | ||
opts: NumberFormatDigitOptions, | ||
mnfdDefault: number, | ||
mxfdDefault: number, | ||
notation: NumberFormatNotation | ||
mxfdDefault: number | ||
) { | ||
@@ -253,22 +251,44 @@ const mnid = getNumberOption(opts, 'minimumIntegerDigits', 1, 21, 1); | ||
let mxsd = opts.maximumSignificantDigits; | ||
setInternalSlot(internalSlotMap, pl, 'minimumIntegerDigits', mnid); | ||
setInternalSlot(internalSlotMap, intlObj, 'minimumIntegerDigits', mnid); | ||
if (mnsd !== undefined || mxsd !== undefined) { | ||
setInternalSlot(internalSlotMap, pl, 'roundingType', 'significantDigits'); | ||
setInternalSlot( | ||
internalSlotMap, | ||
intlObj, | ||
'roundingType', | ||
'significantDigits' | ||
); | ||
mnsd = defaultNumberOption(mnsd, 1, 21, 1); | ||
mxsd = defaultNumberOption(mxsd, mnsd, 21, 21); | ||
setInternalSlot(internalSlotMap, pl, 'minimumSignificantDigits', mnsd); | ||
setInternalSlot(internalSlotMap, pl, 'maximumSignificantDigits', mxsd); | ||
setInternalSlot(internalSlotMap, intlObj, 'minimumSignificantDigits', mnsd); | ||
setInternalSlot(internalSlotMap, intlObj, 'maximumSignificantDigits', mxsd); | ||
} else if (mnfd !== undefined || mxfd !== undefined) { | ||
setInternalSlot(internalSlotMap, pl, 'roundingType', 'fractionDigits'); | ||
setInternalSlot(internalSlotMap, intlObj, 'roundingType', 'fractionDigits'); | ||
mnfd = defaultNumberOption(mnfd, 0, 20, mnfdDefault); | ||
const mxfdActualDefault = Math.max(mnfd, mxfdDefault); | ||
mxfd = defaultNumberOption(mxfd, mnfd, 20, mxfdActualDefault); | ||
setInternalSlot(internalSlotMap, pl, 'minimumFractionDigits', mnfd); | ||
setInternalSlot(internalSlotMap, pl, 'maximumFractionDigits', mxfd); | ||
} else if (notation === 'compact') { | ||
setInternalSlot(internalSlotMap, pl, 'roundingType', 'compactRounding'); | ||
setInternalSlot(internalSlotMap, intlObj, 'minimumFractionDigits', mnfd); | ||
setInternalSlot(internalSlotMap, intlObj, 'maximumFractionDigits', mxfd); | ||
} else if ( | ||
getInternalSlot(internalSlotMap, intlObj, 'notation') === 'compact' | ||
) { | ||
setInternalSlot( | ||
internalSlotMap, | ||
intlObj, | ||
'roundingType', | ||
'compactRounding' | ||
); | ||
} else { | ||
setInternalSlot(internalSlotMap, pl, 'roundingType', 'fractionDigits'); | ||
setInternalSlot(internalSlotMap, pl, 'minimumFractionDigits', mnfdDefault); | ||
setInternalSlot(internalSlotMap, pl, 'maximumFractionDigits', mxfdDefault); | ||
setInternalSlot(internalSlotMap, intlObj, 'roundingType', 'fractionDigits'); | ||
setInternalSlot( | ||
internalSlotMap, | ||
intlObj, | ||
'minimumFractionDigits', | ||
mnfdDefault | ||
); | ||
setInternalSlot( | ||
internalSlotMap, | ||
intlObj, | ||
'maximumFractionDigits', | ||
mxfdDefault | ||
); | ||
} | ||
@@ -275,0 +295,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
189325
4786