Skip to content

convertIconSetInfo()

This function is part of Iconify Utils package.

Function convertIconSetInfo() converts and validates icon set information.

Some old icon sets might have information in legacy format, which was created before Iconify projects moved to TypeScript. This function will accept both old and new formats, will convert and validate it and will return correct IconifyInfo data.

Usage

Function has the following parameters:

  • data, unknown. Icon set information, which can be legacy object or IconifyInfo.
  • expectedPrefix, string. Optional. If set, and source object has prefix property with different value, function will throw an error. This can be used legacy information might be incorrect.

Function returns:

Example

usage.ts
tsimport { convertIconSetInfo } from '@iconify/utils';

// Original data
const data = {
   name: 'Remix Icon',
   total: 2271,
   author: 'Remix Design',
   url: 'https://github.com/Remix-Design/RemixIcon',
   license: 'Apache 2.0',
   licenseURL: 'https://github.com/Remix-Design/RemixIcon/blob/master/License',
   height: 24,
   samples: ['lock-2-line', 'mark-pen-fill', 'moon-line'],
   palette: 'Colorless',
   category: 'General',
};

// Convert it
const converted = convertIconSetInfo(data);

// Log result
console.log(converted);
Result:
json{
   "name": "Remix Icon",
   "total": 2271,
   "author": {
       "name": "Remix Design",
       "url": "https://github.com/Remix-Design/RemixIcon"
   },
   "license": {
       "title": "Apache 2.0",
       "url": "https://github.com/Remix-Design/RemixIcon/blob/master/License"
   },
   "samples": ["lock-2-line", "mark-pen-fill", "moon-line"],
   "height": 24,
   "displayHeight": 24,
   "category": "General",
   "palette": false
}

Released under the Apache 2.0 License.