1.0.2 • Published 7 years ago

localstorage-mock v1.0.2

Weekly downloads
2
License
ISC
Repository
github
Last release
7 years ago

localstorage-mock

A mock implementation of Window.localStorage.

Usage

1) Install package:

  • npm i localstorage-mock --save-dev2) Import / require module:
  • import 'localstorage-mock' or require('localstorage-mock')

    Mock should now be accessible globally as localStorage.

    API

  • getItem(key) - get item by key

  • setItem(key, value) - insert new item
  • clear() - clear storage
  • length - number of items in storage

    Note: 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.