1
0
mirror of https://github.com/simple-icons/simple-icons.git synced 2024-11-26 01:00:27 +02:00

Optimize package getter (#4356)

Remove redundant truthy check for properties of icons in index.js

We test if all icon scan be retrieved anyway, if any icon is missing these properties we would find out during testing.
This commit is contained in:
Álvaro Mondéjar 2020-12-14 16:37:15 +01:00 committed by GitHub
parent f2dc528780
commit f6bd00315a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,14 +5,12 @@ Object.defineProperty(icons, "get", {
value: function(targetName) { value: function(targetName) {
if (icons[targetName]) { if (icons[targetName]) {
return icons[targetName]; return icons[targetName];
} else { }
var normalizedName = targetName.toLowerCase(); var normalizedName = targetName.toLowerCase();
for (var iconName in icons) { for (var iconName in icons) {
var icon = icons[iconName]; var icon = icons[iconName];
if ((icon.title && icon.title.toLowerCase() === normalizedName) if (icon.title.toLowerCase() === normalizedName || icon.slug === normalizedName) {
|| (icon.slug && icon.slug === normalizedName)) { return icon;
return icon;
}
} }
} }
} }