intl-locales-supported
Version:
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.
34 lines • 1.1 kB
JavaScript
/*
* Copyright 2015, Yahoo Inc.
* Copyrights licensed under the New BSD License.
* See the accompanying LICENSE file for terms.
*/
Object.defineProperty(exports, "__esModule", { value: true });
function areIntlLocalesSupported(locales, constructorsToCheck) {
if (typeof Intl === 'undefined') {
return false;
}
if (!locales) {
throw new Error('locales must be supplied.');
}
if (!Array.isArray(locales)) {
locales = [locales];
}
var intlConstructors = constructorsToCheck || [
Intl.DateTimeFormat,
Intl.NumberFormat,
Intl.PluralRules,
];
intlConstructors = intlConstructors.filter(Boolean);
if (intlConstructors.length === 0 ||
(constructorsToCheck &&
intlConstructors.length !== constructorsToCheck.length)) {
return false;
}
return intlConstructors.every(function (intlConstructor) {
return intlConstructor.supportedLocalesOf(locales).length === locales.length;
});
}
exports.default = areIntlLocalesSupported;
//# sourceMappingURL=index.js.map
;