Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ccjoe/store.js

封装localstorage的api,并引入expires
https://github.com/ccjoe/store.js

Last synced: 18 days ago
JSON representation

封装localstorage的api,并引入expires

Awesome Lists containing this project

README

        

## store : object
**Kind**: global namespace

* [store](#store) : object
* [.each(callback)](#store.each)
* [.expired(key)](#store.expired) ⇒
* [.get(key)](#store.get) ⇒
* [.del(key)](#store.del) ⇒
* [.clear(key)](#store.clear) ⇒
* [.clean(key)](#store.clean) ⇒
* [.has(key)](#store.has) ⇒
* [.size(unit)](#store.size) ⇒

### store.each(callback)
遍历 store

**Kind**: static method of [store](#store)

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

### store.expired(key) ⇒
判断key是否过期,没有返回key的值,过期返回false

**Kind**: static method of [store](#store)
**Returns**: expired

| Param | Type |
| --- | --- |
| key | string |

### store.get(key) ⇒
通过key获取store的value值(不包含过期的)

**Kind**: static method of [store](#store)
**Returns**: vaule || object

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

### store.del(key) ⇒
删除store某个key及值

**Kind**: static method of [store](#store)
**Returns**: store

| Param | Type | Description |
| --- | --- | --- |
| key | string | string |

### store.clear(key) ⇒
清除所有store存储

**Kind**: static method of [store](#store)
**Returns**: store

| Param | Type | Description |
| --- | --- | --- |
| key | string | string |

### store.clean(key) ⇒
清除所有已过期的store存储, 运行时即执行

**Kind**: static method of [store](#store)
**Returns**: store

| Param | Type | Description |
| --- | --- | --- |
| key | string | string |

### store.has(key) ⇒
判断某key是否存在

**Kind**: static method of [store](#store)
**Returns**: boolean

| Param | Type | Description |
| --- | --- | --- |
| key | string | string |

### store.size(unit) ⇒
获取store已存储的大小

**Kind**: static method of [store](#store)
**Returns**: int

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

## Licence ##

The MIT License

Copyright (c) 2015 Joe github.com@ccjoe