Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Tiny Node library for persisting small runtime objects on filesystem
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
example
lib
.gitignore
LICENSE
README.md
package.json

README.md

fs-persistent-object

Tiny Node library for persisting small runtime objects on filesystem

Install

$ npm install fs-persistent-object

Usage

var persistentObject = require('../lib/fs-persistent-object');
var path = require('path');


// register exit handlers so that process.on('exit') works
var exitFunc = function(){
    console.log('\nShutting down');
    process.exit(0);
}

process.on('SIGINT', exitFunc);
process.on('SIGTERM', exitFunc);

// load persistent object or initialize it with some defaults
var pObject = persistentObject.load(path.resolve(path.dirname(__filename), './runtime', 'example1.pObject'), {
    filename: __filename,
    datetime: new Date(),
    iterator: 0
});

console.log(pObject);

pObject.iterator += 1;

console.log('Now start me again and see that pObject.iterator is changing while pObject.datetime isn\'t.');

process.exit(0);
Something went wrong with that request. Please try again.