get-user-locale
Advanced tools
Comparing version 2.1.1 to 2.1.2
@@ -14,11 +14,12 @@ "use strict"; | ||
} | ||
function normalizeLocales(arr) { | ||
return arr.map(function (el) { | ||
if (!el || el.indexOf('-') === -1 || el.toLowerCase() !== el) { | ||
return el; | ||
} | ||
var splitEl = el.split('-'); | ||
return "".concat(splitEl[0], "-").concat(splitEl[1].toUpperCase()); | ||
}); | ||
function isAllLowerCase(el) { | ||
return el.toLowerCase() === el; | ||
} | ||
function normalizeLocale(el) { | ||
if (!el || el.indexOf('-') === -1 || !isAllLowerCase(el)) { | ||
return el; | ||
} | ||
var _a = el.split('-'), _b = _a[0], splitEl1 = _b === void 0 ? '' : _b, _c = _a[1], splitEl2 = _c === void 0 ? '' : _c; | ||
return "".concat(splitEl1, "-").concat(splitEl2.toUpperCase()); | ||
} | ||
function getUserLocalesInternal(_a) { | ||
@@ -33,3 +34,3 @@ var _b = _a === void 0 ? {} : _a, _c = _b.useFallbackLocale, useFallbackLocale = _c === void 0 ? true : _c, _d = _b.fallbackLocale, fallbackLocale = _d === void 0 ? 'en-US' : _d; | ||
} | ||
return normalizeLocales(uniqDefined(languageList)); | ||
return uniqDefined(languageList).map(normalizeLocale); | ||
} | ||
@@ -36,0 +37,0 @@ exports.getUserLocales = (0, lodash_memoize_1.default)(getUserLocalesInternal, resolver); |
@@ -8,11 +8,12 @@ import memoize from 'lodash.memoize'; | ||
} | ||
function normalizeLocales(arr) { | ||
return arr.map(function (el) { | ||
if (!el || el.indexOf('-') === -1 || el.toLowerCase() !== el) { | ||
return el; | ||
} | ||
var splitEl = el.split('-'); | ||
return "".concat(splitEl[0], "-").concat(splitEl[1].toUpperCase()); | ||
}); | ||
function isAllLowerCase(el) { | ||
return el.toLowerCase() === el; | ||
} | ||
function normalizeLocale(el) { | ||
if (!el || el.indexOf('-') === -1 || !isAllLowerCase(el)) { | ||
return el; | ||
} | ||
var _a = el.split('-'), _b = _a[0], splitEl1 = _b === void 0 ? '' : _b, _c = _a[1], splitEl2 = _c === void 0 ? '' : _c; | ||
return "".concat(splitEl1, "-").concat(splitEl2.toUpperCase()); | ||
} | ||
function getUserLocalesInternal(_a) { | ||
@@ -27,3 +28,3 @@ var _b = _a === void 0 ? {} : _a, _c = _b.useFallbackLocale, useFallbackLocale = _c === void 0 ? true : _c, _d = _b.fallbackLocale, fallbackLocale = _d === void 0 ? 'en-US' : _d; | ||
} | ||
return normalizeLocales(uniqDefined(languageList)); | ||
return uniqDefined(languageList).map(normalizeLocale); | ||
} | ||
@@ -30,0 +31,0 @@ export var getUserLocales = memoize(getUserLocalesInternal, resolver); |
{ | ||
"name": "get-user-locale", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"description": "Returns a list of strings representing the user's preferred languages.", | ||
@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js", |
@@ -16,11 +16,14 @@ import memoize from 'lodash.memoize'; | ||
function normalizeLocales(arr: string[]) { | ||
return arr.map((el) => { | ||
if (!el || el.indexOf('-') === -1 || el.toLowerCase() !== el) { | ||
return el; | ||
} | ||
function isAllLowerCase(el: string) { | ||
return el.toLowerCase() === el; | ||
} | ||
const splitEl = el.split('-'); | ||
return `${splitEl[0]}-${splitEl[1].toUpperCase()}`; | ||
}); | ||
function normalizeLocale(el: string) { | ||
if (!el || el.indexOf('-') === -1 || !isAllLowerCase(el)) { | ||
return el; | ||
} | ||
const [splitEl1 = '', splitEl2 = ''] = el.split('-'); | ||
return `${splitEl1}-${splitEl2.toUpperCase()}`; | ||
} | ||
@@ -42,3 +45,3 @@ | ||
return normalizeLocales(uniqDefined(languageList)); | ||
return uniqDefined(languageList).map(normalizeLocale); | ||
} | ||
@@ -45,0 +48,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
19256
306