1.0.24 • Published 2 years ago

nw-storage v1.0.24

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

本地存储

使用浏览器APIlocalStorage实现,仅限浏览器端使用

安装

npm i nw-storage

API

setStorage 设置缓存

  • 类型定义
/**
 * @param   {string}  key     [key]
 * @param   {any}     value   [value]
 * @param   {number}  expire  [expire 过期时间,如: 24 * 60 * 60 = 1天]
 * @return  {void}            [return]
 */
declare const setStorage: (key: string, value: any, expire?: number) => void;
  • 使用,过期时间格式,参考上类型定义中说明
import { setStorage } from 'nw-storage'

setStorage('name', 1) // NAME => 1

getStorage 获取缓存

  • 使用, 如果缓存设置了有效期,失效则返回null
import { getStorage } from 'nw-storage'

getStorage('name') // 1

removeStorage 移除缓存

  • 使用
import { removeStorage } from 'nw-storage'

removeStorage('name') // null

setStorageNameSpace 设置缓存命名空间

  • 使用
import { setStorageNameSpace } from 'nw-storage'

setStorageNameSpace('nw') // NW-NAME => 1
1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.22

2 years ago

1.0.21

2 years ago

1.0.20

2 years ago

1.0.24

2 years ago

1.0.23

2 years ago

1.0.11

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago