Sha256: 3425a3e4e843036aa7985f19c9db4ca777e67d746eaaff24393868706d2d48d5

Contents?: true

Size: 1.89 KB

Versions: 62

Compression:

Stored size: 1.89 KB

Contents

# configstore [![Build Status](https://secure.travis-ci.org/yeoman/configstore.svg?branch=master)](http://travis-ci.org/yeoman/configstore)

> 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`.  
Example: `~/.config/configstore/some-id.json`


## Usage

```js
const Configstore = require('configstore');
const pkg = require('./package.json');

// Init a Configstore instance with an unique ID e.g.
// package name and optionally some default values
const 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

### Configstore(packageName, [defaults], [options])

Create a new Configstore instance `config`.

#### packageName

Type: `string`

Name of your package.

#### defaults

Type: `object`

Default content to init the config store with.

#### options

Type: `object`

##### globalConfigPath

Type: `boolean`  
Default: `false`

Store the config at `$CONFIG/package-name/config.json` instead of the default `$CONFIG/configstore/package-name.json`. This is not recommended as you might end up conflicting with other tools, rendering the "without having to think" idea moot.

### config.set(key, value)

Set an item.

### config.get(key)

Get an item.

### config.del(key)

Delete an item.

### config.clear()

Delete all items.

### config.all

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

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

### config.size

Get the item count.

### config.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](http://opensource.org/licenses/bsd-license.php)  
Copyright Google

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
trusty-festivity-extension-2.3.21 node_modules/bower/node_modules/insight/node_modules/configstore/readme.md
trusty-festivity-extension-2.3.20 node_modules/bower/node_modules/insight/node_modules/configstore/readme.md
trusty-festivity-extension-2.3.19 node_modules/bower/node_modules/insight/node_modules/configstore/readme.md
trusty-festivity-extension-2.3.18 node_modules/bower/node_modules/insight/node_modules/configstore/readme.md
trusty-festivity-extension-2.3.17 node_modules/bower/node_modules/insight/node_modules/configstore/readme.md
trusty-festivity-extension-2.3.16 node_modules/bower/node_modules/insight/node_modules/configstore/readme.md
trusty-festivity-extension-2.3.15 node_modules/bower/node_modules/insight/node_modules/configstore/readme.md
trusty-festivity-extension-2.3.14 node_modules/bower/node_modules/insight/node_modules/configstore/readme.md
trusty-festivity-extension-2.3.13 node_modules/bower/node_modules/insight/node_modules/configstore/readme.md
trusty-festivity-extension-2.3.12 node_modules/bower/node_modules/insight/node_modules/configstore/readme.md
trusty-festivity-extension-2.3.11g node_modules/bower/node_modules/insight/node_modules/configstore/readme.md
trusty-festivity-extension-2.3.10 node_modules/bower/node_modules/insight/node_modules/configstore/readme.md
trusty-festivity-extension-2.3.9 node_modules/bower/node_modules/insight/node_modules/configstore/readme.md
trusty-festivity-extension-2.3.8 node_modules/bower/node_modules/insight/node_modules/configstore/readme.md
trusty-festivity-extension-2.3.7 node_modules/bower/node_modules/insight/node_modules/configstore/readme.md
trusty-festivity-extension-2.3.6 node_modules/bower/node_modules/insight/node_modules/configstore/readme.md
trusty-festivity-extension-2.3.5 node_modules/bower/node_modules/insight/node_modules/configstore/readme.md
trusty-festivity-extension-2.3.4 node_modules/bower/node_modules/insight/node_modules/configstore/readme.md
trusty-festivity-extension-2.3.3 node_modules/bower/node_modules/insight/node_modules/configstore/readme.md
trusty-festivity-extension-2.3.2 node_modules/bower/node_modules/insight/node_modules/configstore/readme.md