GithubHelp home page GithubHelp logo

store's Introduction

h5store

这是带有过期时间的h5数据存储组件支持sessionStorage,localStorage

该存储组件可以用方便数据读取

PRs Welcome NPM version License MIT

Content

Installation

  • 1.Run npm i h5store --save
  • 2.import store from 'h5store'

Getting started

Add store to your js file.

import store from 'store'

sessionStorage use:

// save
store.sset('key', value);

// read
const value = store.sget('key');

// read set default value {}
const value = store.sget('key', {});

// delete 
store.sset('key', null);

// clear
store.sclear();

sessionStorage expiration time use:

// save set expiration time 1m
store.sset('key', value, 1000 * 60);

localStorage use:

// save
store.lset('key', value);

// read
const value = store.lget('key');

// read set default value {}
const value = store.lget('key', {});

// delete 
store.lset('key', null);

// clear
store.lclear();

localStorage expiration time use:

// save set expiration time 1m
store.lset('key', value, 1000 * 60);

API

Method Type Optional Description
sset(string, any, number) function true sessionStorage save
sget(string, any) function true sessionStorage read
sclear() function true sessionStorage clear
lset(string, any, number) function true localStorage save
lget(string, any) function true localStorage read
lclear() function true localStorage clear
clearAll() function true localStorage,sessionStorage clear

Contribution

Issues are welcome. Please add a screenshot of bug and code snippet. Quickest way to solve issue is to reproduce it on one of the examples.

Pull requests are welcome. If you want to change API or making something big better to create issue and discuss it first.


MIT Licensed

store's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.