# electron-save

> A module for cross platform saving and loading

Latest version **1.1.0** (published 2016-09-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install electron-save
pnpm add electron-save
yarn add electron-save
bun add electron-save
```

## 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 | 1.1.0 |
| Published | 2016-09-07 |
| First published | 2016-09-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | JDB |
| Maintainers | legodude |
| Keywords | electron, save, file |

## Links

- npm: https://www.npmjs.com/package/electron-save
- Repository: https://github.com/legodude17/electron-save
- Homepage: https://github.com/legodude17/electron-save#readme
- npm.io page: https://npm.io/package/electron-save

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 1.1.0 (latest) — 2016-09-07
- 1.0.0 — 2016-09-07

## README

# electron-save
A way to save and then load them.

## Usage
```js
var load = require('electron-save');
load('world', function(err, config) {
  if (err) {
    return console.error(err);
  }
  console.log('Loaded ' + config.path);
  var hello = config.get('hello');
  config.set('hello', hello || 'hello');
  config.save(function (err) {
    if (err) {
      return console.error(err);
    }
    console.log('File saved to ' + config.path);
  });
});
```

## API

### load(name, cb)
Calling `load` is what actually gets a config.
##### Args
name (String): name of file to load
cb: (function(err, config)): Called with config object

### load.sync(name)
Synchronous alternative to `load`. Returns config or throws error. config object is the same except for the `save` method, which is also sync.

### config.get(key)
Get `key` from the loaded `config`.

### config.getAll()
Get all keys and values from `config` as an object.
NOTE: Does not return actual object, just a copy.

### config.set(key, value)
Set `key` to `value`. The file will be updated once you call `config.save`.

### config.setAll(obj)
Set `config`'s object to `obj`. `obj` must be JSON-safe.
NOTE: Will not set `config`'s object to a reference to `obj`, it will be a copy.

### config.save(cb)
Write the config file with JSON encoded version of `config`'s object.
NOTE: If the config was gotten with `load.sync`, this method is also sync.

### config.path
Resolved path to JSON file holding this `config`.

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