diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2019-05-11 16:38:08 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2019-05-11 16:38:08 +0900 |
commit | c6288f19d93a05f96274dd172450b8350389c39f (patch) | |
tree | 75b5a168af535aa640bc21e70281497915dade63 /src/content/repositories/MarkRepository.ts | |
parent | ebfb172520f7077a15cd5d4e865e5d86593c55ac (diff) |
Mark set/jump as a clean architecture
Diffstat (limited to 'src/content/repositories/MarkRepository.ts')
-rw-r--r-- | src/content/repositories/MarkRepository.ts | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/content/repositories/MarkRepository.ts b/src/content/repositories/MarkRepository.ts new file mode 100644 index 0000000..ed5afe2 --- /dev/null +++ b/src/content/repositories/MarkRepository.ts @@ -0,0 +1,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 }; + } +} |