JSPM

  • Created
  • Published
  • Downloads 43302
  • Score
    100M100P100Q133146F

Easily get, set and persist config data.

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 NPM version

Easily get, set and persist config data.

Install

Install with npm

npm i data-store --save

Run tests

npm test

Usage

var dataStore = require('data-store');

API

Store

Initialize a new Store with the given name and options.

  • name {String}: Dest file name. foo would result in .foo.json
  • dest {String}: Dest directory. If not defined, the user home directory for the current OS is used.
var store = new Store('bar', 'foo');
//=> saves `{}` to 'foo/.bar.json'

var store = new Store('baz');
//=> saves `{}` to '~/data-store/.baz.json'

.set

Assign value to key and save to disk.

  • key {String}
  • val {*}: The value to save to key. 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 of key.
store.set('foo', 'bar');
store.get('foo');
//=> 'bar'

.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 store
store.omit('foo');
// or
store.omit(['foo', 'bar']);

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 November 15, 2014.