rm blob caching

This commit is contained in:
Olivier Gagnon
2022-01-20 16:11:48 -05:00
parent 53727f6222
commit 77f525c98c
7 changed files with 19 additions and 119 deletions
-18
View File
@@ -1,18 +0,0 @@
const blobCache: { [hash: string]: string } = {};
export class BlobCache {
static get(hash: string): string {
return blobCache[hash];
}
static store(hash: string, value: string): void {
if (blobCache[hash]) return;
blobCache[hash] = value;
}
static removeByValue(value: string): void {
const keys = Object.keys(blobCache).filter((key) => blobCache[key] === value);
keys.forEach((key) => delete blobCache[key]);
}
}
-18
View File
@@ -1,18 +0,0 @@
import { ScriptUrl } from "../Script/ScriptUrl";
const importCache: { [hash: string]: ScriptUrl[] } = {};
export class ImportCache {
static get(hash: string): ScriptUrl[] | null {
return importCache[hash] || null;
}
static store(hash: string, value: ScriptUrl[]): void {
if (importCache[hash]) return;
importCache[hash] = value;
}
static remove(hash: string): void {
delete importCache[hash];
}
}
-12
View File
@@ -1,12 +0,0 @@
import { sha256 } from "js-sha256";
/**
* Computes a SHA-256 hash of a string synchronously
* @param message The input string
* @returns The SHA-256 hash in hex
*/
export function computeHash(message: string): string {
const hash = sha256.create();
hash.update(message);
return hash.hex();
}