Capitalize background scripts
This commit is contained in:
parent
21788740c1
commit
a26d8a8a1b
50 changed files with 247 additions and 245 deletions
19
src/background/infrastructures/MemoryStorage.js
Normal file
19
src/background/infrastructures/MemoryStorage.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
const db = {};
|
||||
|
||||
export default class MemoryStorage {
|
||||
set(name, value) {
|
||||
let data = JSON.stringify(value);
|
||||
if (typeof data === 'undefined') {
|
||||
throw new Error('value is not serializable');
|
||||
}
|
||||
db[name] = data;
|
||||
}
|
||||
|
||||
get(name) {
|
||||
let data = db[name];
|
||||
if (!data) {
|
||||
return undefined;
|
||||
}
|
||||
return JSON.parse(data);
|
||||
}
|
||||
}
|
Reference in a new issue