Skip to content

📎 Sync a plain-old-javascript-object with a local json file - in 1 line of code!

Notifications You must be signed in to change notification settings

digital-taco/pojo-stick

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pojo-stick

📎 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.