Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Path from 'path';
- import AppPaths from 'app-paths';
- import Persist from 'auto-persister';
- let settings = Persist.manageFile({
- path: Path.join(ApPaths.ConfigFile, 'default.myapp-settings'),
- json: true, // read & write will marshall JSON automatically
- autocreate: true, // file (and parent dirs) will be immediately created if they don't already exist
- initialData: DefaultSettings, // value that will be returned if file doesn't exist, and that will be written if autocreate true
- // all other options are passed to underlying FS methods
- encoding: 'utf8',
- ...
- });
- // invoke whenever to write data into the file
- settings.write({ data: someObj, async: true })
- // invoke whenever to read data from file
- settings.read({ async: true })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement