balena-settings-storage
Version:
Balena settings storage utilities
25 lines (22 loc) • 486 B
text/typescript
import type { StorageFactory } from '../types';
export const createStore: StorageFactory = () => {
let _store: { [key: string]: string } = Object.create(null);
return {
getItem(key: string) {
if (Object.prototype.hasOwnProperty.call(_store, key)) {
return _store[key];
} else {
return null;
}
},
setItem(key: string, value: string) {
_store[key] = value;
},
removeItem(key: string) {
delete _store[key];
},
clear() {
_store = {};
},
};
};