1.1.0 • Published 9 years ago

obj-auto-persist v1.1.0

Weekly downloads
1
License
ISC
Repository
github
Last release
9 years ago

node-obj-auto-persist

Simple, automatic, file-system object persistence for NodeJS.

This component returns a JS object from a JSON file and watches the object for changes which are then written back to the file. This allows node applications a simple way of persisting data across multiple executions and restarts.

The following app simply echos out how many times it has been run. Modifying the data object automatically persists the changes to the file system.

var persist = require('obj-auto-persist'),
    data = persist(require('path').resolve('./data.json'));

if (!data.run) {
    data.run = 1;
} else {
    data.run++;
}

console.log('This app has been run ' + data.run + ' times.');
1.1.0

9 years ago

1.0.0

9 years ago