Package Exports
- prefs
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (prefs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
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(); // => {}