![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
batch-stream2
Advanced tools
Transform a stream into batches, with custom async operation before emitting data
Transform stream which batches a bunch of input data into groups of specified size. Will emit arrays, so that you can deal with pieces of input asynchronously.
var batch = new BatchStream({
size : 100, // the size for each chunk
timeout: 5000 // emit data after this amount of milliseconds
// even if the size of buffered writes not reaching `size`
});
stream
.pipe(batch)
.pipe(new ArrayStream()); // deals with array input from pipe.
This is also usefull when you want transform continuous writes into batches:
Suppose you have a docs
stream, instead of:
docs.on('data', function(doc) {
db.insert(doc)
})
You can:
var batch = new BatchStream({
transform: function(items, callback) {
db.bulkInsert(items, callback)
})
})
docs.pipe(batch)
.on('finish', function() {
console.log('All doc inserted.')
})
Note that by passing a options.transform
to the constructor, instead of
listening on data
events, the insertions are ensured to be sequential.
If insertions are allowed to happen parrallelly:
var batch = new BatchStream()
docs.pipe(batch)
.on('data', function(items) {
db.bulkInsert(items, ...)
})
.on('finish', function() {
console.log('All docs queued for insertion.')
})
the MIT license.
FAQs
Transform a stream into batches, with custom async operation before emitting data
The npm package batch-stream2 receives a total of 0 weekly downloads. As such, batch-stream2 popularity was classified as not popular.
We found that batch-stream2 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.