1.1.4 • Published 4 years ago

prefs v1.1.4

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

Prefs.js

An easy-to-use library providing a simple interface for saving and retrieving key-value pairs in JSON format.

Installation

$ npm install prefs

Usage

const prefs = require('prefs');
const { load, add, remove, clear } = prefs('./path/to/config');

// or in a shorter way

const { load, add, remove, clear } = require('prefs')('./path/to/config');

To start using prefs, you need to specify a path where the /config directory will be created, containing the preference files.

e.g.

const { load, add, remove, clear } = require('prefs')(__dirname);

Add a preference

add({ name: 'John', surname: 'Doe' });

Load preferences

load(); // => { name: 'John', surname: 'Doe' })

Edit a preference

add({ name: 'Jane' }); // => { name: 'Jane', surname: 'Doe' })

Remove a preference

remove('surname'); // => { name: 'Jane' }

Clear all preferences

clear(); // => {}

License

MIT

1.1.4

4 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago