Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

yields-store

yields45.2kMIT1.0.2

minimal store inspired by component/cookie

browser

readme

store

minimal store inspired by component/cookie

Installation

$ component install yields/store

Example

store('foo', ['baz']);
store('foo'); // > ['baz']
store({ foo: 'baz' });
store('foo'); // > 'baz'
store('foo', null);
store('foo'); // > null
store('baz', 0);
store(); // > { baz: 0 }
store(null);
store(); // > {}

API

store(key, val)

set key to val, the value will be JSON.stringify()ied.

store(obj)

store the given object.

store(key, null)

remove key.

store(key)

get key value, it will be unserialized.

store(null)

invokes localStorage.clear()

store()

get all items, they will be unserialized.

License

MIT

changelog

1.0.2 / 2015-01-01

  • fix: add try/catch for blocked localstorage access (safari throws)

1.0.1 / 2014-09-24

  • add component.json

1.0.0 / 2014-08-18

  • duo

0.2.0 / 2013-05-28

  • added ability to set objects [ianstormtaylor]

0.1.0 / 2013-04-25

  • add .supported, export methods

0.0.1 / 2013-04-20

  • initial commit