0.0.5 • Published 5 years ago

cat-box v0.0.5

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

Cat-box

Unique wrapper for web localStorage and React-Native's AsyncStorage

Installation

npm install -s cat-box

Usage

import {
  storageGet,
  storageSet,
  storageRemove
} from 'cat-box';

storageSet(keys, defaultValue)

keys should be object with values, also it's possilbe to pass array with keys or just a key name Promise is returned.

storageSet({
  a: 'Some value'
}).then(v => console.log(v)); // {a: 'Some value'}
storageSet(['c', 'd'], -1).then(v => console.log(v)); // {c: -1, d: -1}
storageSet('myKey', 100).then(v => console.log(v)); // {myKey: 100}

storageGet(keys)

keys can be array of the keys, object with any values (keys will be used) or just a key name Promise is returned, you should use .then to get the values

storageGet({
  a: true,
  b: true,
  myKey: true
}).then(v => console.log(v)); // {a: 'Some value', b: null, myKey: 100}
storageGet(['a','c'])
  .then(v => console.log(v)); // {a: 'Some value', c: -1}
storageGet('a')
  .then(v => console.log(v)); // {a: 'Some value'}

storageRemove(keys)

keys can be array of the keys, object with any values (keys will be used) or just a key name Promise is returned

storageRemove({
  a: true,
  b: true,
  myKey: true
}).then(v => console.log(v)); // {a: null, b: null, myKey: null}
storageRemove(['c','d'])
  .then(v => console.log(v)); // {a: null, c: null}
storageRemove('a')
  .then(v => console.log(v)); // {a: null}
0.0.5

5 years ago

0.0.4

6 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago