local-storage-mock
v1.0.2
Published
localStorage mock for NodeJS.
Downloads
4
Maintainers
Readme
Local Storage
#[Author: Hussain Mir Ali] Local Storage mock for testing browser code in NodeJS.
#To use the project:
run: npm install -g local-storage-mock
#Sample usage:
var lstorage = require('local-storage-mock');
lstorage.setItem('Hello', 'World');
lstorage.setItem('Node', 'JS');
lstorage.setItem('Weight', 100);
lstorage.setItem('Car', {'Engine': 'V8', 'Make': 'BMW', 'Year': 2013});
lstorage.setItem('Words', ['Pen', 'Pineapple', 'Apple','Pen']);
console.log(lstorage.getItem('Hello')==='World');//true
console.log(lstorage.getItem('Weight')===100);//true
console.log(lstorage.getlength() === 5);//true
lstorage.removeItem('Hello');
console.log(lstorage.getlength() === 4);//true
console.log(lstorage.key(0) === 'Node');//true