intl-locales-supported
Advanced tools
Comparing version 1.4.4 to 1.4.5
@@ -6,2 +6,13 @@ # Change Log | ||
## [1.4.5](https://github.com/formatjs/formatjs/compare/intl-locales-supported@1.4.4...intl-locales-supported@1.4.5) (2019-08-12) | ||
### Bug Fixes | ||
* **intl-locales-supported:** lazily default constructors, fixes [#151](https://github.com/formatjs/formatjs/issues/151) ([0cba7a6](https://github.com/formatjs/formatjs/commit/0cba7a6)) | ||
## [1.4.4](https://github.com/formatjs/formatjs/compare/intl-locales-supported@1.4.3...intl-locales-supported@1.4.4) (2019-08-11) | ||
@@ -8,0 +19,0 @@ |
@@ -1,13 +0,5 @@ | ||
export default function areIntlLocalesSupported(locales: string | string[], constructorsToCheck?: ({ | ||
(locales?: string | string[] | undefined, options?: Intl.NumberFormatOptions | undefined): Intl.NumberFormat; | ||
new (locales?: string | string[] | undefined, options?: Intl.NumberFormatOptions | undefined): Intl.NumberFormat; | ||
supportedLocalesOf(locales: string | string[], options?: Intl.NumberFormatOptions | undefined): string[]; | ||
} | { | ||
(locales?: string | string[] | undefined, options?: Intl.DateTimeFormatOptions | undefined): Intl.DateTimeFormat; | ||
new (locales?: string | string[] | undefined, options?: Intl.DateTimeFormatOptions | undefined): Intl.DateTimeFormat; | ||
supportedLocalesOf(locales: string | string[], options?: Intl.DateTimeFormatOptions | undefined): string[]; | ||
} | { | ||
(locales?: string | string[] | undefined, options?: Intl.PluralRulesOptions | undefined): Intl.PluralRules; | ||
new (locales?: string | string[] | undefined, options?: Intl.PluralRulesOptions | undefined): Intl.PluralRules; | ||
supportedLocalesOf(locales: string | string[], options?: Intl.PluralRulesOptions | undefined): string[]; | ||
})[]): boolean; | ||
declare type IntlConstructor = { | ||
supportedLocalesOf(locales: string | string[], options?: any): string[]; | ||
}; | ||
export default function areIntlLocalesSupported(locales: string | string[], constructorsToCheck?: Array<IntlConstructor>): boolean; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/* | ||
@@ -8,9 +7,4 @@ * Copyright 2015, Yahoo Inc. | ||
*/ | ||
var DEFAULT_CONSTRUCTORS = [ | ||
Intl.DateTimeFormat, | ||
Intl.NumberFormat, | ||
Intl.PluralRules | ||
]; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function areIntlLocalesSupported(locales, constructorsToCheck) { | ||
if (constructorsToCheck === void 0) { constructorsToCheck = DEFAULT_CONSTRUCTORS; } | ||
if (typeof Intl === 'undefined') { | ||
@@ -25,2 +19,10 @@ return false; | ||
} | ||
// Per https://github.com/formatjs/formatjs/issues/151 | ||
if (!constructorsToCheck) { | ||
constructorsToCheck = [ | ||
Intl.DateTimeFormat, | ||
Intl.NumberFormat, | ||
Intl.PluralRules, | ||
]; | ||
} | ||
var intlConstructors = constructorsToCheck.filter(Boolean); | ||
@@ -27,0 +29,0 @@ if (intlConstructors.length === 0) { |
@@ -1,13 +0,5 @@ | ||
export default function areIntlLocalesSupported(locales: string | string[], constructorsToCheck?: ({ | ||
(locales?: string | string[] | undefined, options?: Intl.NumberFormatOptions | undefined): Intl.NumberFormat; | ||
new (locales?: string | string[] | undefined, options?: Intl.NumberFormatOptions | undefined): Intl.NumberFormat; | ||
supportedLocalesOf(locales: string | string[], options?: Intl.NumberFormatOptions | undefined): string[]; | ||
} | { | ||
(locales?: string | string[] | undefined, options?: Intl.DateTimeFormatOptions | undefined): Intl.DateTimeFormat; | ||
new (locales?: string | string[] | undefined, options?: Intl.DateTimeFormatOptions | undefined): Intl.DateTimeFormat; | ||
supportedLocalesOf(locales: string | string[], options?: Intl.DateTimeFormatOptions | undefined): string[]; | ||
} | { | ||
(locales?: string | string[] | undefined, options?: Intl.PluralRulesOptions | undefined): Intl.PluralRules; | ||
new (locales?: string | string[] | undefined, options?: Intl.PluralRulesOptions | undefined): Intl.PluralRules; | ||
supportedLocalesOf(locales: string | string[], options?: Intl.PluralRulesOptions | undefined): string[]; | ||
})[]): boolean; | ||
declare type IntlConstructor = { | ||
supportedLocalesOf(locales: string | string[], options?: any): string[]; | ||
}; | ||
export default function areIntlLocalesSupported(locales: string | string[], constructorsToCheck?: Array<IntlConstructor>): boolean; | ||
export {}; |
@@ -6,9 +6,3 @@ /* | ||
*/ | ||
var DEFAULT_CONSTRUCTORS = [ | ||
Intl.DateTimeFormat, | ||
Intl.NumberFormat, | ||
Intl.PluralRules | ||
]; | ||
export default function areIntlLocalesSupported(locales, constructorsToCheck) { | ||
if (constructorsToCheck === void 0) { constructorsToCheck = DEFAULT_CONSTRUCTORS; } | ||
if (typeof Intl === 'undefined') { | ||
@@ -23,2 +17,10 @@ return false; | ||
} | ||
// Per https://github.com/formatjs/formatjs/issues/151 | ||
if (!constructorsToCheck) { | ||
constructorsToCheck = [ | ||
Intl.DateTimeFormat, | ||
Intl.NumberFormat, | ||
Intl.PluralRules, | ||
]; | ||
} | ||
var intlConstructors = constructorsToCheck.filter(Boolean); | ||
@@ -25,0 +27,0 @@ if (intlConstructors.length === 0) { |
{ | ||
"name": "intl-locales-supported", | ||
"version": "1.4.4", | ||
"version": "1.4.5", | ||
"description": "Utility to help you polyfill the Node.js runtime when the Intl APIs are missing, or if the built-in Intl is missing locale data that you need.", | ||
@@ -29,5 +29,5 @@ "main": "dist/index.js", | ||
"build": "tsc && tsc -p tsconfig.cjs.json", | ||
"test": "mocha --opts ../../mocha.opts tests/index.ts" | ||
"test": "cross-env NODE_ICU_DATA=../../node_modules/full-icu mocha --opts ../../mocha.opts tests/index.ts" | ||
}, | ||
"gitHead": "e5de8b825e305ca36ebbc821f15d9721b0c9451b" | ||
"gitHead": "ced8ad1608c25e47fbb0578b11a6184296fd4045" | ||
} |
@@ -6,10 +6,10 @@ /* | ||
*/ | ||
const DEFAULT_CONSTRUCTORS = [ | ||
Intl.DateTimeFormat, | ||
Intl.NumberFormat, | ||
Intl.PluralRules | ||
]; | ||
type IntlConstructor = { | ||
supportedLocalesOf(locales: string | string[], options?: any): string[]; | ||
}; | ||
export default function areIntlLocalesSupported( | ||
locales: string | string[], | ||
constructorsToCheck = DEFAULT_CONSTRUCTORS | ||
constructorsToCheck?: Array<IntlConstructor> | ||
): boolean { | ||
@@ -28,2 +28,11 @@ if (typeof Intl === 'undefined') { | ||
// Per https://github.com/formatjs/formatjs/issues/151 | ||
if (!constructorsToCheck) { | ||
constructorsToCheck = [ | ||
Intl.DateTimeFormat, | ||
Intl.NumberFormat, | ||
Intl.PluralRules, | ||
]; | ||
} | ||
const intlConstructors = constructorsToCheck.filter(Boolean); | ||
@@ -30,0 +39,0 @@ |
Sorry, the diff of this file is not supported yet
13337
113