Advertisement
Guest User

Untitled

a guest
Apr 30th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. import Path from 'path';
  2. import AppPaths from 'app-paths';
  3. import Persist from 'auto-persister';
  4.  
  5.  
  6. let settings = Persist.manageFile({
  7. path: Path.join(ApPaths.ConfigFile, 'default.myapp-settings'),
  8. json: true, // read & write will marshall JSON automatically
  9. autocreate: true, // file (and parent dirs) will be immediately created if they don't already exist
  10. initialData: DefaultSettings, // value that will be returned if file doesn't exist, and that will be written if autocreate true
  11. // all other options are passed to underlying FS methods
  12. encoding: 'utf8',
  13. ...
  14. });
  15.  
  16.  
  17. // invoke whenever to write data into the file
  18. settings.write({ data: someObj, async: true })
  19.  
  20.  
  21. // invoke whenever to read data from file
  22. settings.read({ async: true })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement