prefs

    1.1.4 • Public • Published

    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

    Install

    npm i prefs

    DownloadsWeekly Downloads

    27

    Version

    1.1.4

    License

    MIT

    Unpacked Size

    8.02 kB

    Total Files

    4

    Last publish

    Collaborators

    • thisseasx