JSPM

  • Created
  • Published
  • Downloads 9484300
  • Score
    100M100P100Q205356F
  • License BSD

Easily load and save config without having to think about where and how

Package Exports

  • configstore

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 (configstore) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

configstore Build Status

Easily load and persist config without having to think about where and how

Config is stored in a JSON file located in $XDG_CONFIG_HOME or ~/.config. Eg: ~/.config/configstore/some-id.json

Usage

var Configstore = require('configstore');
var pkg = require('./package.json');

// Init a Configstore instance with an unique ID eg. package name
// and optionally some default values
var conf = new Configstore(pkg.name, {foo: 'bar'});

conf.set('awesome', true);
console.log(conf.get('awesome'));  // true
console.log(conf.get('foo'));      // bar

conf.del('awesome');
console.log(conf.get('awesome'));  // undefined

API

.set(key, value)

Set an item.

.get(key)

Get an item.

.del(key)

Delete an item.

.all

Get all items as an object or replace the current config with an object:

conf.all = {
    hello: 'world'
};

.size

Get the item count.

.path

Get the path to the config file. Can be used to show the user where the config file is located or even better open it for them.

License

BSD license
Copyright Google