From 696a5514e2687d44358bd6e5d6df15010a609db7 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sat, 2 Jul 2022 18:19:41 +0300 Subject: [PATCH] Minor optimisations in core package to reduce bundle size --- packages/core/src/icon/list.ts | 2 +- packages/core/src/storage/functions.ts | 14 +++++--------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/packages/core/src/icon/list.ts b/packages/core/src/icon/list.ts index 653cebc..ff71dc4 100644 --- a/packages/core/src/icon/list.ts +++ b/packages/core/src/icon/list.ts @@ -15,7 +15,7 @@ export function listToIcons( const icon = typeof item === 'string' ? (stringToIcon(item, validate, simpleNames) as IconifyIconName) - : { ...item }; + : item; if (icon) { result.push(icon); } diff --git a/packages/core/src/storage/functions.ts b/packages/core/src/storage/functions.ts index 14a34c9..7f679cc 100644 --- a/packages/core/src/storage/functions.ts +++ b/packages/core/src/storage/functions.ts @@ -95,15 +95,11 @@ export function addCollection(data: IconifyJSON, provider?: string): boolean { // Get provider if (typeof provider !== 'string') { - provider = typeof data.provider === 'string' ? data.provider : ''; + provider = data.provider || ''; } // Check for simple names: requires empty provider and prefix - if ( - simpleNames && - provider === '' && - (typeof data.prefix !== 'string' || data.prefix === '') - ) { + if (simpleNames && !provider && !data.prefix) { // Simple names: add icons one by one let added = false; @@ -121,18 +117,18 @@ export function addCollection(data: IconifyJSON, provider?: string): boolean { } // Validate provider and prefix + const prefix = data.prefix; if ( - typeof data.prefix !== 'string' || !validateIconName({ provider, - prefix: data.prefix, + prefix, name: 'a', }) ) { return false; } - const storage = getStorage(provider, data.prefix); + const storage = getStorage(provider, prefix); return !!addIconSet(storage, data); }