Commits

Michael Koch authored f093dce92b2
Added first version for retrieving and displaying citation information for items and collections.
No tags

src/app/shared/citations/cache.ts

Added
1 +export class Cache<T> {
2 + private cache = new Set<T>();
3 +
4 + add(item: T): void {
5 + this.cache.add(item);
6 + }
7 +
8 + has(item: T): boolean {
9 + return this.cache.has(item);
10 + }
11 +
12 + remove(item: T): void {
13 + this.cache.delete(item);
14 + }
15 +
16 + clear(): void {
17 + this.cache.clear();
18 + }
19 +
20 + getAll(): T[] {
21 + return Array.from(this.cache);
22 + }
23 +
24 + forEach(callback: (item: T) => void): void {
25 + this.cache.forEach((item) => callback(item));
26 + }
27 +}
28 +

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut