2.0.2 • Published 9 years ago

client-storage v2.0.2

Weekly downloads
3
License
ISC
Repository
github
Last release
9 years ago

client-storage

clientStoragelocalStorage的基础上支持集合


API

clientStoragewindow.localStorage的API基本一一对应,但也有特殊,例如.length

clientStorage 的属性&方法

  • setItem(key, value)
  • getItem(key)
  • removeItem(key)
  • clear()
  • key(number)
  • getLength()
  • Collection(name)

创建集合

var todos = new clientStorage.Collection('todos');

"集合对象"的属性&方法

  • create(model)
  • update(id, data)
  • destroy(id)
  • destroyAll()
  • find(id)
  • findAll()
  • getLength()

异步风格

上面的API是同步返回数据,下面的配置可以使返回值为Promise对象

clientStorage.config('async', true);

兼容

  • clientStorage是在window.localStorage上扩展的
  • 当使用参数async,使用了浏览器原生的Promise构造函数

由于上面两点,clientStorage存在很多兼容问题

注意: 传入参数async,只是其接口是promise对象,其实内部是同步执行的

2.0.2

9 years ago

2.0.1

9 years ago

2.0.0

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago