
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.
readable-to-readable
Advanced tools
ReadableToReadable
forwards the data of another Readable
.
This can be useful if a Readable must be wrapped into another Readable
.
The package exports the ReadableToReadable
class.
It can be imported like this:
const ReadableToReadable = require('readable-to-readable')
The ReadableToReadable
class can be used as a base class to create the new Readable
.
The constructor must be called with the input stream as the first parameter.
The following optional options can be given as the second argument:
end
: Close the instance at the end of the input stream. (default: false
)map
: A function that translates the incoming chunks.Readable
constructor.The readFrom
function returns a read
function for Readable
instances.
It will forward the chunks from the given input
Readable
.
The function can be useful to create more customized instances of Readable
.
The following optional options can be given as the second argument:
end
: Close the output stream at the end of the input stream. (default: false
)map
: A function that translates the incoming chunks.The function returns true
when the end of the input stream is reached and false
for the case that the readable buffer is full.
Two streams are created in this example.
Data is pushed to the input
stream and read from the output
stream.
The output
stream is a ReadableToReadable
that takes care of forwarding and also translated the string to upper case.
Once the data passed the two streams, it's written to the console.
This is done until the output
is finished.
const { promisify } = require('util')
const { finished, Readable } = require('readable-stream')
const ReadableToReadable = require('..')
async function main () {
// just a plain Readable to push some data
const input = new Readable({
read: () => {}
})
// in the output stream we forward the data from input whenever .read is called
const output = new ReadableToReadable(input, {
map: chunk => chunk.toString().toUpperCase()
})
// add some data and close the stream
input.push('a')
input.push('b')
input.push('c')
input.push(null)
// write each chunk to the console
output.on('data', chunk => console.log(chunk.toString()))
// wait till the end event of output was emitted
await promisify(finished)(output)
}
main()
FAQs
Forwards the data of one Readable to another Readable
We found that readable-to-readable 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.