{"library":"stream-browserify","title":"Node.js Stream API for Browsers (Browserify)","type":"library","description":"stream-browserify is a module that provides the Node.js `stream` API for browser environments. It serves as a polyfill, allowing npm packages designed for Node.js streams to function correctly within a browser context when bundled. The current stable version is 3.0.0, released after a period of using `readable-stream` v2, and now fully leverages `readable-stream` v3. This package is primarily intended for use with bundlers like Browserify, which automatically substitute the native Node.js `stream` module with `stream-browserify` during the bundling process. Its key differentiator is providing a consistent, spec-compliant stream implementation that bridges the gap between Node.js module expectations and browser limitations, ensuring broad compatibility for legacy and modern stream APIs in the browser.","language":"javascript","status":"active","last_verified":"Tue Apr 21","install":{"commands":["npm install stream-browserify"],"cli":null},"imports":["import { Readable } from 'stream-browserify';","import { Writable } from 'stream-browserify';","import { Transform } from 'stream-browserify';"],"auth":{"required":false,"env_vars":[]},"links":{"homepage":null,"github":"https://github.com/browserify/stream-browserify","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/stream-browserify","openapi_spec":null,"status_page":null,"smithery":null},"quickstart":{"code":"import { Readable, Writable } from 'stream-browserify';\n\nclass MyReadable extends Readable {\n  constructor(options) {\n    super(options);\n    this.index = 0;\n  }\n\n  _read(size) {\n    if (this.index < 5) {\n      this.push(`Chunk ${this.index++}\\n`);\n    } else {\n      this.push(null); // No more data\n    }\n  }\n}\n\nclass MyWritable extends Writable {\n  _write(chunk, encoding, callback) {\n    console.log(`Received: ${chunk.toString()}`);\n    callback();\n  }\n}\n\nconst readableStream = new MyReadable();\nconst writableStream = new MyWritable();\n\nreadableStream.pipe(writableStream);\n\n// Expected output:\n// Received: Chunk 0\n// Received: Chunk 1\n// Received: Chunk 2\n// Received: Chunk 3\n// Received: Chunk 4\n","lang":"javascript","description":"Demonstrates creating and piping a basic readable stream to a writable stream using `stream-browserify`.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}