![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.
flush-write-stream
Advanced tools
A write stream constructor that supports a flush function that is called before finish is emitted
The flush-write-stream npm package is a Node.js module that provides a writable stream with a flush function that is called before the 'finish' event is emitted. This allows for any remaining data to be processed or cleanup tasks to be performed before the stream is closed.
Creating a writable stream with a flush function
This feature allows you to create a writable stream that will execute a custom flush function before the stream finishes. The flush function is useful for handling any remaining data or performing cleanup tasks.
const FlushWriteStream = require('flush-write-stream');
const writable = FlushWriteStream((data, enc, cb) => {
// Write data logic
cb();
}, (cb) => {
// Flush logic
cb();
});
Through2 is a tiny wrapper around Node streams.Transform that makes it easier to create transform streams. It is similar to flush-write-stream in that it allows you to process data as it passes through the stream, but it does not provide a specific flush functionality.
Pumpify combines an array of streams into a single duplex stream. It can be used to pipe between streams and handle their errors properly. While it is related to stream processing like flush-write-stream, it focuses on combining streams rather than providing a flush mechanism.
End-of-stream is a module that helps you call a callback when a readable/writable/duplex stream has completed or failed. Unlike flush-write-stream, it does not provide a way to define a flush function, but it is useful for handling the end of a stream.
A write stream constructor that supports a flush function that is called before finish
is emitted
npm install flush-write-stream
var writer = require('flush-write-stream')
var ws = writer(write, flush)
ws.on('finish', function () {
console.log('finished')
})
ws.write('hello')
ws.write('world')
ws.end()
function write (data, enc, cb) {
// i am your normal ._write method
console.log('writing', data.toString())
cb()
}
function flush (cb) {
// i am called before finish is emitted
setTimeout(cb, 1000) // wait 1 sec
}
If you run the above it will produce the following output
writing hello
writing world
(nothing happens for 1 sec)
finished
var ws = writer([options], write, [flush])
Create a new writable stream. Options are forwarded to the stream constructor.
var ws = writer.obj([options], write, [flush])
Same as the above except objectMode
is set to true
per default.
MIT
FAQs
A write stream constructor that supports a flush function that is called before finish is emitted
The npm package flush-write-stream receives a total of 955,681 weekly downloads. As such, flush-write-stream popularity was classified as popular.
We found that flush-write-stream 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.