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.
@types/readable-stream
Advanced tools
The @types/readable-stream package provides TypeScript type definitions for the readable-stream package, which is a userland implementation of the Streams API from Node.js. This allows developers to use and interact with streams in a type-safe manner, ensuring that the code adheres to the expected interfaces and behaviors of streams.
Creating a readable stream
This feature allows you to create a readable stream that you can push data into. The stream can then be consumed by other parts of your application.
import { Readable } from 'readable-stream';
const readable = new Readable({
read(size) {
this.push('some data');
this.push(null); // No more data
}
});
readable.on('data', (chunk) => console.log(chunk.toString()));
Piping a readable stream to a writable stream
This demonstrates how to pipe data from a readable stream directly into a writable stream, effectively transferring data from one source to a destination.
import { Readable, Writable } from 'readable-stream';
const readable = new Readable({
read(size) {
this.push('data to write');
this.push(null); // No more data
}
});
const writable = new Writable({
write(chunk, encoding, callback) {
console.log(chunk.toString());
callback();
}
});
readable.pipe(writable);
The 'stream' package is actually the native Node.js Streams module. It provides the foundational building blocks for working with streams in Node.js. Compared to @types/readable-stream, it does not require type definitions because it's part of Node.js itself, but using it in TypeScript projects without type definitions might not provide the same level of type safety.
Through2 is a tiny wrapper around Node.js streams.Transform (Streams2/3) to avoid explicit subclassing noise. It's similar to @types/readable-stream in that it provides a simpler interface for working with streams, but it focuses more on transform streams and does not come with TypeScript types out of the box.
Highland.js manages synchronous and asynchronous code easily, using nothing more than standard JavaScript and Node-like Streams. While it offers functionality similar to @types/readable-stream by working with streams, it also introduces utilities for handling asynchronous operations and managing backpressure, making it more of a utility library on top of streams rather than just type definitions.
npm install --save @types/readable-stream
This package contains type definitions for readable-stream (https://github.com/nodejs/readable-stream).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/readable-stream.
_Readable
These definitions were written by TeamworkGuy2.
FAQs
TypeScript definitions for readable-stream
The npm package @types/readable-stream receives a total of 1,387,117 weekly downloads. As such, @types/readable-stream popularity was classified as popular.
We found that @types/readable-stream demonstrated a healthy version release cadence and project activity because the last version was released less than 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.