{
  "type": "module",
  "source": "doc/api/stream.md",
  "modules": [
    {
      "textRaw": "Stream",
      "name": "stream",
      "introduced_in": "v0.10.0",
      "type": "module",
      "stability": 2,
      "stabilityText": "Stable",
      "desc": "<p>A stream is an abstract interface for working with streaming data in Node.js.\nThe <code>node:stream</code> module provides an API for implementing the stream interface.</p>\n<p>There are many stream objects provided by Node.js. For instance, a\n<a href=\"http.html#class-httpincomingmessage\">request to an HTTP server</a> and <a href=\"process.html#processstdout\"><code>process.stdout</code></a>\nare both stream instances.</p>\n<p>Streams can be readable, writable, or both. All streams are instances of\n<a href=\"events.html#class-eventemitter\"><code>EventEmitter</code></a>.</p>\n<p>To access the <code>node:stream</code> module:</p>\n<pre><code class=\"language-js\">const stream = require('node:stream');\n</code></pre>\n<p>The <code>node:stream</code> module is useful for creating new types of stream instances.\nIt is usually not necessary to use the <code>node:stream</code> module to consume streams.</p>",
      "modules": [
        {
          "textRaw": "Organization of this document",
          "name": "organization_of_this_document",
          "type": "module",
          "desc": "<p>This document contains two primary sections and a third section for notes. The\nfirst section explains how to use existing streams within an application. The\nsecond section explains how to create new types of streams.</p>",
          "displayName": "Organization of this document"
        },
        {
          "textRaw": "Types of streams",
          "name": "types_of_streams",
          "type": "module",
          "desc": "<p>There are four fundamental stream types within Node.js:</p>\n<ul>\n<li><a href=\"#class-streamwritable\"><code>Writable</code></a>: streams to which data can be written (for example,\n<a href=\"fs.html#fscreatewritestreampath-options\"><code>fs.createWriteStream()</code></a>).</li>\n<li><a href=\"#class-streamreadable\"><code>Readable</code></a>: streams from which data can be read (for example,\n<a href=\"fs.html#fscreatereadstreampath-options\"><code>fs.createReadStream()</code></a>).</li>\n<li><a href=\"#class-streamduplex\"><code>Duplex</code></a>: streams that are both <code>Readable</code> and <code>Writable</code> (for example,\n<a href=\"net.html#class-netsocket\"><code>net.Socket</code></a>).</li>\n<li><a href=\"#class-streamtransform\"><code>Transform</code></a>: <code>Duplex</code> streams that can modify or transform the data as it\nis written and read (for example, <a href=\"zlib.html#zlibcreatedeflateoptions\"><code>zlib.createDeflate()</code></a>).</li>\n</ul>\n<p>Additionally, this module includes the utility functions\n<a href=\"#streamduplexpairoptions\"><code>stream.duplexPair()</code></a>,\n<a href=\"#streampipelinesource-transforms-destination-callback\"><code>stream.pipeline()</code></a>,\n<a href=\"#streamfinishedstream-options-callback\"><code>stream.finished()</code></a>\n<a href=\"#streamreadablefromiterable-options\"><code>stream.Readable.from()</code></a>, and\n<a href=\"#streamaddabortsignalsignal-stream\"><code>stream.addAbortSignal()</code></a>.</p>",
          "modules": [
            {
              "textRaw": "Streams Promises API",
              "name": "streams_promises_api",
              "type": "module",
              "meta": {
                "added": [
                  "v15.0.0"
                ],
                "changes": []
              },
              "desc": "<p>The <code>stream/promises</code> API provides an alternative set of asynchronous utility\nfunctions for streams that return <code>Promise</code> objects rather than using\ncallbacks. The API is accessible via <code>require('node:stream/promises')</code>\nor <code>require('node:stream').promises</code>.</p>",
              "displayName": "Streams Promises API"
            },
            {
              "textRaw": "Object mode",
              "name": "object_mode",
              "type": "module",
              "desc": "<p>All streams created by Node.js APIs operate exclusively on strings, <a href=\"buffer.html#class-buffer\"><code>&#x3C;Buffer></code></a>,\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray\"><code>&#x3C;TypedArray></code></a> and <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView\"><code>&#x3C;DataView></code></a> objects:</p>\n<ul>\n<li><code>Strings</code> and <code>Buffers</code> are the most common types used with streams.</li>\n<li><code>TypedArray</code> and <code>DataView</code> lets you handle binary data with types like\n<code>Int32Array</code> or <code>Uint8Array</code>. When you write a TypedArray or DataView to a\nstream, Node.js processes\nthe raw bytes.</li>\n</ul>\n<p>It is possible, however, for stream\nimplementations to work with other types of JavaScript values (with the\nexception of <code>null</code>, which serves a special purpose within streams).\nSuch streams are considered to operate in \"object mode\".</p>\n<p>Stream instances are switched into object mode using the <code>objectMode</code> option\nwhen the stream is created. Attempting to switch an existing stream into\nobject mode is not safe.</p>",
              "displayName": "Object mode"
            }
          ],
          "methods": [
            {
              "textRaw": "`stream.pipeline(streams[, options])`",
              "name": "pipeline",
              "type": "method",
              "signatures": [
                {
                  "params": [
                    {
                      "name": "streams"
                    },
                    {
                      "name": "options",
                      "optional": true
                    }
                  ]
                }
              ]
            },
            {
              "textRaw": "`stream.pipeline(source[, ...transforms], destination[, options])`",
              "name": "pipeline",
              "type": "method",
              "meta": {
                "added": [
                  "v15.0.0"
                ],
                "changes": [
                  {
                    "version": [
                      "v18.0.0",
                      "v17.2.0",
                      "v16.14.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/40886",
                    "description": "Add the `end` option, which can be set to `false` to prevent automatically closing the destination stream when the source ends."
                  }
                ]
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`source` {Stream|AsyncIterable|Function}",
                      "name": "source",
                      "type": "Stream|AsyncIterable|Function",
                      "options": [
                        {
                          "textRaw": "Returns: {Promise|AsyncIterable}",
                          "name": "return",
                          "type": "Promise|AsyncIterable"
                        }
                      ]
                    },
                    {
                      "textRaw": "`...transforms` {Stream|Function}",
                      "name": "...transforms",
                      "type": "Stream|Function",
                      "options": [
                        {
                          "textRaw": "`source` {AsyncIterable}",
                          "name": "source",
                          "type": "AsyncIterable"
                        },
                        {
                          "textRaw": "Returns: {Promise|AsyncIterable}",
                          "name": "return",
                          "type": "Promise|AsyncIterable"
                        }
                      ],
                      "optional": true
                    },
                    {
                      "textRaw": "`destination` {Stream|Function}",
                      "name": "destination",
                      "type": "Stream|Function",
                      "options": [
                        {
                          "textRaw": "`source` {AsyncIterable}",
                          "name": "source",
                          "type": "AsyncIterable"
                        },
                        {
                          "textRaw": "Returns: {Promise|AsyncIterable}",
                          "name": "return",
                          "type": "Promise|AsyncIterable"
                        }
                      ]
                    },
                    {
                      "textRaw": "`options` {Object} Pipeline options",
                      "name": "options",
                      "type": "Object",
                      "desc": "Pipeline options",
                      "options": [
                        {
                          "textRaw": "`signal` {AbortSignal}",
                          "name": "signal",
                          "type": "AbortSignal"
                        },
                        {
                          "textRaw": "`end` {boolean} End the destination stream when the source stream ends. Transform streams are always ended, even if this value is `false`. **Default:** `true`.",
                          "name": "end",
                          "type": "boolean",
                          "default": "`true`",
                          "desc": "End the destination stream when the source stream ends. Transform streams are always ended, even if this value is `false`."
                        }
                      ],
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {Promise} Fulfills when the pipeline is complete.",
                    "name": "return",
                    "type": "Promise",
                    "desc": "Fulfills when the pipeline is complete."
                  }
                }
              ],
              "desc": "<pre><code class=\"language-cjs\">const { pipeline } = require('node:stream/promises');\nconst fs = require('node:fs');\nconst zlib = require('node:zlib');\n\nasync function run() {\n  await pipeline(\n    fs.createReadStream('archive.tar'),\n    zlib.createGzip(),\n    fs.createWriteStream('archive.tar.gz'),\n  );\n  console.log('Pipeline succeeded.');\n}\n\nrun().catch(console.error);\n</code></pre>\n<pre><code class=\"language-mjs\">import { pipeline } from 'node:stream/promises';\nimport { createReadStream, createWriteStream } from 'node:fs';\nimport { createGzip } from 'node:zlib';\n\nawait pipeline(\n  createReadStream('archive.tar'),\n  createGzip(),\n  createWriteStream('archive.tar.gz'),\n);\nconsole.log('Pipeline succeeded.');\n</code></pre>\n<p>To use an <code>AbortSignal</code>, pass it inside an options object, as the last argument.\nWhen the signal is aborted, <code>destroy</code> will be called on the underlying pipeline,\nwith an <code>AbortError</code>.</p>\n<pre><code class=\"language-cjs\">const { pipeline } = require('node:stream/promises');\nconst fs = require('node:fs');\nconst zlib = require('node:zlib');\n\nasync function run() {\n  const ac = new AbortController();\n  const signal = ac.signal;\n\n  setImmediate(() => ac.abort());\n  await pipeline(\n    fs.createReadStream('archive.tar'),\n    zlib.createGzip(),\n    fs.createWriteStream('archive.tar.gz'),\n    { signal },\n  );\n}\n\nrun().catch(console.error); // AbortError\n</code></pre>\n<pre><code class=\"language-mjs\">import { pipeline } from 'node:stream/promises';\nimport { createReadStream, createWriteStream } from 'node:fs';\nimport { createGzip } from 'node:zlib';\n\nconst ac = new AbortController();\nconst { signal } = ac;\nsetImmediate(() => ac.abort());\ntry {\n  await pipeline(\n    createReadStream('archive.tar'),\n    createGzip(),\n    createWriteStream('archive.tar.gz'),\n    { signal },\n  );\n} catch (err) {\n  console.error(err); // AbortError\n}\n</code></pre>\n<p>The <code>pipeline</code> API also supports async generators:</p>\n<pre><code class=\"language-cjs\">const { pipeline } = require('node:stream/promises');\nconst fs = require('node:fs');\n\nasync function run() {\n  await pipeline(\n    fs.createReadStream('lowercase.txt'),\n    async function* (source, { signal }) {\n      source.setEncoding('utf8');  // Work with strings rather than `Buffer`s.\n      for await (const chunk of source) {\n        yield await processChunk(chunk, { signal });\n      }\n    },\n    fs.createWriteStream('uppercase.txt'),\n  );\n  console.log('Pipeline succeeded.');\n}\n\nrun().catch(console.error);\n</code></pre>\n<pre><code class=\"language-mjs\">import { pipeline } from 'node:stream/promises';\nimport { createReadStream, createWriteStream } from 'node:fs';\n\nawait pipeline(\n  createReadStream('lowercase.txt'),\n  async function* (source, { signal }) {\n    source.setEncoding('utf8');  // Work with strings rather than `Buffer`s.\n    for await (const chunk of source) {\n      yield await processChunk(chunk, { signal });\n    }\n  },\n  createWriteStream('uppercase.txt'),\n);\nconsole.log('Pipeline succeeded.');\n</code></pre>\n<p>Remember to handle the <code>signal</code> argument passed into the async generator.\nEspecially in the case where the async generator is the source for the\npipeline (i.e. first argument) or the pipeline will never complete.</p>\n<pre><code class=\"language-cjs\">const { pipeline } = require('node:stream/promises');\nconst fs = require('node:fs');\n\nasync function run() {\n  await pipeline(\n    async function* ({ signal }) {\n      await someLongRunningfn({ signal });\n      yield 'asd';\n    },\n    fs.createWriteStream('uppercase.txt'),\n  );\n  console.log('Pipeline succeeded.');\n}\n\nrun().catch(console.error);\n</code></pre>\n<pre><code class=\"language-mjs\">import { pipeline } from 'node:stream/promises';\nimport fs from 'node:fs';\nawait pipeline(\n  async function* ({ signal }) {\n    await someLongRunningfn({ signal });\n    yield 'asd';\n  },\n  fs.createWriteStream('uppercase.txt'),\n);\nconsole.log('Pipeline succeeded.');\n</code></pre>\n<p>The <code>pipeline</code> API provides <a href=\"#streampipelinesource-transforms-destination-callback\">callback version</a>:</p>"
            },
            {
              "textRaw": "`stream.finished(stream[, options])`",
              "name": "finished",
              "type": "method",
              "meta": {
                "added": [
                  "v15.0.0"
                ],
                "changes": [
                  {
                    "version": [
                      "v19.5.0",
                      "v18.14.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/46205",
                    "description": "Added support for `ReadableStream` and `WritableStream`."
                  },
                  {
                    "version": [
                      "v19.1.0",
                      "v18.13.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/44862",
                    "description": "The `cleanup` option was added."
                  }
                ]
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`stream` {Stream|ReadableStream|WritableStream} A readable and/or writable stream/webstream.",
                      "name": "stream",
                      "type": "Stream|ReadableStream|WritableStream",
                      "desc": "A readable and/or writable stream/webstream."
                    },
                    {
                      "textRaw": "`options` {Object}",
                      "name": "options",
                      "type": "Object",
                      "options": [
                        {
                          "textRaw": "`error` {boolean|undefined}",
                          "name": "error",
                          "type": "boolean|undefined"
                        },
                        {
                          "textRaw": "`readable` {boolean|undefined}",
                          "name": "readable",
                          "type": "boolean|undefined"
                        },
                        {
                          "textRaw": "`writable` {boolean|undefined}",
                          "name": "writable",
                          "type": "boolean|undefined"
                        },
                        {
                          "textRaw": "`signal` {AbortSignal|undefined}",
                          "name": "signal",
                          "type": "AbortSignal|undefined"
                        },
                        {
                          "textRaw": "`cleanup` {boolean|undefined} If `true`, removes the listeners registered by this function before the promise is fulfilled. **Default:** `false`.",
                          "name": "cleanup",
                          "type": "boolean|undefined",
                          "default": "`false`",
                          "desc": "If `true`, removes the listeners registered by this function before the promise is fulfilled."
                        }
                      ],
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {Promise} Fulfills when the stream is no longer readable or writable.",
                    "name": "return",
                    "type": "Promise",
                    "desc": "Fulfills when the stream is no longer readable or writable."
                  }
                }
              ],
              "desc": "<pre><code class=\"language-cjs\">const { finished } = require('node:stream/promises');\nconst fs = require('node:fs');\n\nconst rs = fs.createReadStream('archive.tar');\n\nasync function run() {\n  await finished(rs);\n  console.log('Stream is done reading.');\n}\n\nrun().catch(console.error);\nrs.resume(); // Drain the stream.\n</code></pre>\n<pre><code class=\"language-mjs\">import { finished } from 'node:stream/promises';\nimport { createReadStream } from 'node:fs';\n\nconst rs = createReadStream('archive.tar');\n\nasync function run() {\n  await finished(rs);\n  console.log('Stream is done reading.');\n}\n\nrun().catch(console.error);\nrs.resume(); // Drain the stream.\n</code></pre>\n<p>The <code>finished</code> API also provides a <a href=\"#streamfinishedstream-options-callback\">callback version</a>.</p>\n<p><code>stream.finished()</code> leaves dangling event listeners (in particular\n<code>'error'</code>, <code>'end'</code>, <code>'finish'</code> and <code>'close'</code>) after the returned promise is\nresolved or rejected. The reason for this is so that unexpected <code>'error'</code>\nevents (due to incorrect stream implementations) do not cause unexpected\ncrashes. If this is unwanted behavior then <code>options.cleanup</code> should be set to\n<code>true</code>:</p>\n<pre><code class=\"language-mjs\">await finished(rs, { cleanup: true });\n</code></pre>"
            }
          ],
          "miscs": [
            {
              "textRaw": "Buffering",
              "name": "Buffering",
              "type": "misc",
              "desc": "<p>Both <a href=\"#class-streamwritable\"><code>Writable</code></a> and <a href=\"#class-streamreadable\"><code>Readable</code></a> streams will store data in an internal\nbuffer.</p>\n<p>The amount of data potentially buffered depends on the <code>highWaterMark</code> option\npassed into the stream's constructor. For normal streams, the <code>highWaterMark</code>\noption specifies a <a href=\"#highwatermark-discrepancy-after-calling-readablesetencoding\">total number of bytes</a>. For streams operating\nin object mode, the <code>highWaterMark</code> specifies a total number of objects. For\nstreams operating on (but not decoding) strings, the <code>highWaterMark</code> specifies\na total number of UTF-16 code units.</p>\n<p>Data is buffered in <code>Readable</code> streams when the implementation calls\n<a href=\"#readablepushchunk-encoding\"><code>stream.push(chunk)</code></a>. If the consumer of the Stream does not\ncall <a href=\"#readablereadsize\"><code>stream.read()</code></a>, the data will sit in the internal\nqueue until it is consumed.</p>\n<p>Once the total size of the internal read buffer reaches the threshold specified\nby <code>highWaterMark</code>, the stream will temporarily stop reading data from the\nunderlying resource until the data currently buffered can be consumed (that is,\nthe stream will stop calling the internal <a href=\"#readable_readsize\"><code>readable._read()</code></a> method that is\nused to fill the read buffer).</p>\n<p>Data is buffered in <code>Writable</code> streams when the\n<a href=\"#writablewritechunk-encoding-callback\"><code>writable.write(chunk)</code></a> method is called repeatedly. While the\ntotal size of the internal write buffer is below the threshold set by\n<code>highWaterMark</code>, calls to <code>writable.write()</code> will return <code>true</code>. Once\nthe size of the internal buffer reaches or exceeds the <code>highWaterMark</code>, <code>false</code>\nwill be returned.</p>\n<p>A key goal of the <code>stream</code> API, particularly the <a href=\"#readablepipedestination-options\"><code>stream.pipe()</code></a> method,\nis to limit the buffering of data to acceptable levels such that sources and\ndestinations of differing speeds will not overwhelm the available memory.</p>\n<p>The <code>highWaterMark</code> option is a threshold, not a limit: it dictates the amount\nof data that a stream buffers before it stops asking for more data. It does not\nenforce a strict memory limitation in general. Specific stream implementations\nmay choose to enforce stricter limits but doing so is optional.</p>\n<p>Because <a href=\"#class-streamduplex\"><code>Duplex</code></a> and <a href=\"#class-streamtransform\"><code>Transform</code></a> streams are both <code>Readable</code> and\n<code>Writable</code>, each maintains <em>two</em> separate internal buffers used for reading and\nwriting, allowing each side to operate independently of the other while\nmaintaining an appropriate and efficient flow of data. For example,\n<a href=\"net.html#class-netsocket\"><code>net.Socket</code></a> instances are <a href=\"#class-streamduplex\"><code>Duplex</code></a> streams whose <code>Readable</code> side allows\nconsumption of data received <em>from</em> the socket and whose <code>Writable</code> side allows\nwriting data <em>to</em> the socket. Because data may be written to the socket at a\nfaster or slower rate than data is received, each side should\noperate (and buffer) independently of the other.</p>\n<p>The mechanics of the internal buffering are an internal implementation detail\nand may be changed at any time. However, for certain advanced implementations,\nthe internal buffers can be retrieved using <code>writable.writableBuffer</code> or\n<code>readable.readableBuffer</code>. Use of these undocumented properties is discouraged.</p>"
            }
          ],
          "displayName": "Types of streams"
        }
      ],
      "miscs": [
        {
          "textRaw": "API for stream consumers",
          "name": "API for stream consumers",
          "type": "misc",
          "desc": "<p>Almost all Node.js applications, no matter how simple, use streams in some\nmanner. The following is an example of using streams in a Node.js application\nthat implements an HTTP server:</p>\n<pre><code class=\"language-js\">const http = require('node:http');\n\nconst server = http.createServer((req, res) => {\n  // `req` is an http.IncomingMessage, which is a readable stream.\n  // `res` is an http.ServerResponse, which is a writable stream.\n\n  let body = '';\n  // Get the data as utf8 strings.\n  // If an encoding is not set, Buffer objects will be received.\n  req.setEncoding('utf8');\n\n  // Readable streams emit 'data' events once a listener is added.\n  req.on('data', (chunk) => {\n    body += chunk;\n  });\n\n  // The 'end' event indicates that the entire body has been received.\n  req.on('end', () => {\n    try {\n      const data = JSON.parse(body);\n      // Write back something interesting to the user:\n      res.write(typeof data);\n      res.end();\n    } catch (er) {\n      // uh oh! bad json!\n      res.statusCode = 400;\n      return res.end(`error: ${er.message}`);\n    }\n  });\n});\n\nserver.listen(1337);\n\n// $ curl localhost:1337 -d \"{}\"\n// object\n// $ curl localhost:1337 -d \"\\\"foo\\\"\"\n// string\n// $ curl localhost:1337 -d \"not json\"\n// error: Unexpected token 'o', \"not json\" is not valid JSON\n</code></pre>\n<p><a href=\"#class-streamwritable\"><code>Writable</code></a> streams (such as <code>res</code> in the example) expose methods such as\n<code>write()</code> and <code>end()</code> that are used to write data onto the stream.</p>\n<p><a href=\"#class-streamreadable\"><code>Readable</code></a> streams use the <a href=\"events.html#class-eventemitter\"><code>EventEmitter</code></a> API for notifying application\ncode when data is available to be read off the stream. That available data can\nbe read from the stream in multiple ways.</p>\n<p>Both <a href=\"#class-streamwritable\"><code>Writable</code></a> and <a href=\"#class-streamreadable\"><code>Readable</code></a> streams use the <a href=\"events.html#class-eventemitter\"><code>EventEmitter</code></a> API in\nvarious ways to communicate the current state of the stream.</p>\n<p><a href=\"#class-streamduplex\"><code>Duplex</code></a> and <a href=\"#class-streamtransform\"><code>Transform</code></a> streams are both <a href=\"#class-streamwritable\"><code>Writable</code></a> and\n<a href=\"#class-streamreadable\"><code>Readable</code></a>.</p>\n<p>Applications that are either writing data to or consuming data from a stream\nare not required to implement the stream interfaces directly and will generally\nhave no reason to call <code>require('node:stream')</code>.</p>\n<p>Developers wishing to implement new types of streams should refer to the\nsection <a href=\"#api-for-stream-implementers\">API for stream implementers</a>.</p>",
          "miscs": [
            {
              "textRaw": "Writable streams",
              "name": "writable_streams",
              "type": "misc",
              "desc": "<p>Writable streams are an abstraction for a <em>destination</em> to which data is\nwritten.</p>\n<p>Examples of <a href=\"#class-streamwritable\"><code>Writable</code></a> streams include:</p>\n<ul>\n<li><a href=\"http.html#class-httpclientrequest\">HTTP requests, on the client</a></li>\n<li><a href=\"http.html#class-httpserverresponse\">HTTP responses, on the server</a></li>\n<li><a href=\"fs.html#class-fswritestream\">fs write streams</a></li>\n<li><a href=\"zlib.html\">zlib streams</a></li>\n<li><a href=\"crypto.html\">crypto streams</a></li>\n<li><a href=\"net.html#class-netsocket\">TCP sockets</a></li>\n<li><a href=\"child_process.html#subprocessstdin\">child process stdin</a></li>\n<li><a href=\"process.html#processstdout\"><code>process.stdout</code></a>, <a href=\"process.html#processstderr\"><code>process.stderr</code></a></li>\n</ul>\n<p>Some of these examples are actually <a href=\"#class-streamduplex\"><code>Duplex</code></a> streams that implement the\n<a href=\"#class-streamwritable\"><code>Writable</code></a> interface.</p>\n<p>All <a href=\"#class-streamwritable\"><code>Writable</code></a> streams implement the interface defined by the\n<code>stream.Writable</code> class.</p>\n<p>While specific instances of <a href=\"#class-streamwritable\"><code>Writable</code></a> streams may differ in various ways,\nall <code>Writable</code> streams follow the same fundamental usage pattern as illustrated\nin the example below:</p>\n<pre><code class=\"language-js\">const myStream = getWritableStreamSomehow();\nmyStream.write('some data');\nmyStream.write('some more data');\nmyStream.end('done writing data');\n</code></pre>",
              "classes": [
                {
                  "textRaw": "Class: `stream.Writable`",
                  "name": "stream.Writable",
                  "type": "class",
                  "meta": {
                    "added": [
                      "v0.9.4"
                    ],
                    "changes": []
                  },
                  "events": [
                    {
                      "textRaw": "Event: `'close'`",
                      "name": "close",
                      "type": "event",
                      "meta": {
                        "added": [
                          "v0.9.4"
                        ],
                        "changes": [
                          {
                            "version": "v10.0.0",
                            "pr-url": "https://github.com/nodejs/node/pull/18438",
                            "description": "Add `emitClose` option to specify if `'close'` is emitted on destroy."
                          }
                        ]
                      },
                      "params": [],
                      "desc": "<p>The <code>'close'</code> event is emitted when the stream and any of its underlying\nresources (a file descriptor, for example) have been closed. The event indicates\nthat no more events will be emitted, and no further computation will occur.</p>\n<p>A <a href=\"#class-streamwritable\"><code>Writable</code></a> stream will always emit the <code>'close'</code> event if it is\ncreated with the <code>emitClose</code> option.</p>"
                    },
                    {
                      "textRaw": "Event: `'drain'`",
                      "name": "drain",
                      "type": "event",
                      "meta": {
                        "added": [
                          "v0.9.4"
                        ],
                        "changes": []
                      },
                      "params": [],
                      "desc": "<p>If a call to <a href=\"#writablewritechunk-encoding-callback\"><code>stream.write(chunk)</code></a> returns <code>false</code>, the\n<code>'drain'</code> event will be emitted when it is appropriate to resume writing data\nto the stream.</p>\n<pre><code class=\"language-js\">// Write the data to the supplied writable stream one million times.\n// Be attentive to back-pressure.\nfunction writeOneMillionTimes(writer, data, encoding, callback) {\n  let i = 1000000;\n  write();\n  function write() {\n    let ok = true;\n    do {\n      i--;\n      if (i === 0) {\n        // Last time!\n        writer.write(data, encoding, callback);\n      } else {\n        // See if we should continue, or wait.\n        // Don't pass the callback, because we're not done yet.\n        ok = writer.write(data, encoding);\n      }\n    } while (i > 0 &#x26;&#x26; ok);\n    if (i > 0) {\n      // Had to stop early!\n      // Write some more once it drains.\n      writer.once('drain', write);\n    }\n  }\n}\n</code></pre>"
                    },
                    {
                      "textRaw": "Event: `'error'`",
                      "name": "error",
                      "type": "event",
                      "meta": {
                        "added": [
                          "v0.9.4"
                        ],
                        "changes": []
                      },
                      "params": [
                        {
                          "textRaw": "Type: {Error}",
                          "name": "type",
                          "type": "Error"
                        }
                      ],
                      "desc": "<p>The <code>'error'</code> event is emitted if an error occurred while writing or piping\ndata. The listener callback is passed a single <code>Error</code> argument when called.</p>\n<p>The stream is closed when the <code>'error'</code> event is emitted unless the\n<a href=\"#new-streamwritableoptions\"><code>autoDestroy</code></a> option was set to <code>false</code> when creating the\nstream.</p>\n<p>After <code>'error'</code>, no further events other than <code>'close'</code> <em>should</em> be emitted\n(including <code>'error'</code> events).</p>"
                    },
                    {
                      "textRaw": "Event: `'finish'`",
                      "name": "finish",
                      "type": "event",
                      "meta": {
                        "added": [
                          "v0.9.4"
                        ],
                        "changes": []
                      },
                      "params": [],
                      "desc": "<p>The <code>'finish'</code> event is emitted after the <a href=\"#writableendchunk-encoding-callback\"><code>stream.end()</code></a> method\nhas been called, and all data has been flushed to the underlying system.</p>\n<pre><code class=\"language-js\">const writer = getWritableStreamSomehow();\nfor (let i = 0; i &#x3C; 100; i++) {\n  writer.write(`hello, #${i}!\\n`);\n}\nwriter.on('finish', () => {\n  console.log('All writes are now complete.');\n});\nwriter.end('This is the end\\n');\n</code></pre>"
                    },
                    {
                      "textRaw": "Event: `'pipe'`",
                      "name": "pipe",
                      "type": "event",
                      "meta": {
                        "added": [
                          "v0.9.4"
                        ],
                        "changes": []
                      },
                      "params": [
                        {
                          "textRaw": "`src` {stream.Readable} source stream that is piping to this writable",
                          "name": "src",
                          "type": "stream.Readable",
                          "desc": "source stream that is piping to this writable"
                        }
                      ],
                      "desc": "<p>The <code>'pipe'</code> event is emitted when the <a href=\"#readablepipedestination-options\"><code>stream.pipe()</code></a> method is called on\na readable stream, adding this writable to its set of destinations.</p>\n<pre><code class=\"language-js\">const writer = getWritableStreamSomehow();\nconst reader = getReadableStreamSomehow();\nwriter.on('pipe', (src) => {\n  console.log('Something is piping into the writer.');\n  assert.equal(src, reader);\n});\nreader.pipe(writer);\n</code></pre>"
                    },
                    {
                      "textRaw": "Event: `'unpipe'`",
                      "name": "unpipe",
                      "type": "event",
                      "meta": {
                        "added": [
                          "v0.9.4"
                        ],
                        "changes": []
                      },
                      "params": [
                        {
                          "textRaw": "`src` {stream.Readable} The source stream that unpiped this writable",
                          "name": "src",
                          "type": "stream.Readable",
                          "desc": "The source stream that unpiped this writable"
                        }
                      ],
                      "desc": "<p>The <code>'unpipe'</code> event is emitted when the <a href=\"#readableunpipedestination\"><code>stream.unpipe()</code></a> method is called\non a <a href=\"#class-streamreadable\"><code>Readable</code></a> stream, removing this <a href=\"#class-streamwritable\"><code>Writable</code></a> from its set of\ndestinations.</p>\n<p>This is also emitted in case this <a href=\"#class-streamwritable\"><code>Writable</code></a> stream emits an error when a\n<a href=\"#class-streamreadable\"><code>Readable</code></a> stream pipes into it.</p>\n<pre><code class=\"language-js\">const writer = getWritableStreamSomehow();\nconst reader = getReadableStreamSomehow();\nwriter.on('unpipe', (src) => {\n  console.log('Something has stopped piping into the writer.');\n  assert.equal(src, reader);\n});\nreader.pipe(writer);\nreader.unpipe(writer);\n</code></pre>"
                    }
                  ],
                  "methods": [
                    {
                      "textRaw": "`writable.cork()`",
                      "name": "cork",
                      "type": "method",
                      "meta": {
                        "added": [
                          "v0.11.2"
                        ],
                        "changes": []
                      },
                      "signatures": [
                        {
                          "params": []
                        }
                      ],
                      "desc": "<p>The <code>writable.cork()</code> method forces all written data to be buffered in memory.\nThe buffered data will be flushed when either the <a href=\"#writableuncork\"><code>stream.uncork()</code></a> or\n<a href=\"#writableendchunk-encoding-callback\"><code>stream.end()</code></a> methods are called.</p>\n<p>The primary intent of <code>writable.cork()</code> is to accommodate a situation in which\nseveral small chunks are written to the stream in rapid succession. Instead of\nimmediately forwarding them to the underlying destination, <code>writable.cork()</code>\nbuffers all the chunks until <code>writable.uncork()</code> is called, which will pass them\nall to <code>writable._writev()</code>, if present. This prevents a head-of-line blocking\nsituation where data is being buffered while waiting for the first small chunk\nto be processed. However, use of <code>writable.cork()</code> without implementing\n<code>writable._writev()</code> may have an adverse effect on throughput.</p>\n<p>See also: <a href=\"#writableuncork\"><code>writable.uncork()</code></a>, <a href=\"#writable_writevchunks-callback\"><code>writable._writev()</code></a>.</p>"
                    },
                    {
                      "textRaw": "`writable.destroy([error])`",
                      "name": "destroy",
                      "type": "method",
                      "meta": {
                        "added": [
                          "v8.0.0"
                        ],
                        "changes": [
                          {
                            "version": "v14.0.0",
                            "pr-url": "https://github.com/nodejs/node/pull/29197",
                            "description": "Work as a no-op on a stream that has already been destroyed."
                          }
                        ]
                      },
                      "signatures": [
                        {
                          "params": [
                            {
                              "textRaw": "`error` {Error} Optional, an error to emit with `'error'` event.",
                              "name": "error",
                              "type": "Error",
                              "desc": "Optional, an error to emit with `'error'` event.",
                              "optional": true
                            }
                          ],
                          "return": {
                            "textRaw": "Returns: {this}",
                            "name": "return",
                            "type": "this"
                          }
                        }
                      ],
                      "desc": "<p>Destroy the stream. Optionally emit an <code>'error'</code> event, and emit a <code>'close'</code>\nevent (unless <code>emitClose</code> is set to <code>false</code>). After this call, the writable\nstream has ended and subsequent calls to <code>write()</code> or <code>end()</code> will result in\nan <code>ERR_STREAM_DESTROYED</code> error.\nThis is a destructive and immediate way to destroy a stream. Previous calls to\n<code>write()</code> may not have drained, and may trigger an <code>ERR_STREAM_DESTROYED</code> error.\nUse <code>end()</code> instead of destroy if data should flush before close, or wait for\nthe <code>'drain'</code> event before destroying the stream.</p>\n<pre><code class=\"language-cjs\">const { Writable } = require('node:stream');\n\nconst myStream = new Writable();\n\nconst fooErr = new Error('foo error');\nmyStream.destroy(fooErr);\nmyStream.on('error', (fooErr) => console.error(fooErr.message)); // foo error\n</code></pre>\n<pre><code class=\"language-cjs\">const { Writable } = require('node:stream');\n\nconst myStream = new Writable();\n\nmyStream.destroy();\nmyStream.on('error', function wontHappen() {});\n</code></pre>\n<pre><code class=\"language-cjs\">const { Writable } = require('node:stream');\n\nconst myStream = new Writable();\nmyStream.destroy();\n\nmyStream.write('foo', (error) => console.error(error.code));\n// ERR_STREAM_DESTROYED\n</code></pre>\n<p>Once <code>destroy()</code> has been called any further calls will be a no-op and no\nfurther errors except from <code>_destroy()</code> may be emitted as <code>'error'</code>.</p>\n<p>Implementors should not override this method,\nbut instead implement <a href=\"#writable_destroyerr-callback\"><code>writable._destroy()</code></a>.</p>"
                    },
                    {
                      "textRaw": "`writable.end([chunk[, encoding]][, callback])`",
                      "name": "end",
                      "type": "method",
                      "meta": {
                        "added": [
                          "v0.9.4"
                        ],
                        "changes": [
                          {
                            "version": [
                              "v22.0.0",
                              "v20.13.0"
                            ],
                            "pr-url": "https://github.com/nodejs/node/pull/51866",
                            "description": "The `chunk` argument can now be a `TypedArray` or `DataView` instance."
                          },
                          {
                            "version": "v15.0.0",
                            "pr-url": "https://github.com/nodejs/node/pull/34101",
                            "description": "The `callback` is invoked before 'finish' or on error."
                          },
                          {
                            "version": "v14.0.0",
                            "pr-url": "https://github.com/nodejs/node/pull/29747",
                            "description": "The `callback` is invoked if 'finish' or 'error' is emitted."
                          },
                          {
                            "version": "v10.0.0",
                            "pr-url": "https://github.com/nodejs/node/pull/18780",
                            "description": "This method now returns a reference to `writable`."
                          },
                          {
                            "version": "v8.0.0",
                            "pr-url": "https://github.com/nodejs/node/pull/11608",
                            "description": "The `chunk` argument can now be a `Uint8Array` instance."
                          }
                        ]
                      },
                      "signatures": [
                        {
                          "params": [
                            {
                              "textRaw": "`chunk` {string|Buffer|TypedArray|DataView|any} Optional data to write. For streams not operating in object mode, `chunk` must be a {string}, {Buffer}, {TypedArray} or {DataView}. For object mode streams, `chunk` may be any JavaScript value other than `null`.",
                              "name": "chunk",
                              "type": "string|Buffer|TypedArray|DataView|any",
                              "desc": "Optional data to write. For streams not operating in object mode, `chunk` must be a {string}, {Buffer}, {TypedArray} or {DataView}. For object mode streams, `chunk` may be any JavaScript value other than `null`.",
                              "optional": true
                            },
                            {
                              "textRaw": "`encoding` {string} The encoding if `chunk` is a string",
                              "name": "encoding",
                              "type": "string",
                              "desc": "The encoding if `chunk` is a string",
                              "optional": true
                            },
                            {
                              "textRaw": "`callback` {Function} Callback for when the stream is finished.",
                              "name": "callback",
                              "type": "Function",
                              "desc": "Callback for when the stream is finished.",
                              "optional": true
                            }
                          ],
                          "return": {
                            "textRaw": "Returns: {this}",
                            "name": "return",
                            "type": "this"
                          }
                        }
                      ],
                      "desc": "<p>Calling the <code>writable.end()</code> method signals that no more data will be written\nto the <a href=\"#class-streamwritable\"><code>Writable</code></a>. The optional <code>chunk</code> and <code>encoding</code> arguments allow one\nfinal additional chunk of data to be written immediately before closing the\nstream.</p>\n<p>Calling the <a href=\"#writablewritechunk-encoding-callback\"><code>stream.write()</code></a> method after calling\n<a href=\"#writableendchunk-encoding-callback\"><code>stream.end()</code></a> will raise an error.</p>\n<pre><code class=\"language-js\">// Write 'hello, ' and then end with 'world!'.\nconst fs = require('node:fs');\nconst file = fs.createWriteStream('example.txt');\nfile.write('hello, ');\nfile.end('world!');\n// Writing more now is not allowed!\n</code></pre>"
                    },
                    {
                      "textRaw": "`writable.setDefaultEncoding(encoding)`",
                      "name": "setDefaultEncoding",
                      "type": "method",
                      "meta": {
                        "added": [
                          "v0.11.15"
                        ],
                        "changes": [
                          {
                            "version": "v6.1.0",
                            "pr-url": "https://github.com/nodejs/node/pull/5040",
                            "description": "This method now returns a reference to `writable`."
                          }
                        ]
                      },
                      "signatures": [
                        {
                          "params": [
                            {
                              "textRaw": "`encoding` {string} The new default encoding",
                              "name": "encoding",
                              "type": "string",
                              "desc": "The new default encoding"
                            }
                          ],
                          "return": {
                            "textRaw": "Returns: {this}",
                            "name": "return",
                            "type": "this"
                          }
                        }
                      ],
                      "desc": "<p>The <code>writable.setDefaultEncoding()</code> method sets the default <code>encoding</code> for a\n<a href=\"#class-streamwritable\"><code>Writable</code></a> stream.</p>"
                    },
                    {
                      "textRaw": "`writable.uncork()`",
                      "name": "uncork",
                      "type": "method",
                      "meta": {
                        "added": [
                          "v0.11.2"
                        ],
                        "changes": []
                      },
                      "signatures": [
                        {
                          "params": []
                        }
                      ],
                      "desc": "<p>The <code>writable.uncork()</code> method flushes all data buffered since\n<a href=\"#writablecork\"><code>stream.cork()</code></a> was called.</p>\n<p>When using <a href=\"#writablecork\"><code>writable.cork()</code></a> and <code>writable.uncork()</code> to manage the buffering\nof writes to a stream, defer calls to <code>writable.uncork()</code> using\n<code>process.nextTick()</code>. Doing so allows batching of all\n<code>writable.write()</code> calls that occur within a given Node.js event loop phase.</p>\n<pre><code class=\"language-js\">stream.cork();\nstream.write('some ');\nstream.write('data ');\nprocess.nextTick(() => stream.uncork());\n</code></pre>\n<p>If the <a href=\"#writablecork\"><code>writable.cork()</code></a> method is called multiple times on a stream, the\nsame number of calls to <code>writable.uncork()</code> must be called to flush the buffered\ndata.</p>\n<pre><code class=\"language-js\">stream.cork();\nstream.write('some ');\nstream.cork();\nstream.write('data ');\nprocess.nextTick(() => {\n  stream.uncork();\n  // The data will not be flushed until uncork() is called a second time.\n  stream.uncork();\n});\n</code></pre>\n<p>See also: <a href=\"#writablecork\"><code>writable.cork()</code></a>.</p>"
                    },
                    {
                      "textRaw": "`writable[Symbol.asyncDispose]()`",
                      "name": "[Symbol.asyncDispose]",
                      "type": "method",
                      "meta": {
                        "added": [
                          "v22.4.0",
                          "v20.16.0"
                        ],
                        "changes": [
                          {
                            "version": "v24.2.0",
                            "pr-url": "https://github.com/nodejs/node/pull/58467",
                            "description": "No longer experimental."
                          }
                        ]
                      },
                      "signatures": [
                        {
                          "params": []
                        }
                      ],
                      "desc": "<p>Calls <a href=\"#writabledestroyerror\"><code>writable.destroy()</code></a> with an <code>AbortError</code> and returns\na promise that fulfills when the stream is finished.</p>"
                    },
                    {
                      "textRaw": "`writable.write(chunk[, encoding][, callback])`",
                      "name": "write",
                      "type": "method",
                      "meta": {
                        "added": [
                          "v0.9.4"
                        ],
                        "changes": [
                          {
                            "version": [
                              "v22.0.0",
                              "v20.13.0"
                            ],
                            "pr-url": "https://github.com/nodejs/node/pull/51866",
                            "description": "The `chunk` argument can now be a `TypedArray` or `DataView` instance."
                          },
                          {
                            "version": "v8.0.0",
                            "pr-url": "https://github.com/nodejs/node/pull/11608",
                            "description": "The `chunk` argument can now be a `Uint8Array` instance."
                          },
                          {
                            "version": "v6.0.0",
                            "pr-url": "https://github.com/nodejs/node/pull/6170",
                            "description": "Passing `null` as the `chunk` parameter will always be considered invalid now, even in object mode."
                          }
                        ]
                      },
                      "signatures": [
                        {
                          "params": [
                            {
                              "textRaw": "`chunk` {string|Buffer|TypedArray|DataView|any} Optional data to write. For streams not operating in object mode, `chunk` must be a {string}, {Buffer}, {TypedArray} or {DataView}. For object mode streams, `chunk` may be any JavaScript value other than `null`.",
                              "name": "chunk",
                              "type": "string|Buffer|TypedArray|DataView|any",
                              "desc": "Optional data to write. For streams not operating in object mode, `chunk` must be a {string}, {Buffer}, {TypedArray} or {DataView}. For object mode streams, `chunk` may be any JavaScript value other than `null`."
                            },
                            {
                              "textRaw": "`encoding` {string|null} The encoding, if `chunk` is a string. **Default:** `'utf8'`",
                              "name": "encoding",
                              "type": "string|null",
                              "default": "`'utf8'`",
                              "desc": "The encoding, if `chunk` is a string.",
                              "optional": true
                            },
                            {
                              "textRaw": "`callback` {Function} Callback for when this chunk of data is flushed.",
                              "name": "callback",
                              "type": "Function",
                              "desc": "Callback for when this chunk of data is flushed.",
                              "optional": true
                            }
                          ],
                          "return": {
                            "textRaw": "Returns: {boolean} `false` if the stream wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`.",
                            "name": "return",
                            "type": "boolean",
                            "desc": "`false` if the stream wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`."
                          }
                        }
                      ],
                      "desc": "<p>The <code>writable.write()</code> method writes some data to the stream, and calls the\nsupplied <code>callback</code> once the data has been fully handled. If an error\noccurs, the <code>callback</code> will be called with the error as its\nfirst argument. The <code>callback</code> is called asynchronously and before <code>'error'</code> is\nemitted.</p>\n<p>The return value is <code>true</code> if the internal buffer is less than the\n<code>highWaterMark</code> configured when the stream was created after admitting <code>chunk</code>.\nIf <code>false</code> is returned, further attempts to write data to the stream should\nstop until the <a href=\"#event-drain\"><code>'drain'</code></a> event is emitted.</p>\n<p>While a stream is not draining, calls to <code>write()</code> will buffer <code>chunk</code>, and\nreturn false. Once all currently buffered chunks are drained (accepted for\ndelivery by the operating system), the <code>'drain'</code> event will be emitted.\nOnce <code>write()</code> returns false, do not write more chunks\nuntil the <code>'drain'</code> event is emitted. While calling <code>write()</code> on a stream that\nis not draining is allowed, Node.js will buffer all written chunks until\nmaximum memory usage occurs, at which point it will abort unconditionally.\nEven before it aborts, high memory usage will cause poor garbage collector\nperformance and high RSS (which is not typically released back to the system,\neven after the memory is no longer required). Since TCP sockets may never\ndrain if the remote peer does not read the data, writing a socket that is\nnot draining may lead to a remotely exploitable vulnerability.</p>\n<p>Writing data while the stream is not draining is particularly\nproblematic for a <a href=\"#class-streamtransform\"><code>Transform</code></a>, because the <code>Transform</code> streams are paused\nby default until they are piped or a <code>'data'</code> or <code>'readable'</code> event handler\nis added.</p>\n<p>If the data to be written can be generated or fetched on demand, it is\nrecommended to encapsulate the logic into a <a href=\"#class-streamreadable\"><code>Readable</code></a> and use\n<a href=\"#readablepipedestination-options\"><code>stream.pipe()</code></a>. However, if calling <code>write()</code> is preferred, it is\npossible to respect backpressure and avoid memory issues using the\n<a href=\"#event-drain\"><code>'drain'</code></a> event:</p>\n<pre><code class=\"language-js\">function write(data, cb) {\n  if (!stream.write(data)) {\n    stream.once('drain', cb);\n  } else {\n    process.nextTick(cb);\n  }\n}\n\n// Wait for cb to be called before doing any other write.\nwrite('hello', () => {\n  console.log('Write completed, do more writes now.');\n});\n</code></pre>\n<p>A <code>Writable</code> stream in object mode will always ignore the <code>encoding</code> argument.</p>"
                    }
                  ],
                  "properties": [
                    {
                      "textRaw": "Type: {boolean}",
                      "name": "closed",
                      "type": "boolean",
                      "meta": {
                        "added": [
                          "v18.0.0"
                        ],
                        "changes": []
                      },
                      "desc": "<p>Is <code>true</code> after <code>'close'</code> has been emitted.</p>"
                    },
                    {
                      "textRaw": "Type: {boolean}",
                      "name": "destroyed",
                      "type": "boolean",
                      "meta": {
                        "added": [
                          "v8.0.0"
                        ],
                        "changes": []
                      },
                      "desc": "<p>Is <code>true</code> after <a href=\"#writabledestroyerror\"><code>writable.destroy()</code></a> has been called.</p>\n<pre><code class=\"language-cjs\">const { Writable } = require('node:stream');\n\nconst myStream = new Writable();\n\nconsole.log(myStream.destroyed); // false\nmyStream.destroy();\nconsole.log(myStream.destroyed); // true\n</code></pre>"
                    },
                    {
                      "textRaw": "Type: {boolean}",
                      "name": "writable",
                      "type": "boolean",
                      "meta": {
                        "added": [
                          "v11.4.0"
                        ],
                        "changes": []
                      },
                      "desc": "<p>Is <code>true</code> if it is safe to call <a href=\"#writablewritechunk-encoding-callback\"><code>writable.write()</code></a>, which means\nthe stream has not been destroyed, errored, or ended.</p>"
                    },
                    {
                      "textRaw": "Type: {boolean}",
                      "name": "writableAborted",
                      "type": "boolean",
                      "meta": {
                        "added": [
                          "v18.0.0",
                          "v16.17.0"
                        ],
                        "changes": [
                          {
                            "version": [
                              "v24.0.0",
                              "v22.17.0"
                            ],
                            "pr-url": "https://github.com/nodejs/node/pull/57513",
                            "description": "Marking the API stable."
                          }
                        ]
                      },
                      "desc": "<p>Returns whether the stream was destroyed or errored before emitting <code>'finish'</code>.</p>"
                    },
                    {
                      "textRaw": "Type: {boolean}",
                      "name": "writableEnded",
                      "type": "boolean",
                      "meta": {
                        "added": [
                          "v12.9.0"
                        ],
                        "changes": []
                      },
                      "desc": "<p>Is <code>true</code> after <a href=\"#writableendchunk-encoding-callback\"><code>writable.end()</code></a> has been called. This property\ndoes not indicate whether the data has been flushed, for this use\n<a href=\"#writablewritablefinished\"><code>writable.writableFinished</code></a> instead.</p>"
                    },
                    {
                      "textRaw": "Type: {integer}",
                      "name": "writableCorked",
                      "type": "integer",
                      "meta": {
                        "added": [
                          "v13.2.0",
                          "v12.16.0"
                        ],
                        "changes": []
                      },
                      "desc": "<p>Number of times <a href=\"#writableuncork\"><code>writable.uncork()</code></a> needs to be\ncalled in order to fully uncork the stream.</p>"
                    },
                    {
                      "textRaw": "Type: {Error}",
                      "name": "errored",
                      "type": "Error",
                      "meta": {
                        "added": [
                          "v18.0.0"
                        ],
                        "changes": []
                      },
                      "desc": "<p>Returns error if the stream has been destroyed with an error.</p>"
                    },
                    {
                      "textRaw": "Type: {boolean}",
                      "name": "writableFinished",
                      "type": "boolean",
                      "meta": {
                        "added": [
                          "v12.6.0"
                        ],
                        "changes": []
                      },
                      "desc": "<p>Is set to <code>true</code> immediately before the <a href=\"#event-finish\"><code>'finish'</code></a> event is emitted.</p>"
                    },
                    {
                      "textRaw": "Type: {number}",
                      "name": "writableHighWaterMark",
                      "type": "number",
                      "meta": {
                        "added": [
                          "v9.3.0"
                        ],
                        "changes": []
                      },
                      "desc": "<p>Return the value of <code>highWaterMark</code> passed when creating this <code>Writable</code>.</p>"
                    },
                    {
                      "textRaw": "Type: {number}",
                      "name": "writableLength",
                      "type": "number",
                      "meta": {
                        "added": [
                          "v9.4.0"
                        ],
                        "changes": []
                      },
                      "desc": "<p>This property contains the number of bytes (or objects) in the queue\nready to be written. The value provides introspection data regarding\nthe status of the <code>highWaterMark</code>.</p>"
                    },
                    {
                      "textRaw": "Type: {boolean}",
                      "name": "writableNeedDrain",
                      "type": "boolean",
                      "meta": {
                        "added": [
                          "v15.2.0",
                          "v14.17.0"
                        ],
                        "changes": []
                      },
                      "desc": "<p>Is <code>true</code> if the stream's buffer has been full and stream will emit <code>'drain'</code>.</p>"
                    },
                    {
                      "textRaw": "Type: {boolean}",
                      "name": "writableObjectMode",
                      "type": "boolean",
                      "meta": {
                        "added": [
                          "v12.3.0"
                        ],
                        "changes": []
                      },
                      "desc": "<p>Getter for the property <code>objectMode</code> of a given <code>Writable</code> stream.</p>"
                    }
                  ]
                }
              ],
              "displayName": "Writable streams"
            },
            {
              "textRaw": "Readable streams",
              "name": "readable_streams",
              "type": "misc",
              "desc": "<p>Readable streams are an abstraction for a <em>source</em> from which data is\nconsumed.</p>\n<p>Examples of <code>Readable</code> streams include:</p>\n<ul>\n<li><a href=\"http.html#class-httpincomingmessage\">HTTP responses, on the client</a></li>\n<li><a href=\"http.html#class-httpincomingmessage\">HTTP requests, on the server</a></li>\n<li><a href=\"fs.html#class-fsreadstream\">fs read streams</a></li>\n<li><a href=\"zlib.html\">zlib streams</a></li>\n<li><a href=\"crypto.html\">crypto streams</a></li>\n<li><a href=\"net.html#class-netsocket\">TCP sockets</a></li>\n<li><a href=\"child_process.html#subprocessstdout\">child process stdout and stderr</a></li>\n<li><a href=\"process.html#processstdin\"><code>process.stdin</code></a></li>\n</ul>\n<p>All <a href=\"#class-streamreadable\"><code>Readable</code></a> streams implement the interface defined by the\n<code>stream.Readable</code> class.</p>",
              "modules": [
                {
                  "textRaw": "Two reading modes",
                  "name": "two_reading_modes",
                  "type": "module",
                  "desc": "<p><code>Readable</code> streams effectively operate in one of two modes: flowing and\npaused. These modes are separate from <a href=\"#object-mode\">object mode</a>.\nA <a href=\"#class-streamreadable\"><code>Readable</code></a> stream can be in object mode or not, regardless of whether\nit is in flowing mode or paused mode.</p>\n<ul>\n<li>\n<p>In flowing mode, data is read from the underlying system automatically\nand provided to an application as quickly as possible using events via the\n<a href=\"events.html#class-eventemitter\"><code>EventEmitter</code></a> interface.</p>\n</li>\n<li>\n<p>In paused mode, the <a href=\"#readablereadsize\"><code>stream.read()</code></a> method must be called\nexplicitly to read chunks of data from the stream.</p>\n</li>\n</ul>\n<p>All <a href=\"#class-streamreadable\"><code>Readable</code></a> streams begin in paused mode but can be switched to flowing\nmode in one of the following ways:</p>\n<ul>\n<li>Adding a <a href=\"#event-data\"><code>'data'</code></a> event handler.</li>\n<li>Calling the <a href=\"#readableresume\"><code>stream.resume()</code></a> method.</li>\n<li>Calling the <a href=\"#readablepipedestination-options\"><code>stream.pipe()</code></a> method to send the data to a <a href=\"#class-streamwritable\"><code>Writable</code></a>.</li>\n</ul>\n<p>The <code>Readable</code> can switch back to paused mode using one of the following:</p>\n<ul>\n<li>If there are no pipe destinations, by calling the\n<a href=\"#readablepause\"><code>stream.pause()</code></a> method.</li>\n<li>If there are pipe destinations, by removing all pipe destinations.\nMultiple pipe destinations may be removed by calling the\n<a href=\"#readableunpipedestination\"><code>stream.unpipe()</code></a> method.</li>\n</ul>\n<p>The important concept to remember is that a <code>Readable</code> will not generate data\nuntil a mechanism for either consuming or ignoring that data is provided. If\nthe consuming mechanism is disabled or taken away, the <code>Readable</code> will <em>attempt</em>\nto stop generating the data.</p>\n<p>For backward compatibility reasons, removing <a href=\"#event-data\"><code>'data'</code></a> event handlers will\n<strong>not</strong> automatically pause the stream. Also, if there are piped destinations,\nthen calling <a href=\"#readablepause\"><code>stream.pause()</code></a> will not guarantee that the\nstream will <em>remain</em> paused once those destinations drain and ask for more data.</p>\n<p>If a <a href=\"#class-streamreadable\"><code>Readable</code></a> is switched into flowing mode and there are no consumers\navailable to handle the data, that data will be lost. This can occur, for\ninstance, when the <code>readable.resume()</code> method is called without a listener\nattached to the <code>'data'</code> event, or when a <code>'data'</code> event handler is removed\nfrom the stream.</p>\n<p>Adding a <a href=\"#event-readable\"><code>'readable'</code></a> event handler automatically makes the stream\nstop flowing, and the data has to be consumed via\n<a href=\"#readablereadsize\"><code>readable.read()</code></a>. If the <a href=\"#event-readable\"><code>'readable'</code></a> event handler is\nremoved, then the stream will start flowing again if there is a\n<a href=\"#event-data\"><code>'data'</code></a> event handler.</p>",
                  "displayName": "Two reading modes"
                },
                {
                  "textRaw": "Three states",
                  "name": "three_states",
                  "type": "module",
                  "desc": "<p>The \"two modes\" of operation for a <code>Readable</code> stream are a simplified\nabstraction for the more complicated internal state management that is happening\nwithin the <code>Readable</code> stream implementation.</p>\n<p>Specifically, at any given point in time, every <code>Readable</code> is in one of three\npossible states:</p>\n<ul>\n<li><code>readable.readableFlowing === null</code></li>\n<li><code>readable.readableFlowing === false</code></li>\n<li><code>readable.readableFlowing === true</code></li>\n</ul>\n<p>When <code>readable.readableFlowing</code> is <code>null</code>, no mechanism for consuming the\nstream's data is provided. Therefore, the stream will not generate data.\nWhile in this state, attaching a listener for the <code>'data'</code> event, calling the\n<code>readable.pipe()</code> method, or calling the <code>readable.resume()</code> method will switch\n<code>readable.readableFlowing</code> to <code>true</code>, causing the <code>Readable</code> to begin actively\nemitting events as data is generated.</p>\n<p>Calling <code>readable.pause()</code>, <code>readable.unpipe()</code>, or receiving backpressure\nwill cause the <code>readable.readableFlowing</code> to be set as <code>false</code>,\ntemporarily halting the flowing of events but <em>not</em> halting the generation of\ndata. While in this state, attaching a listener for the <code>'data'</code> event\nwill not switch <code>readable.readableFlowing</code> to <code>true</code>.</p>\n<pre><code class=\"language-js\">const { PassThrough, Writable } = require('node:stream');\nconst pass = new PassThrough();\nconst writable = new Writable();\n\npass.pipe(writable);\npass.unpipe(writable);\n// readableFlowing is now false.\n\npass.on('data', (chunk) => { console.log(chunk.toString()); });\n// readableFlowing is still false.\npass.write('ok');  // Will not emit 'data'.\npass.resume();     // Must be called to make stream emit 'data'.\n// readableFlowing is now true.\n</code></pre>\n<p>While <code>readable.readableFlowing</code> is <code>false</code>, data may be accumulating\nwithin the stream's internal buffer.</p>",
                  "displayName": "Three states"
                },
                {
                  "textRaw": "Choose one API style",
                  "name": "choose_one_api_style",
                  "type": "module",
                  "desc": "<p>The <code>Readable</code> stream API evolved across multiple Node.js versions and provides\nmultiple methods of consuming stream data. In general, developers should choose\n<em>one</em> of the methods of consuming data and <em>should never</em> use multiple methods\nto consume data from a single stream. Specifically, using a combination\nof <code>on('data')</code>, <code>on('readable')</code>, <code>pipe()</code>, or async iterators could\nlead to unintuitive behavior.</p>",
                  "displayName": "Choose one API style"
                }
              ],
              "classes": [
                {
                  "textRaw": "Class: `stream.Readable`",
                  "name": "stream.Readable",
                  "type": "class",
                  "meta": {
                    "added": [
                      "v0.9.4"
                    ],
                    "changes": []
                  },
                  "events": [
                    {
                      "textRaw": "Event: `'close'`",
                      "name": "close",
                      "type": "event",
                      "meta": {
                        "added": [
                          "v0.9.4"
                        ],
                        "changes": [
                          {
                            "version": "v10.0.0",
                            "pr-url": "https://github.com/nodejs/node/pull/18438",
                            "description": "Add `emitClose` option to specify if `'close'` is emitted on destroy."
                          }
                        ]
                      },
                      "params": [],
                      "desc": "<p>The <code>'close'</code> event is emitted when the stream and any of its underlying\nresources (a file descriptor, for example) have been closed. The event indicates\nthat no more events will be emitted, and no further computation will occur.</p>\n<p>A <a href=\"#class-streamreadable\"><code>Readable</code></a> stream will always emit the <code>'close'</code> event if it is\ncreated with the <code>emitClose</code> option.</p>"
                    },
                    {
                      "textRaw": "Event: `'data'`",
                      "name": "data",
                      "type": "event",
                      "meta": {
                        "added": [
                          "v0.9.4"
                        ],
                        "changes": []
                      },
                      "params": [
                        {
                          "textRaw": "`chunk` {Buffer|string|any} The chunk of data. For streams that are not operating in object mode, the chunk will be either a string or `Buffer`. For streams that are in object mode, the chunk can be any JavaScript value other than `null`.",
                          "name": "chunk",
                          "type": "Buffer|string|any",
                          "desc": "The chunk of data. For streams that are not operating in object mode, the chunk will be either a string or `Buffer`. For streams that are in object mode, the chunk can be any JavaScript value other than `null`."
                        }
                      ],
                      "desc": "<p>The <code>'data'</code> event is emitted whenever the stream is relinquishing ownership of\na chunk of data to a consumer. This may occur whenever the stream is switched\nin flowing mode by calling <code>readable.pipe()</code>, <code>readable.resume()</code>, or by\nattaching a listener callback to the <code>'data'</code> event. The <code>'data'</code> event will\nalso be emitted whenever the <code>readable.read()</code> method is called and a chunk of\ndata is available to be returned.</p>\n<p>Attaching a <code>'data'</code> event listener to a stream that has not been explicitly\npaused will switch the stream into flowing mode. Data will then be passed as\nsoon as it is available.</p>\n<p>The listener callback will be passed the chunk of data as a string if a default\nencoding has been specified for the stream using the\n<code>readable.setEncoding()</code> method; otherwise the data will be passed as a\n<code>Buffer</code>.</p>\n<pre><code class=\"language-js\">const readable = getReadableStreamSomehow();\nreadable.on('data', (chunk) => {\n  console.log(`Received ${chunk.length} bytes of data.`);\n});\n</code></pre>"
                    },
                    {
                      "textRaw": "Event: `'end'`",
                      "name": "end",
                      "type": "event",
                      "meta": {
                        "added": [
                          "v0.9.4"
                        ],
                        "changes": []
                      },
                      "params": [],
                      "desc": "<p>The <code>'end'</code> event is emitted when there is no more data to be consumed from\nthe stream.</p>\n<p>The <code>'end'</code> event <strong>will not be emitted</strong> unless the data is completely\nconsumed. This can be accomplished by switching the stream into flowing mode,\nor by calling <a href=\"#readablereadsize\"><code>stream.read()</code></a> repeatedly until all data has been\nconsumed.</p>\n<pre><code class=\"language-js\">const readable = getReadableStreamSomehow();\nreadable.on('data', (chunk) => {\n  console.log(`Received ${chunk.length} bytes of data.`);\n});\nreadable.on('end', () => {\n  console.log('There will be no more data.');\n});\n</code></pre>"
                    },
                    {
                      "textRaw": "Event: `'error'`",
                      "name": "error",
                      "type": "event",
                      "meta": {
                        "added": [
                          "v0.9.4"
                        ],
                        "changes": []
                      },
                      "params": [
                        {
                          "textRaw": "Type: {Error}",
                          "name": "type",
                          "type": "Error"
                        }
                      ],
                      "desc": "<p>The <code>'error'</code> event may be emitted by a <code>Readable</code> implementation at any time.\nTypically, this may occur if the underlying stream is unable to generate data\ndue to an underlying internal failure, or when a stream implementation attempts\nto push an invalid chunk of data.</p>\n<p>The listener callback will be passed a single <code>Error</code> object.</p>"
                    },
                    {
                      "textRaw": "Event: `'pause'`",
                      "name": "pause",
                      "type": "event",
                      "meta": {
                        "added": [
                          "v0.9.4"
                        ],
                        "changes": []
                      },
                      "params": [],
                      "desc": "<p>The <code>'pause'</code> event is emitted when <a href=\"#readablepause\"><code>stream.pause()</code></a> is called\nand <code>readableFlowing</code> is not <code>false</code>.</p>"
                    },
                    {
                      "textRaw": "Event: `'readable'`",
                      "name": "readable",
                      "type": "event",
                      "meta": {
                        "added": [
                          "v0.9.4"
                        ],
                        "changes": [
                          {
                            "version": "v10.0.0",
                            "pr-url": "https://github.com/nodejs/node/pull/17979",
                            "description": "The `'readable'` is always emitted in the next tick after `.push()` is called."
                          },
                          {
                            "version": "v10.0.0",
                            "pr-url": "https://github.com/nodejs/node/pull/18994",
                            "description": "Using `'readable'` requires calling `.read()`."
                          }
                        ]
                      },
                      "params": [],
                      "desc": "<p>The <code>'readable'</code> event is emitted when there is data available to be read from\nthe stream, up to the configured high water mark (<code>state.highWaterMark</code>). Effectively,\nit indicates that the stream has new information within the buffer. If data is available\nwithin this buffer, <a href=\"#readablereadsize\"><code>stream.read()</code></a> can be called to retrieve that data.\nAdditionally, the <code>'readable'</code> event may also be emitted when the end of the stream has been\nreached.</p>\n<pre><code class=\"language-js\">const readable = getReadableStreamSomehow();\nreadable.on('readable', function() {\n  // There is some data to read now.\n  let data;\n\n  while ((data = this.read()) !== null) {\n    console.log(data);\n  }\n});\n</code></pre>\n<p>If the end of the stream has been reached, calling\n<a href=\"#readablereadsize\"><code>stream.read()</code></a> will return <code>null</code> and trigger the <code>'end'</code>\nevent. This is also true if there never was any data to be read. For instance,\nin the following example, <code>foo.txt</code> is an empty file:</p>\n<pre><code class=\"language-js\">const fs = require('node:fs');\nconst rr = fs.createReadStream('foo.txt');\nrr.on('readable', () => {\n  console.log(`readable: ${rr.read()}`);\n});\nrr.on('end', () => {\n  console.log('end');\n});\n</code></pre>\n<p>The output of running this script is:</p>\n<pre><code class=\"language-console\">$ node test.js\nreadable: null\nend\n</code></pre>\n<p>In some cases, attaching a listener for the <code>'readable'</code> event will cause some\namount of data to be read into an internal buffer.</p>\n<p>In general, the <code>readable.pipe()</code> and <code>'data'</code> event mechanisms are easier to\nunderstand than the <code>'readable'</code> event. However, handling <code>'readable'</code> might\nresult in increased throughput.</p>\n<p>If both <code>'readable'</code> and <a href=\"#event-data\"><code>'data'</code></a> are used at the same time, <code>'readable'</code>\ntakes precedence in controlling the flow, i.e. <code>'data'</code> will be emitted\nonly when <a href=\"#readablereadsize\"><code>stream.read()</code></a> is called. The\n<code>readableFlowing</code> property would become <code>false</code>.\nIf there are <code>'data'</code> listeners when <code>'readable'</code> is removed, the stream\nwill start flowing, i.e. <code>'data'</code> events will be emitted without calling\n<code>.resume()</code>.</p>"
                    },
                    {
                      "textRaw": "Event: `'resume'`",
                      "name": "resume",
                      "type": "event",
                      "meta": {
                        "added": [
                          "v0.9.4"
                        ],
                        "changes": []
                      },
                      "params": [],
                      "desc": "<p>The <code>'resume'</code> event is emitted when <a href=\"#readableresume\"><code>stream.resume()</code></a> is\ncalled and <code>readableFlowing</code> is not <code>true</code>.</p>"
                    }
                  ],
                  "methods": [
                    {
                      "textRaw": "`readable.destroy([error])`",
                      "name": "destroy",
                      "type": "method",
                      "meta": {
                        "added": [
                          "v8.0.0"
                        ],
                        "changes": [
                          {
                            "version": "v14.0.0",
                            "pr-url": "https://github.com/nodejs/node/pull/29197",
                            "description": "Work as a no-op on a stream that has already been destroyed."
                          }
                        ]
                      },
                      "signatures": [
                        {
                          "params": [
                            {
                              "textRaw": "`error` {Error} Error which will be passed as payload in `'error'` event",
                              "name": "error",
                              "type": "Error",
                              "desc": "Error which will be passed as payload in `'error'` event",
                              "optional": true
                            }
                          ],
                          "return": {
                            "textRaw": "Returns: {this}",
                            "name": "return",
                            "type": "this"
                          }
                        }
                      ],
                      "desc": "<p>Destroy the stream. Optionally emit an <code>'error'</code> event, and emit a <code>'close'</code>\nevent (unless <code>emitClose</code> is set to <code>false</code>). After this call, the readable\nstream will release any internal resources and subsequent calls to <code>push()</code>\nwill be ignored.</p>\n<p>Once <code>destroy()</code> has been called any further calls will be a no-op and no\nfurther errors except from <code>_destroy()</code> may be emitted as <code>'error'</code>.</p>\n<p>Implementors should not override this method, but instead implement\n<a href=\"#readable_destroyerr-callback\"><code>readable._destroy()</code></a>.</p>"
                    },
                    {
                      "textRaw": "`readable.isPaused()`",
                      "name": "isPaused",
                      "type": "method",
                      "meta": {
                        "added": [
                          "v0.11.14"
                        ],
                        "changes": []
                      },
                      "signatures": [
                        {
                          "params": [],
                          "return": {
                            "textRaw": "Returns: {boolean}",
                            "name": "return",
                            "type": "boolean"
                          }
                        }
                      ],
                      "desc": "<p>The <code>readable.isPaused()</code> method returns the current operating state of the\n<code>Readable</code>. This is used primarily by the mechanism that underlies the\n<code>readable.pipe()</code> method. In most typical cases, there will be no reason to\nuse this method directly.</p>\n<pre><code class=\"language-js\">const readable = new stream.Readable();\n\nreadable.isPaused(); // === false\nreadable.pause();\nreadable.isPaused(); // === true\nreadable.resume();\nreadable.isPaused(); // === false\n</code></pre>"
                    },
                    {
                      "textRaw": "`readable.pause()`",
                      "name": "pause",
                      "type": "method",
                      "meta": {
                        "added": [
                          "v0.9.4"
                        ],
                        "changes": []
                      },
                      "signatures": [
                        {
                          "params": [],
                          "return": {
                            "textRaw": "Returns: {this}",
                            "name": "return",
                            "type": "this"
                          }
                        }
                      ],
                      "desc": "<p>The <code>readable.pause()</code> method will cause a stream in flowing mode to stop\nemitting <a href=\"#event-data\"><code>'data'</code></a> events, switching out of flowing mode. Any data that\nbecomes available will remain in the internal buffer.</p>\n<pre><code class=\"language-js\">const readable = getReadableStreamSomehow();\nreadable.on('data', (chunk) => {\n  console.log(`Received ${chunk.length} bytes of data.`);\n  readable.pause();\n  console.log('There will be no additional data for 1 second.');\n  setTimeout(() => {\n    console.log('Now data will start flowing again.');\n    readable.resume();\n  }, 1000);\n});\n</code></pre>\n<p>The <code>readable.pause()</code> method has no effect if there is a <code>'readable'</code>\nevent listener.</p>"
                    },
                    {
                      "textRaw": "`readable.pipe(destination[, options])`",
                      "name": "pipe",
                      "type": "method",
                      "meta": {
                        "added": [
                          "v0.9.4"
                        ],
                        "changes": []
                      },
                      "signatures": [
                        {
                          "params": [
                            {
                              "textRaw": "`destination` {stream.Writable} The destination for writing data",
                              "name": "destination",
                              "type": "stream.Writable",
                              "desc": "The destination for writing data"
                            },
                            {
                              "textRaw": "`options` {Object} Pipe options",
                              "name": "options",
                              "type": "Object",
                              "desc": "Pipe options",
                              "options": [
                                {
                                  "textRaw": "`end` {boolean} End the writer when the reader ends. **Default:** `true`.",
                                  "name": "end",
                                  "type": "boolean",
                                  "default": "`true`",
                                  "desc": "End the writer when the reader ends."
                                }
                              ],
                              "optional": true
                            }
                          ],
                          "return": {
                            "textRaw": "Returns: {stream.Writable} The _destination_, allowing for a chain of pipes if it is a `Duplex` or a `Transform` stream",
                            "name": "return",
                            "type": "stream.Writable",
                            "desc": "The _destination_, allowing for a chain of pipes if it is a `Duplex` or a `Transform` stream"
                          }
                        }
                      ],
                      "desc": "<p>The <code>readable.pipe()</code> method attaches a <a href=\"#class-streamwritable\"><code>Writable</code></a> stream to the <code>readable</code>,\ncausing it to switch automatically into flowing mode and push all of its data\nto the attached <a href=\"#class-streamwritable\"><code>Writable</code></a>. The flow of data will be automatically managed\nso that the destination <code>Writable</code> stream is not overwhelmed by a faster\n<code>Readable</code> stream.</p>\n<p>The following example pipes all of the data from the <code>readable</code> into a file\nnamed <code>file.txt</code>:</p>\n<pre><code class=\"language-js\">const fs = require('node:fs');\nconst readable = getReadableStreamSomehow();\nconst writable = fs.createWriteStream('file.txt');\n// All the data from readable goes into 'file.txt'.\nreadable.pipe(writable);\n</code></pre>\n<p>It is possible to attach multiple <code>Writable</code> streams to a single <code>Readable</code>\nstream.</p>\n<p>The <code>readable.pipe()</code> method returns a reference to the <em>destination</em> stream\nmaking it possible to set up chains of piped streams:</p>\n<pre><code class=\"language-js\">const fs = require('node:fs');\nconst zlib = require('node:zlib');\nconst r = fs.createReadStream('file.txt');\nconst z = zlib.createGzip();\nconst w = fs.createWriteStream('file.txt.gz');\nr.pipe(z).pipe(w);\n</code></pre>\n<p>By default, <a href=\"#writableendchunk-encoding-callback\"><code>stream.end()</code></a> is called on the destination <code>Writable</code>\nstream when the source <code>Readable</code> stream emits <a href=\"#event-end\"><code>'end'</code></a>, so that the\ndestination is no longer writable. To disable this default behavior, the <code>end</code>\noption can be passed as <code>false</code>, causing the destination stream to remain open:</p>\n<pre><code class=\"language-js\">reader.pipe(writer, { end: false });\nreader.on('end', () => {\n  writer.end('Goodbye\\n');\n});\n</code></pre>\n<p>One important caveat is that if the <code>Readable</code> stream emits an error during\nprocessing, the <code>Writable</code> destination <em>is not closed</em> automatically. If an\nerror occurs, it will be necessary to <em>manually</em> close each stream in order\nto prevent memory leaks.</p>\n<p>The <a href=\"process.html#processstderr\"><code>process.stderr</code></a> and <a href=\"process.html#processstdout\"><code>process.stdout</code></a> <code>Writable</code> streams are never\nclosed until the Node.js process exits, regardless of the specified options.</p>"
                    },
                    {
                      "textRaw": "`readable.read([size])`",
                      "name": "read",
                      "type": "method",
                      "meta": {
                        "added": [
                          "v0.9.4"
                        ],
                        "changes": []
                      },
                      "signatures": [
                        {
                          "params": [
                            {
                              "textRaw": "`size` {number} Optional argument to specify how much data to read.",
                              "name": "size",
                              "type": "number",
                              "desc": "Optional argument to specify how much data to read.",
                              "optional": true
                            }
                          ],
                          "return": {
                            "textRaw": "Returns: {string|Buffer|null|any}",
                            "name": "return",
                            "type": "string|Buffer|null|any"
                          }
                        }
                      ],
                      "desc": "<p>The <code>readable.read()</code> method reads data out of the internal buffer and\nreturns it. If no data is available to be read, <code>null</code> is returned. By default,\nthe data is returned as a <code>Buffer</code> object unless an encoding has been\nspecified using the <code>readable.setEncoding()</code> method or the stream is operating\nin object mode.</p>\n<p>The optional <code>size</code> argument specifies a specific number of bytes to read. If\n<code>size</code> bytes are not available to be read, <code>null</code> will be returned <em>unless</em>\nthe stream has ended, in which case all of the data remaining in the internal\nbuffer will be returned.</p>\n<p>If the <code>size</code> argument is not specified, all of the data contained in the\ninternal buffer will be returned.</p>\n<p>The <code>size</code> argument must be less than or equal to 1 GiB.</p>\n<p>The <code>readable.read()</code> method should only be called on <code>Readable</code> streams\noperating in paused mode. In flowing mode, <code>readable.read()</code> is called\nautomatically until the internal buffer is fully drained.</p>\n<pre><code class=\"language-js\">const readable = getReadableStreamSomehow();\n\n// 'readable' may be triggered multiple times as data is buffered in\nreadable.on('readable', () => {\n  let chunk;\n  console.log('Stream is readable (new data received in buffer)');\n  // Use a loop to make sure we read all currently available data\n  while (null !== (chunk = readable.read())) {\n    console.log(`Read ${chunk.length} bytes of data...`);\n  }\n});\n\n// 'end' will be triggered once when there is no more data available\nreadable.on('end', () => {\n  console.log('Reached end of stream.');\n});\n</code></pre>\n<p>Each call to <code>readable.read()</code> returns a chunk of data or <code>null</code>, signifying\nthat there's no more data to read at that moment. These chunks aren't automatically\nconcatenated. Because a single <code>read()</code> call does not return all the data, using\na while loop may be necessary to continuously read chunks until all data is retrieved.\nWhen reading a large file, <code>.read()</code> might return <code>null</code> temporarily, indicating\nthat it has consumed all buffered content but there may be more data yet to be\nbuffered. In such cases, a new <code>'readable'</code> event is emitted once there's more\ndata in the buffer, and the <code>'end'</code> event signifies the end of data transmission.</p>\n<p>Therefore to read a file's whole contents from a <code>readable</code>, it is necessary\nto collect chunks across multiple <code>'readable'</code> events:</p>\n<pre><code class=\"language-js\">const chunks = [];\n\nreadable.on('readable', () => {\n  let chunk;\n  while (null !== (chunk = readable.read())) {\n    chunks.push(chunk);\n  }\n});\n\nreadable.on('end', () => {\n  const content = chunks.join('');\n});\n</code></pre>\n<p>A <code>Readable</code> stream in object mode will always return a single item from\na call to <a href=\"#readablereadsize\"><code>readable.read(size)</code></a>, regardless of the value of the\n<code>size</code> argument.</p>\n<p>If the <code>readable.read()</code> method returns a chunk of data, a <code>'data'</code> event will\nalso be emitted.</p>\n<p>Calling <a href=\"#readablereadsize\"><code>stream.read([size])</code></a> after the <a href=\"#event-end\"><code>'end'</code></a> event has\nbeen emitted will return <code>null</code>. No runtime error will be raised.</p>"
                    },
                    {
                      "textRaw": "`readable.resume()`",
                      "name": "resume",
                      "type": "method",
                      "meta": {
                        "added": [
                          "v0.9.4"
                        ],
                        "changes": [
                          {
                            "version": "v10.0.0",
                            "pr-url": "https://github.com/nodejs/node/pull/18994",
                            "description": "The `resume()` has no effect if there is a `'readable'` event listening."
                          }
                        ]
                      },
                      "signatures": [
                        {
                          "params": [],
                          "return": {
                            "textRaw": "Returns: {this}",
                            "name": "return",
                            "type": "this"
                          }
                        }
                      ],
                      "desc": "<p>The <code>readable.resume()</code> method causes an explicitly paused <code>Readable</code> stream to\nresume emitting <a href=\"#event-data\"><code>'data'</code></a> events, switching the stream into flowing mode.</p>\n<p>The <code>readable.resume()</code> method can be used to fully consume the data from a\nstream without actually processing any of that data:</p>\n<pre><code class=\"language-js\">getReadableStreamSomehow()\n  .resume()\n  .on('end', () => {\n    console.log('Reached the end, but did not read anything.');\n  });\n</code></pre>\n<p>The <code>readable.resume()</code> method has no effect if there is a <code>'readable'</code>\nevent listener.</p>"
                    },
                    {
                      "textRaw": "`readable.setEncoding(encoding)`",
                      "name": "setEncoding",
                      "type": "method",
                      "meta": {
                        "added": [
                          "v0.9.4"
                        ],
                        "changes": []
                      },
                      "signatures": [
                        {
                          "params": [
                            {
                              "textRaw": "`encoding` {string} The encoding to use.",
                              "name": "encoding",
                              "type": "string",
                              "desc": "The encoding to use."
                            }
                          ],
                          "return": {
                            "textRaw": "Returns: {this}",
                            "name": "return",
                            "type": "this"
                          }
                        }
                      ],
                      "desc": "<p>The <code>readable.setEncoding()</code> method sets the character encoding for\ndata read from the <code>Readable</code> stream.</p>\n<p>By default, no encoding is assigned and stream data will be returned as\n<code>Buffer</code> objects. Setting an encoding causes the stream data\nto be returned as strings of the specified encoding rather than as <code>Buffer</code>\nobjects. For instance, calling <code>readable.setEncoding('utf8')</code> will cause the\noutput data to be interpreted as UTF-8 data, and passed as strings. Calling\n<code>readable.setEncoding('hex')</code> will cause the data to be encoded in hexadecimal\nstring format.</p>\n<p>The <code>Readable</code> stream will properly handle multi-byte characters delivered\nthrough the stream that would otherwise become improperly decoded if simply\npulled from the stream as <code>Buffer</code> objects.</p>\n<pre><code class=\"language-js\">const readable = getReadableStreamSomehow();\nreadable.setEncoding('utf8');\nreadable.on('data', (chunk) => {\n  assert.equal(typeof chunk, 'string');\n  console.log('Got %d characters of string data:', chunk.length);\n});\n</code></pre>"
                    },
                    {
                      "textRaw": "`readable.unpipe([destination])`",
                      "name": "unpipe",
                      "type": "method",
                      "meta": {
                        "added": [
                          "v0.9.4"
                        ],
                        "changes": []
                      },
                      "signatures": [
                        {
                          "params": [
                            {
                              "textRaw": "`destination` {stream.Writable} Optional specific stream to unpipe",
                              "name": "destination",
                              "type": "stream.Writable",
                              "desc": "Optional specific stream to unpipe",
                              "optional": true
                            }
                          ],
                          "return": {
                            "textRaw": "Returns: {this}",
                            "name": "return",
                            "type": "this"
                          }
                        }
                      ],
                      "desc": "<p>The <code>readable.unpipe()</code> method detaches a <code>Writable</code> stream previously attached\nusing the <a href=\"#readablepipedestination-options\"><code>stream.pipe()</code></a> method.</p>\n<p>If the <code>destination</code> is not specified, then <em>all</em> pipes are detached.</p>\n<p>If the <code>destination</code> is specified, but no pipe is set up for it, then\nthe method does nothing.</p>\n<pre><code class=\"language-js\">const fs = require('node:fs');\nconst readable = getReadableStreamSomehow();\nconst writable = fs.createWriteStream('file.txt');\n// All the data from readable goes into 'file.txt',\n// but only for the first second.\nreadable.pipe(writable);\nsetTimeout(() => {\n  console.log('Stop writing to file.txt.');\n  readable.unpipe(writable);\n  console.log('Manually close the file stream.');\n  writable.end();\n}, 1000);\n</code></pre>"
                    },
                    {
                      "textRaw": "`readable.unshift(chunk[, encoding])`",
                      "name": "unshift",
                      "type": "method",
                      "meta": {
                        "added": [
                          "v0.9.11"
                        ],
                        "changes": [
                          {
                            "version": [
                              "v22.0.0",
                              "v20.13.0"
                            ],
                            "pr-url": "https://github.com/nodejs/node/pull/51866",
                            "description": "The `chunk` argument can now be a `TypedArray` or `DataView` instance."
                          },
                          {
                            "version": "v8.0.0",
                            "pr-url": "https://github.com/nodejs/node/pull/11608",
                            "description": "The `chunk` argument can now be a `Uint8Array` instance."
                          }
                        ]
                      },
                      "signatures": [
                        {
                          "params": [
                            {
                              "textRaw": "`chunk` {Buffer|TypedArray|DataView|string|null|any} Chunk of data to unshift onto the read queue. For streams not operating in object mode, `chunk` must be a {string}, {Buffer}, {TypedArray}, {DataView} or `null`. For object mode streams, `chunk` may be any JavaScript value.",
                              "name": "chunk",
                              "type": "Buffer|TypedArray|DataView|string|null|any",
                              "desc": "Chunk of data to unshift onto the read queue. For streams not operating in object mode, `chunk` must be a {string}, {Buffer}, {TypedArray}, {DataView} or `null`. For object mode streams, `chunk` may be any JavaScript value."
                            },
                            {
                              "textRaw": "`encoding` {string} Encoding of string chunks. Must be a valid `Buffer` encoding, such as `'utf8'` or `'ascii'`.",
                              "name": "encoding",
                              "type": "string",
                              "desc": "Encoding of string chunks. Must be a valid `Buffer` encoding, such as `'utf8'` or `'ascii'`.",
                              "optional": true
                            }
                          ]
                        }
                      ],
                      "desc": "<p>Passing <code>chunk</code> as <code>null</code> signals the end of the stream (EOF) and behaves the\nsame as <code>readable.push(null)</code>, after which no more data can be written. The EOF\nsignal is put at the end of the buffer and any buffered data will still be\nflushed.</p>\n<p>The <code>readable.unshift()</code> method pushes a chunk of data back into the internal\nbuffer. This is useful in certain situations where a stream is being consumed by\ncode that needs to \"un-consume\" some amount of data that it has optimistically\npulled out of the source, so that the data can be passed on to some other party.</p>\n<p>The <code>stream.unshift(chunk)</code> method cannot be called after the <a href=\"#event-end\"><code>'end'</code></a> event\nhas been emitted or a runtime error will be thrown.</p>\n<p>Developers using <code>stream.unshift()</code> often should consider switching to\nuse of a <a href=\"#class-streamtransform\"><code>Transform</code></a> stream instead. See the <a href=\"#api-for-stream-implementers\">API for stream implementers</a>\nsection for more information.</p>\n<pre><code class=\"language-js\">// Pull off a header delimited by \\n\\n.\n// Use unshift() if we get too much.\n// Call the callback with (error, header, stream).\nconst { StringDecoder } = require('node:string_decoder');\nfunction parseHeader(stream, callback) {\n  stream.on('error', callback);\n  stream.on('readable', onReadable);\n  const decoder = new StringDecoder('utf8');\n  let header = '';\n  function onReadable() {\n    let chunk;\n    while (null !== (chunk = stream.read())) {\n      const str = decoder.write(chunk);\n      if (str.includes('\\n\\n')) {\n        // Found the header boundary.\n        const split = str.split(/\\n\\n/);\n        header += split.shift();\n        const remaining = split.join('\\n\\n');\n        const buf = Buffer.from(remaining, 'utf8');\n        stream.removeListener('error', callback);\n        // Remove the 'readable' listener before unshifting.\n        stream.removeListener('readable', onReadable);\n        if (buf.length)\n          stream.unshift(buf);\n        // Now the body of the message can be read from the stream.\n        callback(null, header, stream);\n        return;\n      }\n      // Still reading the header.\n      header += str;\n    }\n  }\n}\n</code></pre>\n<p>Unlike <a href=\"#readablepushchunk-encoding\"><code>stream.push(chunk)</code></a>, <code>stream.unshift(chunk)</code> will not\nend the reading process by resetting the internal reading state of the stream.\nThis can cause unexpected results if <code>readable.unshift()</code> is called during a\nread (i.e. from within a <a href=\"#readable_readsize\"><code>stream._read()</code></a> implementation on a\ncustom stream). Following the call to <code>readable.unshift()</code> with an immediate\n<a href=\"#readablepushchunk-encoding\"><code>stream.push('')</code></a> will reset the reading state appropriately,\nhowever it is best to simply avoid calling <code>readable.unshift()</code> while in the\nprocess of performing a read.</p>"
                    },
                    {
                      "textRaw": "`readable.wrap(stream)`",
                      "name": "wrap",
                      "type": "method",
                      "meta": {
                        "added": [
                          "v0.9.4"
                        ],
                        "changes": []
                      },
                      "signatures": [
                        {
                          "params": [
                            {
                              "textRaw": "`stream` {Stream} An \"old style\" readable stream",
                              "name": "stream",
                              "type": "Stream",
                              "desc": "An \"old style\" readable stream"
                            }
                          ],
                          "return": {
                            "textRaw": "Returns: {this}",
                            "name": "return",
                            "type": "this"
                          }
                        }
                      ],
                      "desc": "<p>Prior to Node.js 0.10, streams did not implement the entire <code>node:stream</code>\nmodule API as it is currently defined. (See <a href=\"#compatibility-with-older-nodejs-versions\">Compatibility</a> for more\ninformation.)</p>\n<p>When using an older Node.js library that emits <a href=\"#event-data\"><code>'data'</code></a> events and has a\n<a href=\"#readablepause\"><code>stream.pause()</code></a> method that is advisory only, the\n<code>readable.wrap()</code> method can be used to create a <a href=\"#class-streamreadable\"><code>Readable</code></a> stream that uses\nthe old stream as its data source.</p>\n<p>It will rarely be necessary to use <code>readable.wrap()</code> but the method has been\nprovided as a convenience for interacting with older Node.js applications and\nlibraries.</p>\n<pre><code class=\"language-js\">const { OldReader } = require('./old-api-module.js');\nconst { Readable } = require('node:stream');\nconst oreader = new OldReader();\nconst myReader = new Readable().wrap(oreader);\n\nmyReader.on('readable', () => {\n  myReader.read(); // etc.\n});\n</code></pre>"
                    },
                    {
                      "textRaw": "`readable[Symbol.asyncIterator]()`",
                      "name": "[Symbol.asyncIterator]",
                      "type": "method",
                      "meta": {
                        "added": [
                          "v10.0.0"
                        ],
                        "changes": [
                          {
                            "version": "v11.14.0",
                            "pr-url": "https://github.com/nodejs/node/pull/26989",
                            "description": "Symbol.asyncIterator support is no longer experimental."
                          }
                        ]
                      },
                      "signatures": [
                        {
                          "params": [],
                          "return": {
                            "textRaw": "Returns: {AsyncIterator} to fully consume the stream.",
                            "name": "return",
                            "type": "AsyncIterator",
                            "desc": "to fully consume the stream."
                          }
                        }
                      ],
                      "desc": "<pre><code class=\"language-js\">const fs = require('node:fs');\n\nasync function print(readable) {\n  readable.setEncoding('utf8');\n  let data = '';\n  for await (const chunk of readable) {\n    data += chunk;\n  }\n  console.log(data);\n}\n\nprint(fs.createReadStream('file')).catch(console.error);\n</code></pre>\n<p>If the loop terminates with a <code>break</code>, <code>return</code>, or a <code>throw</code>, the stream will\nbe destroyed. In other terms, iterating over a stream will consume the stream\nfully. The stream will be read in chunks of size equal to the <code>highWaterMark</code>\noption. In the code example above, data will be in a single chunk if the file\nhas less then 64 KiB of data because no <code>highWaterMark</code> option is provided to\n<a href=\"fs.html#fscreatereadstreampath-options\"><code>fs.createReadStream()</code></a>.</p>"
                    },
                    {
                      "textRaw": "`readable[Symbol.for('Stream.toAsyncStreamable')]()`",
                      "name": "[Symbol.for('Stream.toAsyncStreamable')]",
                      "type": "method",
                      "meta": {
                        "added": [
                          "v26.1.0"
                        ],
                        "changes": []
                      },
                      "stability": 1,
                      "stabilityText": "Experimental",
                      "signatures": [
                        {
                          "params": [],
                          "return": {
                            "textRaw": "Returns: {AsyncIterable} An `AsyncIterable<Uint8Array[]>` that yields batched chunks from the stream.",
                            "name": "return",
                            "type": "AsyncIterable",
                            "desc": "An `AsyncIterable<Uint8Array[]>` that yields batched chunks from the stream."
                          }
                        }
                      ],
                      "desc": "<p>When the <code>--experimental-stream-iter</code> flag is enabled, <code>Readable</code> streams\nimplement the <a href=\"stream_iter.html#streamtoasyncstreamable\"><code>Stream.toAsyncStreamable</code></a> protocol, enabling efficient\nconsumption by the <a href=\"stream_iter.html\"><code>stream/iter</code></a> API.</p>\n<p>This provides a batched async iterator that drains the stream's internal\nbuffer into <code>Uint8Array[]</code> batches, amortizing the per-chunk Promise overhead\nof the standard <code>Symbol.asyncIterator</code> path. For byte-mode streams, chunks\nare yielded directly as <code>Buffer</code> instances (which are <code>Uint8Array</code> subclasses).\nFor object-mode or encoded streams, each chunk is normalized to <code>Uint8Array</code>\nbefore batching.</p>\n<p>The returned iterator is tagged as a validated source, so <a href=\"stream_iter.html#frominput\"><code>from()</code></a>\npasses it through without additional normalization.</p>\n<pre><code class=\"language-mjs\">import { Readable } from 'node:stream';\nimport { text, from } from 'node:stream/iter';\n\nconst readable = new Readable({\n  read() { this.push('hello'); this.push(null); },\n});\n\n// Readable is automatically consumed via toAsyncStreamable\nconsole.log(await text(from(readable))); // 'hello'\n</code></pre>\n<pre><code class=\"language-cjs\">const { Readable } = require('node:stream');\nconst { text, from } = require('node:stream/iter');\n\nasync function run() {\n  const readable = new Readable({\n    read() { this.push('hello'); this.push(null); },\n  });\n\n  console.log(await text(from(readable))); // 'hello'\n}\n\nrun().catch(console.error);\n</code></pre>\n<p>Without the <code>--experimental-stream-iter</code> flag, calling this method throws\n<a href=\"errors.html#err_stream_iter_missing_flag\"><code>ERR_STREAM_ITER_MISSING_FLAG</code></a>.</p>"
                    },
                    {
                      "textRaw": "`readable[Symbol.asyncDispose]()`",
                      "name": "[Symbol.asyncDispose]",
                      "type": "method",
                      "meta": {
                        "added": [
                          "v20.4.0",
                          "v18.18.0"
                        ],
                        "changes": [
                          {
                            "version": "v24.2.0",
                            "pr-url": "https://github.com/nodejs/node/pull/58467",
                            "description": "No longer experimental."
                          }
                        ]
                      },
                      "signatures": [
                        {
                          "params": []
                        }
                      ],
                      "desc": "<p>Calls <a href=\"#readabledestroyerror\"><code>readable.destroy()</code></a> with an <code>AbortError</code> and returns\na promise that fulfills when the stream is finished.</p>"
                    },
                    {
                      "textRaw": "`readable.compose(stream[, options])`",
                      "name": "compose",
                      "type": "method",
                      "meta": {
                        "added": [
                          "v19.1.0",
                          "v18.13.0"
                        ],
                        "changes": [
                          {
                            "version": [
                              "v24.0.0",
                              "v22.17.0"
                            ],
                            "pr-url": "https://github.com/nodejs/node/pull/57513",
                            "description": "Marking the API stable."
                          }
                        ]
                      },
                      "signatures": [
                        {
                          "params": [
                            {
                              "textRaw": "`stream` {Writable|Duplex|WritableStream|TransformStream|Function}",
                              "name": "stream",
                              "type": "Writable|Duplex|WritableStream|TransformStream|Function"
                            },
                            {
                              "textRaw": "`options` {Object}",
                              "name": "options",
                              "type": "Object",
                              "options": [
                                {
                                  "textRaw": "`signal` {AbortSignal} allows destroying the stream if the signal is aborted.",
                                  "name": "signal",
                                  "type": "AbortSignal",
                                  "desc": "allows destroying the stream if the signal is aborted."
                                }
                              ],
                              "optional": true
                            }
                          ],
                          "return": {
                            "textRaw": "Returns: {Duplex} a stream composed with the stream `stream`.",
                            "name": "return",
                            "type": "Duplex",
                            "desc": "a stream composed with the stream `stream`."
                          }
                        }
                      ],
                      "desc": "<pre><code class=\"language-mjs\">import { Readable } from 'node:stream';\n\nasync function* splitToWords(source) {\n  for await (const chunk of source) {\n    const words = String(chunk).split(' ');\n\n    for (const word of words) {\n      yield word;\n    }\n  }\n}\n\nconst wordsStream = Readable.from(['text passed through', 'composed stream']).compose(splitToWords);\nconst words = await wordsStream.toArray();\n\nconsole.log(words); // prints ['text', 'passed', 'through', 'composed', 'stream']\n</code></pre>\n<p><code>readable.compose(s)</code> is equivalent to <code>stream.compose(readable, s)</code>.</p>\n<p>This method also allows for an <a href=\"globals.html#class-abortsignal\"><code>&#x3C;AbortSignal></code></a> to be provided, which will destroy\nthe composed stream when aborted.</p>\n<p>See <a href=\"#streamcomposestreams\"><code>stream.compose(...streams)</code></a> for more information.</p>"
                    },
                    {
                      "textRaw": "`readable.iterator([options])`",
                      "name": "iterator",
                      "type": "method",
                      "meta": {
                        "added": [
                          "v16.3.0"
                        ],
                        "changes": [
                          {
                            "version": [
                              "v24.0.0",
                              "v22.17.0"
                            ],
                            "pr-url": "https://github.com/nodejs/node/pull/57513",
                            "description": "Marking the API stable."
                          }
                        ]
                      },
                      "signatures": [
                        {
                          "params": [
                            {
                              "textRaw": "`options` {Object}",
                              "name": "options",
                              "type": "Object",
                              "options": [
                                {
                                  "textRaw": "`destroyOnReturn` {boolean} When set to `false`, calling `return` on the async iterator, or exiting a `for await...of` iteration using a `break`, `return`, or `throw` will not destroy the stream. **Default:** `true`.",
                                  "name": "destroyOnReturn",
                                  "type": "boolean",
                                  "default": "`true`",
                                  "desc": "When set to `false`, calling `return` on the async iterator, or exiting a `for await...of` iteration using a `break`, `return`, or `throw` will not destroy the stream."
                                }
                              ],
                              "optional": true
                            }
                          ],
                          "return": {
                            "textRaw": "Returns: {AsyncIterator} to consume the stream.",
                            "name": "return",
                            "type": "AsyncIterator",
                            "desc": "to consume the stream."
                          }
                        }
                      ],
                      "desc": "<p>The iterator created by this method gives users the option to cancel the\ndestruction of the stream if the <code>for await...of</code> loop is exited by <code>return</code>,\n<code>break</code>, or <code>throw</code>, or if the iterator should destroy the stream if the stream\nemitted an error during iteration.</p>\n<pre><code class=\"language-js\">const { Readable } = require('node:stream');\n\nasync function printIterator(readable) {\n  for await (const chunk of readable.iterator({ destroyOnReturn: false })) {\n    console.log(chunk); // 1\n    break;\n  }\n\n  console.log(readable.destroyed); // false\n\n  for await (const chunk of readable.iterator({ destroyOnReturn: false })) {\n    console.log(chunk); // Will print 2 and then 3\n  }\n\n  console.log(readable.destroyed); // True, stream was totally consumed\n}\n\nasync function printSymbolAsyncIterator(readable) {\n  for await (const chunk of readable) {\n    console.log(chunk); // 1\n    break;\n  }\n\n  console.log(readable.destroyed); // true\n}\n\nasync function showBoth() {\n  await printIterator(Readable.from([1, 2, 3]));\n  await printSymbolAsyncIterator(Readable.from([1, 2, 3]));\n}\n\nshowBoth();\n</code></pre>"
                    },
                    {
                      "textRaw": "`readable.map(fn[, options])`",
                      "name": "map",
                      "type": "method",
                      "meta": {
                        "added": [
                          "v17.4.0",
                          "v16.14.0"
                        ],
                        "changes": [
                          {
                            "version": [
                              "v20.7.0",
                              "v18.19.0"
                            ],
                            "pr-url": "https://github.com/nodejs/node/pull/49249",
                            "description": "added `highWaterMark` in options."
                          }
                        ]
                      },
                      "stability": 1,
                      "stabilityText": "Experimental",
                      "signatures": [
                        {
                          "params": [
                            {
                              "textRaw": "`fn` {Function|AsyncFunction} a function to map over every chunk in the stream.",
                              "name": "fn",
                              "type": "Function|AsyncFunction",
                              "desc": "a function to map over every chunk in the stream.",
                              "options": [
                                {
                                  "textRaw": "`data` {any} a chunk of data from the stream.",
                                  "name": "data",
                                  "type": "any",
                                  "desc": "a chunk of data from the stream."
                                },
                                {
                                  "textRaw": "`options` {Object}",
                                  "name": "options",
                                  "type": "Object",
                                  "options": [
                                    {
                                      "textRaw": "`signal` {AbortSignal} aborted if the stream is destroyed allowing to abort the `fn` call early.",
                                      "name": "signal",
                                      "type": "AbortSignal",
                                      "desc": "aborted if the stream is destroyed allowing to abort the `fn` call early."
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "textRaw": "`options` {Object}",
                              "name": "options",
                              "type": "Object",
                              "options": [
                                {
                                  "textRaw": "`concurrency` {number} the maximum concurrent invocation of `fn` to call on the stream at once. **Default:** `1`.",
                                  "name": "concurrency",
                                  "type": "number",
                                  "default": "`1`",
                                  "desc": "the maximum concurrent invocation of `fn` to call on the stream at once."
                                },
                                {
                                  "textRaw": "`highWaterMark` {number} how many items to buffer while waiting for user consumption of the mapped items. **Default:** `concurrency * 2 - 1`.",
                                  "name": "highWaterMark",
                                  "type": "number",
                                  "default": "`concurrency * 2 - 1`",
                                  "desc": "how many items to buffer while waiting for user consumption of the mapped items."
                                },
                                {
                                  "textRaw": "`signal` {AbortSignal} allows destroying the stream if the signal is aborted.",
                                  "name": "signal",
                                  "type": "AbortSignal",
                                  "desc": "allows destroying the stream if the signal is aborted."
                                }
                              ],
                              "optional": true
                            }
                          ],
                          "return": {
                            "textRaw": "Returns: {Readable} a stream mapped with the function `fn`.",
                            "name": "return",
                            "type": "Readable",
                            "desc": "a stream mapped with the function `fn`."
                          }
                        }
                      ],
                      "desc": "<p>This method allows mapping over the stream. The <code>fn</code> function will be called\nfor every chunk in the stream. If the <code>fn</code> function returns a promise - that\npromise will be <code>await</code>ed before being passed to the result stream.</p>\n<pre><code class=\"language-mjs\">import { Readable } from 'node:stream';\nimport { Resolver } from 'node:dns/promises';\n\n// With a synchronous mapper.\nfor await (const chunk of Readable.from([1, 2, 3, 4]).map((x) => x * 2)) {\n  console.log(chunk); // 2, 4, 6, 8\n}\n// With an asynchronous mapper, making at most 2 queries at a time.\nconst resolver = new Resolver();\nconst dnsResults = Readable.from([\n  'nodejs.org',\n  'openjsf.org',\n  'www.linuxfoundation.org',\n]).map((domain) => resolver.resolve4(domain), { concurrency: 2 });\nfor await (const result of dnsResults) {\n  console.log(result); // Logs the DNS result of resolver.resolve4.\n}\n</code></pre>"
                    },
                    {
                      "textRaw": "`readable.filter(fn[, options])`",
                      "name": "filter",
                      "type": "method",
                      "meta": {
                        "added": [
                          "v17.4.0",
                          "v16.14.0"
                        ],
                        "changes": [
                          {
                            "version": [
                              "v20.7.0",
                              "v18.19.0"
                            ],
                            "pr-url": "https://github.com/nodejs/node/pull/49249",
                            "description": "added `highWaterMark` in options."
                          }
                        ]
                      },
                      "stability": 1,
                      "stabilityText": "Experimental",
                      "signatures": [
                        {
                          "params": [
                            {
                              "textRaw": "`fn` {Function|AsyncFunction} a function to filter chunks from the stream.",
                              "name": "fn",
                              "type": "Function|AsyncFunction",
                              "desc": "a function to filter chunks from the stream.",
                              "options": [
                                {
                                  "textRaw": "`data` {any} a chunk of data from the stream.",
                                  "name": "data",
                                  "type": "any",
                                  "desc": "a chunk of data from the stream."
                                },
                                {
                                  "textRaw": "`options` {Object}",
                                  "name": "options",
                                  "type": "Object",
                                  "options": [
                                    {
                                      "textRaw": "`signal` {AbortSignal} aborted if the stream is destroyed allowing to abort the `fn` call early.",
                                      "name": "signal",
                                      "type": "AbortSignal",
                                      "desc": "aborted if the stream is destroyed allowing to abort the `fn` call early."
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "textRaw": "`options` {Object}",
                              "name": "options",
                              "type": "Object",
                              "options": [
                                {
                                  "textRaw": "`concurrency` {number} the maximum concurrent invocation of `fn` to call on the stream at once. **Default:** `1`.",
                                  "name": "concurrency",
                                  "type": "number",
                                  "default": "`1`",
                                  "desc": "the maximum concurrent invocation of `fn` to call on the stream at once."
                                },
                                {
                                  "textRaw": "`highWaterMark` {number} how many items to buffer while waiting for user consumption of the filtered items. **Default:** `concurrency * 2 - 1`.",
                                  "name": "highWaterMark",
                                  "type": "number",
                                  "default": "`concurrency * 2 - 1`",
                                  "desc": "how many items to buffer while waiting for user consumption of the filtered items."
                                },
                                {
                                  "textRaw": "`signal` {AbortSignal} allows destroying the stream if the signal is aborted.",
                                  "name": "signal",
                                  "type": "AbortSignal",
                                  "desc": "allows destroying the stream if the signal is aborted."
                                }
                              ],
                              "optional": true
                            }
                          ],
                          "return": {
                            "textRaw": "Returns: {Readable} a stream filtered with the predicate `fn`.",
                            "name": "return",
                            "type": "Readable",
                            "desc": "a stream filtered with the predicate `fn`."
                          }
                        }
                      ],
                      "desc": "<p>This method allows filtering the stream. For each chunk in the stream the <code>fn</code>\nfunction will be called and if it returns a truthy value, the chunk will be\npassed to the result stream. If the <code>fn</code> function returns a promise - that\npromise will be <code>await</code>ed.</p>\n<pre><code class=\"language-mjs\">import { Readable } from 'node:stream';\nimport { Resolver } from 'node:dns/promises';\n\n// With a synchronous predicate.\nfor await (const chunk of Readable.from([1, 2, 3, 4]).filter((x) => x > 2)) {\n  console.log(chunk); // 3, 4\n}\n// With an asynchronous predicate, making at most 2 queries at a time.\nconst resolver = new Resolver();\nconst dnsResults = Readable.from([\n  'nodejs.org',\n  'openjsf.org',\n  'www.linuxfoundation.org',\n]).filter(async (domain) => {\n  const { address } = await resolver.resolve4(domain, { ttl: true });\n  return address.ttl > 60;\n}, { concurrency: 2 });\nfor await (const result of dnsResults) {\n  // Logs domains with more than 60 seconds on the resolved dns record.\n  console.log(result);\n}\n</code></pre>"
                    },
                    {
                      "textRaw": "`readable.forEach(fn[, options])`",
                      "name": "forEach",
                      "type": "method",
                      "meta": {
                        "added": [
                          "v17.5.0",
                          "v16.15.0"
                        ],
                        "changes": []
                      },
                      "stability": 1,
                      "stabilityText": "Experimental",
                      "signatures": [
                        {
                          "params": [
                            {
                              "textRaw": "`fn` {Function|AsyncFunction} a function to call on each chunk of the stream.",
                              "name": "fn",
                              "type": "Function|AsyncFunction",
                              "desc": "a function to call on each chunk of the stream.",
                              "options": [
                                {
                                  "textRaw": "`data` {any} a chunk of data from the stream.",
                                  "name": "data",
                                  "type": "any",
                                  "desc": "a chunk of data from the stream."
                                },
                                {
                                  "textRaw": "`options` {Object}",
                                  "name": "options",
                                  "type": "Object",
                                  "options": [
                                    {
                                      "textRaw": "`signal` {AbortSignal} aborted if the stream is destroyed allowing to abort the `fn` call early.",
                                      "name": "signal",
                                      "type": "AbortSignal",
                                      "desc": "aborted if the stream is destroyed allowing to abort the `fn` call early."
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "textRaw": "`options` {Object}",
                              "name": "options",
                              "type": "Object",
                              "options": [
                                {
                                  "textRaw": "`concurrency` {number} the maximum concurrent invocation of `fn` to call on the stream at once. **Default:** `1`.",
                                  "name": "concurrency",
                                  "type": "number",
                                  "default": "`1`",
                                  "desc": "the maximum concurrent invocation of `fn` to call on the stream at once."
                                },
                                {
                                  "textRaw": "`signal` {AbortSignal} allows destroying the stream if the signal is aborted.",
                                  "name": "signal",
                                  "type": "AbortSignal",
                                  "desc": "allows destroying the stream if the signal is aborted."
                                }
                              ],
                              "optional": true
                            }
                          ],
                          "return": {
                            "textRaw": "Returns: {Promise} a promise for when the stream has finished.",
                            "name": "return",
                            "type": "Promise",
                            "desc": "a promise for when the stream has finished."
                          }
                        }
                      ],
                      "desc": "<p>This method allows iterating a stream. For each chunk in the stream the\n<code>fn</code> function will be called. If the <code>fn</code> function returns a promise - that\npromise will be <code>await</code>ed.</p>\n<p>This method is different from <code>for await...of</code> loops in that it can optionally\nprocess chunks concurrently. In addition, a <code>forEach</code> iteration can only be\nstopped by having passed a <code>signal</code> option and aborting the related\n<code>AbortController</code> while <code>for await...of</code> can be stopped with <code>break</code> or\n<code>return</code>. In either case the stream will be destroyed.</p>\n<p>This method is different from listening to the <a href=\"#event-data\"><code>'data'</code></a> event in that it\nuses the <a href=\"#class-streamreadable\"><code>readable</code></a> event in the underlying machinery and can limit the\nnumber of concurrent <code>fn</code> calls.</p>\n<pre><code class=\"language-mjs\">import { Readable } from 'node:stream';\nimport { Resolver } from 'node:dns/promises';\n\n// With a synchronous predicate.\nfor await (const chunk of Readable.from([1, 2, 3, 4]).filter((x) => x > 2)) {\n  console.log(chunk); // 3, 4\n}\n// With an asynchronous predicate, making at most 2 queries at a time.\nconst resolver = new Resolver();\nconst dnsResults = Readable.from([\n  'nodejs.org',\n  'openjsf.org',\n  'www.linuxfoundation.org',\n]).map(async (domain) => {\n  const { address } = await resolver.resolve4(domain, { ttl: true });\n  return address;\n}, { concurrency: 2 });\nawait dnsResults.forEach((result) => {\n  // Logs result, similar to `for await (const result of dnsResults)`\n  console.log(result);\n});\nconsole.log('done'); // Stream has finished\n</code></pre>"
                    },
                    {
                      "textRaw": "`readable.toArray([options])`",
                      "name": "toArray",
                      "type": "method",
                      "meta": {
                        "added": [
                          "v17.5.0",
                          "v16.15.0"
                        ],
                        "changes": []
                      },
                      "stability": 1,
                      "stabilityText": "Experimental",
                      "signatures": [
                        {
                          "params": [
                            {
                              "textRaw": "`options` {Object}",
                              "name": "options",
                              "type": "Object",
                              "options": [
                                {
                                  "textRaw": "`signal` {AbortSignal} allows cancelling the toArray operation if the signal is aborted.",
                                  "name": "signal",
                                  "type": "AbortSignal",
                                  "desc": "allows cancelling the toArray operation if the signal is aborted."
                                }
                              ],
                              "optional": true
                            }
                          ],
                          "return": {
                            "textRaw": "Returns: {Promise} a promise containing an array with the contents of the stream.",
                            "name": "return",
                            "type": "Promise",
                            "desc": "a promise containing an array with the contents of the stream."
                          }
                        }
                      ],
                      "desc": "<p>This method allows easily obtaining the contents of a stream.</p>\n<p>As this method reads the entire stream into memory, it negates the benefits of\nstreams. It's intended for interoperability and convenience, not as the primary\nway to consume streams.</p>\n<pre><code class=\"language-mjs\">import { Readable } from 'node:stream';\nimport { Resolver } from 'node:dns/promises';\n\nawait Readable.from([1, 2, 3, 4]).toArray(); // [1, 2, 3, 4]\n\nconst resolver = new Resolver();\n\n// Make dns queries concurrently using .map and collect\n// the results into an array using toArray\nconst dnsResults = await Readable.from([\n  'nodejs.org',\n  'openjsf.org',\n  'www.linuxfoundation.org',\n]).map(async (domain) => {\n  const { address } = await resolver.resolve4(domain, { ttl: true });\n  return address;\n}, { concurrency: 2 }).toArray();\n</code></pre>"
                    },
                    {
                      "textRaw": "`readable.some(fn[, options])`",
                      "name": "some",
                      "type": "method",
                      "meta": {
                        "added": [
                          "v17.5.0",
                          "v16.15.0"
                        ],
                        "changes": []
                      },
                      "stability": 1,
                      "stabilityText": "Experimental",
                      "signatures": [
                        {
                          "params": [
                            {
                              "textRaw": "`fn` {Function|AsyncFunction} a function to call on each chunk of the stream.",
                              "name": "fn",
                              "type": "Function|AsyncFunction",
                              "desc": "a function to call on each chunk of the stream.",
                              "options": [
                                {
                                  "textRaw": "`data` {any} a chunk of data from the stream.",
                                  "name": "data",
                                  "type": "any",
                                  "desc": "a chunk of data from the stream."
                                },
                                {
                                  "textRaw": "`options` {Object}",
                                  "name": "options",
                                  "type": "Object",
                                  "options": [
                                    {
                                      "textRaw": "`signal` {AbortSignal} aborted if the stream is destroyed allowing to abort the `fn` call early.",
                                      "name": "signal",
                                      "type": "AbortSignal",
                                      "desc": "aborted if the stream is destroyed allowing to abort the `fn` call early."
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "textRaw": "`options` {Object}",
                              "name": "options",
                              "type": "Object",
                              "options": [
                                {
                                  "textRaw": "`concurrency` {number} the maximum concurrent invocation of `fn` to call on the stream at once. **Default:** `1`.",
                                  "name": "concurrency",
                                  "type": "number",
                                  "default": "`1`",
                                  "desc": "the maximum concurrent invocation of `fn` to call on the stream at once."
                                },
                                {
                                  "textRaw": "`signal` {AbortSignal} allows destroying the stream if the signal is aborted.",
                                  "name": "signal",
                                  "type": "AbortSignal",
                                  "desc": "allows destroying the stream if the signal is aborted."
                                }
                              ],
                              "optional": true
                            }
                          ],
                          "return": {
                            "textRaw": "Returns: {Promise} a promise evaluating to `true` if `fn` returned a truthy value for at least one of the chunks.",
                            "name": "return",
                            "type": "Promise",
                            "desc": "a promise evaluating to `true` if `fn` returned a truthy value for at least one of the chunks."
                          }
                        }
                      ],
                      "desc": "<p>This method is similar to <code>Array.prototype.some</code> and calls <code>fn</code> on each chunk\nin the stream until the awaited return value is <code>true</code> (or any truthy value).\nOnce an <code>fn</code> call on a chunk awaited return value is truthy, the stream is\ndestroyed and the promise is fulfilled with <code>true</code>. If none of the <code>fn</code>\ncalls on the chunks return a truthy value, the promise is fulfilled with\n<code>false</code>.</p>\n<pre><code class=\"language-mjs\">import { Readable } from 'node:stream';\nimport { stat } from 'node:fs/promises';\n\n// With a synchronous predicate.\nawait Readable.from([1, 2, 3, 4]).some((x) => x > 2); // true\nawait Readable.from([1, 2, 3, 4]).some((x) => x &#x3C; 0); // false\n\n// With an asynchronous predicate, making at most 2 file checks at a time.\nconst anyBigFile = await Readable.from([\n  'file1',\n  'file2',\n  'file3',\n]).some(async (fileName) => {\n  const stats = await stat(fileName);\n  return stats.size > 1024 * 1024;\n}, { concurrency: 2 });\nconsole.log(anyBigFile); // `true` if any file in the list is bigger than 1MB\nconsole.log('done'); // Stream has finished\n</code></pre>"
                    },
                    {
                      "textRaw": "`readable.find(fn[, options])`",
                      "name": "find",
                      "type": "method",
                      "meta": {
                        "added": [
                          "v17.5.0",
                          "v16.17.0"
                        ],
                        "changes": []
                      },
                      "stability": 1,
                      "stabilityText": "Experimental",
                      "signatures": [
                        {
                          "params": [
                            {
                              "textRaw": "`fn` {Function|AsyncFunction} a function to call on each chunk of the stream.",
                              "name": "fn",
                              "type": "Function|AsyncFunction",
                              "desc": "a function to call on each chunk of the stream.",
                              "options": [
                                {
                                  "textRaw": "`data` {any} a chunk of data from the stream.",
                                  "name": "data",
                                  "type": "any",
                                  "desc": "a chunk of data from the stream."
                                },
                                {
                                  "textRaw": "`options` {Object}",
                                  "name": "options",
                                  "type": "Object",
                                  "options": [
                                    {
                                      "textRaw": "`signal` {AbortSignal} aborted if the stream is destroyed allowing to abort the `fn` call early.",
                                      "name": "signal",
                                      "type": "AbortSignal",
                                      "desc": "aborted if the stream is destroyed allowing to abort the `fn` call early."
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "textRaw": "`options` {Object}",
                              "name": "options",
                              "type": "Object",
                              "options": [
                                {
                                  "textRaw": "`concurrency` {number} the maximum concurrent invocation of `fn` to call on the stream at once. **Default:** `1`.",
                                  "name": "concurrency",
                                  "type": "number",
                                  "default": "`1`",
                                  "desc": "the maximum concurrent invocation of `fn` to call on the stream at once."
                                },
                                {
                                  "textRaw": "`signal` {AbortSignal} allows destroying the stream if the signal is aborted.",
                                  "name": "signal",
                                  "type": "AbortSignal",
                                  "desc": "allows destroying the stream if the signal is aborted."
                                }
                              ],
                              "optional": true
                            }
                          ],
                          "return": {
                            "textRaw": "Returns: {Promise} a promise evaluating to the first chunk for which `fn` evaluated with a truthy value, or `undefined` if no element was found.",
                            "name": "return",
                            "type": "Promise",
                            "desc": "a promise evaluating to the first chunk for which `fn` evaluated with a truthy value, or `undefined` if no element was found."
                          }
                        }
                      ],
                      "desc": "<p>This method is similar to <code>Array.prototype.find</code> and calls <code>fn</code> on each chunk\nin the stream to find a chunk with a truthy value for <code>fn</code>. Once an <code>fn</code> call's\nawaited return value is truthy, the stream is destroyed and the promise is\nfulfilled with value for which <code>fn</code> returned a truthy value. If all of the\n<code>fn</code> calls on the chunks return a falsy value, the promise is fulfilled with\n<code>undefined</code>.</p>\n<pre><code class=\"language-mjs\">import { Readable } from 'node:stream';\nimport { stat } from 'node:fs/promises';\n\n// With a synchronous predicate.\nawait Readable.from([1, 2, 3, 4]).find((x) => x > 2); // 3\nawait Readable.from([1, 2, 3, 4]).find((x) => x > 0); // 1\nawait Readable.from([1, 2, 3, 4]).find((x) => x > 10); // undefined\n\n// With an asynchronous predicate, making at most 2 file checks at a time.\nconst foundBigFile = await Readable.from([\n  'file1',\n  'file2',\n  'file3',\n]).find(async (fileName) => {\n  const stats = await stat(fileName);\n  return stats.size > 1024 * 1024;\n}, { concurrency: 2 });\nconsole.log(foundBigFile); // File name of large file, if any file in the list is bigger than 1MB\nconsole.log('done'); // Stream has finished\n</code></pre>"
                    },
                    {
                      "textRaw": "`readable.every(fn[, options])`",
                      "name": "every",
                      "type": "method",
                      "meta": {
                        "added": [
                          "v17.5.0",
                          "v16.15.0"
                        ],
                        "changes": []
                      },
                      "stability": 1,
                      "stabilityText": "Experimental",
                      "signatures": [
                        {
                          "params": [
                            {
                              "textRaw": "`fn` {Function|AsyncFunction} a function to call on each chunk of the stream.",
                              "name": "fn",
                              "type": "Function|AsyncFunction",
                              "desc": "a function to call on each chunk of the stream.",
                              "options": [
                                {
                                  "textRaw": "`data` {any} a chunk of data from the stream.",
                                  "name": "data",
                                  "type": "any",
                                  "desc": "a chunk of data from the stream."
                                },
                                {
                                  "textRaw": "`options` {Object}",
                                  "name": "options",
                                  "type": "Object",
                                  "options": [
                                    {
                                      "textRaw": "`signal` {AbortSignal} aborted if the stream is destroyed allowing to abort the `fn` call early.",
                                      "name": "signal",
                                      "type": "AbortSignal",
                                      "desc": "aborted if the stream is destroyed allowing to abort the `fn` call early."
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "textRaw": "`options` {Object}",
                              "name": "options",
                              "type": "Object",
                              "options": [
                                {
                                  "textRaw": "`concurrency` {number} the maximum concurrent invocation of `fn` to call on the stream at once. **Default:** `1`.",
                                  "name": "concurrency",
                                  "type": "number",
                                  "default": "`1`",
                                  "desc": "the maximum concurrent invocation of `fn` to call on the stream at once."
                                },
                                {
                                  "textRaw": "`signal` {AbortSignal} allows destroying the stream if the signal is aborted.",
                                  "name": "signal",
                                  "type": "AbortSignal",
                                  "desc": "allows destroying the stream if the signal is aborted."
                                }
                              ],
                              "optional": true
                            }
                          ],
                          "return": {
                            "textRaw": "Returns: {Promise} a promise evaluating to `true` if `fn` returned a truthy value for all of the chunks.",
                            "name": "return",
                            "type": "Promise",
                            "desc": "a promise evaluating to `true` if `fn` returned a truthy value for all of the chunks."
                          }
                        }
                      ],
                      "desc": "<p>This method is similar to <code>Array.prototype.every</code> and calls <code>fn</code> on each chunk\nin the stream to check if all awaited return values are truthy value for <code>fn</code>.\nOnce an <code>fn</code> call on a chunk awaited return value is falsy, the stream is\ndestroyed and the promise is fulfilled with <code>false</code>. If all of the <code>fn</code> calls\non the chunks return a truthy value, the promise is fulfilled with <code>true</code>.</p>\n<pre><code class=\"language-mjs\">import { Readable } from 'node:stream';\nimport { stat } from 'node:fs/promises';\n\n// With a synchronous predicate.\nawait Readable.from([1, 2, 3, 4]).every((x) => x > 2); // false\nawait Readable.from([1, 2, 3, 4]).every((x) => x > 0); // true\n\n// With an asynchronous predicate, making at most 2 file checks at a time.\nconst allBigFiles = await Readable.from([\n  'file1',\n  'file2',\n  'file3',\n]).every(async (fileName) => {\n  const stats = await stat(fileName);\n  return stats.size > 1024 * 1024;\n}, { concurrency: 2 });\n// `true` if all files in the list are bigger than 1MiB\nconsole.log(allBigFiles);\nconsole.log('done'); // Stream has finished\n</code></pre>"
                    },
                    {
                      "textRaw": "`readable.flatMap(fn[, options])`",
                      "name": "flatMap",
                      "type": "method",
                      "meta": {
                        "added": [
                          "v17.5.0",
                          "v16.15.0"
                        ],
                        "changes": []
                      },
                      "stability": 1,
                      "stabilityText": "Experimental",
                      "signatures": [
                        {
                          "params": [
                            {
                              "textRaw": "`fn` {Function|AsyncGeneratorFunction|AsyncFunction} a function to map over every chunk in the stream.",
                              "name": "fn",
                              "type": "Function|AsyncGeneratorFunction|AsyncFunction",
                              "desc": "a function to map over every chunk in the stream.",
                              "options": [
                                {
                                  "textRaw": "`data` {any} a chunk of data from the stream.",
                                  "name": "data",
                                  "type": "any",
                                  "desc": "a chunk of data from the stream."
                                },
                                {
                                  "textRaw": "`options` {Object}",
                                  "name": "options",
                                  "type": "Object",
                                  "options": [
                                    {
                                      "textRaw": "`signal` {AbortSignal} aborted if the stream is destroyed allowing to abort the `fn` call early.",
                                      "name": "signal",
                                      "type": "AbortSignal",
                                      "desc": "aborted if the stream is destroyed allowing to abort the `fn` call early."
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "textRaw": "`options` {Object}",
                              "name": "options",
                              "type": "Object",
                              "options": [
                                {
                                  "textRaw": "`concurrency` {number} the maximum concurrent invocation of `fn` to call on the stream at once. **Default:** `1`.",
                                  "name": "concurrency",
                                  "type": "number",
                                  "default": "`1`",
                                  "desc": "the maximum concurrent invocation of `fn` to call on the stream at once."
                                },
                                {
                                  "textRaw": "`signal` {AbortSignal} allows destroying the stream if the signal is aborted.",
                                  "name": "signal",
                                  "type": "AbortSignal",
                                  "desc": "allows destroying the stream if the signal is aborted."
                                }
                              ],
                              "optional": true
                            }
                          ],
                          "return": {
                            "textRaw": "Returns: {Readable} a stream flat-mapped with the function `fn`.",
                            "name": "return",
                            "type": "Readable",
                            "desc": "a stream flat-mapped with the function `fn`."
                          }
                        }
                      ],
                      "desc": "<p>This method returns a new stream by applying the given callback to each\nchunk of the stream and then flattening the result.</p>\n<p>It is possible to return a stream or another iterable or async iterable from\n<code>fn</code> and the result streams will be merged (flattened) into the returned\nstream.</p>\n<pre><code class=\"language-mjs\">import { Readable } from 'node:stream';\nimport { createReadStream } from 'node:fs';\n\n// With a synchronous mapper.\nfor await (const chunk of Readable.from([1, 2, 3, 4]).flatMap((x) => [x, x])) {\n  console.log(chunk); // 1, 1, 2, 2, 3, 3, 4, 4\n}\n// With an asynchronous mapper, combine the contents of 4 files\nconst concatResult = Readable.from([\n  './1.mjs',\n  './2.mjs',\n  './3.mjs',\n  './4.mjs',\n]).flatMap((fileName) => createReadStream(fileName));\nfor await (const result of concatResult) {\n  // This will contain the contents (all chunks) of all 4 files\n  console.log(result);\n}\n</code></pre>"
                    },
                    {
                      "textRaw": "`readable.drop(limit[, options])`",
                      "name": "drop",
                      "type": "method",
                      "meta": {
                        "added": [
                          "v17.5.0",
                          "v16.15.0"
                        ],
                        "changes": []
                      },
                      "stability": 1,
                      "stabilityText": "Experimental",
                      "signatures": [
                        {
                          "params": [
                            {
                              "textRaw": "`limit` {number} the number of chunks to drop from the readable.",
                              "name": "limit",
                              "type": "number",
                              "desc": "the number of chunks to drop from the readable."
                            },
                            {
                              "textRaw": "`options` {Object}",
                              "name": "options",
                              "type": "Object",
                              "options": [
                                {
                                  "textRaw": "`signal` {AbortSignal} allows destroying the stream if the signal is aborted.",
                                  "name": "signal",
                                  "type": "AbortSignal",
                                  "desc": "allows destroying the stream if the signal is aborted."
                                }
                              ],
                              "optional": true
                            }
                          ],
                          "return": {
                            "textRaw": "Returns: {Readable} a stream with `limit` chunks dropped.",
                            "name": "return",
                            "type": "Readable",
                            "desc": "a stream with `limit` chunks dropped."
                          }
                        }
                      ],
                      "desc": "<p>This method returns a new stream with the first <code>limit</code> chunks dropped.</p>\n<pre><code class=\"language-mjs\">import { Readable } from 'node:stream';\n\nawait Readable.from([1, 2, 3, 4]).drop(2).toArray(); // [3, 4]\n</code></pre>"
                    },
                    {
                      "textRaw": "`readable.take(limit[, options])`",
                      "name": "take",
                      "type": "method",
                      "meta": {
                        "added": [
                          "v17.5.0",
                          "v16.15.0"
                        ],
                        "changes": []
                      },
                      "stability": 1,
                      "stabilityText": "Experimental",
                      "signatures": [
                        {
                          "params": [
                            {
                              "textRaw": "`limit` {number} the number of chunks to take from the readable.",
                              "name": "limit",
                              "type": "number",
                              "desc": "the number of chunks to take from the readable."
                            },
                            {
                              "textRaw": "`options` {Object}",
                              "name": "options",
                              "type": "Object",
                              "options": [
                                {
                                  "textRaw": "`signal` {AbortSignal} allows destroying the stream if the signal is aborted.",
                                  "name": "signal",
                                  "type": "AbortSignal",
                                  "desc": "allows destroying the stream if the signal is aborted."
                                }
                              ],
                              "optional": true
                            }
                          ],
                          "return": {
                            "textRaw": "Returns: {Readable} a stream with `limit` chunks taken.",
                            "name": "return",
                            "type": "Readable",
                            "desc": "a stream with `limit` chunks taken."
                          }
                        }
                      ],
                      "desc": "<p>This method returns a new stream with the first <code>limit</code> chunks.</p>\n<pre><code class=\"language-mjs\">import { Readable } from 'node:stream';\n\nawait Readable.from([1, 2, 3, 4]).take(2).toArray(); // [1, 2]\n</code></pre>"
                    },
                    {
                      "textRaw": "`readable.reduce(fn[, initial[, options]])`",
                      "name": "reduce",
                      "type": "method",
                      "meta": {
                        "added": [
                          "v17.5.0",
                          "v16.15.0"
                        ],
                        "changes": []
                      },
                      "stability": 1,
                      "stabilityText": "Experimental",
                      "signatures": [
                        {
                          "params": [
                            {
                              "textRaw": "`fn` {Function|AsyncFunction} a reducer function to call over every chunk in the stream.",
                              "name": "fn",
                              "type": "Function|AsyncFunction",
                              "desc": "a reducer function to call over every chunk in the stream.",
                              "options": [
                                {
                                  "textRaw": "`previous` {any} the value obtained from the last call to `fn` or the `initial` value if specified or the first chunk of the stream otherwise.",
                                  "name": "previous",
                                  "type": "any",
                                  "desc": "the value obtained from the last call to `fn` or the `initial` value if specified or the first chunk of the stream otherwise."
                                },
                                {
                                  "textRaw": "`data` {any} a chunk of data from the stream.",
                                  "name": "data",
                                  "type": "any",
                                  "desc": "a chunk of data from the stream."
                                },
                                {
                                  "textRaw": "`options` {Object}",
                                  "name": "options",
                                  "type": "Object",
                                  "options": [
                                    {
                                      "textRaw": "`signal` {AbortSignal} aborted if the stream is destroyed allowing to abort the `fn` call early.",
                                      "name": "signal",
                                      "type": "AbortSignal",
                                      "desc": "aborted if the stream is destroyed allowing to abort the `fn` call early."
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "textRaw": "`initial` {any} the initial value to use in the reduction.",
                              "name": "initial",
                              "type": "any",
                              "desc": "the initial value to use in the reduction.",
                              "optional": true
                            },
                            {
                              "textRaw": "`options` {Object}",
                              "name": "options",
                              "type": "Object",
                              "options": [
                                {
                                  "textRaw": "`signal` {AbortSignal} allows destroying the stream if the signal is aborted.",
                                  "name": "signal",
                                  "type": "AbortSignal",
                                  "desc": "allows destroying the stream if the signal is aborted."
                                }
                              ],
                              "optional": true
                            }
                          ],
                          "return": {
                            "textRaw": "Returns: {Promise} a promise for the final value of the reduction.",
                            "name": "return",
                            "type": "Promise",
                            "desc": "a promise for the final value of the reduction."
                          }
                        }
                      ],
                      "desc": "<p>This method calls <code>fn</code> on each chunk of the stream in order, passing it the\nresult from the calculation on the previous element. It returns a promise for\nthe final value of the reduction.</p>\n<p>If no <code>initial</code> value is supplied the first chunk of the stream is used as the\ninitial value. If the stream is empty, the promise is rejected with a\n<code>TypeError</code> with the <code>ERR_INVALID_ARGS</code> code property.</p>\n<pre><code class=\"language-mjs\">import { Readable } from 'node:stream';\nimport { readdir, stat } from 'node:fs/promises';\nimport { join } from 'node:path';\n\nconst directoryPath = './src';\nconst filesInDir = await readdir(directoryPath);\n\nconst folderSize = await Readable.from(filesInDir)\n  .reduce(async (totalSize, file) => {\n    const { size } = await stat(join(directoryPath, file));\n    return totalSize + size;\n  }, 0);\n\nconsole.log(folderSize);\n</code></pre>\n<p>The reducer function iterates the stream element-by-element which means that\nthere is no <code>concurrency</code> parameter or parallelism. To perform a <code>reduce</code>\nconcurrently, you can extract the async function to <a href=\"#readablemapfn-options\"><code>readable.map</code></a> method.</p>\n<pre><code class=\"language-mjs\">import { Readable } from 'node:stream';\nimport { readdir, stat } from 'node:fs/promises';\nimport { join } from 'node:path';\n\nconst directoryPath = './src';\nconst filesInDir = await readdir(directoryPath);\n\nconst folderSize = await Readable.from(filesInDir)\n  .map((file) => stat(join(directoryPath, file)), { concurrency: 2 })\n  .reduce((totalSize, { size }) => totalSize + size, 0);\n\nconsole.log(folderSize);\n</code></pre>"
                    }
                  ],
                  "properties": [
                    {
                      "textRaw": "Type: {boolean}",
                      "name": "closed",
                      "type": "boolean",
                      "meta": {
                        "added": [
                          "v18.0.0"
                        ],
                        "changes": []
                      },
                      "desc": "<p>Is <code>true</code> after <code>'close'</code> has been emitted.</p>"
                    },
                    {
                      "textRaw": "Type: {boolean}",
                      "name": "destroyed",
                      "type": "boolean",
                      "meta": {
                        "added": [
                          "v8.0.0"
                        ],
                        "changes": []
                      },
                      "desc": "<p>Is <code>true</code> after <a href=\"#readabledestroyerror\"><code>readable.destroy()</code></a> has been called.</p>"
                    },
                    {
                      "textRaw": "Type: {boolean}",
                      "name": "readable",
                      "type": "boolean",
                      "meta": {
                        "added": [
                          "v11.4.0"
                        ],
                        "changes": []
                      },
                      "desc": "<p>Is <code>true</code> if it is safe to call <a href=\"#readablereadsize\"><code>readable.read()</code></a>, which means\nthe stream has not been destroyed or emitted <code>'error'</code> or <code>'end'</code>.</p>"
                    },
                    {
                      "textRaw": "Type: {boolean}",
                      "name": "readableAborted",
                      "type": "boolean",
                      "meta": {
                        "added": [
                          "v16.8.0"
                        ],
                        "changes": [
                          {
                            "version": [
                              "v24.0.0",
                              "v22.17.0"
                            ],
                            "pr-url": "https://github.com/nodejs/node/pull/57513",
                            "description": "Marking the API stable."
                          }
                        ]
                      },
                      "desc": "<p>Returns whether the stream was destroyed or errored before emitting <code>'end'</code>.</p>"
                    },
                    {
                      "textRaw": "Type: {boolean}",
                      "name": "readableDidRead",
                      "type": "boolean",
                      "meta": {
                        "added": [
                          "v16.7.0",
                          "v14.18.0"
                        ],
                        "changes": [
                          {
                            "version": [
                              "v24.0.0",
                              "v22.17.0"
                            ],
                            "pr-url": "https://github.com/nodejs/node/pull/57513",
                            "description": "Marking the API stable."
                          }
                        ]
                      },
                      "desc": "<p>Returns whether <code>'data'</code> has been emitted.</p>"
                    },
                    {
                      "textRaw": "Type: {null|string}",
                      "name": "readableEncoding",
                      "type": "null|string",
                      "meta": {
                        "added": [
                          "v12.7.0"
                        ],
                        "changes": []
                      },
                      "desc": "<p>Getter for the property <code>encoding</code> of a given <code>Readable</code> stream. The <code>encoding</code>\nproperty can be set using the <a href=\"#readablesetencodingencoding\"><code>readable.setEncoding()</code></a> method.</p>"
                    },
                    {
                      "textRaw": "Type: {boolean}",
                      "name": "readableEnded",
                      "type": "boolean",
                      "meta": {
                        "added": [
                          "v12.9.0"
                        ],
                        "changes": []
                      },
                      "desc": "<p>Becomes <code>true</code> when <a href=\"#event-end\"><code>'end'</code></a> event is emitted.</p>"
                    },
                    {
                      "textRaw": "Type: {Error}",
                      "name": "errored",
                      "type": "Error",
                      "meta": {
                        "added": [
                          "v18.0.0"
                        ],
                        "changes": []
                      },
                      "desc": "<p>Returns error if the stream has been destroyed with an error.</p>"
                    },
                    {
                      "textRaw": "Type: {boolean}",
                      "name": "readableFlowing",
                      "type": "boolean",
                      "meta": {
                        "added": [
                          "v9.4.0"
                        ],
                        "changes": []
                      },
                      "desc": "<p>This property reflects the current state of a <code>Readable</code> stream as described\nin the <a href=\"#three-states\">Three states</a> section.</p>"
                    },
                    {
                      "textRaw": "Type: {number}",
                      "name": "readableHighWaterMark",
                      "type": "number",
                      "meta": {
                        "added": [
                          "v9.3.0"
                        ],
                        "changes": []
                      },
                      "desc": "<p>Returns the value of <code>highWaterMark</code> passed when creating this <code>Readable</code>.</p>"
                    },
                    {
                      "textRaw": "Type: {number}",
                      "name": "readableLength",
                      "type": "number",
                      "meta": {
                        "added": [
                          "v9.4.0"
                        ],
                        "changes": []
                      },
                      "desc": "<p>This property contains the number of bytes (or objects) in the queue\nready to be read. The value provides introspection data regarding\nthe status of the <code>highWaterMark</code>.</p>"
                    },
                    {
                      "textRaw": "Type: {boolean}",
                      "name": "readableObjectMode",
                      "type": "boolean",
                      "meta": {
                        "added": [
                          "v12.3.0"
                        ],
                        "changes": []
                      },
                      "desc": "<p>Getter for the property <code>objectMode</code> of a given <code>Readable</code> stream.</p>"
                    }
                  ]
                }
              ],
              "displayName": "Readable streams"
            },
            {
              "textRaw": "Duplex and transform streams",
              "name": "duplex_and_transform_streams",
              "type": "misc",
              "classes": [
                {
                  "textRaw": "Class: `stream.Duplex`",
                  "name": "stream.Duplex",
                  "type": "class",
                  "meta": {
                    "added": [
                      "v0.9.4"
                    ],
                    "changes": [
                      {
                        "version": "v6.8.0",
                        "pr-url": "https://github.com/nodejs/node/pull/8834",
                        "description": "Instances of `Duplex` now return `true` when checking `instanceof stream.Writable`."
                      }
                    ]
                  },
                  "desc": "<p>Duplex streams are streams that implement both the <a href=\"#class-streamreadable\"><code>Readable</code></a> and\n<a href=\"#class-streamwritable\"><code>Writable</code></a> interfaces.</p>\n<p>Examples of <code>Duplex</code> streams include:</p>\n<ul>\n<li><a href=\"net.html#class-netsocket\">TCP sockets</a></li>\n<li><a href=\"zlib.html\">zlib streams</a></li>\n<li><a href=\"crypto.html\">crypto streams</a></li>\n</ul>",
                  "properties": [
                    {
                      "textRaw": "Type: {boolean}",
                      "name": "allowHalfOpen",
                      "type": "boolean",
                      "meta": {
                        "added": [
                          "v0.9.4"
                        ],
                        "changes": []
                      },
                      "desc": "<p>If <code>false</code> then the stream will automatically end the writable side when the\nreadable side ends. Set initially by the <code>allowHalfOpen</code> constructor option,\nwhich defaults to <code>true</code>.</p>\n<p>This can be changed manually to change the half-open behavior of an existing\n<code>Duplex</code> stream instance, but must be changed before the <code>'end'</code> event is\nemitted.</p>"
                    }
                  ]
                },
                {
                  "textRaw": "Class: `stream.Transform`",
                  "name": "stream.Transform",
                  "type": "class",
                  "meta": {
                    "added": [
                      "v0.9.4"
                    ],
                    "changes": []
                  },
                  "desc": "<p>Transform streams are <a href=\"#class-streamduplex\"><code>Duplex</code></a> streams where the output is in some way\nrelated to the input. Like all <a href=\"#class-streamduplex\"><code>Duplex</code></a> streams, <code>Transform</code> streams\nimplement both the <a href=\"#class-streamreadable\"><code>Readable</code></a> and <a href=\"#class-streamwritable\"><code>Writable</code></a> interfaces.</p>\n<p>Examples of <code>Transform</code> streams include:</p>\n<ul>\n<li><a href=\"zlib.html\">zlib streams</a></li>\n<li><a href=\"crypto.html\">crypto streams</a></li>\n</ul>",
                  "methods": [
                    {
                      "textRaw": "`transform.destroy([error])`",
                      "name": "destroy",
                      "type": "method",
                      "meta": {
                        "added": [
                          "v8.0.0"
                        ],
                        "changes": [
                          {
                            "version": "v14.0.0",
                            "pr-url": "https://github.com/nodejs/node/pull/29197",
                            "description": "Work as a no-op on a stream that has already been destroyed."
                          }
                        ]
                      },
                      "signatures": [
                        {
                          "params": [
                            {
                              "textRaw": "`error` {Error}",
                              "name": "error",
                              "type": "Error",
                              "optional": true
                            }
                          ],
                          "return": {
                            "textRaw": "Returns: {this}",
                            "name": "return",
                            "type": "this"
                          }
                        }
                      ],
                      "desc": "<p>Destroy the stream, and optionally emit an <code>'error'</code> event. After this call, the\ntransform stream would release any internal resources.\nImplementors should not override this method, but instead implement\n<a href=\"#readable_destroyerr-callback\"><code>readable._destroy()</code></a>.\nThe default implementation of <code>_destroy()</code> for <code>Transform</code> also emit <code>'close'</code>\nunless <code>emitClose</code> is set in false.</p>\n<p>Once <code>destroy()</code> has been called, any further calls will be a no-op and no\nfurther errors except from <code>_destroy()</code> may be emitted as <code>'error'</code>.</p>"
                    }
                  ]
                }
              ],
              "methods": [
                {
                  "textRaw": "`stream.duplexPair([options])`",
                  "name": "duplexPair",
                  "type": "method",
                  "meta": {
                    "added": [
                      "v22.6.0",
                      "v20.17.0"
                    ],
                    "changes": []
                  },
                  "signatures": [
                    {
                      "params": [
                        {
                          "textRaw": "`options` {Object} A value to pass to both `Duplex` constructors, to set options such as buffering.",
                          "name": "options",
                          "type": "Object",
                          "desc": "A value to pass to both `Duplex` constructors, to set options such as buffering.",
                          "optional": true
                        }
                      ],
                      "return": {
                        "textRaw": "Returns: {Array} of two `Duplex` instances.",
                        "name": "return",
                        "type": "Array",
                        "desc": "of two `Duplex` instances."
                      }
                    }
                  ],
                  "desc": "<p>The utility function <code>duplexPair</code> returns an Array with two items,\neach being a <code>Duplex</code> stream connected to the other side:</p>\n<pre><code class=\"language-js\">const [ sideA, sideB ] = duplexPair();\n</code></pre>\n<p>Whatever is written to one stream is made readable on the other. It provides\nbehavior analogous to a network connection, where the data written by the client\nbecomes readable by the server, and vice-versa.</p>\n<p>The Duplex streams are symmetrical; one or the other may be used without any\ndifference in behavior.</p>"
                }
              ],
              "displayName": "Duplex and transform streams"
            }
          ],
          "methods": [
            {
              "textRaw": "`stream.finished(stream[, options], callback)`",
              "name": "finished",
              "type": "method",
              "meta": {
                "added": [
                  "v10.0.0"
                ],
                "changes": [
                  {
                    "version": "v19.5.0",
                    "pr-url": "https://github.com/nodejs/node/pull/46205",
                    "description": "Added support for `ReadableStream` and `WritableStream`."
                  },
                  {
                    "version": "v15.11.0",
                    "pr-url": "https://github.com/nodejs/node/pull/37354",
                    "description": "The `signal` option was added."
                  },
                  {
                    "version": "v14.0.0",
                    "pr-url": "https://github.com/nodejs/node/pull/32158",
                    "description": "The `finished(stream, cb)` will wait for the `'close'` event before invoking the callback. The implementation tries to detect legacy streams and only apply this behavior to streams which are expected to emit `'close'`."
                  },
                  {
                    "version": "v14.0.0",
                    "pr-url": "https://github.com/nodejs/node/pull/31545",
                    "description": "Emitting `'close'` before `'end'` on a `Readable` stream will cause an `ERR_STREAM_PREMATURE_CLOSE` error."
                  },
                  {
                    "version": "v14.0.0",
                    "pr-url": "https://github.com/nodejs/node/pull/31509",
                    "description": "Callback will be invoked on streams which have already finished before the call to `finished(stream, cb)`."
                  }
                ]
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`stream` {Stream|ReadableStream|WritableStream} A readable and/or writable stream/webstream.",
                      "name": "stream",
                      "type": "Stream|ReadableStream|WritableStream",
                      "desc": "A readable and/or writable stream/webstream."
                    },
                    {
                      "textRaw": "`options` {Object}",
                      "name": "options",
                      "type": "Object",
                      "options": [
                        {
                          "textRaw": "`error` {boolean} If set to `false`, then a call to `emit('error', err)` is not treated as finished. **Default:** `true`.",
                          "name": "error",
                          "type": "boolean",
                          "default": "`true`",
                          "desc": "If set to `false`, then a call to `emit('error', err)` is not treated as finished."
                        },
                        {
                          "textRaw": "`readable` {boolean} When set to `false`, the callback will be called when the stream ends even though the stream might still be readable. **Default:** `true`.",
                          "name": "readable",
                          "type": "boolean",
                          "default": "`true`",
                          "desc": "When set to `false`, the callback will be called when the stream ends even though the stream might still be readable."
                        },
                        {
                          "textRaw": "`writable` {boolean} When set to `false`, the callback will be called when the stream ends even though the stream might still be writable. **Default:** `true`.",
                          "name": "writable",
                          "type": "boolean",
                          "default": "`true`",
                          "desc": "When set to `false`, the callback will be called when the stream ends even though the stream might still be writable."
                        },
                        {
                          "textRaw": "`signal` {AbortSignal} allows aborting the wait for the stream finish. The underlying stream will _not_ be aborted if the signal is aborted. The callback will get called with an `AbortError`. All registered listeners added by this function will also be removed.",
                          "name": "signal",
                          "type": "AbortSignal",
                          "desc": "allows aborting the wait for the stream finish. The underlying stream will _not_ be aborted if the signal is aborted. The callback will get called with an `AbortError`. All registered listeners added by this function will also be removed."
                        }
                      ],
                      "optional": true
                    },
                    {
                      "textRaw": "`callback` {Function} A callback function that takes an optional error argument.",
                      "name": "callback",
                      "type": "Function",
                      "desc": "A callback function that takes an optional error argument."
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {Function} A cleanup function which removes all registered listeners.",
                    "name": "return",
                    "type": "Function",
                    "desc": "A cleanup function which removes all registered listeners."
                  }
                }
              ],
              "desc": "<p>A function to get notified when a stream is no longer readable, writable\nor has experienced an error or a premature close event.</p>\n<pre><code class=\"language-js\">const { finished } = require('node:stream');\nconst fs = require('node:fs');\n\nconst rs = fs.createReadStream('archive.tar');\n\nfinished(rs, (err) => {\n  if (err) {\n    console.error('Stream failed.', err);\n  } else {\n    console.log('Stream is done reading.');\n  }\n});\n\nrs.resume(); // Drain the stream.\n</code></pre>\n<p>Especially useful in error handling scenarios where a stream is destroyed\nprematurely (like an aborted HTTP request), and will not emit <code>'end'</code>\nor <code>'finish'</code>.</p>\n<p>The <code>finished</code> API provides <a href=\"#streamfinishedstream-options\">promise version</a>.</p>\n<p><code>stream.finished()</code> leaves dangling event listeners (in particular\n<code>'error'</code>, <code>'end'</code>, <code>'finish'</code> and <code>'close'</code>) after <code>callback</code> has been\ninvoked. The reason for this is so that unexpected <code>'error'</code> events (due to\nincorrect stream implementations) do not cause unexpected crashes.\nIf this is unwanted behavior then the returned cleanup function needs to be\ninvoked in the callback:</p>\n<pre><code class=\"language-js\">const cleanup = finished(rs, (err) => {\n  cleanup();\n  // ...\n});\n</code></pre>"
            },
            {
              "textRaw": "`stream.pipeline(source[, ...transforms], destination, callback)`",
              "name": "pipeline",
              "type": "method",
              "signatures": [
                {
                  "params": [
                    {
                      "name": "source"
                    },
                    {
                      "name": "...transforms",
                      "optional": true
                    },
                    {
                      "name": "destination"
                    },
                    {
                      "name": "callback"
                    }
                  ]
                }
              ]
            },
            {
              "textRaw": "`stream.pipeline(streams, callback)`",
              "name": "pipeline",
              "type": "method",
              "meta": {
                "added": [
                  "v10.0.0"
                ],
                "changes": [
                  {
                    "version": [
                      "v19.7.0",
                      "v18.16.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/46307",
                    "description": "Added support for webstreams."
                  },
                  {
                    "version": "v18.0.0",
                    "pr-url": "https://github.com/nodejs/node/pull/41678",
                    "description": "Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."
                  },
                  {
                    "version": "v14.0.0",
                    "pr-url": "https://github.com/nodejs/node/pull/32158",
                    "description": "The `pipeline(..., cb)` will wait for the `'close'` event before invoking the callback. The implementation tries to detect legacy streams and only apply this behavior to streams which are expected to emit `'close'`."
                  },
                  {
                    "version": "v13.10.0",
                    "pr-url": "https://github.com/nodejs/node/pull/31223",
                    "description": "Add support for async generators."
                  }
                ]
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`streams` {Stream[]|AsyncIterable[]|Function[]|ReadableStream[]|WritableStream[]|TransformStream[]}",
                      "name": "streams",
                      "type": "Stream[]|AsyncIterable[]|Function[]|ReadableStream[]|WritableStream[]|TransformStream[]"
                    },
                    {
                      "textRaw": "`callback` {Function} Called when the pipeline is fully done.",
                      "name": "callback",
                      "type": "Function",
                      "desc": "Called when the pipeline is fully done.",
                      "options": [
                        {
                          "textRaw": "`err` {Error}",
                          "name": "err",
                          "type": "Error"
                        },
                        {
                          "textRaw": "`val` Resolved value of `Promise` returned by `destination`.",
                          "name": "val",
                          "desc": "Resolved value of `Promise` returned by `destination`."
                        }
                      ]
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {Stream}",
                    "name": "return",
                    "type": "Stream"
                  }
                }
              ],
              "desc": "<p>A module method to pipe between streams and generators forwarding errors and\nproperly cleaning up and provide a callback when the pipeline is complete.</p>\n<pre><code class=\"language-js\">const { pipeline } = require('node:stream');\nconst fs = require('node:fs');\nconst zlib = require('node:zlib');\n\n// Use the pipeline API to easily pipe a series of streams\n// together and get notified when the pipeline is fully done.\n\n// A pipeline to gzip a potentially huge tar file efficiently:\n\npipeline(\n  fs.createReadStream('archive.tar'),\n  zlib.createGzip(),\n  fs.createWriteStream('archive.tar.gz'),\n  (err) => {\n    if (err) {\n      console.error('Pipeline failed.', err);\n    } else {\n      console.log('Pipeline succeeded.');\n    }\n  },\n);\n</code></pre>\n<p>The <code>pipeline</code> API provides a <a href=\"#streampipelinesource-transforms-destination-options\">promise version</a>.</p>\n<p><code>stream.pipeline()</code> will call <code>stream.destroy(err)</code> on all streams except:</p>\n<ul>\n<li><code>Readable</code> streams which have emitted <code>'end'</code> or <code>'close'</code>.</li>\n<li><code>Writable</code> streams which have emitted <code>'finish'</code> or <code>'close'</code>.</li>\n</ul>\n<p><code>stream.pipeline()</code> leaves dangling event listeners on the streams\nafter the <code>callback</code> has been invoked. In the case of reuse of streams after\nfailure, this can cause event listener leaks and swallowed errors. If the last\nstream is readable, dangling event listeners will be removed so that the last\nstream can be consumed later.</p>\n<p><code>stream.pipeline()</code> closes all the streams when an error is raised.\nThe <code>IncomingRequest</code> usage with <code>pipeline</code> could lead to an unexpected behavior\nonce it would destroy the socket without sending the expected response.\nSee the example below:</p>\n<pre><code class=\"language-js\">const fs = require('node:fs');\nconst http = require('node:http');\nconst { pipeline } = require('node:stream');\n\nconst server = http.createServer((req, res) => {\n  const fileStream = fs.createReadStream('./fileNotExist.txt');\n  pipeline(fileStream, res, (err) => {\n    if (err) {\n      console.log(err); // No such file\n      // this message can't be sent once `pipeline` already destroyed the socket\n      return res.end('error!!!');\n    }\n  });\n});\n</code></pre>"
            },
            {
              "textRaw": "`stream.compose(...streams)`",
              "name": "compose",
              "type": "method",
              "meta": {
                "added": [
                  "v16.9.0"
                ],
                "changes": [
                  {
                    "version": "v26.2.0",
                    "pr-url": "https://github.com/nodejs/node/pull/62562",
                    "description": "Marking the API stable."
                  },
                  {
                    "version": [
                      "v21.1.0",
                      "v20.10.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/50187",
                    "description": "Added support for stream class."
                  },
                  {
                    "version": [
                      "v19.8.0",
                      "v18.16.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/46675",
                    "description": "Added support for webstreams."
                  }
                ]
              },
              "stability": 2,
              "stabilityText": "Stable",
              "signatures": [
                {
                  "params": [
                    {
                      "name": "...streams"
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {stream.Duplex}",
                    "name": "return",
                    "type": "stream.Duplex"
                  }
                }
              ],
              "desc": "<p>Combines two or more streams into a <code>Duplex</code> stream that writes to the\nfirst stream and reads from the last. Each provided stream is piped into\nthe next, using <code>stream.pipeline</code>. If any of the streams error then all\nare destroyed, including the outer <code>Duplex</code> stream.</p>\n<p>Because <code>stream.compose</code> returns a new stream that in turn can (and\nshould) be piped into other streams, it enables composition. In contrast,\nwhen passing streams to <code>stream.pipeline</code>, typically the first stream is\na readable stream and the last a writable stream, forming a closed\ncircuit.</p>\n<p>If passed a <code>Function</code> it must be a factory method taking a <code>source</code>\n<code>Iterable</code>.</p>\n<pre><code class=\"language-mjs\">import { compose, Transform } from 'node:stream';\n\nconst removeSpaces = new Transform({\n  transform(chunk, encoding, callback) {\n    callback(null, String(chunk).replace(' ', ''));\n  },\n});\n\nasync function* toUpper(source) {\n  for await (const chunk of source) {\n    yield String(chunk).toUpperCase();\n  }\n}\n\nlet res = '';\nfor await (const buf of compose(removeSpaces, toUpper).end('hello world')) {\n  res += buf;\n}\n\nconsole.log(res); // prints 'HELLOWORLD'\n</code></pre>\n<p><code>stream.compose</code> can be used to convert async iterables, generators and\nfunctions into streams.</p>\n<ul>\n<li><code>AsyncIterable</code> converts into a readable <code>Duplex</code>. Cannot yield\n<code>null</code>.</li>\n<li><code>AsyncGeneratorFunction</code> converts into a readable/writable transform <code>Duplex</code>.\nMust take a source <code>AsyncIterable</code> as first parameter. Cannot yield\n<code>null</code>.</li>\n<li><code>AsyncFunction</code> converts into a writable <code>Duplex</code>. Must return\neither <code>null</code> or <code>undefined</code>.</li>\n</ul>\n<pre><code class=\"language-mjs\">import { compose } from 'node:stream';\nimport { finished } from 'node:stream/promises';\n\n// Convert AsyncIterable into readable Duplex.\nconst s1 = compose(async function*() {\n  yield 'Hello';\n  yield 'World';\n}());\n\n// Convert AsyncGenerator into transform Duplex.\nconst s2 = compose(async function*(source) {\n  for await (const chunk of source) {\n    yield String(chunk).toUpperCase();\n  }\n});\n\nlet res = '';\n\n// Convert AsyncFunction into writable Duplex.\nconst s3 = compose(async function(source) {\n  for await (const chunk of source) {\n    res += chunk;\n  }\n});\n\nawait finished(compose(s1, s2, s3));\n\nconsole.log(res); // prints 'HELLOWORLD'\n</code></pre>\n<p>For convenience, the <a href=\"#readablecomposestream-options\"><code>readable.compose(stream)</code></a> method is available on\n<a href=\"stream.html#class-streamreadable\"><code>&#x3C;Readable></code></a> and <a href=\"stream.html#class-streamduplex\"><code>&#x3C;Duplex></code></a> streams as a wrapper for this function.</p>"
            },
            {
              "textRaw": "`stream.isErrored(stream)`",
              "name": "isErrored",
              "type": "method",
              "meta": {
                "added": [
                  "v17.3.0",
                  "v16.14.0"
                ],
                "changes": [
                  {
                    "version": [
                      "v24.0.0",
                      "v22.17.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/57513",
                    "description": "Marking the API stable."
                  }
                ]
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`stream` {Readable|Writable|Duplex|WritableStream|ReadableStream}",
                      "name": "stream",
                      "type": "Readable|Writable|Duplex|WritableStream|ReadableStream"
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {boolean}",
                    "name": "return",
                    "type": "boolean"
                  }
                }
              ],
              "desc": "<p>Returns whether the stream has encountered an error.</p>"
            },
            {
              "textRaw": "`stream.isReadable(stream)`",
              "name": "isReadable",
              "type": "method",
              "meta": {
                "added": [
                  "v17.4.0",
                  "v16.14.0"
                ],
                "changes": [
                  {
                    "version": [
                      "v24.0.0",
                      "v22.17.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/57513",
                    "description": "Marking the API stable."
                  }
                ]
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`stream` {Readable|Duplex|ReadableStream}",
                      "name": "stream",
                      "type": "Readable|Duplex|ReadableStream"
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {boolean|null} - Only returns `null` if `stream` is not a valid `Readable`, `Duplex` or `ReadableStream`.",
                    "name": "return",
                    "type": "boolean|null",
                    "desc": "Only returns `null` if `stream` is not a valid `Readable`, `Duplex` or `ReadableStream`."
                  }
                }
              ],
              "desc": "<p>Returns whether the stream is readable.</p>"
            },
            {
              "textRaw": "`stream.isWritable(stream)`",
              "name": "isWritable",
              "type": "method",
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`stream` {Writable|Duplex|WritableStream}",
                      "name": "stream",
                      "type": "Writable|Duplex|WritableStream"
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {boolean|null} - Only returns `null` if `stream` is not a valid `Writable`, `Duplex` or `WritableStream`.",
                    "name": "return",
                    "type": "boolean|null",
                    "desc": "Only returns `null` if `stream` is not a valid `Writable`, `Duplex` or `WritableStream`."
                  }
                }
              ],
              "desc": "<p>Returns whether the stream is writable.</p>"
            },
            {
              "textRaw": "`stream.Readable.from(iterable[, options])`",
              "name": "from",
              "type": "method",
              "meta": {
                "added": [
                  "v12.3.0",
                  "v10.17.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "name": "iterable"
                    },
                    {
                      "name": "options",
                      "optional": true
                    }
                  ]
                }
              ],
              "desc": "<ul>\n<li><code>iterable</code> {Iterable} Object implementing the <code>Symbol.asyncIterator</code> or\n<code>Symbol.iterator</code> iterable protocol. Emits an 'error' event if a null\nvalue is passed.</li>\n<li><code>options</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object\"><code>&#x3C;Object></code></a> Options provided to <code>new stream.Readable([options])</code>.\nBy default, <code>Readable.from()</code> will set <code>options.objectMode</code> to <code>true</code>, unless\nthis is explicitly opted out by setting <code>options.objectMode</code> to <code>false</code>.</li>\n<li>Returns: <a href=\"stream.html#class-streamreadable\"><code>&#x3C;stream.Readable></code></a></li>\n</ul>\n<p>A utility method for creating readable streams out of iterators.</p>\n<pre><code class=\"language-js\">const { Readable } = require('node:stream');\n\nasync function * generate() {\n  yield 'hello';\n  yield 'streams';\n}\n\nconst readable = Readable.from(generate());\n\nreadable.on('data', (chunk) => {\n  console.log(chunk);\n});\n</code></pre>\n<p>Calling <code>Readable.from(string)</code> or <code>Readable.from(buffer)</code> will not have\nthe strings or buffers be iterated to match the other streams semantics\nfor performance reasons.</p>\n<p>If an <code>Iterable</code> object containing promises is passed as an argument,\nit might result in unhandled rejection.</p>\n<pre><code class=\"language-js\">const { Readable } = require('node:stream');\n\nReadable.from([\n  new Promise((resolve) => setTimeout(resolve('1'), 1500)),\n  new Promise((_, reject) => setTimeout(reject(new Error('2')), 1000)), // Unhandled rejection\n]);\n</code></pre>"
            },
            {
              "textRaw": "`stream.Readable.fromWeb(readableStream[, options])`",
              "name": "fromWeb",
              "type": "method",
              "meta": {
                "added": [
                  "v17.0.0"
                ],
                "changes": [
                  {
                    "version": [
                      "v24.0.0",
                      "v22.17.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/57513",
                    "description": "Marking the API stable."
                  }
                ]
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`readableStream` {ReadableStream}",
                      "name": "readableStream",
                      "type": "ReadableStream"
                    },
                    {
                      "textRaw": "`options` {Object}",
                      "name": "options",
                      "type": "Object",
                      "options": [
                        {
                          "textRaw": "`encoding` {string}",
                          "name": "encoding",
                          "type": "string"
                        },
                        {
                          "textRaw": "`highWaterMark` {number}",
                          "name": "highWaterMark",
                          "type": "number"
                        },
                        {
                          "textRaw": "`objectMode` {boolean}",
                          "name": "objectMode",
                          "type": "boolean"
                        },
                        {
                          "textRaw": "`signal` {AbortSignal}",
                          "name": "signal",
                          "type": "AbortSignal"
                        }
                      ],
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {stream.Readable}",
                    "name": "return",
                    "type": "stream.Readable"
                  }
                }
              ]
            },
            {
              "textRaw": "`stream.Readable.isDisturbed(stream)`",
              "name": "isDisturbed",
              "type": "method",
              "meta": {
                "added": [
                  "v16.8.0"
                ],
                "changes": [
                  {
                    "version": [
                      "v24.0.0",
                      "v22.17.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/57513",
                    "description": "Marking the API stable."
                  }
                ]
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`stream` {stream.Readable|ReadableStream}",
                      "name": "stream",
                      "type": "stream.Readable|ReadableStream"
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: `boolean`",
                    "name": "return",
                    "desc": "`boolean`"
                  }
                }
              ],
              "desc": "<p>Returns whether the stream has been read from or cancelled.</p>"
            },
            {
              "textRaw": "`stream.Readable.toWeb(streamReadable[, options])`",
              "name": "toWeb",
              "type": "method",
              "meta": {
                "added": [
                  "v17.0.0"
                ],
                "changes": [
                  {
                    "version": [
                      "v25.4.0",
                      "v24.14.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/58664",
                    "description": "Add 'type' option to specify 'bytes'."
                  },
                  {
                    "version": [
                      "v24.0.0",
                      "v22.17.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/57513",
                    "description": "Marking the API stable."
                  },
                  {
                    "version": [
                      "v18.7.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/43515",
                    "description": "include strategy options on Readable."
                  }
                ]
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`streamReadable` {stream.Readable}",
                      "name": "streamReadable",
                      "type": "stream.Readable"
                    },
                    {
                      "textRaw": "`options` {Object}",
                      "name": "options",
                      "type": "Object",
                      "options": [
                        {
                          "textRaw": "`strategy` {Object}",
                          "name": "strategy",
                          "type": "Object",
                          "options": [
                            {
                              "textRaw": "`highWaterMark` {number} The maximum internal queue size (of the created `ReadableStream`) before backpressure is applied in reading from the given `stream.Readable`. If no value is provided, it will be taken from the given `stream.Readable`.",
                              "name": "highWaterMark",
                              "type": "number",
                              "desc": "The maximum internal queue size (of the created `ReadableStream`) before backpressure is applied in reading from the given `stream.Readable`. If no value is provided, it will be taken from the given `stream.Readable`."
                            },
                            {
                              "textRaw": "`size` {Function} A function that size of the given chunk of data. If no value is provided, the size will be `1` for all the chunks.",
                              "name": "size",
                              "type": "Function",
                              "desc": "A function that size of the given chunk of data. If no value is provided, the size will be `1` for all the chunks.",
                              "options": [
                                {
                                  "textRaw": "`chunk` {any}",
                                  "name": "chunk",
                                  "type": "any"
                                },
                                {
                                  "textRaw": "Returns: {number}",
                                  "name": "return",
                                  "type": "number"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "textRaw": "`type` {string} Specifies the type of the created `ReadableStream`. Must be `'bytes'` or undefined.",
                          "name": "type",
                          "type": "string",
                          "desc": "Specifies the type of the created `ReadableStream`. Must be `'bytes'` or undefined."
                        }
                      ],
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {ReadableStream}",
                    "name": "return",
                    "type": "ReadableStream"
                  }
                }
              ]
            },
            {
              "textRaw": "`stream.Writable.fromWeb(writableStream[, options])`",
              "name": "fromWeb",
              "type": "method",
              "meta": {
                "added": [
                  "v17.0.0"
                ],
                "changes": [
                  {
                    "version": [
                      "v24.0.0",
                      "v22.17.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/57513",
                    "description": "Marking the API stable."
                  }
                ]
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`writableStream` {WritableStream}",
                      "name": "writableStream",
                      "type": "WritableStream"
                    },
                    {
                      "textRaw": "`options` {Object}",
                      "name": "options",
                      "type": "Object",
                      "options": [
                        {
                          "textRaw": "`decodeStrings` {boolean}",
                          "name": "decodeStrings",
                          "type": "boolean"
                        },
                        {
                          "textRaw": "`highWaterMark` {number}",
                          "name": "highWaterMark",
                          "type": "number"
                        },
                        {
                          "textRaw": "`objectMode` {boolean}",
                          "name": "objectMode",
                          "type": "boolean"
                        },
                        {
                          "textRaw": "`signal` {AbortSignal}",
                          "name": "signal",
                          "type": "AbortSignal"
                        }
                      ],
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {stream.Writable}",
                    "name": "return",
                    "type": "stream.Writable"
                  }
                }
              ]
            },
            {
              "textRaw": "`stream.Writable.toWeb(streamWritable)`",
              "name": "toWeb",
              "type": "method",
              "meta": {
                "added": [
                  "v17.0.0"
                ],
                "changes": [
                  {
                    "version": [
                      "v24.0.0",
                      "v22.17.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/57513",
                    "description": "Marking the API stable."
                  }
                ]
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`streamWritable` {stream.Writable}",
                      "name": "streamWritable",
                      "type": "stream.Writable"
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {WritableStream}",
                    "name": "return",
                    "type": "WritableStream"
                  }
                }
              ]
            },
            {
              "textRaw": "`stream.Duplex.from(src)`",
              "name": "from",
              "type": "method",
              "meta": {
                "added": [
                  "v16.8.0"
                ],
                "changes": [
                  {
                    "version": [
                      "v19.5.0",
                      "v18.17.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/46190",
                    "description": "The `src` argument can now be a `ReadableStream` or `WritableStream`."
                  }
                ]
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`src` {Stream|Blob|ArrayBuffer|string|AsyncIterable|AsyncGeneratorFunction|AsyncFunction|Promise|Object|ReadableStream|WritableStream}",
                      "name": "src",
                      "type": "Stream|Blob|ArrayBuffer|string|AsyncIterable|AsyncGeneratorFunction|AsyncFunction|Promise|Object|ReadableStream|WritableStream"
                    }
                  ]
                }
              ],
              "desc": "<p>A utility method for creating duplex streams.</p>\n<ul>\n<li><code>Stream</code> converts writable stream into writable <code>Duplex</code> and readable stream\nto <code>Duplex</code>.</li>\n<li><code>Blob</code> converts into readable <code>Duplex</code>.</li>\n<li><code>string</code> converts into readable <code>Duplex</code>.</li>\n<li><code>ArrayBuffer</code> converts into readable <code>Duplex</code>.</li>\n<li><code>AsyncIterable</code> converts into a readable <code>Duplex</code>. Cannot yield\n<code>null</code>.</li>\n<li><code>AsyncGeneratorFunction</code> converts into a readable/writable transform\n<code>Duplex</code>. Must take a source <code>AsyncIterable</code> as first parameter. Cannot yield\n<code>null</code>.</li>\n<li><code>AsyncFunction</code> converts into a writable <code>Duplex</code>. Must return\neither <code>null</code> or <code>undefined</code></li>\n<li><code>Object ({ writable, readable })</code> converts <code>readable</code> and\n<code>writable</code> into <code>Stream</code> and then combines them into <code>Duplex</code> where the\n<code>Duplex</code> will write to the <code>writable</code> and read from the <code>readable</code>.</li>\n<li><code>Promise</code> converts into readable <code>Duplex</code>. Value <code>null</code> is ignored.</li>\n<li><code>ReadableStream</code> converts into readable <code>Duplex</code>.</li>\n<li><code>WritableStream</code> converts into writable <code>Duplex</code>.</li>\n<li>Returns: <a href=\"stream.html#class-streamduplex\"><code>&#x3C;stream.Duplex></code></a></li>\n</ul>\n<p>If an <code>Iterable</code> object containing promises is passed as an argument,\nit might result in unhandled rejection.</p>\n<pre><code class=\"language-js\">const { Duplex } = require('node:stream');\n\nDuplex.from([\n  new Promise((resolve) => setTimeout(resolve('1'), 1500)),\n  new Promise((_, reject) => setTimeout(reject(new Error('2')), 1000)), // Unhandled rejection\n]);\n</code></pre>"
            },
            {
              "textRaw": "`stream.Duplex.fromWeb(pair[, options])`",
              "name": "fromWeb",
              "type": "method",
              "meta": {
                "added": [
                  "v17.0.0"
                ],
                "changes": [
                  {
                    "version": [
                      "v24.0.0",
                      "v22.17.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/57513",
                    "description": "Marking the API stable."
                  }
                ]
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`pair` {Object}",
                      "name": "pair",
                      "type": "Object",
                      "options": [
                        {
                          "textRaw": "`readable` {ReadableStream}",
                          "name": "readable",
                          "type": "ReadableStream"
                        },
                        {
                          "textRaw": "`writable` {WritableStream}",
                          "name": "writable",
                          "type": "WritableStream"
                        }
                      ]
                    },
                    {
                      "textRaw": "`options` {Object}",
                      "name": "options",
                      "type": "Object",
                      "options": [
                        {
                          "textRaw": "`allowHalfOpen` {boolean}",
                          "name": "allowHalfOpen",
                          "type": "boolean"
                        },
                        {
                          "textRaw": "`decodeStrings` {boolean}",
                          "name": "decodeStrings",
                          "type": "boolean"
                        },
                        {
                          "textRaw": "`encoding` {string}",
                          "name": "encoding",
                          "type": "string"
                        },
                        {
                          "textRaw": "`highWaterMark` {number}",
                          "name": "highWaterMark",
                          "type": "number"
                        },
                        {
                          "textRaw": "`objectMode` {boolean}",
                          "name": "objectMode",
                          "type": "boolean"
                        },
                        {
                          "textRaw": "`signal` {AbortSignal}",
                          "name": "signal",
                          "type": "AbortSignal"
                        }
                      ],
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {stream.Duplex}",
                    "name": "return",
                    "type": "stream.Duplex"
                  }
                }
              ],
              "desc": "<pre><code class=\"language-mjs\">import { Duplex } from 'node:stream';\nimport {\n  ReadableStream,\n  WritableStream,\n} from 'node:stream/web';\n\nconst readable = new ReadableStream({\n  start(controller) {\n    controller.enqueue('world');\n  },\n});\n\nconst writable = new WritableStream({\n  write(chunk) {\n    console.log('writable', chunk);\n  },\n});\n\nconst pair = {\n  readable,\n  writable,\n};\nconst duplex = Duplex.fromWeb(pair, { encoding: 'utf8', objectMode: true });\n\nduplex.write('hello');\n\nfor await (const chunk of duplex) {\n  console.log('readable', chunk);\n}\n</code></pre>\n<pre><code class=\"language-cjs\">const { Duplex } = require('node:stream');\nconst {\n  ReadableStream,\n  WritableStream,\n} = require('node:stream/web');\n\nconst readable = new ReadableStream({\n  start(controller) {\n    controller.enqueue('world');\n  },\n});\n\nconst writable = new WritableStream({\n  write(chunk) {\n    console.log('writable', chunk);\n  },\n});\n\nconst pair = {\n  readable,\n  writable,\n};\nconst duplex = Duplex.fromWeb(pair, { encoding: 'utf8', objectMode: true });\n\nduplex.write('hello');\nduplex.once('readable', () => console.log('readable', duplex.read()));\n</code></pre>"
            },
            {
              "textRaw": "`stream.Duplex.toWeb(streamDuplex[, options])`",
              "name": "toWeb",
              "type": "method",
              "meta": {
                "added": [
                  "v17.0.0"
                ],
                "changes": [
                  {
                    "version": "v25.7.0",
                    "pr-url": "https://github.com/nodejs/node/pull/61632",
                    "description": "Added the 'readableType' option to specify the ReadableStream type. The 'type' option is deprecated."
                  },
                  {
                    "version": [
                      "v25.4.0",
                      "v24.14.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/58664",
                    "description": "Added the 'type' option to specify the ReadableStream type."
                  },
                  {
                    "version": [
                      "v24.0.0",
                      "v22.17.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/57513",
                    "description": "Marking the API stable."
                  }
                ]
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`streamDuplex` {stream.Duplex}",
                      "name": "streamDuplex",
                      "type": "stream.Duplex"
                    },
                    {
                      "textRaw": "`options` {Object}",
                      "name": "options",
                      "type": "Object",
                      "options": [
                        {
                          "textRaw": "`readableType` {string} Specifies the type of the `ReadableStream` half of the created readable-writable pair. Must be `'bytes'` or undefined. (`options.type` is a deprecated alias for this option.)",
                          "name": "readableType",
                          "type": "string",
                          "desc": "Specifies the type of the `ReadableStream` half of the created readable-writable pair. Must be `'bytes'` or undefined. (`options.type` is a deprecated alias for this option.)"
                        }
                      ],
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {Object}",
                    "name": "return",
                    "type": "Object",
                    "options": [
                      {
                        "textRaw": "`readable` {ReadableStream}",
                        "name": "readable",
                        "type": "ReadableStream"
                      },
                      {
                        "textRaw": "`writable` {WritableStream}",
                        "name": "writable",
                        "type": "WritableStream"
                      }
                    ]
                  }
                }
              ],
              "desc": "<pre><code class=\"language-mjs\">import { Duplex } from 'node:stream';\n\nconst duplex = Duplex({\n  objectMode: true,\n  read() {\n    this.push('world');\n    this.push(null);\n  },\n  write(chunk, encoding, callback) {\n    console.log('writable', chunk);\n    callback();\n  },\n});\n\nconst { readable, writable } = Duplex.toWeb(duplex);\nwritable.getWriter().write('hello');\n\nconst { value } = await readable.getReader().read();\nconsole.log('readable', value);\n</code></pre>\n<pre><code class=\"language-cjs\">const { Duplex } = require('node:stream');\n\nconst duplex = Duplex({\n  objectMode: true,\n  read() {\n    this.push('world');\n    this.push(null);\n  },\n  write(chunk, encoding, callback) {\n    console.log('writable', chunk);\n    callback();\n  },\n});\n\nconst { readable, writable } = Duplex.toWeb(duplex);\nwritable.getWriter().write('hello');\n\nreadable.getReader().read().then((result) => {\n  console.log('readable', result.value);\n});\n</code></pre>"
            },
            {
              "textRaw": "`stream.addAbortSignal(signal, stream)`",
              "name": "addAbortSignal",
              "type": "method",
              "meta": {
                "added": [
                  "v15.4.0"
                ],
                "changes": [
                  {
                    "version": [
                      "v19.7.0",
                      "v18.16.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/46273",
                    "description": "Added support for `ReadableStream` and `WritableStream`."
                  }
                ]
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`signal` {AbortSignal} A signal representing possible cancellation",
                      "name": "signal",
                      "type": "AbortSignal",
                      "desc": "A signal representing possible cancellation"
                    },
                    {
                      "textRaw": "`stream` {Stream|ReadableStream|WritableStream} A stream to attach a signal to.",
                      "name": "stream",
                      "type": "Stream|ReadableStream|WritableStream",
                      "desc": "A stream to attach a signal to."
                    }
                  ]
                }
              ],
              "desc": "<p>Attaches an AbortSignal to a readable or writeable stream. This lets code\ncontrol stream destruction using an <code>AbortController</code>.</p>\n<p>Calling <code>abort</code> on the <code>AbortController</code> corresponding to the passed\n<code>AbortSignal</code> will behave the same way as calling <code>.destroy(new AbortError())</code>\non the stream, and <code>controller.error(new AbortError())</code> for webstreams.</p>\n<pre><code class=\"language-js\">const fs = require('node:fs');\n\nconst controller = new AbortController();\nconst read = addAbortSignal(\n  controller.signal,\n  fs.createReadStream(('object.json')),\n);\n// Later, abort the operation closing the stream\ncontroller.abort();\n</code></pre>\n<p>Or using an <code>AbortSignal</code> with a readable stream as an async iterable:</p>\n<pre><code class=\"language-js\">const controller = new AbortController();\nsetTimeout(() => controller.abort(), 10_000); // set a timeout\nconst stream = addAbortSignal(\n  controller.signal,\n  fs.createReadStream(('object.json')),\n);\n(async () => {\n  try {\n    for await (const chunk of stream) {\n      await process(chunk);\n    }\n  } catch (e) {\n    if (e.name === 'AbortError') {\n      // The operation was cancelled\n    } else {\n      throw e;\n    }\n  }\n})();\n</code></pre>\n<p>Or using an <code>AbortSignal</code> with a ReadableStream:</p>\n<pre><code class=\"language-js\">const controller = new AbortController();\nconst rs = new ReadableStream({\n  start(controller) {\n    controller.enqueue('hello');\n    controller.enqueue('world');\n    controller.close();\n  },\n});\n\naddAbortSignal(controller.signal, rs);\n\nfinished(rs, (err) => {\n  if (err) {\n    if (err.name === 'AbortError') {\n      // The operation was cancelled\n    }\n  }\n});\n\nconst reader = rs.getReader();\n\nreader.read().then(({ value, done }) => {\n  console.log(value); // hello\n  console.log(done); // false\n  controller.abort();\n});\n</code></pre>"
            },
            {
              "textRaw": "`stream.getDefaultHighWaterMark(objectMode)`",
              "name": "getDefaultHighWaterMark",
              "type": "method",
              "meta": {
                "added": [
                  "v19.9.0",
                  "v18.17.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`objectMode` {boolean}",
                      "name": "objectMode",
                      "type": "boolean"
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {integer}",
                    "name": "return",
                    "type": "integer"
                  }
                }
              ],
              "desc": "<p>Returns the default highWaterMark used by streams.\nDefaults to <code>65536</code> (64 KiB), or <code>16</code> for <code>objectMode</code>.</p>"
            },
            {
              "textRaw": "`stream.setDefaultHighWaterMark(objectMode, value)`",
              "name": "setDefaultHighWaterMark",
              "type": "method",
              "meta": {
                "added": [
                  "v19.9.0",
                  "v18.17.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`objectMode` {boolean}",
                      "name": "objectMode",
                      "type": "boolean"
                    },
                    {
                      "textRaw": "`value` {integer} highWaterMark value",
                      "name": "value",
                      "type": "integer",
                      "desc": "highWaterMark value"
                    }
                  ]
                }
              ],
              "desc": "<p>Sets the default highWaterMark used by streams.</p>"
            }
          ]
        },
        {
          "textRaw": "API for stream implementers",
          "name": "API for stream implementers",
          "type": "misc",
          "desc": "<p>The <code>node:stream</code> module API has been designed to make it possible to easily\nimplement streams using JavaScript's prototypal inheritance model.</p>\n<p>First, a stream developer would declare a new JavaScript class that extends one\nof the four basic stream classes (<code>stream.Writable</code>, <code>stream.Readable</code>,\n<code>stream.Duplex</code>, or <code>stream.Transform</code>), making sure they call the appropriate\nparent class constructor:</p>\n<pre><code class=\"language-js\">const { Writable } = require('node:stream');\n\nclass MyWritable extends Writable {\n  constructor({ highWaterMark, ...options }) {\n    super({ highWaterMark });\n    // ...\n  }\n}\n</code></pre>\n<p>When extending streams, keep in mind what options the user\ncan and should provide before forwarding these to the base constructor. For\nexample, if the implementation makes assumptions in regard to the\n<code>autoDestroy</code> and <code>emitClose</code> options, do not allow the\nuser to override these. Be explicit about what\noptions are forwarded instead of implicitly forwarding all options.</p>\n<p>The new stream class must then implement one or more specific methods, depending\non the type of stream being created, as detailed in the chart below:</p>\n<table>\n<thead>\n<tr>\n<th>Use-case</th>\n<th>Class</th>\n<th>Method(s) to implement</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Reading only</td>\n<td><a href=\"#class-streamreadable\"><code>Readable</code></a></td>\n<td><a href=\"#readable_readsize\"><code>_read()</code></a></td>\n</tr>\n<tr>\n<td>Writing only</td>\n<td><a href=\"#class-streamwritable\"><code>Writable</code></a></td>\n<td><a href=\"#writable_writechunk-encoding-callback\"><code>_write()</code></a>, <a href=\"#writable_writevchunks-callback\"><code>_writev()</code></a>, <a href=\"#writable_finalcallback\"><code>_final()</code></a></td>\n</tr>\n<tr>\n<td>Reading and writing</td>\n<td><a href=\"#class-streamduplex\"><code>Duplex</code></a></td>\n<td><a href=\"#readable_readsize\"><code>_read()</code></a>, <a href=\"#writable_writechunk-encoding-callback\"><code>_write()</code></a>, <a href=\"#writable_writevchunks-callback\"><code>_writev()</code></a>, <a href=\"#writable_finalcallback\"><code>_final()</code></a></td>\n</tr>\n<tr>\n<td>Operate on written data, then read the result</td>\n<td><a href=\"#class-streamtransform\"><code>Transform</code></a></td>\n<td><a href=\"#transform_transformchunk-encoding-callback\"><code>_transform()</code></a>, <a href=\"#transform_flushcallback\"><code>_flush()</code></a>, <a href=\"#writable_finalcallback\"><code>_final()</code></a></td>\n</tr>\n</tbody>\n</table>\n<p>The implementation code for a stream should <em>never</em> call the \"public\" methods\nof a stream that are intended for use by consumers (as described in the\n<a href=\"#api-for-stream-consumers\">API for stream consumers</a> section). Doing so may lead to adverse side effects\nin application code consuming the stream.</p>\n<p>Avoid overriding public methods such as <code>write()</code>, <code>end()</code>, <code>cork()</code>,\n<code>uncork()</code>, <code>read()</code> and <code>destroy()</code>, or emitting internal events such\nas <code>'error'</code>, <code>'data'</code>, <code>'end'</code>, <code>'finish'</code> and <code>'close'</code> through <code>.emit()</code>.\nDoing so can break current and future stream invariants leading to behavior\nand/or compatibility issues with other streams, stream utilities, and user\nexpectations.</p>",
          "miscs": [
            {
              "textRaw": "Simplified construction",
              "name": "simplified_construction",
              "type": "misc",
              "meta": {
                "added": [
                  "v1.2.0"
                ],
                "changes": []
              },
              "desc": "<p>For many simple cases, it is possible to create a stream without relying on\ninheritance. This can be accomplished by directly creating instances of the\n<code>stream.Writable</code>, <code>stream.Readable</code>, <code>stream.Duplex</code>, or <code>stream.Transform</code>\nobjects and passing appropriate methods as constructor options.</p>\n<pre><code class=\"language-js\">const { Writable } = require('node:stream');\n\nconst myWritable = new Writable({\n  construct(callback) {\n    // Initialize state and load resources...\n  },\n  write(chunk, encoding, callback) {\n    // ...\n  },\n  destroy() {\n    // Free resources...\n  },\n});\n</code></pre>",
              "displayName": "Simplified construction"
            },
            {
              "textRaw": "Implementing a writable stream",
              "name": "implementing_a_writable_stream",
              "type": "misc",
              "desc": "<p>The <code>stream.Writable</code> class is extended to implement a <a href=\"#class-streamwritable\"><code>Writable</code></a> stream.</p>\n<p>Custom <code>Writable</code> streams <em>must</em> call the <code>new stream.Writable([options])</code>\nconstructor and implement the <code>writable._write()</code> and/or <code>writable._writev()</code>\nmethod.</p>",
              "signatures": [
                {
                  "textRaw": "`new stream.Writable([options])`",
                  "name": "stream.Writable",
                  "type": "ctor",
                  "meta": {
                    "changes": [
                      {
                        "version": "v22.0.0",
                        "pr-url": "https://github.com/nodejs/node/pull/52037",
                        "description": "bump default highWaterMark."
                      },
                      {
                        "version": "v15.5.0",
                        "pr-url": "https://github.com/nodejs/node/pull/36431",
                        "description": "support passing in an AbortSignal."
                      },
                      {
                        "version": "v14.0.0",
                        "pr-url": "https://github.com/nodejs/node/pull/30623",
                        "description": "Change `autoDestroy` option default to `true`."
                      },
                      {
                        "version": [
                          "v11.2.0",
                          "v10.16.0"
                        ],
                        "pr-url": "https://github.com/nodejs/node/pull/22795",
                        "description": "Add `autoDestroy` option to automatically `destroy()` the stream when it emits `'finish'` or errors."
                      },
                      {
                        "version": "v10.0.0",
                        "pr-url": "https://github.com/nodejs/node/pull/18438",
                        "description": "Add `emitClose` option to specify if `'close'` is emitted on destroy."
                      }
                    ]
                  },
                  "params": [
                    {
                      "textRaw": "`options` {Object}",
                      "name": "options",
                      "type": "Object",
                      "options": [
                        {
                          "textRaw": "`highWaterMark` {number} Buffer level when `stream.write()` starts returning `false`. **Default:** `65536` (64 KiB), or `16` for `objectMode` streams.",
                          "name": "highWaterMark",
                          "type": "number",
                          "default": "`65536` (64 KiB), or `16` for `objectMode` streams",
                          "desc": "Buffer level when `stream.write()` starts returning `false`."
                        },
                        {
                          "textRaw": "`decodeStrings` {boolean} Whether to encode `string`s passed to `stream.write()` to `Buffer`s (with the encoding specified in the `stream.write()` call) before passing them to `stream._write()`. Other types of data are not converted (i.e. `Buffer`s are not decoded into `string`s). Setting to false will prevent `string`s from being converted. **Default:** `true`.",
                          "name": "decodeStrings",
                          "type": "boolean",
                          "default": "`true`",
                          "desc": "Whether to encode `string`s passed to `stream.write()` to `Buffer`s (with the encoding specified in the `stream.write()` call) before passing them to `stream._write()`. Other types of data are not converted (i.e. `Buffer`s are not decoded into `string`s). Setting to false will prevent `string`s from being converted."
                        },
                        {
                          "textRaw": "`defaultEncoding` {string} The default encoding that is used when no encoding is specified as an argument to `stream.write()`. **Default:** `'utf8'`.",
                          "name": "defaultEncoding",
                          "type": "string",
                          "default": "`'utf8'`",
                          "desc": "The default encoding that is used when no encoding is specified as an argument to `stream.write()`."
                        },
                        {
                          "textRaw": "`objectMode` {boolean} Whether or not the `stream.write(anyObj)` is a valid operation. When set, it becomes possible to write JavaScript values other than string, {Buffer}, {TypedArray} or {DataView} if supported by the stream implementation. **Default:** `false`.",
                          "name": "objectMode",
                          "type": "boolean",
                          "default": "`false`",
                          "desc": "Whether or not the `stream.write(anyObj)` is a valid operation. When set, it becomes possible to write JavaScript values other than string, {Buffer}, {TypedArray} or {DataView} if supported by the stream implementation."
                        },
                        {
                          "textRaw": "`emitClose` {boolean} Whether or not the stream should emit `'close'` after it has been destroyed. **Default:** `true`.",
                          "name": "emitClose",
                          "type": "boolean",
                          "default": "`true`",
                          "desc": "Whether or not the stream should emit `'close'` after it has been destroyed."
                        },
                        {
                          "textRaw": "`write` {Function} Implementation for the `stream._write()` method.",
                          "name": "write",
                          "type": "Function",
                          "desc": "Implementation for the `stream._write()` method."
                        },
                        {
                          "textRaw": "`writev` {Function} Implementation for the `stream._writev()` method.",
                          "name": "writev",
                          "type": "Function",
                          "desc": "Implementation for the `stream._writev()` method."
                        },
                        {
                          "textRaw": "`destroy` {Function} Implementation for the `stream._destroy()` method.",
                          "name": "destroy",
                          "type": "Function",
                          "desc": "Implementation for the `stream._destroy()` method."
                        },
                        {
                          "textRaw": "`final` {Function} Implementation for the `stream._final()` method.",
                          "name": "final",
                          "type": "Function",
                          "desc": "Implementation for the `stream._final()` method."
                        },
                        {
                          "textRaw": "`construct` {Function} Implementation for the `stream._construct()` method.",
                          "name": "construct",
                          "type": "Function",
                          "desc": "Implementation for the `stream._construct()` method."
                        },
                        {
                          "textRaw": "`autoDestroy` {boolean} Whether this stream should automatically call `.destroy()` on itself after ending. **Default:** `true`.",
                          "name": "autoDestroy",
                          "type": "boolean",
                          "default": "`true`",
                          "desc": "Whether this stream should automatically call `.destroy()` on itself after ending."
                        },
                        {
                          "textRaw": "`signal` {AbortSignal} A signal representing possible cancellation.",
                          "name": "signal",
                          "type": "AbortSignal",
                          "desc": "A signal representing possible cancellation."
                        }
                      ],
                      "optional": true
                    }
                  ],
                  "desc": "<pre><code class=\"language-js\">const { Writable } = require('node:stream');\n\nclass MyWritable extends Writable {\n  constructor(options) {\n    // Calls the stream.Writable() constructor.\n    super(options);\n    // ...\n  }\n}\n</code></pre>\n<p>Or, when using pre-ES6 style constructors:</p>\n<pre><code class=\"language-js\">const { Writable } = require('node:stream');\nconst util = require('node:util');\n\nfunction MyWritable(options) {\n  if (!(this instanceof MyWritable))\n    return new MyWritable(options);\n  Writable.call(this, options);\n}\nutil.inherits(MyWritable, Writable);\n</code></pre>\n<p>Or, using the simplified constructor approach:</p>\n<pre><code class=\"language-js\">const { Writable } = require('node:stream');\n\nconst myWritable = new Writable({\n  write(chunk, encoding, callback) {\n    // ...\n  },\n  writev(chunks, callback) {\n    // ...\n  },\n});\n</code></pre>\n<p>Calling <code>abort</code> on the <code>AbortController</code> corresponding to the passed\n<code>AbortSignal</code> will behave the same way as calling <code>.destroy(new AbortError())</code>\non the writeable stream.</p>\n<pre><code class=\"language-js\">const { Writable } = require('node:stream');\n\nconst controller = new AbortController();\nconst myWritable = new Writable({\n  write(chunk, encoding, callback) {\n    // ...\n  },\n  writev(chunks, callback) {\n    // ...\n  },\n  signal: controller.signal,\n});\n// Later, abort the operation closing the stream\ncontroller.abort();\n</code></pre>"
                }
              ],
              "methods": [
                {
                  "textRaw": "`writable._construct(callback)`",
                  "name": "_construct",
                  "type": "method",
                  "meta": {
                    "added": [
                      "v15.0.0"
                    ],
                    "changes": []
                  },
                  "signatures": [
                    {
                      "params": [
                        {
                          "textRaw": "`callback` {Function} Call this function (optionally with an error argument) when the stream has finished initializing.",
                          "name": "callback",
                          "type": "Function",
                          "desc": "Call this function (optionally with an error argument) when the stream has finished initializing."
                        }
                      ]
                    }
                  ],
                  "desc": "<p>The <code>_construct()</code> method MUST NOT be called directly. It may be implemented\nby child classes, and if so, will be called by the internal <code>Writable</code>\nclass methods only.</p>\n<p>This optional function will be called in a tick after the stream constructor\nhas returned, delaying any <code>_write()</code>, <code>_final()</code> and <code>_destroy()</code> calls until\n<code>callback</code> is called. This is useful to initialize state or asynchronously\ninitialize resources before the stream can be used.</p>\n<pre><code class=\"language-js\">const { Writable } = require('node:stream');\nconst fs = require('node:fs');\n\nclass WriteStream extends Writable {\n  constructor(filename) {\n    super();\n    this.filename = filename;\n    this.fd = null;\n  }\n  _construct(callback) {\n    fs.open(this.filename, 'w', (err, fd) => {\n      if (err) {\n        callback(err);\n      } else {\n        this.fd = fd;\n        callback();\n      }\n    });\n  }\n  _write(chunk, encoding, callback) {\n    fs.write(this.fd, chunk, callback);\n  }\n  _destroy(err, callback) {\n    if (this.fd) {\n      fs.close(this.fd, (er) => callback(er || err));\n    } else {\n      callback(err);\n    }\n  }\n}\n</code></pre>"
                },
                {
                  "textRaw": "`writable._write(chunk, encoding, callback)`",
                  "name": "_write",
                  "type": "method",
                  "meta": {
                    "changes": [
                      {
                        "version": "v12.11.0",
                        "pr-url": "https://github.com/nodejs/node/pull/29639",
                        "description": "_write() is optional when providing _writev()."
                      }
                    ]
                  },
                  "signatures": [
                    {
                      "params": [
                        {
                          "textRaw": "`chunk` {Buffer|string|any} The `Buffer` to be written, converted from the `string` passed to `stream.write()`. If the stream's `decodeStrings` option is `false` or the stream is operating in object mode, the chunk will not be converted & will be whatever was passed to `stream.write()`.",
                          "name": "chunk",
                          "type": "Buffer|string|any",
                          "desc": "The `Buffer` to be written, converted from the `string` passed to `stream.write()`. If the stream's `decodeStrings` option is `false` or the stream is operating in object mode, the chunk will not be converted & will be whatever was passed to `stream.write()`."
                        },
                        {
                          "textRaw": "`encoding` {string} If the chunk is a string, then `encoding` is the character encoding of that string. If chunk is a `Buffer`, or if the stream is operating in object mode, `encoding` may be ignored.",
                          "name": "encoding",
                          "type": "string",
                          "desc": "If the chunk is a string, then `encoding` is the character encoding of that string. If chunk is a `Buffer`, or if the stream is operating in object mode, `encoding` may be ignored."
                        },
                        {
                          "textRaw": "`callback` {Function} Call this function (optionally with an error argument) when processing is complete for the supplied chunk.",
                          "name": "callback",
                          "type": "Function",
                          "desc": "Call this function (optionally with an error argument) when processing is complete for the supplied chunk."
                        }
                      ]
                    }
                  ],
                  "desc": "<p>All <code>Writable</code> stream implementations must provide a\n<a href=\"#writable_writechunk-encoding-callback\"><code>writable._write()</code></a> and/or\n<a href=\"#writable_writevchunks-callback\"><code>writable._writev()</code></a> method to send data to the underlying\nresource.</p>\n<p><a href=\"#class-streamtransform\"><code>Transform</code></a> streams provide their own implementation of the\n<a href=\"#writable_writechunk-encoding-callback\"><code>writable._write()</code></a>.</p>\n<p>This function MUST NOT be called by application code directly. It should be\nimplemented by child classes, and called by the internal <code>Writable</code> class\nmethods only.</p>\n<p>The <code>callback</code> function must be called synchronously inside of\n<code>writable._write()</code> or asynchronously (i.e. different tick) to signal either\nthat the write completed successfully or failed with an error.\nThe first argument passed to the <code>callback</code> must be the <code>Error</code> object if the\ncall failed or <code>null</code> if the write succeeded.</p>\n<p>All calls to <code>writable.write()</code> that occur between the time <code>writable._write()</code>\nis called and the <code>callback</code> is called will cause the written data to be\nbuffered. When the <code>callback</code> is invoked, the stream might emit a <a href=\"#event-drain\"><code>'drain'</code></a>\nevent. If a stream implementation is capable of processing multiple chunks of\ndata at once, the <code>writable._writev()</code> method should be implemented.</p>\n<p>If the <code>decodeStrings</code> property is explicitly set to <code>false</code> in the constructor\noptions, then <code>chunk</code> will remain the same object that is passed to <code>.write()</code>,\nand may be a string rather than a <code>Buffer</code>. This is to support implementations\nthat have an optimized handling for certain string data encodings. In that case,\nthe <code>encoding</code> argument will indicate the character encoding of the string.\nOtherwise, the <code>encoding</code> argument can be safely ignored.</p>\n<p>The <code>writable._write()</code> method is prefixed with an underscore because it is\ninternal to the class that defines it, and should never be called directly by\nuser programs.</p>"
                },
                {
                  "textRaw": "`writable._writev(chunks, callback)`",
                  "name": "_writev",
                  "type": "method",
                  "signatures": [
                    {
                      "params": [
                        {
                          "textRaw": "`chunks` {Object[]} The data to be written. The value is an array of {Object} that each represent a discrete chunk of data to write. The properties of these objects are:",
                          "name": "chunks",
                          "type": "Object[]",
                          "desc": "The data to be written. The value is an array of {Object} that each represent a discrete chunk of data to write. The properties of these objects are:",
                          "options": [
                            {
                              "textRaw": "`chunk` {Buffer|string} A buffer instance or string containing the data to be written. The `chunk` will be a string if the `Writable` was created with the `decodeStrings` option set to `false` and a string was passed to `write()`.",
                              "name": "chunk",
                              "type": "Buffer|string",
                              "desc": "A buffer instance or string containing the data to be written. The `chunk` will be a string if the `Writable` was created with the `decodeStrings` option set to `false` and a string was passed to `write()`."
                            },
                            {
                              "textRaw": "`encoding` {string} The character encoding of the `chunk`. If `chunk` is a `Buffer`, the `encoding` will be `'buffer'`.",
                              "name": "encoding",
                              "type": "string",
                              "desc": "The character encoding of the `chunk`. If `chunk` is a `Buffer`, the `encoding` will be `'buffer'`."
                            }
                          ]
                        },
                        {
                          "textRaw": "`callback` {Function} A callback function (optionally with an error argument) to be invoked when processing is complete for the supplied chunks.",
                          "name": "callback",
                          "type": "Function",
                          "desc": "A callback function (optionally with an error argument) to be invoked when processing is complete for the supplied chunks."
                        }
                      ]
                    }
                  ],
                  "desc": "<p>This function MUST NOT be called by application code directly. It should be\nimplemented by child classes, and called by the internal <code>Writable</code> class\nmethods only.</p>\n<p>The <code>writable._writev()</code> method may be implemented in addition or alternatively\nto <code>writable._write()</code> in stream implementations that are capable of processing\nmultiple chunks of data at once. If implemented and if there is buffered data\nfrom previous writes, <code>_writev()</code> will be called instead of <code>_write()</code>.</p>\n<p>The <code>writable._writev()</code> method is prefixed with an underscore because it is\ninternal to the class that defines it, and should never be called directly by\nuser programs.</p>"
                },
                {
                  "textRaw": "`writable._destroy(err, callback)`",
                  "name": "_destroy",
                  "type": "method",
                  "meta": {
                    "added": [
                      "v8.0.0"
                    ],
                    "changes": []
                  },
                  "signatures": [
                    {
                      "params": [
                        {
                          "textRaw": "`err` {Error} A possible error.",
                          "name": "err",
                          "type": "Error",
                          "desc": "A possible error."
                        },
                        {
                          "textRaw": "`callback` {Function} A callback function that takes an optional error argument.",
                          "name": "callback",
                          "type": "Function",
                          "desc": "A callback function that takes an optional error argument."
                        }
                      ]
                    }
                  ],
                  "desc": "<p>The <code>_destroy()</code> method is called by <a href=\"#writabledestroyerror\"><code>writable.destroy()</code></a>.\nIt can be overridden by child classes but it <strong>must not</strong> be called directly.</p>"
                },
                {
                  "textRaw": "`writable._final(callback)`",
                  "name": "_final",
                  "type": "method",
                  "meta": {
                    "added": [
                      "v8.0.0"
                    ],
                    "changes": []
                  },
                  "signatures": [
                    {
                      "params": [
                        {
                          "textRaw": "`callback` {Function} Call this function (optionally with an error argument) when finished writing any remaining data.",
                          "name": "callback",
                          "type": "Function",
                          "desc": "Call this function (optionally with an error argument) when finished writing any remaining data."
                        }
                      ]
                    }
                  ],
                  "desc": "<p>The <code>_final()</code> method <strong>must not</strong> be called directly. It may be implemented\nby child classes, and if so, will be called by the internal <code>Writable</code>\nclass methods only.</p>\n<p>This optional function will be called before the stream closes, delaying the\n<code>'finish'</code> event until <code>callback</code> is called. This is useful to close resources\nor write buffered data before a stream ends.</p>"
                }
              ],
              "modules": [
                {
                  "textRaw": "Errors while writing",
                  "name": "errors_while_writing",
                  "type": "module",
                  "desc": "<p>Errors occurring during the processing of the <a href=\"#writable_writechunk-encoding-callback\"><code>writable._write()</code></a>,\n<a href=\"#writable_writevchunks-callback\"><code>writable._writev()</code></a> and <a href=\"#writable_finalcallback\"><code>writable._final()</code></a> methods must be propagated\nby invoking the callback and passing the error as the first argument.\nThrowing an <code>Error</code> from within these methods or manually emitting an <code>'error'</code>\nevent results in undefined behavior.</p>\n<p>If a <code>Readable</code> stream pipes into a <code>Writable</code> stream when <code>Writable</code> emits an\nerror, the <code>Readable</code> stream will be unpiped.</p>\n<pre><code class=\"language-js\">const { Writable } = require('node:stream');\n\nconst myWritable = new Writable({\n  write(chunk, encoding, callback) {\n    if (chunk.toString().indexOf('a') >= 0) {\n      callback(new Error('chunk is invalid'));\n    } else {\n      callback();\n    }\n  },\n});\n</code></pre>",
                  "displayName": "Errors while writing"
                },
                {
                  "textRaw": "An example writable stream",
                  "name": "an_example_writable_stream",
                  "type": "module",
                  "desc": "<p>The following illustrates a rather simplistic (and somewhat pointless) custom\n<code>Writable</code> stream implementation. While this specific <code>Writable</code> stream instance\nis not of any real particular usefulness, the example illustrates each of the\nrequired elements of a custom <a href=\"#class-streamwritable\"><code>Writable</code></a> stream instance:</p>\n<pre><code class=\"language-js\">const { Writable } = require('node:stream');\n\nclass MyWritable extends Writable {\n  _write(chunk, encoding, callback) {\n    if (chunk.toString().indexOf('a') >= 0) {\n      callback(new Error('chunk is invalid'));\n    } else {\n      callback();\n    }\n  }\n}\n</code></pre>",
                  "displayName": "An example writable stream"
                },
                {
                  "textRaw": "Decoding buffers in a writable stream",
                  "name": "decoding_buffers_in_a_writable_stream",
                  "type": "module",
                  "desc": "<p>Decoding buffers is a common task, for instance, when using transformers whose\ninput is a string. This is not a trivial process when using multi-byte\ncharacters encoding, such as UTF-8. The following example shows how to decode\nmulti-byte strings using <code>StringDecoder</code> and <a href=\"#class-streamwritable\"><code>Writable</code></a>.</p>\n<pre><code class=\"language-js\">const { Writable } = require('node:stream');\nconst { StringDecoder } = require('node:string_decoder');\n\nclass StringWritable extends Writable {\n  constructor(options) {\n    super(options);\n    this._decoder = new StringDecoder(options?.defaultEncoding);\n    this.data = '';\n  }\n  _write(chunk, encoding, callback) {\n    if (encoding === 'buffer') {\n      chunk = this._decoder.write(chunk);\n    }\n    this.data += chunk;\n    callback();\n  }\n  _final(callback) {\n    this.data += this._decoder.end();\n    callback();\n  }\n}\n\nconst euro = [[0xE2, 0x82], [0xAC]].map(Buffer.from);\nconst w = new StringWritable();\n\nw.write('currency: ');\nw.write(euro[0]);\nw.end(euro[1]);\n\nconsole.log(w.data); // currency: €\n</code></pre>",
                  "displayName": "Decoding buffers in a writable stream"
                }
              ],
              "displayName": "Implementing a writable stream"
            },
            {
              "textRaw": "Implementing a readable stream",
              "name": "implementing_a_readable_stream",
              "type": "misc",
              "desc": "<p>The <code>stream.Readable</code> class is extended to implement a <a href=\"#class-streamreadable\"><code>Readable</code></a> stream.</p>\n<p>Custom <code>Readable</code> streams <em>must</em> call the <code>new stream.Readable([options])</code>\nconstructor and implement the <a href=\"#readable_readsize\"><code>readable._read()</code></a> method.</p>",
              "signatures": [
                {
                  "textRaw": "`new stream.Readable([options])`",
                  "name": "stream.Readable",
                  "type": "ctor",
                  "meta": {
                    "changes": [
                      {
                        "version": "v22.0.0",
                        "pr-url": "https://github.com/nodejs/node/pull/52037",
                        "description": "bump default highWaterMark."
                      },
                      {
                        "version": "v15.5.0",
                        "pr-url": "https://github.com/nodejs/node/pull/36431",
                        "description": "support passing in an AbortSignal."
                      },
                      {
                        "version": "v14.0.0",
                        "pr-url": "https://github.com/nodejs/node/pull/30623",
                        "description": "Change `autoDestroy` option default to `true`."
                      },
                      {
                        "version": [
                          "v11.2.0",
                          "v10.16.0"
                        ],
                        "pr-url": "https://github.com/nodejs/node/pull/22795",
                        "description": "Add `autoDestroy` option to automatically `destroy()` the stream when it emits `'end'` or errors."
                      }
                    ]
                  },
                  "params": [
                    {
                      "textRaw": "`options` {Object}",
                      "name": "options",
                      "type": "Object",
                      "options": [
                        {
                          "textRaw": "`highWaterMark` {number} The maximum number of bytes to store in the internal buffer before ceasing to read from the underlying resource. **Default:** `65536` (64 KiB), or `16` for `objectMode` streams.",
                          "name": "highWaterMark",
                          "type": "number",
                          "default": "`65536` (64 KiB), or `16` for `objectMode` streams",
                          "desc": "The maximum number of bytes to store in the internal buffer before ceasing to read from the underlying resource."
                        },
                        {
                          "textRaw": "`encoding` {string} If specified, then buffers will be decoded to strings using the specified encoding. **Default:** `null`.",
                          "name": "encoding",
                          "type": "string",
                          "default": "`null`",
                          "desc": "If specified, then buffers will be decoded to strings using the specified encoding."
                        },
                        {
                          "textRaw": "`objectMode` {boolean} Whether this stream should behave as a stream of objects. Meaning that `stream.read(n)` returns a single value instead of a `Buffer` of size `n`. **Default:** `false`.",
                          "name": "objectMode",
                          "type": "boolean",
                          "default": "`false`",
                          "desc": "Whether this stream should behave as a stream of objects. Meaning that `stream.read(n)` returns a single value instead of a `Buffer` of size `n`."
                        },
                        {
                          "textRaw": "`emitClose` {boolean} Whether or not the stream should emit `'close'` after it has been destroyed. **Default:** `true`.",
                          "name": "emitClose",
                          "type": "boolean",
                          "default": "`true`",
                          "desc": "Whether or not the stream should emit `'close'` after it has been destroyed."
                        },
                        {
                          "textRaw": "`read` {Function} Implementation for the `stream._read()` method.",
                          "name": "read",
                          "type": "Function",
                          "desc": "Implementation for the `stream._read()` method."
                        },
                        {
                          "textRaw": "`destroy` {Function} Implementation for the `stream._destroy()` method.",
                          "name": "destroy",
                          "type": "Function",
                          "desc": "Implementation for the `stream._destroy()` method."
                        },
                        {
                          "textRaw": "`construct` {Function} Implementation for the `stream._construct()` method.",
                          "name": "construct",
                          "type": "Function",
                          "desc": "Implementation for the `stream._construct()` method."
                        },
                        {
                          "textRaw": "`autoDestroy` {boolean} Whether this stream should automatically call `.destroy()` on itself after ending. **Default:** `true`.",
                          "name": "autoDestroy",
                          "type": "boolean",
                          "default": "`true`",
                          "desc": "Whether this stream should automatically call `.destroy()` on itself after ending."
                        },
                        {
                          "textRaw": "`signal` {AbortSignal} A signal representing possible cancellation.",
                          "name": "signal",
                          "type": "AbortSignal",
                          "desc": "A signal representing possible cancellation."
                        }
                      ],
                      "optional": true
                    }
                  ],
                  "desc": "<pre><code class=\"language-js\">const { Readable } = require('node:stream');\n\nclass MyReadable extends Readable {\n  constructor(options) {\n    // Calls the stream.Readable(options) constructor.\n    super(options);\n    // ...\n  }\n}\n</code></pre>\n<p>Or, when using pre-ES6 style constructors:</p>\n<pre><code class=\"language-js\">const { Readable } = require('node:stream');\nconst util = require('node:util');\n\nfunction MyReadable(options) {\n  if (!(this instanceof MyReadable))\n    return new MyReadable(options);\n  Readable.call(this, options);\n}\nutil.inherits(MyReadable, Readable);\n</code></pre>\n<p>Or, using the simplified constructor approach:</p>\n<pre><code class=\"language-js\">const { Readable } = require('node:stream');\n\nconst myReadable = new Readable({\n  read(size) {\n    // ...\n  },\n});\n</code></pre>\n<p>Calling <code>abort</code> on the <code>AbortController</code> corresponding to the passed\n<code>AbortSignal</code> will behave the same way as calling <code>.destroy(new AbortError())</code>\non the readable created.</p>\n<pre><code class=\"language-js\">const { Readable } = require('node:stream');\nconst controller = new AbortController();\nconst read = new Readable({\n  read(size) {\n    // ...\n  },\n  signal: controller.signal,\n});\n// Later, abort the operation closing the stream\ncontroller.abort();\n</code></pre>"
                }
              ],
              "methods": [
                {
                  "textRaw": "`readable._construct(callback)`",
                  "name": "_construct",
                  "type": "method",
                  "meta": {
                    "added": [
                      "v15.0.0"
                    ],
                    "changes": []
                  },
                  "signatures": [
                    {
                      "params": [
                        {
                          "textRaw": "`callback` {Function} Call this function (optionally with an error argument) when the stream has finished initializing.",
                          "name": "callback",
                          "type": "Function",
                          "desc": "Call this function (optionally with an error argument) when the stream has finished initializing."
                        }
                      ]
                    }
                  ],
                  "desc": "<p>The <code>_construct()</code> method MUST NOT be called directly. It may be implemented\nby child classes, and if so, will be called by the internal <code>Readable</code>\nclass methods only.</p>\n<p>This optional function will be scheduled in the next tick by the stream\nconstructor, delaying any <code>_read()</code> and <code>_destroy()</code> calls until <code>callback</code> is\ncalled. This is useful to initialize state or asynchronously initialize\nresources before the stream can be used.</p>\n<pre><code class=\"language-js\">const { Readable } = require('node:stream');\nconst fs = require('node:fs');\n\nclass ReadStream extends Readable {\n  constructor(filename) {\n    super();\n    this.filename = filename;\n    this.fd = null;\n  }\n  _construct(callback) {\n    fs.open(this.filename, (err, fd) => {\n      if (err) {\n        callback(err);\n      } else {\n        this.fd = fd;\n        callback();\n      }\n    });\n  }\n  _read(n) {\n    const buf = Buffer.alloc(n);\n    fs.read(this.fd, buf, 0, n, null, (err, bytesRead) => {\n      if (err) {\n        this.destroy(err);\n      } else {\n        this.push(bytesRead > 0 ? buf.slice(0, bytesRead) : null);\n      }\n    });\n  }\n  _destroy(err, callback) {\n    if (this.fd) {\n      fs.close(this.fd, (er) => callback(er || err));\n    } else {\n      callback(err);\n    }\n  }\n}\n</code></pre>"
                },
                {
                  "textRaw": "`readable._read(size)`",
                  "name": "_read",
                  "type": "method",
                  "meta": {
                    "added": [
                      "v0.9.4"
                    ],
                    "changes": []
                  },
                  "signatures": [
                    {
                      "params": [
                        {
                          "textRaw": "`size` {number} Number of bytes to read asynchronously",
                          "name": "size",
                          "type": "number",
                          "desc": "Number of bytes to read asynchronously"
                        }
                      ]
                    }
                  ],
                  "desc": "<p>This function MUST NOT be called by application code directly. It should be\nimplemented by child classes, and called by the internal <code>Readable</code> class\nmethods only.</p>\n<p>All <code>Readable</code> stream implementations must provide an implementation of the\n<a href=\"#readable_readsize\"><code>readable._read()</code></a> method to fetch data from the underlying resource.</p>\n<p>When <a href=\"#readable_readsize\"><code>readable._read()</code></a> is called, if data is available from the resource,\nthe implementation should begin pushing that data into the read queue using the\n<a href=\"#readablepushchunk-encoding\"><code>this.push(dataChunk)</code></a> method. <code>_read()</code> will be called again\nafter each call to <a href=\"#readablepushchunk-encoding\"><code>this.push(dataChunk)</code></a> once the stream is\nready to accept more data. <code>_read()</code> may continue reading from the resource and\npushing data until <code>readable.push()</code> returns <code>false</code>. Only when <code>_read()</code> is\ncalled again after it has stopped should it resume pushing additional data into\nthe queue.</p>\n<p>Once the <a href=\"#readable_readsize\"><code>readable._read()</code></a> method has been called, it will not be called\nagain until more data is pushed through the <a href=\"#readablepushchunk-encoding\"><code>readable.push()</code></a>\nmethod. Empty data such as empty buffers and strings will not cause\n<a href=\"#readable_readsize\"><code>readable._read()</code></a> to be called.</p>\n<p>The <code>size</code> argument is advisory. For implementations where a \"read\" is a\nsingle operation that returns data can use the <code>size</code> argument to determine how\nmuch data to fetch. Other implementations may ignore this argument and simply\nprovide data whenever it becomes available. There is no need to \"wait\" until\n<code>size</code> bytes are available before calling <a href=\"#readablepushchunk-encoding\"><code>stream.push(chunk)</code></a>.</p>\n<p>The <a href=\"#readable_readsize\"><code>readable._read()</code></a> method is prefixed with an underscore because it is\ninternal to the class that defines it, and should never be called directly by\nuser programs.</p>"
                },
                {
                  "textRaw": "`readable._destroy(err, callback)`",
                  "name": "_destroy",
                  "type": "method",
                  "meta": {
                    "added": [
                      "v8.0.0"
                    ],
                    "changes": []
                  },
                  "signatures": [
                    {
                      "params": [
                        {
                          "textRaw": "`err` {Error} A possible error.",
                          "name": "err",
                          "type": "Error",
                          "desc": "A possible error."
                        },
                        {
                          "textRaw": "`callback` {Function} A callback function that takes an optional error argument.",
                          "name": "callback",
                          "type": "Function",
                          "desc": "A callback function that takes an optional error argument."
                        }
                      ]
                    }
                  ],
                  "desc": "<p>The <code>_destroy()</code> method is called by <a href=\"#readabledestroyerror\"><code>readable.destroy()</code></a>.\nIt can be overridden by child classes but it <strong>must not</strong> be called directly.</p>"
                },
                {
                  "textRaw": "`readable.push(chunk[, encoding])`",
                  "name": "push",
                  "type": "method",
                  "meta": {
                    "changes": [
                      {
                        "version": [
                          "v22.0.0",
                          "v20.13.0"
                        ],
                        "pr-url": "https://github.com/nodejs/node/pull/51866",
                        "description": "The `chunk` argument can now be a `TypedArray` or `DataView` instance."
                      },
                      {
                        "version": "v8.0.0",
                        "pr-url": "https://github.com/nodejs/node/pull/11608",
                        "description": "The `chunk` argument can now be a `Uint8Array` instance."
                      }
                    ]
                  },
                  "signatures": [
                    {
                      "params": [
                        {
                          "textRaw": "`chunk` {Buffer|TypedArray|DataView|string|null|any} Chunk of data to push into the read queue. For streams not operating in object mode, `chunk` must be a {string}, {Buffer}, {TypedArray} or {DataView}. For object mode streams, `chunk` may be any JavaScript value.",
                          "name": "chunk",
                          "type": "Buffer|TypedArray|DataView|string|null|any",
                          "desc": "Chunk of data to push into the read queue. For streams not operating in object mode, `chunk` must be a {string}, {Buffer}, {TypedArray} or {DataView}. For object mode streams, `chunk` may be any JavaScript value."
                        },
                        {
                          "textRaw": "`encoding` {string} Encoding of string chunks. Must be a valid `Buffer` encoding, such as `'utf8'` or `'ascii'`.",
                          "name": "encoding",
                          "type": "string",
                          "desc": "Encoding of string chunks. Must be a valid `Buffer` encoding, such as `'utf8'` or `'ascii'`.",
                          "optional": true
                        }
                      ],
                      "return": {
                        "textRaw": "Returns: {boolean} `true` if additional chunks of data may continue to be pushed; `false` otherwise.",
                        "name": "return",
                        "type": "boolean",
                        "desc": "`true` if additional chunks of data may continue to be pushed; `false` otherwise."
                      }
                    }
                  ],
                  "desc": "<p>When <code>chunk</code> is a <a href=\"buffer.html#class-buffer\"><code>&#x3C;Buffer></code></a>, <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray\"><code>&#x3C;TypedArray></code></a>, <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView\"><code>&#x3C;DataView></code></a> or <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#string_type\"><code>&#x3C;string></code></a>, the <code>chunk</code>\nof data will be added to the internal queue for users of the stream to consume.\nPassing <code>chunk</code> as <code>null</code> signals the end of the stream (EOF), after which no\nmore data can be written.</p>\n<p>When the <code>Readable</code> is operating in paused mode, the data added with\n<code>readable.push()</code> can be read out by calling the\n<a href=\"#readablereadsize\"><code>readable.read()</code></a> method when the <a href=\"#event-readable\"><code>'readable'</code></a> event is\nemitted.</p>\n<p>When the <code>Readable</code> is operating in flowing mode, the data added with\n<code>readable.push()</code> will be delivered by emitting a <code>'data'</code> event.</p>\n<p>The <code>readable.push()</code> method is designed to be as flexible as possible. For\nexample, when wrapping a lower-level source that provides some form of\npause/resume mechanism, and a data callback, the low-level source can be wrapped\nby the custom <code>Readable</code> instance:</p>\n<pre><code class=\"language-js\">// `_source` is an object with readStop() and readStart() methods,\n// and an `ondata` member that gets called when it has data, and\n// an `onend` member that gets called when the data is over.\n\nclass SourceWrapper extends Readable {\n  constructor(options) {\n    super(options);\n\n    this._source = getLowLevelSourceObject();\n\n    // Every time there's data, push it into the internal buffer.\n    this._source.ondata = (chunk) => {\n      // If push() returns false, then stop reading from source.\n      if (!this.push(chunk))\n        this._source.readStop();\n    };\n\n    // When the source ends, push the EOF-signaling `null` chunk.\n    this._source.onend = () => {\n      this.push(null);\n    };\n  }\n  // _read() will be called when the stream wants to pull more data in.\n  // The advisory size argument is ignored in this case.\n  _read(size) {\n    this._source.readStart();\n  }\n}\n</code></pre>\n<p>The <code>readable.push()</code> method is used to push the content\ninto the internal buffer. It can be driven by the <a href=\"#readable_readsize\"><code>readable._read()</code></a> method.</p>\n<p>For streams not operating in object mode, if the <code>chunk</code> parameter of\n<code>readable.push()</code> is <code>undefined</code>, it will be treated as empty string or\nbuffer. See <a href=\"#readablepush\"><code>readable.push('')</code></a> for more information.</p>"
                }
              ],
              "modules": [
                {
                  "textRaw": "Errors while reading",
                  "name": "errors_while_reading",
                  "type": "module",
                  "desc": "<p>Errors occurring during processing of the <a href=\"#readable_readsize\"><code>readable._read()</code></a> must be\npropagated through the <a href=\"#readable_destroyerr-callback\"><code>readable.destroy(err)</code></a> method.\nThrowing an <code>Error</code> from within <a href=\"#readable_readsize\"><code>readable._read()</code></a> or manually emitting an\n<code>'error'</code> event results in undefined behavior.</p>\n<pre><code class=\"language-js\">const { Readable } = require('node:stream');\n\nconst myReadable = new Readable({\n  read(size) {\n    const err = checkSomeErrorCondition();\n    if (err) {\n      this.destroy(err);\n    } else {\n      // Do some work.\n    }\n  },\n});\n</code></pre>",
                  "displayName": "Errors while reading"
                }
              ],
              "examples": [
                {
                  "textRaw": "An example counting stream",
                  "name": "An example counting stream",
                  "type": "example",
                  "desc": "<p>The following is a basic example of a <code>Readable</code> stream that emits the numerals\nfrom 1 to 1,000,000 in ascending order, and then ends.</p>\n<pre><code class=\"language-js\">const { Readable } = require('node:stream');\n\nclass Counter extends Readable {\n  constructor(opt) {\n    super(opt);\n    this._max = 1000000;\n    this._index = 1;\n  }\n\n  _read() {\n    const i = this._index++;\n    if (i > this._max)\n      this.push(null);\n    else {\n      const str = String(i);\n      const buf = Buffer.from(str, 'ascii');\n      this.push(buf);\n    }\n  }\n}\n</code></pre>"
                }
              ],
              "displayName": "Implementing a readable stream"
            },
            {
              "textRaw": "Implementing a duplex stream",
              "name": "implementing_a_duplex_stream",
              "type": "misc",
              "desc": "<p>A <a href=\"#class-streamduplex\"><code>Duplex</code></a> stream is one that implements both <a href=\"#class-streamreadable\"><code>Readable</code></a> and\n<a href=\"#class-streamwritable\"><code>Writable</code></a>, such as a TCP socket connection.</p>\n<p>Because JavaScript does not have support for multiple inheritance, the\n<code>stream.Duplex</code> class is extended to implement a <a href=\"#class-streamduplex\"><code>Duplex</code></a> stream (as opposed\nto extending the <code>stream.Readable</code> <em>and</em> <code>stream.Writable</code> classes).</p>\n<p>The <code>stream.Duplex</code> class prototypically inherits from <code>stream.Readable</code> and\nparasitically from <code>stream.Writable</code>, but <code>instanceof</code> will work properly for\nboth base classes due to overriding <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/hasInstance\"><code>Symbol.hasInstance</code></a> on\n<code>stream.Writable</code>.</p>\n<p>Custom <code>Duplex</code> streams <em>must</em> call the <code>new stream.Duplex([options])</code>\nconstructor and implement <em>both</em> the <a href=\"#readable_readsize\"><code>readable._read()</code></a> and\n<code>writable._write()</code> methods.</p>",
              "signatures": [
                {
                  "textRaw": "`new stream.Duplex(options)`",
                  "name": "stream.Duplex",
                  "type": "ctor",
                  "meta": {
                    "changes": [
                      {
                        "version": "v8.4.0",
                        "pr-url": "https://github.com/nodejs/node/pull/14636",
                        "description": "The `readableHighWaterMark` and `writableHighWaterMark` options are supported now."
                      }
                    ]
                  },
                  "params": [
                    {
                      "textRaw": "`options` {Object} Passed to both `Writable` and `Readable` constructors. Also has the following fields:",
                      "name": "options",
                      "type": "Object",
                      "desc": "Passed to both `Writable` and `Readable` constructors. Also has the following fields:",
                      "options": [
                        {
                          "textRaw": "`allowHalfOpen` {boolean} If set to `false`, then the stream will automatically end the writable side when the readable side ends. **Default:** `true`.",
                          "name": "allowHalfOpen",
                          "type": "boolean",
                          "default": "`true`",
                          "desc": "If set to `false`, then the stream will automatically end the writable side when the readable side ends."
                        },
                        {
                          "textRaw": "`readable` {boolean} Sets whether the `Duplex` should be readable. **Default:** `true`.",
                          "name": "readable",
                          "type": "boolean",
                          "default": "`true`",
                          "desc": "Sets whether the `Duplex` should be readable."
                        },
                        {
                          "textRaw": "`writable` {boolean} Sets whether the `Duplex` should be writable. **Default:** `true`.",
                          "name": "writable",
                          "type": "boolean",
                          "default": "`true`",
                          "desc": "Sets whether the `Duplex` should be writable."
                        },
                        {
                          "textRaw": "`readableObjectMode` {boolean} Sets `objectMode` for readable side of the stream. Has no effect if `objectMode` is `true`. **Default:** `false`.",
                          "name": "readableObjectMode",
                          "type": "boolean",
                          "default": "`false`",
                          "desc": "Sets `objectMode` for readable side of the stream. Has no effect if `objectMode` is `true`."
                        },
                        {
                          "textRaw": "`writableObjectMode` {boolean} Sets `objectMode` for writable side of the stream. Has no effect if `objectMode` is `true`. **Default:** `false`.",
                          "name": "writableObjectMode",
                          "type": "boolean",
                          "default": "`false`",
                          "desc": "Sets `objectMode` for writable side of the stream. Has no effect if `objectMode` is `true`."
                        },
                        {
                          "textRaw": "`readableHighWaterMark` {number} Sets `highWaterMark` for the readable side of the stream. Has no effect if `highWaterMark` is provided.",
                          "name": "readableHighWaterMark",
                          "type": "number",
                          "desc": "Sets `highWaterMark` for the readable side of the stream. Has no effect if `highWaterMark` is provided."
                        },
                        {
                          "textRaw": "`writableHighWaterMark` {number} Sets `highWaterMark` for the writable side of the stream. Has no effect if `highWaterMark` is provided.",
                          "name": "writableHighWaterMark",
                          "type": "number",
                          "desc": "Sets `highWaterMark` for the writable side of the stream. Has no effect if `highWaterMark` is provided."
                        }
                      ]
                    }
                  ],
                  "desc": "<pre><code class=\"language-js\">const { Duplex } = require('node:stream');\n\nclass MyDuplex extends Duplex {\n  constructor(options) {\n    super(options);\n    // ...\n  }\n}\n</code></pre>\n<p>Or, when using pre-ES6 style constructors:</p>\n<pre><code class=\"language-js\">const { Duplex } = require('node:stream');\nconst util = require('node:util');\n\nfunction MyDuplex(options) {\n  if (!(this instanceof MyDuplex))\n    return new MyDuplex(options);\n  Duplex.call(this, options);\n}\nutil.inherits(MyDuplex, Duplex);\n</code></pre>\n<p>Or, using the simplified constructor approach:</p>\n<pre><code class=\"language-js\">const { Duplex } = require('node:stream');\n\nconst myDuplex = new Duplex({\n  read(size) {\n    // ...\n  },\n  write(chunk, encoding, callback) {\n    // ...\n  },\n});\n</code></pre>\n<p>When using pipeline:</p>\n<pre><code class=\"language-js\">const { Transform, pipeline } = require('node:stream');\nconst fs = require('node:fs');\n\npipeline(\n  fs.createReadStream('object.json')\n    .setEncoding('utf8'),\n  new Transform({\n    decodeStrings: false, // Accept string input rather than Buffers\n    construct(callback) {\n      this.data = '';\n      callback();\n    },\n    transform(chunk, encoding, callback) {\n      this.data += chunk;\n      callback();\n    },\n    flush(callback) {\n      try {\n        // Make sure is valid json.\n        JSON.parse(this.data);\n        this.push(this.data);\n        callback();\n      } catch (err) {\n        callback(err);\n      }\n    },\n  }),\n  fs.createWriteStream('valid-object.json'),\n  (err) => {\n    if (err) {\n      console.error('failed', err);\n    } else {\n      console.log('completed');\n    }\n  },\n);\n</code></pre>"
                }
              ],
              "modules": [
                {
                  "textRaw": "An example duplex stream",
                  "name": "an_example_duplex_stream",
                  "type": "module",
                  "desc": "<p>The following illustrates a simple example of a <code>Duplex</code> stream that wraps a\nhypothetical lower-level source object to which data can be written, and\nfrom which data can be read, albeit using an API that is not compatible with\nNode.js streams.\nThe following illustrates a simple example of a <code>Duplex</code> stream that buffers\nincoming written data via the <a href=\"#class-streamwritable\"><code>Writable</code></a> interface that is read back out\nvia the <a href=\"#class-streamreadable\"><code>Readable</code></a> interface.</p>\n<pre><code class=\"language-js\">const { Duplex } = require('node:stream');\nconst kSource = Symbol('source');\n\nclass MyDuplex extends Duplex {\n  constructor(source, options) {\n    super(options);\n    this[kSource] = source;\n  }\n\n  _write(chunk, encoding, callback) {\n    // The underlying source only deals with strings.\n    if (Buffer.isBuffer(chunk))\n      chunk = chunk.toString();\n    this[kSource].writeSomeData(chunk);\n    callback();\n  }\n\n  _read(size) {\n    this[kSource].fetchSomeData(size, (data, encoding) => {\n      this.push(Buffer.from(data, encoding));\n    });\n  }\n}\n</code></pre>\n<p>The most important aspect of a <code>Duplex</code> stream is that the <code>Readable</code> and\n<code>Writable</code> sides operate independently of one another despite co-existing within\na single object instance.</p>",
                  "displayName": "An example duplex stream"
                },
                {
                  "textRaw": "Object mode duplex streams",
                  "name": "object_mode_duplex_streams",
                  "type": "module",
                  "desc": "<p>For <code>Duplex</code> streams, <code>objectMode</code> can be set exclusively for either the\n<code>Readable</code> or <code>Writable</code> side using the <code>readableObjectMode</code> and\n<code>writableObjectMode</code> options respectively.</p>\n<p>In the following example, for instance, a new <code>Transform</code> stream (which is a\ntype of <a href=\"#class-streamduplex\"><code>Duplex</code></a> stream) is created that has an object mode <code>Writable</code> side\nthat accepts JavaScript numbers that are converted to hexadecimal strings on\nthe <code>Readable</code> side.</p>\n<pre><code class=\"language-js\">const { Transform } = require('node:stream');\n\n// All Transform streams are also Duplex Streams.\nconst myTransform = new Transform({\n  writableObjectMode: true,\n\n  transform(chunk, encoding, callback) {\n    // Coerce the chunk to a number if necessary.\n    chunk |= 0;\n\n    // Transform the chunk into something else.\n    const data = chunk.toString(16);\n\n    // Push the data onto the readable queue.\n    callback(null, '0'.repeat(data.length % 2) + data);\n  },\n});\n\nmyTransform.setEncoding('ascii');\nmyTransform.on('data', (chunk) => console.log(chunk));\n\nmyTransform.write(1);\n// Prints: 01\nmyTransform.write(10);\n// Prints: 0a\nmyTransform.write(100);\n// Prints: 64\n</code></pre>",
                  "displayName": "Object mode duplex streams"
                }
              ],
              "displayName": "Implementing a duplex stream"
            },
            {
              "textRaw": "Implementing a transform stream",
              "name": "implementing_a_transform_stream",
              "type": "misc",
              "desc": "<p>A <a href=\"#class-streamtransform\"><code>Transform</code></a> stream is a <a href=\"#class-streamduplex\"><code>Duplex</code></a> stream where the output is computed\nin some way from the input. Examples include <a href=\"zlib.html\">zlib</a> streams or <a href=\"crypto.html\">crypto</a>\nstreams that compress, encrypt, or decrypt data.</p>\n<p>There is no requirement that the output be the same size as the input, the same\nnumber of chunks, or arrive at the same time. For example, a <code>Hash</code> stream will\nonly ever have a single chunk of output which is provided when the input is\nended. A <code>zlib</code> stream will produce output that is either much smaller or much\nlarger than its input.</p>\n<p>The <code>stream.Transform</code> class is extended to implement a <a href=\"#class-streamtransform\"><code>Transform</code></a> stream.</p>\n<p>The <code>stream.Transform</code> class prototypically inherits from <code>stream.Duplex</code> and\nimplements its own versions of the <code>writable._write()</code> and\n<a href=\"#readable_readsize\"><code>readable._read()</code></a> methods. Custom <code>Transform</code> implementations <em>must</em>\nimplement the <a href=\"#transform_transformchunk-encoding-callback\"><code>transform._transform()</code></a> method and <em>may</em>\nalso implement the <a href=\"#transform_flushcallback\"><code>transform._flush()</code></a> method.</p>\n<p>Care must be taken when using <code>Transform</code> streams in that data written to the\nstream can cause the <code>Writable</code> side of the stream to become paused if the\noutput on the <code>Readable</code> side is not consumed.</p>",
              "signatures": [
                {
                  "textRaw": "`new stream.Transform([options])`",
                  "name": "stream.Transform",
                  "type": "ctor",
                  "params": [
                    {
                      "textRaw": "`options` {Object} Passed to both `Writable` and `Readable` constructors. Also has the following fields:",
                      "name": "options",
                      "type": "Object",
                      "desc": "Passed to both `Writable` and `Readable` constructors. Also has the following fields:",
                      "options": [
                        {
                          "textRaw": "`transform` {Function} Implementation for the `stream._transform()` method.",
                          "name": "transform",
                          "type": "Function",
                          "desc": "Implementation for the `stream._transform()` method."
                        },
                        {
                          "textRaw": "`flush` {Function} Implementation for the `stream._flush()` method.",
                          "name": "flush",
                          "type": "Function",
                          "desc": "Implementation for the `stream._flush()` method."
                        }
                      ],
                      "optional": true
                    }
                  ],
                  "desc": "<pre><code class=\"language-js\">const { Transform } = require('node:stream');\n\nclass MyTransform extends Transform {\n  constructor(options) {\n    super(options);\n    // ...\n  }\n}\n</code></pre>\n<p>Or, when using pre-ES6 style constructors:</p>\n<pre><code class=\"language-js\">const { Transform } = require('node:stream');\nconst util = require('node:util');\n\nfunction MyTransform(options) {\n  if (!(this instanceof MyTransform))\n    return new MyTransform(options);\n  Transform.call(this, options);\n}\nutil.inherits(MyTransform, Transform);\n</code></pre>\n<p>Or, using the simplified constructor approach:</p>\n<pre><code class=\"language-js\">const { Transform } = require('node:stream');\n\nconst myTransform = new Transform({\n  transform(chunk, encoding, callback) {\n    // ...\n  },\n});\n</code></pre>"
                }
              ],
              "events": [
                {
                  "textRaw": "Event: `'end'`",
                  "name": "end",
                  "type": "event",
                  "params": [],
                  "desc": "<p>The <a href=\"#event-end\"><code>'end'</code></a> event is from the <code>stream.Readable</code> class. The <code>'end'</code> event is\nemitted after all data has been output, which occurs after the callback in\n<a href=\"#transform_flushcallback\"><code>transform._flush()</code></a> has been called. In the case of an error,\n<code>'end'</code> should not be emitted.</p>"
                },
                {
                  "textRaw": "Event: `'finish'`",
                  "name": "finish",
                  "type": "event",
                  "params": [],
                  "desc": "<p>The <a href=\"#event-finish\"><code>'finish'</code></a> event is from the <code>stream.Writable</code> class. The <code>'finish'</code>\nevent is emitted after <a href=\"#writableendchunk-encoding-callback\"><code>stream.end()</code></a> is called and all chunks\nhave been processed by <a href=\"#transform_transformchunk-encoding-callback\"><code>stream._transform()</code></a>. In the case\nof an error, <code>'finish'</code> should not be emitted.</p>"
                }
              ],
              "methods": [
                {
                  "textRaw": "`transform._flush(callback)`",
                  "name": "_flush",
                  "type": "method",
                  "signatures": [
                    {
                      "params": [
                        {
                          "textRaw": "`callback` {Function} A callback function (optionally with an error argument and data) to be called when remaining data has been flushed.",
                          "name": "callback",
                          "type": "Function",
                          "desc": "A callback function (optionally with an error argument and data) to be called when remaining data has been flushed."
                        }
                      ]
                    }
                  ],
                  "desc": "<p>This function MUST NOT be called by application code directly. It should be\nimplemented by child classes, and called by the internal <code>Readable</code> class\nmethods only.</p>\n<p>In some cases, a transform operation may need to emit an additional bit of\ndata at the end of the stream. For example, a <code>zlib</code> compression stream will\nstore an amount of internal state used to optimally compress the output. When\nthe stream ends, however, that additional data needs to be flushed so that the\ncompressed data will be complete.</p>\n<p>Custom <a href=\"#class-streamtransform\"><code>Transform</code></a> implementations <em>may</em> implement the <code>transform._flush()</code>\nmethod. This will be called when there is no more written data to be consumed,\nbut before the <a href=\"#event-end\"><code>'end'</code></a> event is emitted signaling the end of the\n<a href=\"#class-streamreadable\"><code>Readable</code></a> stream.</p>\n<p>Within the <code>transform._flush()</code> implementation, the <code>transform.push()</code> method\nmay be called zero or more times, as appropriate. The <code>callback</code> function must\nbe called when the flush operation is complete.</p>\n<p>The <code>transform._flush()</code> method is prefixed with an underscore because it is\ninternal to the class that defines it, and should never be called directly by\nuser programs.</p>"
                },
                {
                  "textRaw": "`transform._transform(chunk, encoding, callback)`",
                  "name": "_transform",
                  "type": "method",
                  "signatures": [
                    {
                      "params": [
                        {
                          "textRaw": "`chunk` {Buffer|string|any} The `Buffer` to be transformed, converted from the `string` passed to `stream.write()`. If the stream's `decodeStrings` option is `false` or the stream is operating in object mode, the chunk will not be converted & will be whatever was passed to `stream.write()`.",
                          "name": "chunk",
                          "type": "Buffer|string|any",
                          "desc": "The `Buffer` to be transformed, converted from the `string` passed to `stream.write()`. If the stream's `decodeStrings` option is `false` or the stream is operating in object mode, the chunk will not be converted & will be whatever was passed to `stream.write()`."
                        },
                        {
                          "textRaw": "`encoding` {string} If the chunk is a string, then this is the encoding type. If chunk is a buffer, then this is the special value `'buffer'`. Ignore it in that case.",
                          "name": "encoding",
                          "type": "string",
                          "desc": "If the chunk is a string, then this is the encoding type. If chunk is a buffer, then this is the special value `'buffer'`. Ignore it in that case."
                        },
                        {
                          "textRaw": "`callback` {Function} A callback function (optionally with an error argument and data) to be called after the supplied `chunk` has been processed.",
                          "name": "callback",
                          "type": "Function",
                          "desc": "A callback function (optionally with an error argument and data) to be called after the supplied `chunk` has been processed."
                        }
                      ]
                    }
                  ],
                  "desc": "<p>This function MUST NOT be called by application code directly. It should be\nimplemented by child classes, and called by the internal <code>Readable</code> class\nmethods only.</p>\n<p>All <code>Transform</code> stream implementations must provide a <code>_transform()</code>\nmethod to accept input and produce output. The <code>transform._transform()</code>\nimplementation handles the bytes being written, computes an output, then passes\nthat output off to the readable portion using the <code>transform.push()</code> method.</p>\n<p>The <code>transform.push()</code> method may be called zero or more times to generate\noutput from a single input chunk, depending on how much is to be output\nas a result of the chunk.</p>\n<p>It is possible that no output is generated from any given chunk of input data.</p>\n<p>The <code>callback</code> function must be called only when the current chunk is completely\nconsumed. The first argument passed to the <code>callback</code> must be an <code>Error</code> object\nif an error occurred while processing the input or <code>null</code> otherwise. If a second\nargument is passed to the <code>callback</code>, it will be forwarded on to the\n<code>transform.push()</code> method, but only if the first argument is falsy. In other\nwords, the following are equivalent:</p>\n<pre><code class=\"language-js\">transform.prototype._transform = function(data, encoding, callback) {\n  this.push(data);\n  callback();\n};\n\ntransform.prototype._transform = function(data, encoding, callback) {\n  callback(null, data);\n};\n</code></pre>\n<p>The <code>transform._transform()</code> method is prefixed with an underscore because it\nis internal to the class that defines it, and should never be called directly by\nuser programs.</p>\n<p><code>transform._transform()</code> is never called in parallel; streams implement a\nqueue mechanism, and to receive the next chunk, <code>callback</code> must be\ncalled, either synchronously or asynchronously.</p>"
                }
              ],
              "classes": [
                {
                  "textRaw": "Class: `stream.PassThrough`",
                  "name": "stream.PassThrough",
                  "type": "class",
                  "desc": "<p>The <code>stream.PassThrough</code> class is a trivial implementation of a <a href=\"#class-streamtransform\"><code>Transform</code></a>\nstream that simply passes the input bytes across to the output. Its purpose is\nprimarily for examples and testing, but there are some use cases where\n<code>stream.PassThrough</code> is useful as a building block for novel sorts of streams.</p>"
                }
              ],
              "displayName": "Implementing a transform stream"
            }
          ]
        },
        {
          "textRaw": "Additional notes",
          "name": "Additional notes",
          "type": "misc",
          "miscs": [
            {
              "textRaw": "Streams compatibility with async generators and async iterators",
              "name": "streams_compatibility_with_async_generators_and_async_iterators",
              "type": "misc",
              "desc": "<p>With the support of async generators and iterators in JavaScript, async\ngenerators are effectively a first-class language-level stream construct at\nthis point.</p>\n<p>Some common interop cases of using Node.js streams with async generators\nand async iterators are provided below.</p>",
              "modules": [
                {
                  "textRaw": "Consuming readable streams with async iterators",
                  "name": "consuming_readable_streams_with_async_iterators",
                  "type": "module",
                  "desc": "<pre><code class=\"language-js\">(async function() {\n  for await (const chunk of readable) {\n    console.log(chunk);\n  }\n})();\n</code></pre>\n<p>Async iterators register a permanent error handler on the stream to prevent any\nunhandled post-destroy errors.</p>",
                  "displayName": "Consuming readable streams with async iterators"
                },
                {
                  "textRaw": "Creating readable streams with async generators",
                  "name": "creating_readable_streams_with_async_generators",
                  "type": "module",
                  "desc": "<p>A Node.js readable stream can be created from an asynchronous generator using\nthe <code>Readable.from()</code> utility method:</p>\n<pre><code class=\"language-js\">const { Readable } = require('node:stream');\n\nconst ac = new AbortController();\nconst signal = ac.signal;\n\nasync function * generate() {\n  yield 'a';\n  await someLongRunningFn({ signal });\n  yield 'b';\n  yield 'c';\n}\n\nconst readable = Readable.from(generate());\nreadable.on('close', () => {\n  ac.abort();\n});\n\nreadable.on('data', (chunk) => {\n  console.log(chunk);\n});\n</code></pre>",
                  "displayName": "Creating readable streams with async generators"
                }
              ],
              "miscs": [
                {
                  "textRaw": "Piping to writable streams from async iterators",
                  "name": "Piping to writable streams from async iterators",
                  "type": "misc",
                  "desc": "<p>When writing to a writable stream from an async iterator, ensure correct\nhandling of backpressure and errors. <a href=\"#streampipelinesource-transforms-destination-callback\"><code>stream.pipeline()</code></a> abstracts away\nthe handling of backpressure and backpressure-related errors:</p>\n<pre><code class=\"language-js\">const fs = require('node:fs');\nconst { pipeline } = require('node:stream');\nconst { pipeline: pipelinePromise } = require('node:stream/promises');\n\nconst writable = fs.createWriteStream('./file');\n\nconst ac = new AbortController();\nconst signal = ac.signal;\n\nconst iterator = createIterator({ signal });\n\n// Callback Pattern\npipeline(iterator, writable, (err, value) => {\n  if (err) {\n    console.error(err);\n  } else {\n    console.log(value, 'value returned');\n  }\n}).on('close', () => {\n  ac.abort();\n});\n\n// Promise Pattern\npipelinePromise(iterator, writable)\n  .then((value) => {\n    console.log(value, 'value returned');\n  })\n  .catch((err) => {\n    console.error(err);\n    ac.abort();\n  });\n</code></pre>"
                }
              ],
              "displayName": "Streams compatibility with async generators and async iterators"
            },
            {
              "textRaw": "Compatibility with older Node.js versions",
              "name": "Compatibility with older Node.js versions",
              "type": "misc",
              "desc": "<p>Prior to Node.js 0.10, the <code>Readable</code> stream interface was simpler, but also\nless powerful and less useful.</p>\n<ul>\n<li>Rather than waiting for calls to the <a href=\"#readablereadsize\"><code>stream.read()</code></a> method,\n<a href=\"#event-data\"><code>'data'</code></a> events would begin emitting immediately. Applications that\nwould need to perform some amount of work to decide how to handle data\nwere required to store read data into buffers so the data would not be lost.</li>\n<li>The <a href=\"#readablepause\"><code>stream.pause()</code></a> method was advisory, rather than\nguaranteed. This meant that it was still necessary to be prepared to receive\n<a href=\"#event-data\"><code>'data'</code></a> events <em>even when the stream was in a paused state</em>.</li>\n</ul>\n<p>In Node.js 0.10, the <a href=\"#class-streamreadable\"><code>Readable</code></a> class was added. For backward\ncompatibility with older Node.js programs, <code>Readable</code> streams switch into\n\"flowing mode\" when a <a href=\"#event-data\"><code>'data'</code></a> event handler is added, or when the\n<a href=\"#readableresume\"><code>stream.resume()</code></a> method is called. The effect is that, even\nwhen not using the new <a href=\"#readablereadsize\"><code>stream.read()</code></a> method and\n<a href=\"#event-readable\"><code>'readable'</code></a> event, it is no longer necessary to worry about losing\n<a href=\"#event-data\"><code>'data'</code></a> chunks.</p>\n<p>While most applications will continue to function normally, this introduces an\nedge case in the following conditions:</p>\n<ul>\n<li>No <a href=\"#event-data\"><code>'data'</code></a> event listener is added.</li>\n<li>The <a href=\"#readableresume\"><code>stream.resume()</code></a> method is never called.</li>\n<li>The stream is not piped to any writable destination.</li>\n</ul>\n<p>For example, consider the following code:</p>\n<pre><code class=\"language-js\">// WARNING!  BROKEN!\nnet.createServer((socket) => {\n\n  // We add an 'end' listener, but never consume the data.\n  socket.on('end', () => {\n    // It will never get here.\n    socket.end('The message was received but was not processed.\\n');\n  });\n\n}).listen(1337);\n</code></pre>\n<p>Prior to Node.js 0.10, the incoming message data would be simply discarded.\nHowever, in Node.js 0.10 and beyond, the socket remains paused forever.</p>\n<p>The workaround in this situation is to call the\n<a href=\"#readableresume\"><code>stream.resume()</code></a> method to begin the flow of data:</p>\n<pre><code class=\"language-js\">// Workaround.\nnet.createServer((socket) => {\n  socket.on('end', () => {\n    socket.end('The message was received but was not processed.\\n');\n  });\n\n  // Start the flow of data, discarding it.\n  socket.resume();\n}).listen(1337);\n</code></pre>\n<p>In addition to new <code>Readable</code> streams switching into flowing mode,\npre-0.10 style streams can be wrapped in a <code>Readable</code> class using the\n<a href=\"#readablewrapstream\"><code>readable.wrap()</code></a> method.</p>"
            },
            {
              "textRaw": "`highWaterMark` discrepancy after calling `readable.setEncoding()`",
              "name": "`highwatermark`_discrepancy_after_calling_`readable.setencoding()`",
              "type": "misc",
              "desc": "<p>The use of <code>readable.setEncoding()</code> will change the behavior of how the\n<code>highWaterMark</code> operates in non-object mode.</p>\n<p>Typically, the size of the current buffer is measured against the\n<code>highWaterMark</code> in <em>bytes</em>. However, after <code>setEncoding()</code> is called, the\ncomparison function will begin to measure the buffer's size in <em>characters</em>.</p>\n<p>This is not a problem in common cases with <code>latin1</code> or <code>ascii</code>. But it is\nadvised to be mindful about this behavior when working with strings that could\ncontain multi-byte characters.</p>",
              "displayName": "`highWaterMark` discrepancy after calling `readable.setEncoding()`"
            }
          ],
          "methods": [
            {
              "textRaw": "`readable.read(0)`",
              "name": "read",
              "type": "method",
              "signatures": [
                {
                  "params": [
                    {
                      "name": "0"
                    }
                  ]
                }
              ],
              "desc": "<p>There are some cases where it is necessary to trigger a refresh of the\nunderlying readable stream mechanisms, without actually consuming any\ndata. In such cases, it is possible to call <code>readable.read(0)</code>, which will\nalways return <code>null</code>.</p>\n<p>If the internal read buffer is below the <code>highWaterMark</code>, and the\nstream is not currently reading, then calling <code>stream.read(0)</code> will trigger\na low-level <a href=\"#readable_readsize\"><code>stream._read()</code></a> call.</p>\n<p>While most applications will almost never need to do this, there are\nsituations within Node.js where this is done, particularly in the\n<code>Readable</code> stream class internals.</p>"
            },
            {
              "textRaw": "`readable.push('')`",
              "name": "push",
              "type": "method",
              "signatures": [
                {
                  "params": [
                    {
                      "name": "''"
                    }
                  ]
                }
              ],
              "desc": "<p>Use of <code>readable.push('')</code> is not recommended.</p>\n<p>Pushing a zero-byte <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#string_type\"><code>&#x3C;string></code></a>, <a href=\"buffer.html#class-buffer\"><code>&#x3C;Buffer></code></a>, <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray\"><code>&#x3C;TypedArray></code></a> or <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView\"><code>&#x3C;DataView></code></a> to a stream\nthat is not in object mode has an interesting side effect.\nBecause it <em>is</em> a call to\n<a href=\"#readablepushchunk-encoding\"><code>readable.push()</code></a>, the call will end the reading process.\nHowever, because the argument is an empty string, no data is added to the\nreadable buffer so there is nothing for a user to consume.</p>"
            }
          ]
        }
      ],
      "methods": [
        {
          "textRaw": "`stream.finished(stream[, options], callback)`",
          "name": "finished",
          "type": "method",
          "meta": {
            "added": [
              "v10.0.0"
            ],
            "changes": [
              {
                "version": "v19.5.0",
                "pr-url": "https://github.com/nodejs/node/pull/46205",
                "description": "Added support for `ReadableStream` and `WritableStream`."
              },
              {
                "version": "v15.11.0",
                "pr-url": "https://github.com/nodejs/node/pull/37354",
                "description": "The `signal` option was added."
              },
              {
                "version": "v14.0.0",
                "pr-url": "https://github.com/nodejs/node/pull/32158",
                "description": "The `finished(stream, cb)` will wait for the `'close'` event before invoking the callback. The implementation tries to detect legacy streams and only apply this behavior to streams which are expected to emit `'close'`."
              },
              {
                "version": "v14.0.0",
                "pr-url": "https://github.com/nodejs/node/pull/31545",
                "description": "Emitting `'close'` before `'end'` on a `Readable` stream will cause an `ERR_STREAM_PREMATURE_CLOSE` error."
              },
              {
                "version": "v14.0.0",
                "pr-url": "https://github.com/nodejs/node/pull/31509",
                "description": "Callback will be invoked on streams which have already finished before the call to `finished(stream, cb)`."
              }
            ]
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`stream` {Stream|ReadableStream|WritableStream} A readable and/or writable stream/webstream.",
                  "name": "stream",
                  "type": "Stream|ReadableStream|WritableStream",
                  "desc": "A readable and/or writable stream/webstream."
                },
                {
                  "textRaw": "`options` {Object}",
                  "name": "options",
                  "type": "Object",
                  "options": [
                    {
                      "textRaw": "`error` {boolean} If set to `false`, then a call to `emit('error', err)` is not treated as finished. **Default:** `true`.",
                      "name": "error",
                      "type": "boolean",
                      "default": "`true`",
                      "desc": "If set to `false`, then a call to `emit('error', err)` is not treated as finished."
                    },
                    {
                      "textRaw": "`readable` {boolean} When set to `false`, the callback will be called when the stream ends even though the stream might still be readable. **Default:** `true`.",
                      "name": "readable",
                      "type": "boolean",
                      "default": "`true`",
                      "desc": "When set to `false`, the callback will be called when the stream ends even though the stream might still be readable."
                    },
                    {
                      "textRaw": "`writable` {boolean} When set to `false`, the callback will be called when the stream ends even though the stream might still be writable. **Default:** `true`.",
                      "name": "writable",
                      "type": "boolean",
                      "default": "`true`",
                      "desc": "When set to `false`, the callback will be called when the stream ends even though the stream might still be writable."
                    },
                    {
                      "textRaw": "`signal` {AbortSignal} allows aborting the wait for the stream finish. The underlying stream will _not_ be aborted if the signal is aborted. The callback will get called with an `AbortError`. All registered listeners added by this function will also be removed.",
                      "name": "signal",
                      "type": "AbortSignal",
                      "desc": "allows aborting the wait for the stream finish. The underlying stream will _not_ be aborted if the signal is aborted. The callback will get called with an `AbortError`. All registered listeners added by this function will also be removed."
                    }
                  ],
                  "optional": true
                },
                {
                  "textRaw": "`callback` {Function} A callback function that takes an optional error argument.",
                  "name": "callback",
                  "type": "Function",
                  "desc": "A callback function that takes an optional error argument."
                }
              ],
              "return": {
                "textRaw": "Returns: {Function} A cleanup function which removes all registered listeners.",
                "name": "return",
                "type": "Function",
                "desc": "A cleanup function which removes all registered listeners."
              }
            }
          ],
          "desc": "<p>A function to get notified when a stream is no longer readable, writable\nor has experienced an error or a premature close event.</p>\n<pre><code class=\"language-js\">const { finished } = require('node:stream');\nconst fs = require('node:fs');\n\nconst rs = fs.createReadStream('archive.tar');\n\nfinished(rs, (err) => {\n  if (err) {\n    console.error('Stream failed.', err);\n  } else {\n    console.log('Stream is done reading.');\n  }\n});\n\nrs.resume(); // Drain the stream.\n</code></pre>\n<p>Especially useful in error handling scenarios where a stream is destroyed\nprematurely (like an aborted HTTP request), and will not emit <code>'end'</code>\nor <code>'finish'</code>.</p>\n<p>The <code>finished</code> API provides <a href=\"#streamfinishedstream-options\">promise version</a>.</p>\n<p><code>stream.finished()</code> leaves dangling event listeners (in particular\n<code>'error'</code>, <code>'end'</code>, <code>'finish'</code> and <code>'close'</code>) after <code>callback</code> has been\ninvoked. The reason for this is so that unexpected <code>'error'</code> events (due to\nincorrect stream implementations) do not cause unexpected crashes.\nIf this is unwanted behavior then the returned cleanup function needs to be\ninvoked in the callback:</p>\n<pre><code class=\"language-js\">const cleanup = finished(rs, (err) => {\n  cleanup();\n  // ...\n});\n</code></pre>"
        },
        {
          "textRaw": "`stream.pipeline(source[, ...transforms], destination, callback)`",
          "name": "pipeline",
          "type": "method",
          "signatures": [
            {
              "params": [
                {
                  "name": "source"
                },
                {
                  "name": "...transforms",
                  "optional": true
                },
                {
                  "name": "destination"
                },
                {
                  "name": "callback"
                }
              ]
            }
          ]
        },
        {
          "textRaw": "`stream.pipeline(streams, callback)`",
          "name": "pipeline",
          "type": "method",
          "meta": {
            "added": [
              "v10.0.0"
            ],
            "changes": [
              {
                "version": [
                  "v19.7.0",
                  "v18.16.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/46307",
                "description": "Added support for webstreams."
              },
              {
                "version": "v18.0.0",
                "pr-url": "https://github.com/nodejs/node/pull/41678",
                "description": "Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."
              },
              {
                "version": "v14.0.0",
                "pr-url": "https://github.com/nodejs/node/pull/32158",
                "description": "The `pipeline(..., cb)` will wait for the `'close'` event before invoking the callback. The implementation tries to detect legacy streams and only apply this behavior to streams which are expected to emit `'close'`."
              },
              {
                "version": "v13.10.0",
                "pr-url": "https://github.com/nodejs/node/pull/31223",
                "description": "Add support for async generators."
              }
            ]
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`streams` {Stream[]|AsyncIterable[]|Function[]|ReadableStream[]|WritableStream[]|TransformStream[]}",
                  "name": "streams",
                  "type": "Stream[]|AsyncIterable[]|Function[]|ReadableStream[]|WritableStream[]|TransformStream[]"
                },
                {
                  "textRaw": "`callback` {Function} Called when the pipeline is fully done.",
                  "name": "callback",
                  "type": "Function",
                  "desc": "Called when the pipeline is fully done.",
                  "options": [
                    {
                      "textRaw": "`err` {Error}",
                      "name": "err",
                      "type": "Error"
                    },
                    {
                      "textRaw": "`val` Resolved value of `Promise` returned by `destination`.",
                      "name": "val",
                      "desc": "Resolved value of `Promise` returned by `destination`."
                    }
                  ]
                }
              ],
              "return": {
                "textRaw": "Returns: {Stream}",
                "name": "return",
                "type": "Stream"
              }
            }
          ],
          "desc": "<p>A module method to pipe between streams and generators forwarding errors and\nproperly cleaning up and provide a callback when the pipeline is complete.</p>\n<pre><code class=\"language-js\">const { pipeline } = require('node:stream');\nconst fs = require('node:fs');\nconst zlib = require('node:zlib');\n\n// Use the pipeline API to easily pipe a series of streams\n// together and get notified when the pipeline is fully done.\n\n// A pipeline to gzip a potentially huge tar file efficiently:\n\npipeline(\n  fs.createReadStream('archive.tar'),\n  zlib.createGzip(),\n  fs.createWriteStream('archive.tar.gz'),\n  (err) => {\n    if (err) {\n      console.error('Pipeline failed.', err);\n    } else {\n      console.log('Pipeline succeeded.');\n    }\n  },\n);\n</code></pre>\n<p>The <code>pipeline</code> API provides a <a href=\"#streampipelinesource-transforms-destination-options\">promise version</a>.</p>\n<p><code>stream.pipeline()</code> will call <code>stream.destroy(err)</code> on all streams except:</p>\n<ul>\n<li><code>Readable</code> streams which have emitted <code>'end'</code> or <code>'close'</code>.</li>\n<li><code>Writable</code> streams which have emitted <code>'finish'</code> or <code>'close'</code>.</li>\n</ul>\n<p><code>stream.pipeline()</code> leaves dangling event listeners on the streams\nafter the <code>callback</code> has been invoked. In the case of reuse of streams after\nfailure, this can cause event listener leaks and swallowed errors. If the last\nstream is readable, dangling event listeners will be removed so that the last\nstream can be consumed later.</p>\n<p><code>stream.pipeline()</code> closes all the streams when an error is raised.\nThe <code>IncomingRequest</code> usage with <code>pipeline</code> could lead to an unexpected behavior\nonce it would destroy the socket without sending the expected response.\nSee the example below:</p>\n<pre><code class=\"language-js\">const fs = require('node:fs');\nconst http = require('node:http');\nconst { pipeline } = require('node:stream');\n\nconst server = http.createServer((req, res) => {\n  const fileStream = fs.createReadStream('./fileNotExist.txt');\n  pipeline(fileStream, res, (err) => {\n    if (err) {\n      console.log(err); // No such file\n      // this message can't be sent once `pipeline` already destroyed the socket\n      return res.end('error!!!');\n    }\n  });\n});\n</code></pre>"
        },
        {
          "textRaw": "`stream.compose(...streams)`",
          "name": "compose",
          "type": "method",
          "meta": {
            "added": [
              "v16.9.0"
            ],
            "changes": [
              {
                "version": "v26.2.0",
                "pr-url": "https://github.com/nodejs/node/pull/62562",
                "description": "Marking the API stable."
              },
              {
                "version": [
                  "v21.1.0",
                  "v20.10.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/50187",
                "description": "Added support for stream class."
              },
              {
                "version": [
                  "v19.8.0",
                  "v18.16.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/46675",
                "description": "Added support for webstreams."
              }
            ]
          },
          "stability": 2,
          "stabilityText": "Stable",
          "signatures": [
            {
              "params": [
                {
                  "name": "...streams"
                }
              ],
              "return": {
                "textRaw": "Returns: {stream.Duplex}",
                "name": "return",
                "type": "stream.Duplex"
              }
            }
          ],
          "desc": "<p>Combines two or more streams into a <code>Duplex</code> stream that writes to the\nfirst stream and reads from the last. Each provided stream is piped into\nthe next, using <code>stream.pipeline</code>. If any of the streams error then all\nare destroyed, including the outer <code>Duplex</code> stream.</p>\n<p>Because <code>stream.compose</code> returns a new stream that in turn can (and\nshould) be piped into other streams, it enables composition. In contrast,\nwhen passing streams to <code>stream.pipeline</code>, typically the first stream is\na readable stream and the last a writable stream, forming a closed\ncircuit.</p>\n<p>If passed a <code>Function</code> it must be a factory method taking a <code>source</code>\n<code>Iterable</code>.</p>\n<pre><code class=\"language-mjs\">import { compose, Transform } from 'node:stream';\n\nconst removeSpaces = new Transform({\n  transform(chunk, encoding, callback) {\n    callback(null, String(chunk).replace(' ', ''));\n  },\n});\n\nasync function* toUpper(source) {\n  for await (const chunk of source) {\n    yield String(chunk).toUpperCase();\n  }\n}\n\nlet res = '';\nfor await (const buf of compose(removeSpaces, toUpper).end('hello world')) {\n  res += buf;\n}\n\nconsole.log(res); // prints 'HELLOWORLD'\n</code></pre>\n<p><code>stream.compose</code> can be used to convert async iterables, generators and\nfunctions into streams.</p>\n<ul>\n<li><code>AsyncIterable</code> converts into a readable <code>Duplex</code>. Cannot yield\n<code>null</code>.</li>\n<li><code>AsyncGeneratorFunction</code> converts into a readable/writable transform <code>Duplex</code>.\nMust take a source <code>AsyncIterable</code> as first parameter. Cannot yield\n<code>null</code>.</li>\n<li><code>AsyncFunction</code> converts into a writable <code>Duplex</code>. Must return\neither <code>null</code> or <code>undefined</code>.</li>\n</ul>\n<pre><code class=\"language-mjs\">import { compose } from 'node:stream';\nimport { finished } from 'node:stream/promises';\n\n// Convert AsyncIterable into readable Duplex.\nconst s1 = compose(async function*() {\n  yield 'Hello';\n  yield 'World';\n}());\n\n// Convert AsyncGenerator into transform Duplex.\nconst s2 = compose(async function*(source) {\n  for await (const chunk of source) {\n    yield String(chunk).toUpperCase();\n  }\n});\n\nlet res = '';\n\n// Convert AsyncFunction into writable Duplex.\nconst s3 = compose(async function(source) {\n  for await (const chunk of source) {\n    res += chunk;\n  }\n});\n\nawait finished(compose(s1, s2, s3));\n\nconsole.log(res); // prints 'HELLOWORLD'\n</code></pre>\n<p>For convenience, the <a href=\"#readablecomposestream-options\"><code>readable.compose(stream)</code></a> method is available on\n<a href=\"stream.html#class-streamreadable\"><code>&#x3C;Readable></code></a> and <a href=\"stream.html#class-streamduplex\"><code>&#x3C;Duplex></code></a> streams as a wrapper for this function.</p>"
        },
        {
          "textRaw": "`stream.isErrored(stream)`",
          "name": "isErrored",
          "type": "method",
          "meta": {
            "added": [
              "v17.3.0",
              "v16.14.0"
            ],
            "changes": [
              {
                "version": [
                  "v24.0.0",
                  "v22.17.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/57513",
                "description": "Marking the API stable."
              }
            ]
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`stream` {Readable|Writable|Duplex|WritableStream|ReadableStream}",
                  "name": "stream",
                  "type": "Readable|Writable|Duplex|WritableStream|ReadableStream"
                }
              ],
              "return": {
                "textRaw": "Returns: {boolean}",
                "name": "return",
                "type": "boolean"
              }
            }
          ],
          "desc": "<p>Returns whether the stream has encountered an error.</p>"
        },
        {
          "textRaw": "`stream.isReadable(stream)`",
          "name": "isReadable",
          "type": "method",
          "meta": {
            "added": [
              "v17.4.0",
              "v16.14.0"
            ],
            "changes": [
              {
                "version": [
                  "v24.0.0",
                  "v22.17.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/57513",
                "description": "Marking the API stable."
              }
            ]
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`stream` {Readable|Duplex|ReadableStream}",
                  "name": "stream",
                  "type": "Readable|Duplex|ReadableStream"
                }
              ],
              "return": {
                "textRaw": "Returns: {boolean|null} - Only returns `null` if `stream` is not a valid `Readable`, `Duplex` or `ReadableStream`.",
                "name": "return",
                "type": "boolean|null",
                "desc": "Only returns `null` if `stream` is not a valid `Readable`, `Duplex` or `ReadableStream`."
              }
            }
          ],
          "desc": "<p>Returns whether the stream is readable.</p>"
        },
        {
          "textRaw": "`stream.isWritable(stream)`",
          "name": "isWritable",
          "type": "method",
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`stream` {Writable|Duplex|WritableStream}",
                  "name": "stream",
                  "type": "Writable|Duplex|WritableStream"
                }
              ],
              "return": {
                "textRaw": "Returns: {boolean|null} - Only returns `null` if `stream` is not a valid `Writable`, `Duplex` or `WritableStream`.",
                "name": "return",
                "type": "boolean|null",
                "desc": "Only returns `null` if `stream` is not a valid `Writable`, `Duplex` or `WritableStream`."
              }
            }
          ],
          "desc": "<p>Returns whether the stream is writable.</p>"
        },
        {
          "textRaw": "`stream.Readable.from(iterable[, options])`",
          "name": "from",
          "type": "method",
          "meta": {
            "added": [
              "v12.3.0",
              "v10.17.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [
                {
                  "name": "iterable"
                },
                {
                  "name": "options",
                  "optional": true
                }
              ]
            }
          ],
          "desc": "<ul>\n<li><code>iterable</code> {Iterable} Object implementing the <code>Symbol.asyncIterator</code> or\n<code>Symbol.iterator</code> iterable protocol. Emits an 'error' event if a null\nvalue is passed.</li>\n<li><code>options</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object\"><code>&#x3C;Object></code></a> Options provided to <code>new stream.Readable([options])</code>.\nBy default, <code>Readable.from()</code> will set <code>options.objectMode</code> to <code>true</code>, unless\nthis is explicitly opted out by setting <code>options.objectMode</code> to <code>false</code>.</li>\n<li>Returns: <a href=\"stream.html#class-streamreadable\"><code>&#x3C;stream.Readable></code></a></li>\n</ul>\n<p>A utility method for creating readable streams out of iterators.</p>\n<pre><code class=\"language-js\">const { Readable } = require('node:stream');\n\nasync function * generate() {\n  yield 'hello';\n  yield 'streams';\n}\n\nconst readable = Readable.from(generate());\n\nreadable.on('data', (chunk) => {\n  console.log(chunk);\n});\n</code></pre>\n<p>Calling <code>Readable.from(string)</code> or <code>Readable.from(buffer)</code> will not have\nthe strings or buffers be iterated to match the other streams semantics\nfor performance reasons.</p>\n<p>If an <code>Iterable</code> object containing promises is passed as an argument,\nit might result in unhandled rejection.</p>\n<pre><code class=\"language-js\">const { Readable } = require('node:stream');\n\nReadable.from([\n  new Promise((resolve) => setTimeout(resolve('1'), 1500)),\n  new Promise((_, reject) => setTimeout(reject(new Error('2')), 1000)), // Unhandled rejection\n]);\n</code></pre>"
        },
        {
          "textRaw": "`stream.Readable.fromWeb(readableStream[, options])`",
          "name": "fromWeb",
          "type": "method",
          "meta": {
            "added": [
              "v17.0.0"
            ],
            "changes": [
              {
                "version": [
                  "v24.0.0",
                  "v22.17.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/57513",
                "description": "Marking the API stable."
              }
            ]
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`readableStream` {ReadableStream}",
                  "name": "readableStream",
                  "type": "ReadableStream"
                },
                {
                  "textRaw": "`options` {Object}",
                  "name": "options",
                  "type": "Object",
                  "options": [
                    {
                      "textRaw": "`encoding` {string}",
                      "name": "encoding",
                      "type": "string"
                    },
                    {
                      "textRaw": "`highWaterMark` {number}",
                      "name": "highWaterMark",
                      "type": "number"
                    },
                    {
                      "textRaw": "`objectMode` {boolean}",
                      "name": "objectMode",
                      "type": "boolean"
                    },
                    {
                      "textRaw": "`signal` {AbortSignal}",
                      "name": "signal",
                      "type": "AbortSignal"
                    }
                  ],
                  "optional": true
                }
              ],
              "return": {
                "textRaw": "Returns: {stream.Readable}",
                "name": "return",
                "type": "stream.Readable"
              }
            }
          ]
        },
        {
          "textRaw": "`stream.Readable.isDisturbed(stream)`",
          "name": "isDisturbed",
          "type": "method",
          "meta": {
            "added": [
              "v16.8.0"
            ],
            "changes": [
              {
                "version": [
                  "v24.0.0",
                  "v22.17.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/57513",
                "description": "Marking the API stable."
              }
            ]
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`stream` {stream.Readable|ReadableStream}",
                  "name": "stream",
                  "type": "stream.Readable|ReadableStream"
                }
              ],
              "return": {
                "textRaw": "Returns: `boolean`",
                "name": "return",
                "desc": "`boolean`"
              }
            }
          ],
          "desc": "<p>Returns whether the stream has been read from or cancelled.</p>"
        },
        {
          "textRaw": "`stream.Readable.toWeb(streamReadable[, options])`",
          "name": "toWeb",
          "type": "method",
          "meta": {
            "added": [
              "v17.0.0"
            ],
            "changes": [
              {
                "version": [
                  "v25.4.0",
                  "v24.14.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/58664",
                "description": "Add 'type' option to specify 'bytes'."
              },
              {
                "version": [
                  "v24.0.0",
                  "v22.17.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/57513",
                "description": "Marking the API stable."
              },
              {
                "version": [
                  "v18.7.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/43515",
                "description": "include strategy options on Readable."
              }
            ]
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`streamReadable` {stream.Readable}",
                  "name": "streamReadable",
                  "type": "stream.Readable"
                },
                {
                  "textRaw": "`options` {Object}",
                  "name": "options",
                  "type": "Object",
                  "options": [
                    {
                      "textRaw": "`strategy` {Object}",
                      "name": "strategy",
                      "type": "Object",
                      "options": [
                        {
                          "textRaw": "`highWaterMark` {number} The maximum internal queue size (of the created `ReadableStream`) before backpressure is applied in reading from the given `stream.Readable`. If no value is provided, it will be taken from the given `stream.Readable`.",
                          "name": "highWaterMark",
                          "type": "number",
                          "desc": "The maximum internal queue size (of the created `ReadableStream`) before backpressure is applied in reading from the given `stream.Readable`. If no value is provided, it will be taken from the given `stream.Readable`."
                        },
                        {
                          "textRaw": "`size` {Function} A function that size of the given chunk of data. If no value is provided, the size will be `1` for all the chunks.",
                          "name": "size",
                          "type": "Function",
                          "desc": "A function that size of the given chunk of data. If no value is provided, the size will be `1` for all the chunks.",
                          "options": [
                            {
                              "textRaw": "`chunk` {any}",
                              "name": "chunk",
                              "type": "any"
                            },
                            {
                              "textRaw": "Returns: {number}",
                              "name": "return",
                              "type": "number"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "textRaw": "`type` {string} Specifies the type of the created `ReadableStream`. Must be `'bytes'` or undefined.",
                      "name": "type",
                      "type": "string",
                      "desc": "Specifies the type of the created `ReadableStream`. Must be `'bytes'` or undefined."
                    }
                  ],
                  "optional": true
                }
              ],
              "return": {
                "textRaw": "Returns: {ReadableStream}",
                "name": "return",
                "type": "ReadableStream"
              }
            }
          ]
        },
        {
          "textRaw": "`stream.Writable.fromWeb(writableStream[, options])`",
          "name": "fromWeb",
          "type": "method",
          "meta": {
            "added": [
              "v17.0.0"
            ],
            "changes": [
              {
                "version": [
                  "v24.0.0",
                  "v22.17.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/57513",
                "description": "Marking the API stable."
              }
            ]
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`writableStream` {WritableStream}",
                  "name": "writableStream",
                  "type": "WritableStream"
                },
                {
                  "textRaw": "`options` {Object}",
                  "name": "options",
                  "type": "Object",
                  "options": [
                    {
                      "textRaw": "`decodeStrings` {boolean}",
                      "name": "decodeStrings",
                      "type": "boolean"
                    },
                    {
                      "textRaw": "`highWaterMark` {number}",
                      "name": "highWaterMark",
                      "type": "number"
                    },
                    {
                      "textRaw": "`objectMode` {boolean}",
                      "name": "objectMode",
                      "type": "boolean"
                    },
                    {
                      "textRaw": "`signal` {AbortSignal}",
                      "name": "signal",
                      "type": "AbortSignal"
                    }
                  ],
                  "optional": true
                }
              ],
              "return": {
                "textRaw": "Returns: {stream.Writable}",
                "name": "return",
                "type": "stream.Writable"
              }
            }
          ]
        },
        {
          "textRaw": "`stream.Writable.toWeb(streamWritable)`",
          "name": "toWeb",
          "type": "method",
          "meta": {
            "added": [
              "v17.0.0"
            ],
            "changes": [
              {
                "version": [
                  "v24.0.0",
                  "v22.17.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/57513",
                "description": "Marking the API stable."
              }
            ]
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`streamWritable` {stream.Writable}",
                  "name": "streamWritable",
                  "type": "stream.Writable"
                }
              ],
              "return": {
                "textRaw": "Returns: {WritableStream}",
                "name": "return",
                "type": "WritableStream"
              }
            }
          ]
        },
        {
          "textRaw": "`stream.Duplex.from(src)`",
          "name": "from",
          "type": "method",
          "meta": {
            "added": [
              "v16.8.0"
            ],
            "changes": [
              {
                "version": [
                  "v19.5.0",
                  "v18.17.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/46190",
                "description": "The `src` argument can now be a `ReadableStream` or `WritableStream`."
              }
            ]
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`src` {Stream|Blob|ArrayBuffer|string|AsyncIterable|AsyncGeneratorFunction|AsyncFunction|Promise|Object|ReadableStream|WritableStream}",
                  "name": "src",
                  "type": "Stream|Blob|ArrayBuffer|string|AsyncIterable|AsyncGeneratorFunction|AsyncFunction|Promise|Object|ReadableStream|WritableStream"
                }
              ]
            }
          ],
          "desc": "<p>A utility method for creating duplex streams.</p>\n<ul>\n<li><code>Stream</code> converts writable stream into writable <code>Duplex</code> and readable stream\nto <code>Duplex</code>.</li>\n<li><code>Blob</code> converts into readable <code>Duplex</code>.</li>\n<li><code>string</code> converts into readable <code>Duplex</code>.</li>\n<li><code>ArrayBuffer</code> converts into readable <code>Duplex</code>.</li>\n<li><code>AsyncIterable</code> converts into a readable <code>Duplex</code>. Cannot yield\n<code>null</code>.</li>\n<li><code>AsyncGeneratorFunction</code> converts into a readable/writable transform\n<code>Duplex</code>. Must take a source <code>AsyncIterable</code> as first parameter. Cannot yield\n<code>null</code>.</li>\n<li><code>AsyncFunction</code> converts into a writable <code>Duplex</code>. Must return\neither <code>null</code> or <code>undefined</code></li>\n<li><code>Object ({ writable, readable })</code> converts <code>readable</code> and\n<code>writable</code> into <code>Stream</code> and then combines them into <code>Duplex</code> where the\n<code>Duplex</code> will write to the <code>writable</code> and read from the <code>readable</code>.</li>\n<li><code>Promise</code> converts into readable <code>Duplex</code>. Value <code>null</code> is ignored.</li>\n<li><code>ReadableStream</code> converts into readable <code>Duplex</code>.</li>\n<li><code>WritableStream</code> converts into writable <code>Duplex</code>.</li>\n<li>Returns: <a href=\"stream.html#class-streamduplex\"><code>&#x3C;stream.Duplex></code></a></li>\n</ul>\n<p>If an <code>Iterable</code> object containing promises is passed as an argument,\nit might result in unhandled rejection.</p>\n<pre><code class=\"language-js\">const { Duplex } = require('node:stream');\n\nDuplex.from([\n  new Promise((resolve) => setTimeout(resolve('1'), 1500)),\n  new Promise((_, reject) => setTimeout(reject(new Error('2')), 1000)), // Unhandled rejection\n]);\n</code></pre>"
        },
        {
          "textRaw": "`stream.Duplex.fromWeb(pair[, options])`",
          "name": "fromWeb",
          "type": "method",
          "meta": {
            "added": [
              "v17.0.0"
            ],
            "changes": [
              {
                "version": [
                  "v24.0.0",
                  "v22.17.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/57513",
                "description": "Marking the API stable."
              }
            ]
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`pair` {Object}",
                  "name": "pair",
                  "type": "Object",
                  "options": [
                    {
                      "textRaw": "`readable` {ReadableStream}",
                      "name": "readable",
                      "type": "ReadableStream"
                    },
                    {
                      "textRaw": "`writable` {WritableStream}",
                      "name": "writable",
                      "type": "WritableStream"
                    }
                  ]
                },
                {
                  "textRaw": "`options` {Object}",
                  "name": "options",
                  "type": "Object",
                  "options": [
                    {
                      "textRaw": "`allowHalfOpen` {boolean}",
                      "name": "allowHalfOpen",
                      "type": "boolean"
                    },
                    {
                      "textRaw": "`decodeStrings` {boolean}",
                      "name": "decodeStrings",
                      "type": "boolean"
                    },
                    {
                      "textRaw": "`encoding` {string}",
                      "name": "encoding",
                      "type": "string"
                    },
                    {
                      "textRaw": "`highWaterMark` {number}",
                      "name": "highWaterMark",
                      "type": "number"
                    },
                    {
                      "textRaw": "`objectMode` {boolean}",
                      "name": "objectMode",
                      "type": "boolean"
                    },
                    {
                      "textRaw": "`signal` {AbortSignal}",
                      "name": "signal",
                      "type": "AbortSignal"
                    }
                  ],
                  "optional": true
                }
              ],
              "return": {
                "textRaw": "Returns: {stream.Duplex}",
                "name": "return",
                "type": "stream.Duplex"
              }
            }
          ],
          "desc": "<pre><code class=\"language-mjs\">import { Duplex } from 'node:stream';\nimport {\n  ReadableStream,\n  WritableStream,\n} from 'node:stream/web';\n\nconst readable = new ReadableStream({\n  start(controller) {\n    controller.enqueue('world');\n  },\n});\n\nconst writable = new WritableStream({\n  write(chunk) {\n    console.log('writable', chunk);\n  },\n});\n\nconst pair = {\n  readable,\n  writable,\n};\nconst duplex = Duplex.fromWeb(pair, { encoding: 'utf8', objectMode: true });\n\nduplex.write('hello');\n\nfor await (const chunk of duplex) {\n  console.log('readable', chunk);\n}\n</code></pre>\n<pre><code class=\"language-cjs\">const { Duplex } = require('node:stream');\nconst {\n  ReadableStream,\n  WritableStream,\n} = require('node:stream/web');\n\nconst readable = new ReadableStream({\n  start(controller) {\n    controller.enqueue('world');\n  },\n});\n\nconst writable = new WritableStream({\n  write(chunk) {\n    console.log('writable', chunk);\n  },\n});\n\nconst pair = {\n  readable,\n  writable,\n};\nconst duplex = Duplex.fromWeb(pair, { encoding: 'utf8', objectMode: true });\n\nduplex.write('hello');\nduplex.once('readable', () => console.log('readable', duplex.read()));\n</code></pre>"
        },
        {
          "textRaw": "`stream.Duplex.toWeb(streamDuplex[, options])`",
          "name": "toWeb",
          "type": "method",
          "meta": {
            "added": [
              "v17.0.0"
            ],
            "changes": [
              {
                "version": "v25.7.0",
                "pr-url": "https://github.com/nodejs/node/pull/61632",
                "description": "Added the 'readableType' option to specify the ReadableStream type. The 'type' option is deprecated."
              },
              {
                "version": [
                  "v25.4.0",
                  "v24.14.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/58664",
                "description": "Added the 'type' option to specify the ReadableStream type."
              },
              {
                "version": [
                  "v24.0.0",
                  "v22.17.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/57513",
                "description": "Marking the API stable."
              }
            ]
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`streamDuplex` {stream.Duplex}",
                  "name": "streamDuplex",
                  "type": "stream.Duplex"
                },
                {
                  "textRaw": "`options` {Object}",
                  "name": "options",
                  "type": "Object",
                  "options": [
                    {
                      "textRaw": "`readableType` {string} Specifies the type of the `ReadableStream` half of the created readable-writable pair. Must be `'bytes'` or undefined. (`options.type` is a deprecated alias for this option.)",
                      "name": "readableType",
                      "type": "string",
                      "desc": "Specifies the type of the `ReadableStream` half of the created readable-writable pair. Must be `'bytes'` or undefined. (`options.type` is a deprecated alias for this option.)"
                    }
                  ],
                  "optional": true
                }
              ],
              "return": {
                "textRaw": "Returns: {Object}",
                "name": "return",
                "type": "Object",
                "options": [
                  {
                    "textRaw": "`readable` {ReadableStream}",
                    "name": "readable",
                    "type": "ReadableStream"
                  },
                  {
                    "textRaw": "`writable` {WritableStream}",
                    "name": "writable",
                    "type": "WritableStream"
                  }
                ]
              }
            }
          ],
          "desc": "<pre><code class=\"language-mjs\">import { Duplex } from 'node:stream';\n\nconst duplex = Duplex({\n  objectMode: true,\n  read() {\n    this.push('world');\n    this.push(null);\n  },\n  write(chunk, encoding, callback) {\n    console.log('writable', chunk);\n    callback();\n  },\n});\n\nconst { readable, writable } = Duplex.toWeb(duplex);\nwritable.getWriter().write('hello');\n\nconst { value } = await readable.getReader().read();\nconsole.log('readable', value);\n</code></pre>\n<pre><code class=\"language-cjs\">const { Duplex } = require('node:stream');\n\nconst duplex = Duplex({\n  objectMode: true,\n  read() {\n    this.push('world');\n    this.push(null);\n  },\n  write(chunk, encoding, callback) {\n    console.log('writable', chunk);\n    callback();\n  },\n});\n\nconst { readable, writable } = Duplex.toWeb(duplex);\nwritable.getWriter().write('hello');\n\nreadable.getReader().read().then((result) => {\n  console.log('readable', result.value);\n});\n</code></pre>"
        },
        {
          "textRaw": "`stream.addAbortSignal(signal, stream)`",
          "name": "addAbortSignal",
          "type": "method",
          "meta": {
            "added": [
              "v15.4.0"
            ],
            "changes": [
              {
                "version": [
                  "v19.7.0",
                  "v18.16.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/46273",
                "description": "Added support for `ReadableStream` and `WritableStream`."
              }
            ]
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`signal` {AbortSignal} A signal representing possible cancellation",
                  "name": "signal",
                  "type": "AbortSignal",
                  "desc": "A signal representing possible cancellation"
                },
                {
                  "textRaw": "`stream` {Stream|ReadableStream|WritableStream} A stream to attach a signal to.",
                  "name": "stream",
                  "type": "Stream|ReadableStream|WritableStream",
                  "desc": "A stream to attach a signal to."
                }
              ]
            }
          ],
          "desc": "<p>Attaches an AbortSignal to a readable or writeable stream. This lets code\ncontrol stream destruction using an <code>AbortController</code>.</p>\n<p>Calling <code>abort</code> on the <code>AbortController</code> corresponding to the passed\n<code>AbortSignal</code> will behave the same way as calling <code>.destroy(new AbortError())</code>\non the stream, and <code>controller.error(new AbortError())</code> for webstreams.</p>\n<pre><code class=\"language-js\">const fs = require('node:fs');\n\nconst controller = new AbortController();\nconst read = addAbortSignal(\n  controller.signal,\n  fs.createReadStream(('object.json')),\n);\n// Later, abort the operation closing the stream\ncontroller.abort();\n</code></pre>\n<p>Or using an <code>AbortSignal</code> with a readable stream as an async iterable:</p>\n<pre><code class=\"language-js\">const controller = new AbortController();\nsetTimeout(() => controller.abort(), 10_000); // set a timeout\nconst stream = addAbortSignal(\n  controller.signal,\n  fs.createReadStream(('object.json')),\n);\n(async () => {\n  try {\n    for await (const chunk of stream) {\n      await process(chunk);\n    }\n  } catch (e) {\n    if (e.name === 'AbortError') {\n      // The operation was cancelled\n    } else {\n      throw e;\n    }\n  }\n})();\n</code></pre>\n<p>Or using an <code>AbortSignal</code> with a ReadableStream:</p>\n<pre><code class=\"language-js\">const controller = new AbortController();\nconst rs = new ReadableStream({\n  start(controller) {\n    controller.enqueue('hello');\n    controller.enqueue('world');\n    controller.close();\n  },\n});\n\naddAbortSignal(controller.signal, rs);\n\nfinished(rs, (err) => {\n  if (err) {\n    if (err.name === 'AbortError') {\n      // The operation was cancelled\n    }\n  }\n});\n\nconst reader = rs.getReader();\n\nreader.read().then(({ value, done }) => {\n  console.log(value); // hello\n  console.log(done); // false\n  controller.abort();\n});\n</code></pre>"
        },
        {
          "textRaw": "`stream.getDefaultHighWaterMark(objectMode)`",
          "name": "getDefaultHighWaterMark",
          "type": "method",
          "meta": {
            "added": [
              "v19.9.0",
              "v18.17.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`objectMode` {boolean}",
                  "name": "objectMode",
                  "type": "boolean"
                }
              ],
              "return": {
                "textRaw": "Returns: {integer}",
                "name": "return",
                "type": "integer"
              }
            }
          ],
          "desc": "<p>Returns the default highWaterMark used by streams.\nDefaults to <code>65536</code> (64 KiB), or <code>16</code> for <code>objectMode</code>.</p>"
        },
        {
          "textRaw": "`stream.setDefaultHighWaterMark(objectMode, value)`",
          "name": "setDefaultHighWaterMark",
          "type": "method",
          "meta": {
            "added": [
              "v19.9.0",
              "v18.17.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`objectMode` {boolean}",
                  "name": "objectMode",
                  "type": "boolean"
                },
                {
                  "textRaw": "`value` {integer} highWaterMark value",
                  "name": "value",
                  "type": "integer",
                  "desc": "highWaterMark value"
                }
              ]
            }
          ],
          "desc": "<p>Sets the default highWaterMark used by streams.</p>"
        },
        {
          "textRaw": "`readable.read(0)`",
          "name": "read",
          "type": "method",
          "signatures": [
            {
              "params": [
                {
                  "name": "0"
                }
              ]
            }
          ],
          "desc": "<p>There are some cases where it is necessary to trigger a refresh of the\nunderlying readable stream mechanisms, without actually consuming any\ndata. In such cases, it is possible to call <code>readable.read(0)</code>, which will\nalways return <code>null</code>.</p>\n<p>If the internal read buffer is below the <code>highWaterMark</code>, and the\nstream is not currently reading, then calling <code>stream.read(0)</code> will trigger\na low-level <a href=\"#readable_readsize\"><code>stream._read()</code></a> call.</p>\n<p>While most applications will almost never need to do this, there are\nsituations within Node.js where this is done, particularly in the\n<code>Readable</code> stream class internals.</p>"
        },
        {
          "textRaw": "`readable.push('')`",
          "name": "push",
          "type": "method",
          "signatures": [
            {
              "params": [
                {
                  "name": "''"
                }
              ]
            }
          ],
          "desc": "<p>Use of <code>readable.push('')</code> is not recommended.</p>\n<p>Pushing a zero-byte <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#string_type\"><code>&#x3C;string></code></a>, <a href=\"buffer.html#class-buffer\"><code>&#x3C;Buffer></code></a>, <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray\"><code>&#x3C;TypedArray></code></a> or <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView\"><code>&#x3C;DataView></code></a> to a stream\nthat is not in object mode has an interesting side effect.\nBecause it <em>is</em> a call to\n<a href=\"#readablepushchunk-encoding\"><code>readable.push()</code></a>, the call will end the reading process.\nHowever, because the argument is an empty string, no data is added to the\nreadable buffer so there is nothing for a user to consume.</p>"
        }
      ],
      "displayName": "Stream"
    }
  ]
}