pojo-stick
v0.1.0
Published
Sync a plain-old-javascript-object with a local json file - in 1 line of code!
Downloads
2
Maintainers
Readme
pojo-stick
:paperclip: Sync a plain-old-javascript-object (POJO) with a local json file - in 1 line of code!
This project is a work in progress. API is subject to change. Issues, Enhancement Ideas, and Pull Requests are very welcome.
Usage
Install with npm:
npm install --save pojo-stick
Simply require and instantiate. That's it.
const pojoStick = require('pojo-stick')
const obj = await pojoStick('/some/save/path')
// EXAMPLE:
// when I change an value under `obj`, it will automatically save to the fileSystem
obj.data = { automaticallySaves: true }
// it also works with sub-properties too
obj.data.array = []
obj.data.array.push('I can push values!')
Or more concisely:
const data = await require('pojo-stick')('/path/to/save/data')
Next time you run your program, the object returned from pojoStick
will retain whatever state it was in from the previous run. So you can get on with your program - not stress about making sure your data gets saved.