2
0
mirror of https://github.com/iconify/iconify.git synced 2025-01-08 07:48:29 +00:00

Minor optimisations in core package to reduce bundle size

This commit is contained in:
Vjacheslav Trushkin 2022-07-02 18:19:41 +03:00
parent 40ba4e076a
commit 696a5514e2
2 changed files with 6 additions and 10 deletions

View File

@ -15,7 +15,7 @@ export function listToIcons(
const icon = const icon =
typeof item === 'string' typeof item === 'string'
? (stringToIcon(item, validate, simpleNames) as IconifyIconName) ? (stringToIcon(item, validate, simpleNames) as IconifyIconName)
: { ...item }; : item;
if (icon) { if (icon) {
result.push(icon); result.push(icon);
} }

View File

@ -95,15 +95,11 @@ export function addCollection(data: IconifyJSON, provider?: string): boolean {
// Get provider // Get provider
if (typeof provider !== 'string') { if (typeof provider !== 'string') {
provider = typeof data.provider === 'string' ? data.provider : ''; provider = data.provider || '';
} }
// Check for simple names: requires empty provider and prefix // Check for simple names: requires empty provider and prefix
if ( if (simpleNames && !provider && !data.prefix) {
simpleNames &&
provider === '' &&
(typeof data.prefix !== 'string' || data.prefix === '')
) {
// Simple names: add icons one by one // Simple names: add icons one by one
let added = false; let added = false;
@ -121,18 +117,18 @@ export function addCollection(data: IconifyJSON, provider?: string): boolean {
} }
// Validate provider and prefix // Validate provider and prefix
const prefix = data.prefix;
if ( if (
typeof data.prefix !== 'string' ||
!validateIconName({ !validateIconName({
provider, provider,
prefix: data.prefix, prefix,
name: 'a', name: 'a',
}) })
) { ) {
return false; return false;
} }
const storage = getStorage(provider, data.prefix); const storage = getStorage(provider, prefix);
return !!addIconSet(storage, data); return !!addIconSet(storage, data);
} }