# configstore-fork

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

Latest version **3.1.6** (published 2018-01-24) · BSD-2-Clause license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install configstore-fork
pnpm add configstore-fork
yarn add configstore-fork
bun add configstore-fork
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 3.1.6 |
| Published | 2018-01-24 |
| First published | 2018-01-24 |
| Weekly downloads | 0 |
| License | BSD-2-Clause |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=4 |
| Dependencies | 6 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Jason Dent |
| Maintainers | jason-dent |
| Keywords | config, store, storage, conf, configuration, settings, preferences, json, data, persist, persistent, save |

## Links

- npm: https://www.npmjs.com/package/configstore-fork
- Repository: https://github.com/jason3s/configstore
- Homepage: https://github.com/jason3s/configstore#readme
- Issues: https://github.com/jason3s/configstore/issues
- npm.io page: https://npm.io/package/configstore-fork

## Dependencies (6)

- [dot-prop](https://npm.io/package/dot-prop.md) ^4.1.0
- [make-dir](https://npm.io/package/make-dir.md) ^1.0.0
- [graceful-fs](https://npm.io/package/graceful-fs.md) ^4.1.2
- [xdg-basedir](https://npm.io/package/xdg-basedir.md) ^3.0.0
- [unique-string](https://npm.io/package/unique-string.md) ^1.0.0
- [write-file-atomic](https://npm.io/package/write-file-atomic.md) ^2.0.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 3.1.6 (latest) — 2018-01-24
- 3.1.5 — 2018-01-24
- 3.1.3 — 2018-01-24

## README

# Note this is a fork of [configstore](https://github.com/yeoman/configstore)

This fork only contains minor differences:
1. Reads are side effect free
1. Only create the store directory on write if it does not exist
1. Only writes to the store if there is something to write

This fork is not meant to be a general replacement for [configstore](https://github.com/yeoman/configstore).
It was solely created to solve issues relating to the changes above.
All credit for this package should go to the original authors.

# configstore [![Build Status](https://travis-ci.org/yeoman/configstore.svg?branch=master)](https://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`.<br>
Example: `~/.config/configstore/some-id.json`

*If you need this for Electron, check out [`electron-store`](https://github.com/sindresorhus/electron-store) instead.*


## Usage

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

// create a Configstore instance with an unique ID e.g.
// Package name and optionally some default values
const conf = new Configstore(pkg.name, {foo: 'bar'});

console.log(conf.get('foo'));
//=> 'bar'

conf.set('awesome', true);
console.log(conf.get('awesome'));
//=> true

// Use dot-notation to access nested properties
conf.set('bar.baz', true);
console.log(conf.get('bar'));
//=> {baz: true}

conf.delete('awesome');
console.log(conf.get('awesome'));
//=> undefined
```


## API

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

Returns a new instance.

#### packageName

Type: `string`

Name of your package.

#### defaults

Type: `Object`

Default config.

#### options

##### globalConfigPath

Type: `boolean`<br>
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.

### Instance

You can use [dot-notation](https://github.com/sindresorhus/dot-prop) in a `key` to access nested properties.

### .set(key, value)

Set an item.

### .set(object)

Set multiple items at once.

### .get(key)

Get an item.

### .has(key)

Check if an item exists.

### .delete(key)

Delete an item.

### .clear()

Delete all items.

### .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.

### .all

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

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


## License

[BSD license](http://opensource.org/licenses/bsd-license.php)<br>
Copyright Google

---
_Source: https://npm.io/package/configstore-fork · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
