(path: string)
| 32 | } |
| 33 | |
| 34 | export function loadImage(path: string): Uint8Array { |
| 35 | if (path.length === 0) { |
| 36 | throw new TypeError("loadImage(path): path must be a non-empty string"); |
| 37 | } |
| 38 | const resolvedPath = resolve(path); |
| 39 | const cached = IMAGE_CACHE.get(resolvedPath); |
| 40 | if (cached) { |
| 41 | IMAGE_CACHE.delete(resolvedPath); |
| 42 | IMAGE_CACHE.set(resolvedPath, cached); |
| 43 | return cached; |
| 44 | } |
| 45 | const bytes = new Uint8Array(readFileSync(resolvedPath)); |
| 46 | IMAGE_CACHE.set(resolvedPath, bytes); |
| 47 | evictOverflowEntries(); |
| 48 | return bytes; |
| 49 | } |
no test coverage detected