Drawer JS
Drawer is like where you store and pick things. Drawer Js can store/set any kind of data and pick/get that data at every file of your project. Assign any thing and get any where in application as a single context/state. just import and you will get every thing you assigned. can also be used as inmemory cache or storing react-router history object to push to new page from any where.
Basic useful feature list:
- Store any kind of data in memory.
- Get data at any place/file of application and update.
- Can get as a clone so you can use it without worry about reference variable update.
- Can check if key or data exist already or not.
- Get all or clear all existing data at once.
installation
npm install drawerjs --save
Class Functions
Functions List:
set({key: value}) // update/set the value against given key
get(key) // will return value with same reference address
getAll()
getClone() // will return the value with change reference address
clear(key)
clearAll()
isExist(key) // return true if data exist
isKeyExist(key) // return true if key exist even with null data
Params Types:
Param | Type | Required | Default |
---|---|---|---|
key | unique String | Required | undefined |
data | Any | Required | undefined |
Coding Example File A
;// for Ecma5 it imports like below// var drawerjs = require("drawerjs").default; drawer;drawer;drawer;
Coding Example File B
;// for Ecma5 it imports like below// var drawerjs = require("drawerjs").default; drawer; // { temp: "mydata" }drawer; // { temp: "mydata" }drawer; // { key1: { temp: "mydata" }, key2: { temp: "mydata2" }, key3: null }drawerclear"key1"; // { key2: { temp: "mydata2" }, key3: null }drawer; // falsedrawer; // truedrawer; // falsedrawer; // falsedrawer; // truedrawer; // truedrawer; // null
Unit Tests Unit test provided with 100% Coverage
npm run test
License
MIT