expandIconSet()
此函数属于 Iconify Utils 包。
函数 expandIconSet() 用于反优化图标集,与 minifyIconSet() 的作用相反。
用法
该函数仅有一个参数:
- data,IconifyJSON 类型。图标集数据。
该函数不会创建新对象,而是直接对传入函数的对象进行反优化。
它具体做了什么?
详情请参阅 minifyIconSet()。
示例
usage.ts
ts
import type { IconifyJSON } from '@iconify/types';
import { expandIconSet } from '@iconify/utils';
// Original data
const data: IconifyJSON = {
prefix: 'foo',
icons: {
icon1: {
body: '<path d="M7 6v12l10-6z" fill="currentColor"/>',
},
icon2: {
body: '<path d="M5 13v-1h6V6h1v6h6v1h-6v6h-1v-6H5z" fill="currentColor"/>',
},
icon3: {
body: '<path d="M10 8a2 2 0 1 1-4 0a2 2 0 0 1 4 0z" fill="currentColor"/>',
width: 16,
height: 16,
},
},
width: 24,
height: 24,
};
// Expand it
expandIconSet(data);
// Log data
console.log(data);结果:
json
{
"prefix": "foo",
"icons": {
"icon1": {
"body": "<path d=\"M7 6v12l10-6z\" fill=\"currentColor\"/>",
"width": 24,
"height": 24
},
"icon2": {
"body": "<path d=\"M5 13v-1h6V6h1v6h6v1h-6v6h-1v-6H5z\" fill=\"currentColor\"/>",
"width": 24,
"height": 24
},
"icon3": {
"body": "<path d=\"M10 8a2 2 0 1 1-4 0a2 2 0 0 1 4 0z\" fill=\"currentColor\"/>",
"width": 16,
"height": 16
}
}
}