1.1.6 • Published 2 months ago

stores.js v1.1.6

Weekly downloads
19
License
MIT
Repository
github
Last release
2 months ago

本地数据存取,由于localStorage没有失效时间。使用stores.js会处理失效时间

Build Status Coverage Status npm package NPM downloads

Install

npm install stores.js --save

Usage

import Store from 'stores.js';

const store = new Store('test', '1Y1m', {
  prefix: 'NG_',
  type: 'localStorage',
});

// 设置值
store.set({ name: 'store name' });

// 获取test值
store.get();

API

new Store 参数配置

参数说明类型默认值
name存取名字string
expire失效时间 年/月/日/小时/分/秒 1Y/1M/1d/1h/2m/1sstring默认失效时间为7天
options参数配置object

options 参数配置

参数说明类型默认值
prefix前缀名字,为了清除localStorage失效数据string
type存取分别为localStorage/sessionStoragestring默认localStorage

创建const store = new Store('test')实例,store提供的 API 如下

参数说明类型return调用方式
has判断本地存储的数据是否失效booleanstore.has({ id: 1 })
get获取本地存储的数据datastore.get()
set设置本地数据ObjectArrayStringNumberbooleanstore.set('date test===',{})
delete删除本地数据booleanstore.delete()
clear清除前缀prefix本地数据store.clear()
clearAll清除全部本地数据store.clearAll()
1.1.6

2 months ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

5 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago