yields-store

1.0.2 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i yields-store

Weekly Downloads

66,069

Version

1.0.2

License

MIT

Last publish

Collaborators

  • yields
  • pirxpilot