Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

data-store

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

data-store

Easily get, set and persist config data.

  • 0.3.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
30K
decreased by-27.05%
Maintainers
1
Weekly downloads
 
Created
Source

data-store NPM version

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 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'

.exists

Returns true if the specified key exists.

  • key {String}
  • returns {Boolean}: Returns true if key 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 store
  • returns {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.

Keywords

FAQs

Package last updated on 17 Dec 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc