Package Exports
- data-store
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (data-store) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
data-store 
Easily get, set and persist config data.
Install with npm
npm i data-store --save
Run tests
npm test
Usage
var Store = require('data-store');
Example
var store = new Store('foo');
store
.set('a', 'b')
.set('c', 'd')
.set('e', 'f');
store.save();
store.omit('a');
console.log(store.get());
API
Store
Initialize a new Store
with the given name
and options
.
name
{String}: Store name.foo
would result in.foo.json
base
{String}: Dest base. If not defined, the user home directory is used, based on OS.
var store = new Store('bar', 'foo');
//=> './foo/.bar.json'
var store = new Store('baz');
//=> '~/data-store/.baz.json'
.set
Assign value
to key
and save to disk. Can be a key-value pair or an object.
key
{String}val
{*}: The value to save tokey
. Must be a valid JSON type: String, Number, Array or Object.returns
{Object}Store
: for chaining
store.set('foo', 'bar');
// or
store.set({foo: 'bar'});
.get
Get the stored value
of key
, or return all stored values if no key
is defined.
key
{String}returns
{*}: The stored value ofkey
.
store.set('foo', 'bar');
store.get('foo');
//=> 'bar'
.exists
Returns true
if the specified key
exists.
key
{String}returns
{Boolean}: Returns true ifkey
exists
store.set('foo', 'bar');
store.exists('foo');
//=> true
.save
Save the store to disk.
dest
{String}: Optionally define an alternate destination.
store.save();
.omit
Delete a property or array of properties from the store then re-save the store.
key
{String|Array}: The key(s) to omit from the storereturns
{Object}Store
: for chaining
store.omit('foo');
// or
store.omit(['foo', 'bar']);
.delete
Delete the entire store. You must pass {force: true}
if the path is outside the current working directory.
store.delete({force: true});
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue
Author
Jon Schlinkert
License
Copyright (c) 2014 Jon Schlinkert
Released under the MIT license
This file was generated by verb on December 17, 2014.