šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
Sign inDemoInstall
Socket

localstorage-mock

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

localstorage-mock

A mock implementation of localStorage for testing.

1.0.2
latest
Source
npm
Version published
Maintainers
1
Created
Source

localstorage-mock

A mock implementation of Window.localStorage.

Usage

  • Install package:
  • npm i localstorage-mock --save-dev
  • 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.

Keywords

localStorage

FAQs

Package last updated on 08 Jul 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts