0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2024-12-22 13:43:03 -05:00
penpot-exporter-figma-plugin/plugin-src/ImageLibrary.ts
Jordi Sala Morales f726dc9cec
Add image library to optimize performance (#133)
* Add image library to optimize performance

* fix and improve

* Add changelog and improve naming

* refactor

* improve

* fix todos
2024-06-03 17:29:33 +02:00

23 lines
526 B
TypeScript

import { ImageColor } from '@ui/lib/types/utils/imageColor';
class ImageLibrary {
private images: Record<string, ImageColor> = {};
public register(hash: string, image: ImageColor) {
this.images[hash] = image;
}
public get(hash: string): ImageColor | undefined {
return this.images[hash];
}
public all(): Record<string, ImageColor> {
return this.images;
}
public init(images: Record<string, ImageColor>): void {
this.images = images;
}
}
export const imagesLibrary = new ImageLibrary();