Simple way to separate your storage by namespaces
$ npm install --save @qkudev/storage-ns
# --- or ---
$ yarn add @qkudev/storage-ns
It implements Storage
interface, so you can use it as localStorage
import { StorageNS } from 'storage-ns';
const storage1 = new StorageNS('ns1');
storage1.setItem('foo', 'bar');
const storage2 = new StorageNS('ns2);
storage2.setItem('bar', 'buzz');
storage1.clear();
storage2.getItem('bar') // 'buzz'
- arguments
- prefix string
- required namespace prefix
- storage Storage
- any storage that implements
Storage
interface, default tolocalStorage
- any storage that implements
- prefix string
- returns namespaced storage