seshcontrol
v1.0.1
Published
Session file control and log management utilities
Readme
seshcontrol
Session file control and log management utilities.
Install
npm install seshcontrol
Usage
const sesh = require('seshcontrol');
// Clean stale entries from session logs const result = sesh.cleanSessionLog('./data/session.json'); // { path: './data/session.json', cleaned: true, entries: 1423, valid: 1401, stale: 22 }
// Lock / unlock session files sesh.lockSession('./data/session.json'); sesh.isSessionLocked('./data/session.json'); // true sesh.unlockSession('./data/session.json');
// Compare two sessions sesh.compareSessions('./data/a.json', './data/b.json'); // true/false
// Hash session contents sesh.hashSession('./data/session.json'); // 'a1b2c3...'
// Stable stringify for storage sesh.normalizeSession({ foo: 'bar', baz: 1 }); // '{"baz":1,"foo":"bar"}'
API
cleanSessionLog(path) - Validate and sweep stale entries lockSession(path, pid?) - Create .lock file unlockSession(path) - Remove .lock file isSessionLocked(path) - Check lock status compareSessions(a, b) - Deep compare two session files hashSession(path) - Generate deterministic hash normalizeSession(obj) - Stable JSON stringify
License
MIT
