
Security News
New CVE Forecasting Tool Predicts 47,000 Disclosures in 2025
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
If you need to write something in very high frequency and you want to reduce system load or network connections, this is the best utility for you.
npm i --save datawriter
new DataWriter(maxBufferSize, maxCacheAge, batchWriteFunction, errorHandler);
maxBufferSize
is the max data rows cached in DataWriter. If the cached data rows grows bigger than this value, an batch write call will be triggered.
maxCacheAge
a max cache time in milliseconds. Once a write()
command is called, a batch write call will be triggered after this time delay.
batchWriteFunction
the function you provide to do a batch writing operation.
errorHandler
the global error handler.
dataWriteInstance.write(...args);
The write command call. args
will be treated as a data row. So you can pass any parameters. Please notice the write
command will not trigger any error. The error occured in the batchWriteFunction
, will be caught by the errorHandler
function.
const DataWriter = require('datawriter');
const fs = require('fs');
let writer = new DataWriter(10, 1000, async arr => {
console.log('batch write', arr.length, 'rows');
fs.appendFileSync('a.log', arr.map(params => JSON.stringify(params)).join('\n') + '\n');
}, function(err) {
console.log('onError', err);
});
writer.write(1);
writer.write('a');
writer.write(1, 2, 3);
writer.write({a: 'A'}, 'nice', [1, 2, 4]);
/*
a.log content will be:
[1]
["a"]
[1,2,3]
[{"a":"A"},"nice",[1,2,4]]
*/
FAQs
cache and write
The npm package datawriter receives a total of 0 weekly downloads. As such, datawriter popularity was classified as not popular.
We found that datawriter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.