diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/background/infrastructures/memory-storage.js | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/background/infrastructures/memory-storage.js b/src/background/infrastructures/memory-storage.js index 0a05928..234a9b8 100644 --- a/src/background/infrastructures/memory-storage.js +++ b/src/background/infrastructures/memory-storage.js @@ -2,10 +2,14 @@ const db = {}; export default class MemoryStorage { set(name, value) { - db[name] = value; + let data = JSON.stringify(value); + if (typeof data === 'undefined') { + throw new Error('value is not serializable'); + } + db[name] = data; } get(name) { - return db[name]; + return JSON.parse(db[name]); } } |