Skip to content

qkudev/storage-ns

Repository files navigation

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 to localStorage
  • returns namespaced storage

About

Tiny library for namespacing storage

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published