New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

storage-plus

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

storage-plus

StoragePlus - A functional wrapper around native localStorage

latest
Source
npmnpm
Version
1.0.1
Version published
Weekly downloads
5
66.67%
Maintainers
1
Weekly downloads
 
Created
Source

StoragePlus

StoragePlus is a functional wrapper around native localStorage.

The main differences with localStorage:

  • no need for JSON.stringify/parse
  • support setting cache time

Install

yarn add storage-plus
# or
npm install storage-plus --save

Usage

import storagePlus from 'storage-plus';

var userInfo = { age: 10, name: 'Jack' };
var cacheTime = 7 * 24 * 3600 * 1000; // expired after seven days

storagePlus.setItem('userInfo', userInfo, cacheTime);
storagePlus.getItem('userInfo');
// => { age: 10, name: 'Jack' }
storagePlus.removeItem('userInfo');

Standalone build available as dist/storage-plus.min.js.

<script src="./node_modules/storage-plus/dist/storage-plus.min.js"></script>
<script>
  storagePlus.setItem('flag', true, 1000);
</script>

API

storagePlus.setItem(key, value, [cacheTime])

Set key to value with cacheTime(optional).

storagePlus.getItem(key)

Get key's value. If expired, return null.

storagePlus.removeItem(key)

Same as localStorage.removeItem(key).

License

Copyright © 2017 MaqicStudio - MIT License

Keywords

localStorage

FAQs

Package last updated on 27 Apr 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