aboutsummaryrefslogtreecommitdiff
path: root/src/content/repositories/MarkRepository.ts
blob: ed5afe2d61ee5fe7d6e6b1e3104fea780bace708 (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
24
25
import Mark from '../domains/Mark';

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

  get(key: string): Mark | null;

  // eslint-disable-next-line semi
}

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

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

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