1.0.24 • Published 10 months ago

nw-storage v1.0.24

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months 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

11 months ago

1.0.18

11 months ago

1.0.17

11 months ago

1.0.16

11 months ago

1.0.22

10 months ago

1.0.21

11 months ago

1.0.20

11 months ago

1.0.24

10 months ago

1.0.23

10 months ago

1.0.11

12 months ago

1.0.15

11 months ago

1.0.14

11 months ago

1.0.13

11 months ago

1.0.12

11 months ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago