aboutsummaryrefslogtreecommitdiff
path: root/src/content/repositories/MarkRepository.ts
blob: e48db257a71386cfb8aaac6f8cae7eb875a0bed0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import Mark from "../domains/Mark";

export default interface MarkRepository {
  set(key: string, mark: Mark): void;

  get(key: string): Mark | null;
}

const saved: { [key: string]: Mark } = {};

export class MarkRepositoryImpl implements MarkRepository {
  set(key: string, mark: Mark): void {
    saved[key] = mark;
  }

  get(key: string): Mark | null {
    const v = saved[key];
    if (!v) {
      return null;
    }
    return { ...v };
  }
}