Skip to content

export()

This function is part of IconSet class in Iconify Tools.

Function export() exports icon set as IconifyJSON object.

Usage

Function has the following parameters:

  • validate, boolean. Optional. If enabled, icons will be validated before export.

Function returns IconifyJSON object.

Result includes all metadata. If icon set has information property, export will automatically update total number of icons in info block.

Example

example.ts
tsimport { blankIconSet } from '@iconify/tools';

// Create icon set, add few icons
const iconSet = blankIconSet('test-prefix');
iconSet.setIcon('add', {
   body: '<path d="M14 7v1H8v6H7V8H1V7h6V1h1v6h6z"/>',
});
iconSet.setIcon('triangle-left', {
   body: '<g fill="currentColor"><path d="M10.44 2l.56.413v11.194l-.54.393L5 8.373v-.827L10.44 2z"/></g>',
});
iconSet.setVariation('triangle-right', 'triangle-left', {
   hFlip: true,
});

// Set information
iconSet.info = {
   name: 'Test',
   author: {
       name: 'Me',
   },
   license: {
       title: 'MIT',
   },
};

// Export icon set
const data = iconSet.export();
console.log(JSON.stringify(data, null, '\t'));
Result:
json{
   "prefix": "test-prefix",
   "info": {
       "name": "Test",
       "author": {
           "name": "Me"
       },
       "license": {
           "title": "MIT"
       },
       "total": 3
   },
   "icons": {
       "add": {
           "body": "<path d=\"M14 7v1H8v6H7V8H1V7h6V1h1v6h6z\"/>"
       },
       "triangle-left": {
           "body": "<g fill=\"currentColor\"><path d=\"M10.44 2l.56.413v11.194l-.54.393L5 8.373v-.827L10.44 2z\"/></g>"
       }
   },
   "aliases": {
       "triangle-right": {
           "parent": "triangle-left",
           "hFlip": true
       }
   }
}

Released under the Apache 2.0 License.