2.1.7 • Published 3 months ago

zstorage v2.1.7

Weekly downloads
2
License
WTFPL
Repository
github
Last release
3 months ago

zstorage

the localStorage that has expired time

NPM version npm FOSSA Status codecov

Install

$ npm install zstorage --save

Test

$ git clone https://github.com/klren0312/localStorage_hasExpiration.git
$ cd localStorage_hasExpiration
$ npm install
$ npm run test

Use

you can see example in ./index.html

import Storage from 'zstorage'
Storage.set('test', {t:1,b:2}, 5)
console.log('current,', Storage.get('test'))
setTimeout(() => console.log('after 5s,', Storage.get('test')), 5000)

Api

get (key)

get the value by key from localStorage

param: 
  key
return:
  null (expired)
  value (not expired)

set (key, value, expired_second)

set the localStorage, with key, value and expired_second(unit: s)

Tips: You'll not use JSON.stringify() to stringify Object or Array

param:
  key
  value
  expired_second
return

remove (key)

remove the value by key from localStorage

param:
  key
return

clear ()

clear all values from localStorage

License

FOSSA Status

2.1.6

3 months ago

2.1.7

3 months ago

2.1.1

2 years ago

2.1.0

2 years ago

2.0.0

4 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.4

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago