mirror of
https://github.com/lucide-icons/lucide.git
synced 2025-12-21 17:19:22 +01:00
16 lines
556 B
TypeScript
16 lines
556 B
TypeScript
|
|
import NextCache from './nextCache';
|
||
|
|
import {parseSync} from 'svgson';
|
||
|
|
import {getAllData} from './icons';
|
||
|
|
|
||
|
|
export type IconNode = [string, object, IconNode[]];
|
||
|
|
export type IconNodes = {[iconName: string]: IconNode};
|
||
|
|
|
||
|
|
export function fetchIconNodes(writeCache = true): Promise<IconNodes> {
|
||
|
|
return NextCache.resolve('api-icon-nodes', async () => {
|
||
|
|
return (await getAllData()).reduce((acc, icon) => {
|
||
|
|
acc[icon.name] = parseSync(icon.src).children.map(({name, attributes}) => [name, attributes]);
|
||
|
|
return acc;
|
||
|
|
}, {});
|
||
|
|
}, writeCache);
|
||
|
|
}
|