Skip to content

count()

This function is part of IconSet class in Iconify Tools.

Function count() counts icons in icon set.

Usage

Function has no parameters.

Function returns number of icons.

What icons are counted?

Counted:

  • Icons.
  • Variations (see below).

Not counted:

  • Hidden icons and their aliases/variations.
  • Aliases.

Icon types

There are 3 types of icon items in IconSet: "icon", "variation", "alias".

"icon" represents a full unique icon.

"variation" represents variation of another icon. It has the following properties:

  • parent, string. Name of parent icon.

and at least one of the transformations:

  • rotate rotation by 90, 180 or 270 degrees.
  • hFlip horizontal flip.
  • vFlip vertical flip.

Variations make it easy to create clones of icons, such as arrow-left after creating arrow-right.

"alias" is an alternative name for icon. It has the following property:

  • parent, string. Name of parent icon.

Aliases can be created to have different name for icon. If you have renamed some icon, alias can be used to allow users to use old name.

Example

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

const iconSet = new IconSet({
   prefix: 'codicon',
   icons: {
       // Counted
       'add': {
           body: '<g fill="currentColor"><path d="M14 7v1H8v6H7V8H1V7h6V1h1v6h6z"/></g>',
       },
       // Ignored: hidden
       'debug-pause': {
           body: '<g fill="currentColor"><path d="M4.5 3H6v10H4.5V3zm7 0v10H10V3h1.5z"/></g>',
           hidden: true,
       },
       // Counted
       'triangle-left': {
           body: '<g fill="currentColor"><path d="M10.44 2l.56.413v11.194l-.54.393L5 8.373v-.827L10.44 2z"/></g>',
       },
   },
   aliases: {
       // Ignored: alias
       'plus': {
           parent: 'add',
       },
       // Counted: variation
       'triangle-right': {
           parent: 'triangle-left',
           hFlip: true,
       },
   },
});

// Count icons: returns 3
console.log(iconSet.count());

Released under the Apache 2.0 License.