@wranggle/storage-config-file-adapter
v0.2.4
Published
Use Conf as underlying json file store for WranggleStorage feature layers
Downloads
14
Maintainers
Readme
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:
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 ```
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')
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) });