Add initial VibeGuard browser extension
This commit is contained in:
parent
f251f0f8ce
commit
9c65a61ebb
43 changed files with 125275 additions and 2 deletions
22
src/inference/cache.ts
Normal file
22
src/inference/cache.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import { hashText, normalizeText } from "../shared/hash";
|
||||
import type { InferenceResult } from "../shared/types";
|
||||
|
||||
export class ResultCache {
|
||||
private readonly values = new Map<string, InferenceResult>();
|
||||
|
||||
get(text: string): InferenceResult | undefined {
|
||||
return this.values.get(hashText(text));
|
||||
}
|
||||
|
||||
set(text: string, result: InferenceResult): void {
|
||||
this.values.set(hashText(normalizeText(text)), result);
|
||||
}
|
||||
|
||||
clear(): void {
|
||||
this.values.clear();
|
||||
}
|
||||
|
||||
get size(): number {
|
||||
return this.values.size;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue