@qkudev/storage-ns
v0.1.1
Published
Simple way to separate your storage by namespaces
Downloads
1
Readme
Storage NS
Simple way to separate your storage by namespaces
Setup
$ npm install --save @qkudev/storage-ns
# --- or ---
$ yarn add @qkudev/storage-ns
Usage
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'
new StorageNS(prefix, [storage])
- 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