@formatjs/ecma402-abstract
Advanced tools
Comparing version 1.4.0 to 1.5.0
@@ -6,3 +6,3 @@ /** | ||
*/ | ||
export declare function BestAvailableLocale(availableLocales: string[], locale: string): string | undefined; | ||
export declare function BestAvailableLocale(availableLocales: Set<String>, locale: string): string | undefined; | ||
//# sourceMappingURL=BestAvailableLocale.d.ts.map |
@@ -12,3 +12,3 @@ "use strict"; | ||
while (true) { | ||
if (~availableLocales.indexOf(candidate)) { | ||
if (availableLocales.has(candidate)) { | ||
return candidate; | ||
@@ -15,0 +15,0 @@ } |
@@ -8,3 +8,3 @@ import { LookupMatcherResult } from './types/core'; | ||
*/ | ||
export declare function BestFitMatcher(availableLocales: string[], requestedLocales: string[], getDefaultLocale: () => string): LookupMatcherResult; | ||
export declare function BestFitMatcher(availableLocales: Set<string>, requestedLocales: string[], getDefaultLocale: () => string): LookupMatcherResult; | ||
//# sourceMappingURL=BestFitMatcher.d.ts.map |
@@ -13,18 +13,41 @@ "use strict"; | ||
function BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale) { | ||
var result = { locale: '' }; | ||
var minimizedAvailableLocaleMap = {}; | ||
var minimizedAvailableLocales = new Set(); | ||
availableLocales.forEach(function (locale) { | ||
var minimizedLocale = new Intl.Locale(locale) | ||
.minimize() | ||
.toString(); | ||
minimizedAvailableLocaleMap[minimizedLocale] = locale; | ||
minimizedAvailableLocales.add(minimizedLocale); | ||
}); | ||
var foundLocale; | ||
for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) { | ||
var locale = requestedLocales_1[_i]; | ||
var noExtensionLocale = locale.replace(utils_1.UNICODE_EXTENSION_SEQUENCE_REGEX, ''); | ||
var availableLocale = BestAvailableLocale_1.BestAvailableLocale(availableLocales, noExtensionLocale); | ||
if (availableLocale) { | ||
result.locale = availableLocale; | ||
if (locale !== noExtensionLocale) { | ||
result.extension = locale.slice(noExtensionLocale.length + 1, locale.length); | ||
} | ||
return result; | ||
var l = requestedLocales_1[_i]; | ||
if (foundLocale) { | ||
break; | ||
} | ||
var noExtensionLocale = l.replace(utils_1.UNICODE_EXTENSION_SEQUENCE_REGEX, ''); | ||
if (availableLocales.has(noExtensionLocale)) { | ||
foundLocale = noExtensionLocale; | ||
break; | ||
} | ||
if (minimizedAvailableLocales.has(noExtensionLocale)) { | ||
foundLocale = minimizedAvailableLocaleMap[noExtensionLocale]; | ||
break; | ||
} | ||
var locale = new Intl.Locale(noExtensionLocale); | ||
var maximizedRequestedLocale = locale.maximize().toString(); | ||
var minimizedRequestedLocale = locale.minimize().toString(); | ||
// Check minimized locale | ||
if (minimizedAvailableLocales.has(minimizedRequestedLocale)) { | ||
foundLocale = minimizedAvailableLocaleMap[minimizedRequestedLocale]; | ||
break; | ||
} | ||
// Lookup algo on maximized locale | ||
foundLocale = BestAvailableLocale_1.BestAvailableLocale(minimizedAvailableLocales, maximizedRequestedLocale); | ||
} | ||
result.locale = getDefaultLocale(); | ||
return result; | ||
return { | ||
locale: foundLocale || getDefaultLocale(), | ||
}; | ||
} | ||
exports.BestFitMatcher = BestFitMatcher; |
@@ -5,3 +5,3 @@ /** | ||
*/ | ||
export declare function CanonicalizeLocaleList(locales?: string | string[]): any; | ||
export declare function CanonicalizeLocaleList(locales?: string | string[]): string[]; | ||
//# sourceMappingURL=CanonicalizeLocaleList.d.ts.map |
@@ -1,3 +0,1 @@ | ||
import { LocaleData } from './types/core'; | ||
export declare function getLocaleHierarchy(locale: string): string[]; | ||
declare class MissingLocaleDataError extends Error { | ||
@@ -7,6 +5,3 @@ type: string; | ||
export declare function isMissingLocaleDataError(e: Error): e is MissingLocaleDataError; | ||
export declare function unpackData<T extends Record<string, any>>(locale: string, localeData: LocaleData<T>, | ||
/** By default shallow merge the dictionaries. */ | ||
reducer?: (all: T, d: T) => T): T; | ||
export {}; | ||
//# sourceMappingURL=data.d.ts.map |
26
data.js
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.unpackData = exports.isMissingLocaleDataError = exports.getLocaleHierarchy = void 0; | ||
exports.isMissingLocaleDataError = void 0; | ||
var tslib_1 = require("tslib"); | ||
function getLocaleHierarchy(locale) { | ||
var results = [locale]; | ||
var localeParts = locale.split('-'); | ||
for (var i = localeParts.length; i > 1; i--) { | ||
results.push(localeParts.slice(0, i - 1).join('-')); | ||
} | ||
return results; | ||
} | ||
exports.getLocaleHierarchy = getLocaleHierarchy; | ||
var MissingLocaleDataError = /** @class */ (function (_super) { | ||
@@ -27,16 +18,1 @@ tslib_1.__extends(MissingLocaleDataError, _super); | ||
exports.isMissingLocaleDataError = isMissingLocaleDataError; | ||
function unpackData(locale, localeData, | ||
/** By default shallow merge the dictionaries. */ | ||
reducer) { | ||
if (reducer === void 0) { reducer = function (all, d) { return (tslib_1.__assign(tslib_1.__assign({}, all), d)); }; } | ||
var localeHierarchy = getLocaleHierarchy(locale); | ||
var dataToMerge = localeHierarchy | ||
.map(function (l) { return localeData.data[l]; }) | ||
.filter(Boolean); | ||
if (!dataToMerge.length) { | ||
throw new MissingLocaleDataError("Missing locale data for \"" + locale + "\", lookup hierarchy: " + localeHierarchy.join(', ')); | ||
} | ||
dataToMerge.reverse(); | ||
return dataToMerge.reduce(reducer, {}); | ||
} | ||
exports.unpackData = unpackData; |
@@ -10,3 +10,3 @@ import { DateTimeFormatOptions, IntlDateTimeFormatInternal, DateTimeFormatLocaleInternalData } from '../types/date-time'; | ||
getInternalSlots(dtf: Intl.DateTimeFormat): IntlDateTimeFormatInternal; | ||
availableLocales: string[]; | ||
availableLocales: Set<string>; | ||
getDefaultLocale(): string; | ||
@@ -13,0 +13,0 @@ getDefaultTimeZone(): string; |
@@ -1,2 +0,2 @@ | ||
export declare function CanonicalCodeForDisplayNames(type: 'language' | 'region' | 'script' | 'currency', code: string): any; | ||
export declare function CanonicalCodeForDisplayNames(type: 'language' | 'region' | 'script' | 'currency', code: string): string; | ||
//# sourceMappingURL=CanonicalCodeForDisplayNames.d.ts.map |
@@ -47,3 +47,3 @@ export { BestFitFormatMatcher } from './DateTimeFormat/BestFitFormatMatcher'; | ||
export { getInternalSlot, getMultiInternalSlots, isLiteralPart, LiteralPart, setInternalSlot, setMultiInternalSlots, getMagnitude, defineProperty, } from './utils'; | ||
export { getLocaleHierarchy, unpackData, isMissingLocaleDataError } from './data'; | ||
export { isMissingLocaleDataError } from './data'; | ||
export * from './types/relative-time'; | ||
@@ -50,0 +50,0 @@ export * from './types/date-time'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.invariant = exports.isMissingLocaleDataError = exports.unpackData = exports.getLocaleHierarchy = exports.defineProperty = exports.getMagnitude = exports.setMultiInternalSlots = exports.setInternalSlot = exports.isLiteralPart = exports.getMultiInternalSlots = exports.getInternalSlot = exports.parseDateTimeSkeleton = exports.DATE_TIME_PROPS = exports._formatToParts = exports.BestFitFormatMatcher = void 0; | ||
exports.invariant = exports.isMissingLocaleDataError = exports.defineProperty = exports.getMagnitude = exports.setMultiInternalSlots = exports.setInternalSlot = exports.isLiteralPart = exports.getMultiInternalSlots = exports.getInternalSlot = exports.parseDateTimeSkeleton = exports.DATE_TIME_PROPS = exports._formatToParts = exports.BestFitFormatMatcher = void 0; | ||
var tslib_1 = require("tslib"); | ||
@@ -63,4 +63,2 @@ var BestFitFormatMatcher_1 = require("./DateTimeFormat/BestFitFormatMatcher"); | ||
var data_1 = require("./data"); | ||
Object.defineProperty(exports, "getLocaleHierarchy", { enumerable: true, get: function () { return data_1.getLocaleHierarchy; } }); | ||
Object.defineProperty(exports, "unpackData", { enumerable: true, get: function () { return data_1.unpackData; } }); | ||
Object.defineProperty(exports, "isMissingLocaleDataError", { enumerable: true, get: function () { return data_1.isMissingLocaleDataError; } }); | ||
@@ -67,0 +65,0 @@ tslib_1.__exportStar(require("./types/relative-time"), exports); |
@@ -6,3 +6,3 @@ /** | ||
*/ | ||
export declare function BestAvailableLocale(availableLocales: string[], locale: string): string | undefined; | ||
export declare function BestAvailableLocale(availableLocales: Set<String>, locale: string): string | undefined; | ||
//# sourceMappingURL=BestAvailableLocale.d.ts.map |
@@ -9,3 +9,3 @@ /** | ||
while (true) { | ||
if (~availableLocales.indexOf(candidate)) { | ||
if (availableLocales.has(candidate)) { | ||
return candidate; | ||
@@ -12,0 +12,0 @@ } |
@@ -8,3 +8,3 @@ import { LookupMatcherResult } from './types/core'; | ||
*/ | ||
export declare function BestFitMatcher(availableLocales: string[], requestedLocales: string[], getDefaultLocale: () => string): LookupMatcherResult; | ||
export declare function BestFitMatcher(availableLocales: Set<string>, requestedLocales: string[], getDefaultLocale: () => string): LookupMatcherResult; | ||
//# sourceMappingURL=BestFitMatcher.d.ts.map |
@@ -10,17 +10,40 @@ import { BestAvailableLocale } from './BestAvailableLocale'; | ||
export function BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale) { | ||
var result = { locale: '' }; | ||
var minimizedAvailableLocaleMap = {}; | ||
var minimizedAvailableLocales = new Set(); | ||
availableLocales.forEach(function (locale) { | ||
var minimizedLocale = new Intl.Locale(locale) | ||
.minimize() | ||
.toString(); | ||
minimizedAvailableLocaleMap[minimizedLocale] = locale; | ||
minimizedAvailableLocales.add(minimizedLocale); | ||
}); | ||
var foundLocale; | ||
for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) { | ||
var locale = requestedLocales_1[_i]; | ||
var noExtensionLocale = locale.replace(UNICODE_EXTENSION_SEQUENCE_REGEX, ''); | ||
var availableLocale = BestAvailableLocale(availableLocales, noExtensionLocale); | ||
if (availableLocale) { | ||
result.locale = availableLocale; | ||
if (locale !== noExtensionLocale) { | ||
result.extension = locale.slice(noExtensionLocale.length + 1, locale.length); | ||
} | ||
return result; | ||
var l = requestedLocales_1[_i]; | ||
if (foundLocale) { | ||
break; | ||
} | ||
var noExtensionLocale = l.replace(UNICODE_EXTENSION_SEQUENCE_REGEX, ''); | ||
if (availableLocales.has(noExtensionLocale)) { | ||
foundLocale = noExtensionLocale; | ||
break; | ||
} | ||
if (minimizedAvailableLocales.has(noExtensionLocale)) { | ||
foundLocale = minimizedAvailableLocaleMap[noExtensionLocale]; | ||
break; | ||
} | ||
var locale = new Intl.Locale(noExtensionLocale); | ||
var maximizedRequestedLocale = locale.maximize().toString(); | ||
var minimizedRequestedLocale = locale.minimize().toString(); | ||
// Check minimized locale | ||
if (minimizedAvailableLocales.has(minimizedRequestedLocale)) { | ||
foundLocale = minimizedAvailableLocaleMap[minimizedRequestedLocale]; | ||
break; | ||
} | ||
// Lookup algo on maximized locale | ||
foundLocale = BestAvailableLocale(minimizedAvailableLocales, maximizedRequestedLocale); | ||
} | ||
result.locale = getDefaultLocale(); | ||
return result; | ||
return { | ||
locale: foundLocale || getDefaultLocale(), | ||
}; | ||
} |
@@ -5,3 +5,3 @@ /** | ||
*/ | ||
export declare function CanonicalizeLocaleList(locales?: string | string[]): any; | ||
export declare function CanonicalizeLocaleList(locales?: string | string[]): string[]; | ||
//# sourceMappingURL=CanonicalizeLocaleList.d.ts.map |
@@ -1,3 +0,1 @@ | ||
import { LocaleData } from './types/core'; | ||
export declare function getLocaleHierarchy(locale: string): string[]; | ||
declare class MissingLocaleDataError extends Error { | ||
@@ -7,6 +5,3 @@ type: string; | ||
export declare function isMissingLocaleDataError(e: Error): e is MissingLocaleDataError; | ||
export declare function unpackData<T extends Record<string, any>>(locale: string, localeData: LocaleData<T>, | ||
/** By default shallow merge the dictionaries. */ | ||
reducer?: (all: T, d: T) => T): T; | ||
export {}; | ||
//# sourceMappingURL=data.d.ts.map |
@@ -1,10 +0,2 @@ | ||
import { __assign, __extends } from "tslib"; | ||
export function getLocaleHierarchy(locale) { | ||
var results = [locale]; | ||
var localeParts = locale.split('-'); | ||
for (var i = localeParts.length; i > 1; i--) { | ||
results.push(localeParts.slice(0, i - 1).join('-')); | ||
} | ||
return results; | ||
} | ||
import { __extends } from "tslib"; | ||
var MissingLocaleDataError = /** @class */ (function (_super) { | ||
@@ -22,15 +14,1 @@ __extends(MissingLocaleDataError, _super); | ||
} | ||
export function unpackData(locale, localeData, | ||
/** By default shallow merge the dictionaries. */ | ||
reducer) { | ||
if (reducer === void 0) { reducer = function (all, d) { return (__assign(__assign({}, all), d)); }; } | ||
var localeHierarchy = getLocaleHierarchy(locale); | ||
var dataToMerge = localeHierarchy | ||
.map(function (l) { return localeData.data[l]; }) | ||
.filter(Boolean); | ||
if (!dataToMerge.length) { | ||
throw new MissingLocaleDataError("Missing locale data for \"" + locale + "\", lookup hierarchy: " + localeHierarchy.join(', ')); | ||
} | ||
dataToMerge.reverse(); | ||
return dataToMerge.reduce(reducer, {}); | ||
} |
@@ -10,3 +10,3 @@ import { DateTimeFormatOptions, IntlDateTimeFormatInternal, DateTimeFormatLocaleInternalData } from '../types/date-time'; | ||
getInternalSlots(dtf: Intl.DateTimeFormat): IntlDateTimeFormatInternal; | ||
availableLocales: string[]; | ||
availableLocales: Set<string>; | ||
getDefaultLocale(): string; | ||
@@ -13,0 +13,0 @@ getDefaultTimeZone(): string; |
@@ -1,2 +0,2 @@ | ||
export declare function CanonicalCodeForDisplayNames(type: 'language' | 'region' | 'script' | 'currency', code: string): any; | ||
export declare function CanonicalCodeForDisplayNames(type: 'language' | 'region' | 'script' | 'currency', code: string): string; | ||
//# sourceMappingURL=CanonicalCodeForDisplayNames.d.ts.map |
@@ -47,3 +47,3 @@ export { BestFitFormatMatcher } from './DateTimeFormat/BestFitFormatMatcher'; | ||
export { getInternalSlot, getMultiInternalSlots, isLiteralPart, LiteralPart, setInternalSlot, setMultiInternalSlots, getMagnitude, defineProperty, } from './utils'; | ||
export { getLocaleHierarchy, unpackData, isMissingLocaleDataError } from './data'; | ||
export { isMissingLocaleDataError } from './data'; | ||
export * from './types/relative-time'; | ||
@@ -50,0 +50,0 @@ export * from './types/date-time'; |
@@ -47,3 +47,3 @@ export { BestFitFormatMatcher } from './DateTimeFormat/BestFitFormatMatcher'; | ||
export { getInternalSlot, getMultiInternalSlots, isLiteralPart, setInternalSlot, setMultiInternalSlots, getMagnitude, defineProperty, } from './utils'; | ||
export { getLocaleHierarchy, unpackData, isMissingLocaleDataError } from './data'; | ||
export { isMissingLocaleDataError } from './data'; | ||
export * from './types/relative-time'; | ||
@@ -50,0 +50,0 @@ export * from './types/date-time'; |
@@ -8,3 +8,3 @@ import { LookupMatcherResult } from './types/core'; | ||
*/ | ||
export declare function LookupMatcher(availableLocales: string[], requestedLocales: string[], getDefaultLocale: () => string): LookupMatcherResult; | ||
export declare function LookupMatcher(availableLocales: Set<string>, requestedLocales: string[], getDefaultLocale: () => string): LookupMatcherResult; | ||
//# sourceMappingURL=LookupMatcher.d.ts.map |
@@ -6,3 +6,3 @@ /** | ||
*/ | ||
export declare function LookupSupportedLocales(availableLocales: string[], requestedLocales: string[]): string[]; | ||
export declare function LookupSupportedLocales(availableLocales: Set<string>, requestedLocales: string[]): string[]; | ||
//# sourceMappingURL=LookupSupportedLocales.d.ts.map |
@@ -8,3 +8,3 @@ import { NumberFormatInternal, NumberFormatOptions, NumberFormatLocaleInternalData } from '../types/number'; | ||
localeData: Record<string, NumberFormatLocaleInternalData | undefined>; | ||
availableLocales: string[]; | ||
availableLocales: Set<string>; | ||
numberingSystemNames: string[]; | ||
@@ -11,0 +11,0 @@ getDefaultLocale(): string; |
@@ -10,11 +10,2 @@ import { CanonicalizeLocaleList } from '../CanonicalizeLocaleList'; | ||
/** | ||
* Chop off the unicode extension from the locale string. | ||
*/ | ||
function removeUnicodeExtensionFromLocale(canonicalLocale) { | ||
var extensionIndex = canonicalLocale.indexOf('-u-'); | ||
return extensionIndex >= 0 | ||
? canonicalLocale.slice(0, extensionIndex) | ||
: canonicalLocale; | ||
} | ||
/** | ||
* https://tc39.es/ecma402/#sec-initializenumberformat | ||
@@ -41,4 +32,4 @@ */ | ||
['nu'], localeData, getDefaultLocale); | ||
var dataLocaleData = localeData[removeUnicodeExtensionFromLocale(r.locale)]; | ||
invariant(!!dataLocaleData, "Missing locale data for " + r.locale); | ||
var dataLocaleData = localeData[r.dataLocale]; | ||
invariant(!!dataLocaleData, "Missing locale data for " + r.dataLocale); | ||
var internalSlots = getInternalSlots(nf); | ||
@@ -45,0 +36,0 @@ internalSlots.locale = r.locale; |
import { PluralRulesInternal, PluralRulesData } from '../types/plural-rules'; | ||
export declare function InitializePluralRules(pl: Intl.PluralRules, locales: string | string[] | undefined, options: Intl.PluralRulesOptions | undefined, { availableLocales, relevantExtensionKeys, localeData, getDefaultLocale, getInternalSlots, }: { | ||
availableLocales: string[]; | ||
availableLocales: Set<string>; | ||
relevantExtensionKeys: string[]; | ||
@@ -5,0 +5,0 @@ localeData: Record<string, PluralRulesData | undefined>; |
import { RelativeTimeFormat, IntlRelativeTimeFormatOptions, RelativeTimeFormatInternal, LocaleFieldsData } from '../types/relative-time'; | ||
export declare function InitializeRelativeTimeFormat(rtf: RelativeTimeFormat, locales: string | string[] | undefined, options: IntlRelativeTimeFormatOptions | undefined, { getInternalSlots, availableLocales, relevantExtensionKeys, localeData, getDefaultLocale, }: { | ||
getInternalSlots(rtf: RelativeTimeFormat): RelativeTimeFormatInternal; | ||
availableLocales: string[]; | ||
availableLocales: Set<string>; | ||
relevantExtensionKeys: string[]; | ||
@@ -6,0 +6,0 @@ localeData: Record<string, LocaleFieldsData | undefined>; |
@@ -28,4 +28,4 @@ import { CanonicalizeLocaleList } from '../CanonicalizeLocaleList'; | ||
internalSlots.numeric = GetOption(opts, 'numeric', 'string', ['always', 'auto'], 'always'); | ||
var fields = localeData[locale]; | ||
invariant(!!fields, "Missing locale data for " + locale); | ||
var fields = localeData[r.dataLocale]; | ||
invariant(!!fields, "Missing locale data for " + r.dataLocale); | ||
internalSlots.fields = fields; | ||
@@ -32,0 +32,0 @@ internalSlots.numberFormat = new Intl.NumberFormat(locales); |
@@ -11,3 +11,3 @@ export interface ResolveLocaleResult { | ||
[k in K]: any; | ||
}>(availableLocales: string[], requestedLocales: string[], options: { | ||
}>(availableLocales: Set<string>, requestedLocales: string[], options: { | ||
localeMatcher: string; | ||
@@ -14,0 +14,0 @@ [k: string]: string; |
@@ -7,5 +7,5 @@ /** | ||
*/ | ||
export declare function SupportedLocales(availableLocales: string[], requestedLocales: string[], options?: { | ||
export declare function SupportedLocales(availableLocales: Set<string>, requestedLocales: string[], options?: { | ||
localeMatcher?: 'best fit' | 'lookup'; | ||
}): string[]; | ||
//# sourceMappingURL=SupportedLocales.d.ts.map |
export declare type Locale = string; | ||
export interface LocaleData<T> { | ||
data: Record<Locale, T>; | ||
availableLocales: string[]; | ||
data: T; | ||
locale: Locale; | ||
} | ||
@@ -6,0 +6,0 @@ export interface LookupMatcherResult { |
@@ -8,3 +8,3 @@ import { LookupMatcherResult } from './types/core'; | ||
*/ | ||
export declare function LookupMatcher(availableLocales: string[], requestedLocales: string[], getDefaultLocale: () => string): LookupMatcherResult; | ||
export declare function LookupMatcher(availableLocales: Set<string>, requestedLocales: string[], getDefaultLocale: () => string): LookupMatcherResult; | ||
//# sourceMappingURL=LookupMatcher.d.ts.map |
@@ -6,3 +6,3 @@ /** | ||
*/ | ||
export declare function LookupSupportedLocales(availableLocales: string[], requestedLocales: string[]): string[]; | ||
export declare function LookupSupportedLocales(availableLocales: Set<string>, requestedLocales: string[]): string[]; | ||
//# sourceMappingURL=LookupSupportedLocales.d.ts.map |
@@ -8,3 +8,3 @@ import { NumberFormatInternal, NumberFormatOptions, NumberFormatLocaleInternalData } from '../types/number'; | ||
localeData: Record<string, NumberFormatLocaleInternalData | undefined>; | ||
availableLocales: string[]; | ||
availableLocales: Set<string>; | ||
numberingSystemNames: string[]; | ||
@@ -11,0 +11,0 @@ getDefaultLocale(): string; |
@@ -13,11 +13,2 @@ "use strict"; | ||
/** | ||
* Chop off the unicode extension from the locale string. | ||
*/ | ||
function removeUnicodeExtensionFromLocale(canonicalLocale) { | ||
var extensionIndex = canonicalLocale.indexOf('-u-'); | ||
return extensionIndex >= 0 | ||
? canonicalLocale.slice(0, extensionIndex) | ||
: canonicalLocale; | ||
} | ||
/** | ||
* https://tc39.es/ecma402/#sec-initializenumberformat | ||
@@ -44,4 +35,4 @@ */ | ||
['nu'], localeData, getDefaultLocale); | ||
var dataLocaleData = localeData[removeUnicodeExtensionFromLocale(r.locale)]; | ||
utils_1.invariant(!!dataLocaleData, "Missing locale data for " + r.locale); | ||
var dataLocaleData = localeData[r.dataLocale]; | ||
utils_1.invariant(!!dataLocaleData, "Missing locale data for " + r.dataLocale); | ||
var internalSlots = getInternalSlots(nf); | ||
@@ -48,0 +39,0 @@ internalSlots.locale = r.locale; |
{ | ||
"name": "@formatjs/ecma402-abstract", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"description": "A collection of implementation for ECMAScript abstract operations", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
import { PluralRulesInternal, PluralRulesData } from '../types/plural-rules'; | ||
export declare function InitializePluralRules(pl: Intl.PluralRules, locales: string | string[] | undefined, options: Intl.PluralRulesOptions | undefined, { availableLocales, relevantExtensionKeys, localeData, getDefaultLocale, getInternalSlots, }: { | ||
availableLocales: string[]; | ||
availableLocales: Set<string>; | ||
relevantExtensionKeys: string[]; | ||
@@ -5,0 +5,0 @@ localeData: Record<string, PluralRulesData | undefined>; |
import { RelativeTimeFormat, IntlRelativeTimeFormatOptions, RelativeTimeFormatInternal, LocaleFieldsData } from '../types/relative-time'; | ||
export declare function InitializeRelativeTimeFormat(rtf: RelativeTimeFormat, locales: string | string[] | undefined, options: IntlRelativeTimeFormatOptions | undefined, { getInternalSlots, availableLocales, relevantExtensionKeys, localeData, getDefaultLocale, }: { | ||
getInternalSlots(rtf: RelativeTimeFormat): RelativeTimeFormatInternal; | ||
availableLocales: string[]; | ||
availableLocales: Set<string>; | ||
relevantExtensionKeys: string[]; | ||
@@ -6,0 +6,0 @@ localeData: Record<string, LocaleFieldsData | undefined>; |
@@ -31,4 +31,4 @@ "use strict"; | ||
internalSlots.numeric = GetOption_1.GetOption(opts, 'numeric', 'string', ['always', 'auto'], 'always'); | ||
var fields = localeData[locale]; | ||
utils_1.invariant(!!fields, "Missing locale data for " + locale); | ||
var fields = localeData[r.dataLocale]; | ||
utils_1.invariant(!!fields, "Missing locale data for " + r.dataLocale); | ||
internalSlots.fields = fields; | ||
@@ -35,0 +35,0 @@ internalSlots.numberFormat = new Intl.NumberFormat(locales); |
@@ -11,3 +11,3 @@ export interface ResolveLocaleResult { | ||
[k in K]: any; | ||
}>(availableLocales: string[], requestedLocales: string[], options: { | ||
}>(availableLocales: Set<string>, requestedLocales: string[], options: { | ||
localeMatcher: string; | ||
@@ -14,0 +14,0 @@ [k: string]: string; |
@@ -7,5 +7,5 @@ /** | ||
*/ | ||
export declare function SupportedLocales(availableLocales: string[], requestedLocales: string[], options?: { | ||
export declare function SupportedLocales(availableLocales: Set<string>, requestedLocales: string[], options?: { | ||
localeMatcher?: 'best fit' | 'lookup'; | ||
}): string[]; | ||
//# sourceMappingURL=SupportedLocales.d.ts.map |
export declare type Locale = string; | ||
export interface LocaleData<T> { | ||
data: Record<Locale, T>; | ||
availableLocales: string[]; | ||
data: T; | ||
locale: Locale; | ||
} | ||
@@ -6,0 +6,0 @@ export interface LookupMatcherResult { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
470792
9254