data-keeper

1.1.7 • Public • Published

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)

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
}

Readme

Keywords

none

Package Sidebar

Install

npm i data-keeper

Weekly Downloads

1

Version

1.1.7

License

ISC

Unpacked Size

8.33 kB

Total Files

7

Last publish

Collaborators

  • coolgo0811