1.0.2 • Published 7 years ago
localstorage-mock v1.0.2
localstorage-mock
A mock implementation of Window.localStorage.
Usage
1) Install package:
npm i localstorage-mock --save-dev
2) Import / require module:import 'localstorage-mock'
orrequire('localstorage-mock')
Mock should now be accessible globally as
localStorage
.API
getItem(key)
- get item by keysetItem(key, value)
- insert new itemclear()
- clear storagelength
- number of items in storageNote: I realise there are already packages out there which implement local storage. I wrote this simply as a fun exercise in publishing my first npm module.