# userdefaults

> User defaults for NodeJS

Latest version **3.0.0** (published 2017-05-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install userdefaults
pnpm add userdefaults
yarn add userdefaults
bun add userdefaults
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2017-05-10 |
| First published | 2015-11-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Jensen Bernard |
| Maintainers | jense5 |
| Keywords | node-user-defaults |

## Links

- npm: https://www.npmjs.com/package/userdefaults
- Repository: https://github.com/Jense5/node-user-defaults
- Homepage: https://github.com/Jense5/node-user-defaults#readme
- Issues: https://github.com/Jense5/node-user-defaults/issues
- npm.io page: https://npm.io/package/userdefaults

## Dependencies (2)

- [untildify](https://npm.io/package/untildify.md) ^3.0.2
- [randomstring](https://npm.io/package/randomstring.md) ^1.1.5

## Recent versions

- 3.0.0 (latest) — 2017-05-10
- 1.0.2 — 2016-10-15
- 1.0.0 — 2015-11-18
- 0.0.5 — 2015-11-18
- 0.0.4 — 2015-11-18
- 0.0.3 — 2015-11-17
- 0.0.2 — 2015-11-17
- 0.0.1 — 2015-11-17

## README

# Node User Defaults

Persistent data store for node apps.

[**This module is renamed to node-user-defaults! Do not use this one anymore, as it won't receive updates in the future!**](https://www.npmjs.com/package/node-user-defaults)

### Getting Started

The goal of this library is to provide a very straighforward way to write persistent data to disk. This can be useful when working with small amounts of data, like a simple configuration of an application or to store some preferences of a user. All data is stored in JSON format.

```sh
# Add the lib to your project and you are good to go.
$ yarn add node-user-defaults

# Not in a hurry? Use npm.
$ npm install --save node-user-defaults
```

#### Sample Code

```js
import Store from 'node-user-defaults';

// OPTIONAL: Choose an output location for the JSON file.
// If this one is not provided, a random one will be created.
// You can always check the location via Store.getLocation().
Store.setLocation('~/.app-name');

// Storing variables is very easy and straighforward.
// You can store any type that is supported by JSON.
Store.write('darkTheme', true);

// Reading data is easy too. It's also possible to provide
// a default value in case the variable is not in the store.
const darkTheme = Store.read('darkTheme');
const name = Store.read('name', 'defaultValue');

// You can also write multiple variables at once by storing
// a plan JSON object. Easy huh?
Store.writeJson({ name: 'John' });

// Last but not least, you can query all the variables at once.
const data = Store.defaults();
```

#### Running the tests

```
$ git clone https://github.com/Jense5/node-user-defaults
$ cd node-user-defaults
$ yarn install
$ yarn test
```

#### Credits

* **Jensen Bernard** - Initial work & maintenance - [Jense5](https://twitter.com/Jense5_)

This project is licensed under the MIT License - see the [license](LICENSE.md) file for details.

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