Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
batch-array
Advanced tools
A simple library to handle batching up an array before calling a function with it.
A simple library to handle batching up an array before calling a function with it. Each call to batcher.push(item)
adds an item to the current batch. After batchInterval
, batchFn
is called with an array of the items pushed.
npm install batch-array
var BatchArray = require('batch-array');
var myBatcher = new BatchArray({
batchFn: handleBatch,
batchInterval: 1000
});
function handleBatch(batch, cb) {
console.log(batch);
return cb();
}
myBatcher.push('a');
myBatcher.push('b');
setTimeout(function() {
myBatcher.push('c');
myBatcher.push('d');
}, 1500);
setTimeout(function() {
myBatcher.push('e');
myBatcher.push('f');
myBatcher.flush();
}, 2500);
// OUTPUT
['a', 'b'] // at 1000ms elapsed
['c', 'd'] // at 2000ms elapsed
['e', 'f'] // at 2500ms elapsed
[] // at 3500ms elapsed
var myBatcher = new BatchArray(options)
options.batchFn
{ function(batch, cb) | required } - function to be called on an interval with the batch and a callback.
options.batchInterval
{ number | required } - interval in ms to call the batch function with the batched arguments.
myBatcher.push(item)
- pushes an item into the current batch.
myBatcher.flush(cb)
- causes an immediate call to the batch function and resets the batchInterval, "flushing" out the current batch. Callback is passed to the batch function.
myBatcher.startInterval()
- starts the batch interval. Automatically called upon creating a batch object.
myBatcher.stopInterval()
- stops the batch interval
FAQs
A simple library to handle batching up an array before calling a function with it.
The npm package batch-array receives a total of 0 weekly downloads. As such, batch-array popularity was classified as not popular.
We found that batch-array 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
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.