pl-fe: this should be processed compile time

Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
nicole mikołajczyk
2025-11-06 16:57:08 +01:00
parent 3890792bb1
commit 7daad4feec
2 changed files with 25 additions and 9 deletions

View File

@ -0,0 +1,16 @@
// Converts cryptocurrency-icon's manifest file from a list to a map.
// See: https://github.com/spothq/cryptocurrency-icons/blob/master/manifest.json
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const manifest = require('cryptocurrency-icons/manifest.json');
const manifestMap = manifest.reduce((acc: Record<string, typeof manifest[0]>, entry: typeof manifest[0]) => {
acc[entry.symbol.toLowerCase()] = entry;
return acc;
}, {});
export default () => ({
data: manifestMap,
});

View File

@ -1,11 +1,11 @@
// Converts cryptocurrency-icon's manifest file from a list to a map.
// See: https://github.com/spothq/cryptocurrency-icons/blob/master/manifest.json
interface ManifestMap {
[s: string]: {
symbol: string;
name: string;
color: string;
};
}
import manifest from 'cryptocurrency-icons/manifest.json';
export default import.meta.compileTime<ManifestMap>('./manifest-map-compiletime.ts');
const manifestMap = manifest.reduce((acc: Record<string, typeof manifest[0]>, entry) => {
acc[entry.symbol.toLowerCase()] = entry;
return acc;
}, {});
export { manifestMap as default };
export type { ManifestMap };