Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

get-user-locale

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-user-locale - npm Package Compare versions

Comparing version 2.1.1 to 2.1.2

19

dist/cjs/index.js

@@ -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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc