mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-02-27 04:06:39 +00:00
17 lines
405 B
JavaScript
17 lines
405 B
JavaScript
const PREFIX = 'shlink';
|
|
const buildPath = (path) => `${PREFIX}.${path}`;
|
|
|
|
export default class Storage {
|
|
constructor(localStorage) {
|
|
this.localStorage = localStorage;
|
|
}
|
|
|
|
get = (key) => {
|
|
const item = this.localStorage.getItem(buildPath(key));
|
|
|
|
return item ? JSON.parse(item) : undefined;
|
|
};
|
|
|
|
set = (key, value) => this.localStorage.setItem(buildPath(key), JSON.stringify(value));
|
|
}
|