nodejs-localstorage-adapter
v1.0.11
Published
A tiny ES6 class for simulating localstorage browser behaviour in nodejs
Downloads
4
Readme
nodejs-localstorage-adapter
A tiny ES6 class for simulating localstorage browser behaviour in nodejs
to install the package run:
npm install nodejs-localstorage-adapter --save
How to use:
first include the package to your project:
var localStorage = require('nodejs-localstorage-adapter');
-Methods
localStorage.setItem("user_id", "12345");
var userId = localStorage.getItem("user_id"); // should return "12345"
localStorage.setItem("user_id", "12345");
localStorage.setItem("user_name", "mark");
localStorage.key(0); // should return "user_id"
localStorage.removeItem('user_id');
localStorage.clear();
-Properties
localStorage.setItem('user_id', '12345');
localStorage.setItem('user_name', 'mark');
localStorage.setItem('user_age', '25');
localStorage.length; // should return 3