/store.js

封装localstorage的api,并引入expires

Primary LanguageHTML

store : object

Kind: global namespace

store.each(callback)

遍历 store

Kind: static method of store

Param Type Description
callback function 参数为key, val(过期key的val在localstorage有 值,但取值会为空)

store.expired(key) ⇒

判断key是否过期,没有返回key的值,过期返回false

Kind: static method of store Returns: expired

Param Type
key string

store.get(key) ⇒

通过key获取store的value值(不包含过期的)

Kind: static method of store Returns: vaule || object

Param Type Description
key string 可以为string或空,为空时取所有的localstorage

store.del(key) ⇒

删除store某个key及值

Kind: static method of store Returns: store

Param Type Description
key string string

store.clear(key) ⇒

清除所有store存储

Kind: static method of store Returns: store

Param Type Description
key string string

store.clean(key) ⇒

清除所有已过期的store存储, 运行时即执行

Kind: static method of store Returns: store

Param Type Description
key string string

store.has(key) ⇒

判断某key是否存在

Kind: static method of store Returns: boolean

Param Type Description
key string string

store.size(unit) ⇒

获取store已存储的大小

Kind: static method of store Returns: int

Param Type Description
unit string 单位默认返回bytes,可以为KB, MB;

Licence

The MIT License

Copyright (c) 2015 Joe github.com@ccjoe