data-keeper
v1.1.7
Published
A utility for store temporary data
Downloads
15
Readme
data-keeper
data-keeper is a utility node-module for keep temporary data (json object) in files. The data will be compressed for disk space saving.
Installation
npm install data-keeper
Example
const DataKeeper = require('data-keeper');
let dataKeeper = new DataKeeper();
API
- init(string)
- write(object)
- read([int])
- dataAvailable()
#init(string)
Set the file path of the storage.
let basePath = path.join(__dirname, '/resume');
dataKeeper.init(basePath);
#write()
Write a data record to file.
let data = { t1: 1, t3: 3, ts: new Date() };
dataKeeper.write(data);
#read([int])
Get a few of data records from files. The input is the count of data that you want. If no input, the default count is 100.
let records = keeper.read(100);
#dataAvailable()
Check if any data records exist or not.
For example:
while (keeper.dataAvailable()) { // check any records exist or not
let records = keeper.read(100); // get 100 records back
}