pl-fe: this should be processed compile time
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
@ -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,
|
||||||
|
});
|
||||||
@ -1,11 +1,11 @@
|
|||||||
// Converts cryptocurrency-icon's manifest file from a list to a map.
|
interface ManifestMap {
|
||||||
// See: https://github.com/spothq/cryptocurrency-icons/blob/master/manifest.json
|
[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) => {
|
export type { ManifestMap };
|
||||||
acc[entry.symbol.toLowerCase()] = entry;
|
|
||||||
return acc;
|
|
||||||
}, {});
|
|
||||||
|
|
||||||
export { manifestMap as default };
|
|
||||||
|
|||||||
Reference in New Issue
Block a user