Socket
Socket
Sign inDemoInstall

expired-localstorage

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    expired-localstorage

A library of cache based on localStorage that supports expired storage.


Version published
Weekly downloads
3
increased by50%
Maintainers
1
Install size
6.36 kB
Created
Weekly downloads
 

Readme

Source

expired-localstorage

A library of cache based on localStorage that supports expired storage.

Installing

Using unpkg CDN

<script src="https://unpkg.com/expired-localstorage@1.0.3/index.js"></script>

Using npm

npm install expired-localstorage --save-dev

Usage

CommonJS usage

const LS = require('expired-localstorage')

Code in Javascript

//get data
LS.get('test');
//set data with expires time
LS.set('test', 123, 60000);
//remove data
LS.remove('test');
//clear all data
LS.clear();

Method Description

Get value from localStorage

LS.get(key)

  • {String} key -> key name.(required)

Set value by localStorage

LS.set(key, value, time)

  • {String} key -> key name.(required)
  • {Any} value -> data value.(required)
  • {Number} time -> expires time, unit is ms, such as passing 60000, that means 1 minute. No value, no expiration.(optional)

Remove data from localStorage

LS.remove(key)

  • {String} key -> key name.(required)

Clear all cached data

LS.clear()

License

expired-localstorage is MIT licensed.

Keywords

FAQs

Last updated on 14 Nov 2022

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc