@wranggle/storage-config-file-adapter
TypeScript icon, indicating that this package has built-in type declarations

0.2.4 • Public • Published

ConfigFileAdapter

The ConfigFileAdapter lets WranggleStorage use sindresorhus/conf for its underlying persistent store, saving data in a json file in a Node environment.

Constructing WranggleStorage with ConfigFileAdapter

Pass your Conf instance to WranggleStorage using the conf shortcut:

const config  = new Conf({ configName: 'user-prefs' });
const store = new WranggleStorage({ conf: config }); 

This works with the Conf-based electron-store as well:

const ElectronStore = require('electron-store');
const conf = new ElectronStore();
const store = new WranggleStorage({ conf }); 

Installing From Individual Packages

The @wranggle/storage-node bundle includes the ConfigFileAdapter as a dependency, plus most main feature layers.

Or you can add/install individual packages:

  1. Add the @wranggle/storage-core and @wranggle/storage-config-file-adapter packages to your project:

    # From the command line using yarn:
    yarn add @wranggle/storage-core @wranggle/storage-config-file-adapter
    
    # or with npm:
    npm install @wranggle/storage-core @wranggle/storage-config-file-adapter    ```
    
  2. In your JavaScript, import or require the packages:

    import WranggleStorage from '@wranggle/storage-core'; 
    import ConfigFileAdapter from '@wranggle/storage-config-file-adapter'
    // or:
    const WranggleStorage = require('@wranggle/storage-core');
    const ConfigFileAdapter = require('@wranggle/storage-config-file-adapter')
  3. Instantiate your store:

    const store = new WranggleStorage({ conf }); // using the "conf" shortcut (see above)

    Or do so without the construction shortcut:

    const conf = new Conf({ configName: 'user-prefs' });
    const store = new WranggleStorage({ persist: new ConfigFileAdapter(conf) });

Package Sidebar

Install

npm i @wranggle/storage-config-file-adapter

Weekly Downloads

3

Version

0.2.4

License

Apache-2.0

Unpacked Size

30.6 kB

Total Files

21

Last publish

Collaborators

  • wranggle.ferbs