memory-key-value-store
In Memory Key Value Datastore with option to associate multiple keys to an object and object keys
npm install --save memory-key-value-store
Example Usage
const memoryKeyValueStore = ; const store = ; store;store;
API
Note that in all cases, simple javascript objects as well as numbers can be used for keys. All keys get converted to strings internally. Javascript objects are serialized using json-stable-stringify
Also note that values should always be javascript objects if you intend on using the save
method.
Methods
find
Find item by its key. Returns null
if item is not found.
store;
save
Create a new item, or extend the old one.
store;store;// the final value is: { foo: 'bar', ball: 'bash', car: 'mash' }
set
Create a new item or replace the old one.
store;store;// the final value is: { ball: 'bash', car: 'mash' }
delete
Delete an item by its key (has no effect if the item doesnt already exist)
store;
secondaryKey
Associate two keys with a reference to the same value. This will cause subsequent calls to edit the values of either key to edit the values of both keys.
store;store;// the value of "b" is now also { foo: 'bar' }
You can optionally associate an array of keys with the original
store;
Method Chaining
The methods: save
, set
, delete
, and secondaryKey
can be chained
store ;
Development
To setup the development environment and run tests:
npm install
flow-typed install
gulp test