{"$schema":"https://doc-kit.nodejs.org/schemas/api-doc/1.0.0.json","id":"webstreams","path":"/webstreams","type":"module","module":"webstreams","title":"Web Streams API","introducedIn":"v16.5.0","sourceLink":null,"stability":{"index":"2","description":"Stable"},"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v21.0.0"],"prUrl":"https://github.com/nodejs/node/pull/45684","commit":null,"description":"No longer experimental."},{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/42225","commit":null,"description":"Use of this API no longer emit a runtime warning."}],"description":"An implementation of the [WHATWG Streams Standard](https://streams.spec.whatwg.org/).","summary":"An implementation of the WHATWG Streams Standard.","examples":[],"children":[{"kind":"section","id":"overview","name":"Overview","title":"Overview","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The [WHATWG Streams Standard](https://streams.spec.whatwg.org/) (or \"web streams\") defines an API for handling\nstreaming data. It is similar to the Node.js [Streams](stream.html) API but emerged later\nand has become the \"standard\" API for streaming data across many JavaScript\nenvironments.\n\nThere are three primary types of objects:\n\n* `ReadableStream` - Represents a source of streaming data.\n* `WritableStream` - Represents a destination for streaming data.\n* `TransformStream` - Represents an algorithm for transforming streaming data.","summary":"The WHATWG Streams Standard (or \"web streams\") defines an API for handling streaming data. It is similar to the Node.js Streams API but emerged later and has become the \"standard\" API for streaming data across many JavaScript environments.","examples":[],"children":[{"kind":"section","id":"example-readablestream","name":"Example ReadableStream","title":"Example `ReadableStream`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"This example creates a simple `ReadableStream` that pushes the current\n`performance.now()` timestamp once every second forever. An async iterable\nis used to read the data from the stream.\n\n```mjs\nimport {\n  ReadableStream,\n} from 'node:stream/web';\n\nimport {\n  setInterval as every,\n} from 'node:timers/promises';\n\nimport {\n  performance,\n} from 'node:perf_hooks';\n\nconst SECOND = 1000;\n\nconst stream = new ReadableStream({\n  async start(controller) {\n    for await (const _ of every(SECOND))\n      controller.enqueue(performance.now());\n  },\n});\n\nfor await (const value of stream)\n  console.log(value);\n```\n\n```cjs\nconst {\n  ReadableStream,\n} = require('node:stream/web');\n\nconst {\n  setInterval: every,\n} = require('node:timers/promises');\n\nconst {\n  performance,\n} = require('node:perf_hooks');\n\nconst SECOND = 1000;\n\nconst stream = new ReadableStream({\n  async start(controller) {\n    for await (const _ of every(SECOND))\n      controller.enqueue(performance.now());\n  },\n});\n\n(async () => {\n  for await (const value of stream)\n    console.log(value);\n})();\n```","summary":"This example creates a simple `ReadableStream` that pushes the current `performance.now()` timestamp once every second forever. An async iterable is used to read the data from the stream.","examples":[{"language":"mjs","displayName":null,"code":"import {\n  ReadableStream,\n} from 'node:stream/web';\n\nimport {\n  setInterval as every,\n} from 'node:timers/promises';\n\nimport {\n  performance,\n} from 'node:perf_hooks';\n\nconst SECOND = 1000;\n\nconst stream = new ReadableStream({\n  async start(controller) {\n    for await (const _ of every(SECOND))\n      controller.enqueue(performance.now());\n  },\n});\n\nfor await (const value of stream)\n  console.log(value);"},{"language":"cjs","displayName":null,"code":"const {\n  ReadableStream,\n} = require('node:stream/web');\n\nconst {\n  setInterval: every,\n} = require('node:timers/promises');\n\nconst {\n  performance,\n} = require('node:perf_hooks');\n\nconst SECOND = 1000;\n\nconst stream = new ReadableStream({\n  async start(controller) {\n    for await (const _ of every(SECOND))\n      controller.enqueue(performance.now());\n  },\n});\n\n(async () => {\n  for await (const value of stream)\n    console.log(value);\n})();"}],"children":[]},{"kind":"section","id":"nodejs-streams-interoperability","name":"Node.js streams interoperability","title":"Node.js streams interoperability","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"Node.js streams can be converted to web streams and vice versa via the `toWeb` and `fromWeb` methods present on [`stream.Readable`](stream.html#class-streamreadable), [`stream.Writable`](stream.html#class-streamwritable) and [`stream.Duplex`](stream.html#class-streamduplex) objects.\n\nFor more details refer to the relevant documentation:\n\n* [`stream.Readable.toWeb`](stream.html#streamreadabletowebstreamreadable-options)\n* [`stream.Readable.fromWeb`](stream.html#streamreadablefromwebreadablestream-options)\n* [`stream.Writable.toWeb`](stream.html#streamwritabletowebstreamwritable)\n* [`stream.Writable.fromWeb`](stream.html#streamwritablefromwebwritablestream-options)\n* [`stream.Duplex.toWeb`](stream.html#streamduplextowebstreamduplex-options)\n* [`stream.Duplex.fromWeb`](stream.html#streamduplexfromwebpair-options)","summary":"Node.js streams can be converted to web streams and vice versa via the `toWeb` and `fromWeb` methods present on `stream.Readable`, `stream.Writable` and `stream.Duplex` objects.","examples":[],"children":[]}]},{"kind":"section","id":"api","name":"API","title":"API","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"","summary":"","examples":[],"children":[{"kind":"method","id":"readablestreamteestream-cloneforbranch2","name":"ReadableStreamTee","title":"`ReadableStreamTee(stream[, cloneForBranch2])`","scope":"module","overloadOf":null,"stability":{"index":"1","description":"Experimental"},"added":["v26.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"stream","type":{"text":"ReadableStream","links":[{"name":"ReadableStream","href":"webstreams.html#class-readablestream","start":0,"end":14}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"cloneForBranch2","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"When `true`, chunks enqueued into the second\nbranch are cloned from chunks enqueued into the first branch.","default":"false","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"ReadableStream[]","links":[{"name":"ReadableStream","href":"webstreams.html#class-readablestream","start":0,"end":14}]},"description":"Two {ReadableStream} branches."}},"description":"Runs the WHATWG `ReadableStreamTee` abstract operation on `stream`.\n\nThis differs from `readableStream.tee()` only when `cloneForBranch2` is\n`true`. The `tee()` method always passes `false`, while other web platform\nspecifications, such as Fetch body cloning, pass `true` so that the second\nbranch receives cloned chunks and consumption of one branch cannot mutate chunks\nseen by the other.","summary":"Runs the WHATWG `ReadableStreamTee` abstract operation on `stream`.","examples":[],"children":[]},{"kind":"class","id":"class-readablestream","name":"ReadableStream","title":"Class: `ReadableStream`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/42225","commit":null,"description":"This class is now exposed on the global object."}],"extends":null,"description":"","summary":"","examples":[],"children":[{"kind":"constructor","id":"-strategy","name":"ReadableStream","title":"`new ReadableStream([underlyingSource [, strategy]])`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"underlyingSource ","type":null,"description":"","default":null,"optional":true,"rest":false,"properties":[]},{"name":"strategy","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"highWaterMark","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"The maximum internal queue size before backpressure\nis applied.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"size","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"A user-defined function used to identify the size of each\nchunk of data.","default":null,"optional":false,"rest":false,"properties":[{"name":"chunk","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}]}],"returns":null},"description":"","summary":"","examples":[],"children":[]},{"kind":"property","id":"readablestreamlocked","name":"locked","title":"`readableStream.locked`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"default":null,"description":"Set to `true` if there is an active reader for this\n{ReadableStream}.\n\nThe `readableStream.locked` property is `false` by default, and is\nswitched to `true` while there is an active reader consuming the\nstream's data.","summary":"The `readableStream.locked` property is `false` by default, and is switched to `true` while there is an active reader consuming the stream's data.","examples":[],"children":[]},{"kind":"method","id":"readablestreamcancelreason","name":"cancel","title":"`readableStream.cancel([reason])`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"reason","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":null,"description":"A promise fulfilled with `undefined` once cancelation has\nbeen completed."}},"description":"","summary":"","examples":[],"children":[]},{"kind":"method","id":"readablestreamgetreaderoptions","name":"getReader","title":"`readableStream.getReader([options])`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"mode","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"`'byob'` or `undefined`","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"ReadableStreamDefaultReader | ReadableStreamBYOBReader","links":[{"name":"ReadableStreamDefaultReader","href":"webstreams.html#class-readablestreamdefaultreader","start":0,"end":27},{"name":"ReadableStreamBYOBReader","href":"webstreams.html#class-readablestreambyobreader","start":30,"end":54}]},"description":""}},"description":"```mjs\nimport { ReadableStream } from 'node:stream/web';\n\nconst stream = new ReadableStream();\n\nconst reader = stream.getReader();\n\nconsole.log(await reader.read());\n```\n\n```cjs\nconst { ReadableStream } = require('node:stream/web');\n\nconst stream = new ReadableStream();\n\nconst reader = stream.getReader();\n\nreader.read().then(console.log);\n```\n\nCauses the `readableStream.locked` to be `true`.","summary":"Causes the `readableStream.locked` to be `true`.","examples":[{"language":"mjs","displayName":null,"code":"import { ReadableStream } from 'node:stream/web';\n\nconst stream = new ReadableStream();\n\nconst reader = stream.getReader();\n\nconsole.log(await reader.read());"},{"language":"cjs","displayName":null,"code":"const { ReadableStream } = require('node:stream/web');\n\nconst stream = new ReadableStream();\n\nconst reader = stream.getReader();\n\nreader.read().then(console.log);"}],"children":[]},{"kind":"method","id":"readablestreampipethroughtransform-options","name":"pipeThrough","title":"`readableStream.pipeThrough(transform[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"transform","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"readable","type":{"text":"ReadableStream","links":[{"name":"ReadableStream","href":"webstreams.html#class-readablestream","start":0,"end":14}]},"description":"The `ReadableStream` to which\n`transform.writable` will push the potentially modified data\nit receives from this `ReadableStream`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"writable","type":{"text":"WritableStream","links":[{"name":"WritableStream","href":"webstreams.html#class-writablestream","start":0,"end":14}]},"description":"The `WritableStream` to which this\n`ReadableStream`'s data will be written.","default":null,"optional":false,"rest":false,"properties":[]}]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"preventAbort","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"When `true`, errors in this `ReadableStream`\nwill not cause `transform.writable` to be aborted.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"preventCancel","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"When `true`, errors in the destination\n`transform.writable` do not cause this `ReadableStream` to be\ncanceled.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"preventClose","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"When `true`, closing this `ReadableStream`\ndoes not cause `transform.writable` to be closed.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"signal","type":{"text":"AbortSignal","links":[{"name":"AbortSignal","href":"globals.html#class-abortsignal","start":0,"end":11}]},"description":"Allows the transfer of data to be canceled\nusing an {AbortController}.","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"ReadableStream","links":[{"name":"ReadableStream","href":"webstreams.html#class-readablestream","start":0,"end":14}]},"description":"From `transform.readable`."}},"description":"Connects this {ReadableStream} to the pair of {ReadableStream} and\n{WritableStream} provided in the `transform` argument such that the\ndata from this {ReadableStream} is written in to `transform.writable`,\npossibly transformed, then pushed to `transform.readable`. Once the\npipeline is configured, `transform.readable` is returned.\n\nCauses the `readableStream.locked` to be `true` while the pipe operation\nis active.\n\n```mjs\nimport {\n  ReadableStream,\n  TransformStream,\n} from 'node:stream/web';\n\nconst stream = new ReadableStream({\n  start(controller) {\n    controller.enqueue('a');\n  },\n});\n\nconst transform = new TransformStream({\n  transform(chunk, controller) {\n    controller.enqueue(chunk.toUpperCase());\n  },\n});\n\nconst transformedStream = stream.pipeThrough(transform);\n\nfor await (const chunk of transformedStream)\n  console.log(chunk);\n  // Prints: A\n```\n\n```cjs\nconst {\n  ReadableStream,\n  TransformStream,\n} = require('node:stream/web');\n\nconst stream = new ReadableStream({\n  start(controller) {\n    controller.enqueue('a');\n  },\n});\n\nconst transform = new TransformStream({\n  transform(chunk, controller) {\n    controller.enqueue(chunk.toUpperCase());\n  },\n});\n\nconst transformedStream = stream.pipeThrough(transform);\n\n(async () => {\n  for await (const chunk of transformedStream)\n    console.log(chunk);\n    // Prints: A\n})();\n```","summary":"Connects this {ReadableStream} to the pair of {ReadableStream} and {WritableStream} provided in the `transform` argument such that the data from this {ReadableStream} is written in to `transform.writable`, possibly transformed, then pushed to `transform.readable`. Once the pipeline is configured, `transform.readable` is returned.","examples":[{"language":"mjs","displayName":null,"code":"import {\n  ReadableStream,\n  TransformStream,\n} from 'node:stream/web';\n\nconst stream = new ReadableStream({\n  start(controller) {\n    controller.enqueue('a');\n  },\n});\n\nconst transform = new TransformStream({\n  transform(chunk, controller) {\n    controller.enqueue(chunk.toUpperCase());\n  },\n});\n\nconst transformedStream = stream.pipeThrough(transform);\n\nfor await (const chunk of transformedStream)\n  console.log(chunk);\n  // Prints: A"},{"language":"cjs","displayName":null,"code":"const {\n  ReadableStream,\n  TransformStream,\n} = require('node:stream/web');\n\nconst stream = new ReadableStream({\n  start(controller) {\n    controller.enqueue('a');\n  },\n});\n\nconst transform = new TransformStream({\n  transform(chunk, controller) {\n    controller.enqueue(chunk.toUpperCase());\n  },\n});\n\nconst transformedStream = stream.pipeThrough(transform);\n\n(async () => {\n  for await (const chunk of transformedStream)\n    console.log(chunk);\n    // Prints: A\n})();"}],"children":[]},{"kind":"method","id":"readablestreampipetodestination-options","name":"pipeTo","title":"`readableStream.pipeTo(destination[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"destination","type":{"text":"WritableStream","links":[{"name":"WritableStream","href":"webstreams.html#class-writablestream","start":0,"end":14}]},"description":"A {WritableStream} to which this\n`ReadableStream`'s data will be written.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"preventAbort","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"When `true`, errors in this `ReadableStream`\nwill not cause `destination` to be aborted.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"preventCancel","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"When `true`, errors in the `destination`\nwill not cause this `ReadableStream` to be canceled.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"preventClose","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"When `true`, closing this `ReadableStream`\ndoes not cause `destination` to be closed.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"signal","type":{"text":"AbortSignal","links":[{"name":"AbortSignal","href":"globals.html#class-abortsignal","start":0,"end":11}]},"description":"Allows the transfer of data to be canceled\nusing an {AbortController}.","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":{"type":null,"description":"A promise fulfilled with `undefined`"}},"description":"Causes the `readableStream.locked` to be `true` while the pipe operation\nis active.","summary":"Causes the `readableStream.locked` to be `true` while the pipe operation is active.","examples":[],"children":[]},{"kind":"method","id":"readablestreamtee","name":"tee","title":"`readableStream.tee()`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.10.0","v16.18.0"],"prUrl":"https://github.com/nodejs/node/pull/44505","commit":null,"description":"Support teeing a readable byte stream."}],"signature":{"parameters":[],"returns":{"type":{"text":"ReadableStream[]","links":[{"name":"ReadableStream","href":"webstreams.html#class-readablestream","start":0,"end":14}]},"description":""}},"description":"Returns a pair of new {ReadableStream} instances to which this\n`ReadableStream`'s data will be forwarded. Each will receive the\nsame data.\n\nCauses the `readableStream.locked` to be `true`.","summary":"Returns a pair of new {ReadableStream} instances to which this `ReadableStream`'s data will be forwarded. Each will receive the same data.","examples":[],"children":[]},{"kind":"method","id":"readablestreamvaluesoptions","name":"values","title":"`readableStream.values([options])`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"preventCancel","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"When `true`, prevents the {ReadableStream}\nfrom being closed when the async iterator abruptly terminates.\n**Default**: `false`.","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Creates and returns an async iterator usable for consuming this\n`ReadableStream`'s data.\n\nCauses the `readableStream.locked` to be `true` while the async iterator\nis active.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst stream = new ReadableStream(getSomeSource());\n\nfor await (const chunk of stream.values({ preventCancel: true }))\n  console.log(Buffer.from(chunk).toString());\n```","summary":"Creates and returns an async iterator usable for consuming this `ReadableStream`'s data.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst stream = new ReadableStream(getSomeSource());\n\nfor await (const chunk of stream.values({ preventCancel: true }))\n  console.log(Buffer.from(chunk).toString());"}],"children":[]},{"kind":"section","id":"async-iteration","name":"Async Iteration","title":"Async Iteration","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The {ReadableStream} object supports the async iterator protocol using\n`for await` syntax.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst stream = new ReadableStream(getSomeSource());\n\nfor await (const chunk of stream)\n  console.log(Buffer.from(chunk).toString());\n```\n\nThe async iterator will consume the {ReadableStream} until it terminates.\n\nBy default, if the async iterator exits early (via either a `break`,\n`return`, or a `throw`), the {ReadableStream} will be closed. To prevent\nautomatic closing of the {ReadableStream}, use the `readableStream.values()`\nmethod to acquire the async iterator and set the `preventCancel` option to\n`true`.\n\nThe {ReadableStream} must not be locked (that is, it must not have an existing\nactive reader). During the async iteration, the {ReadableStream} will be locked.","summary":"The {ReadableStream} object supports the async iterator protocol using `for await` syntax.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst stream = new ReadableStream(getSomeSource());\n\nfor await (const chunk of stream)\n  console.log(Buffer.from(chunk).toString());"}],"children":[]},{"kind":"section","id":"transferring-with-postmessage","name":"Transferring with postMessage()","title":"Transferring with `postMessage()`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"A {ReadableStream} instance can be transferred using a {MessagePort}.\n\n```js\nconst stream = new ReadableStream(getReadableSourceSomehow());\n\nconst { port1, port2 } = new MessageChannel();\n\nport1.onmessage = ({ data }) => {\n  data.getReader().read().then((chunk) => {\n    console.log(chunk);\n  });\n};\n\nport2.postMessage(stream, [stream]);\n```","summary":"A {ReadableStream} instance can be transferred using a {MessagePort}.","examples":[{"language":"js","displayName":null,"code":"const stream = new ReadableStream(getReadableSourceSomehow());\n\nconst { port1, port2 } = new MessageChannel();\n\nport1.onmessage = ({ data }) => {\n  data.getReader().read().then((chunk) => {\n    console.log(chunk);\n  });\n};\n\nport2.postMessage(stream, [stream]);"}],"children":[]}]},{"kind":"method","id":"readablestreamfromiterable","name":"from","title":"`ReadableStream.from(iterable)`","scope":"module","overloadOf":null,"stability":null,"added":["v20.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"iterable","type":{"text":"Iterable","links":[{"name":"Iterable","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterable_protocol","start":0,"end":8}]},"description":"Object implementing the `Symbol.asyncIterator` or\n`Symbol.iterator` iterable protocol.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":null},"description":"A utility method that creates a new {ReadableStream} from an iterable.\n\n```mjs\nimport { ReadableStream } from 'node:stream/web';\n\nasync function* asyncIterableGenerator() {\n  yield 'a';\n  yield 'b';\n  yield 'c';\n}\n\nconst stream = ReadableStream.from(asyncIterableGenerator());\n\nfor await (const chunk of stream)\n  console.log(chunk); // Prints: 'a', 'b', 'c'\n```\n\n```cjs\nconst { ReadableStream } = require('node:stream/web');\n\nasync function* asyncIterableGenerator() {\n  yield 'a';\n  yield 'b';\n  yield 'c';\n}\n\n(async () => {\n  const stream = ReadableStream.from(asyncIterableGenerator());\n\n  for await (const chunk of stream)\n    console.log(chunk); // Prints: 'a', 'b', 'c'\n})();\n```\n\nTo pipe the resulting {ReadableStream} into a {WritableStream} the {Iterable}\nshould yield a sequence of {Buffer}, {TypedArray}, or {DataView} objects.\n\n```mjs\nimport { ReadableStream } from 'node:stream/web';\nimport { Buffer } from 'node:buffer';\n\nasync function* asyncIterableGenerator() {\n  yield Buffer.from('a');\n  yield Buffer.from('b');\n  yield Buffer.from('c');\n}\n\nconst stream = ReadableStream.from(asyncIterableGenerator());\n\nawait stream.pipeTo(createWritableStreamSomehow());\n```\n\n```cjs\nconst { ReadableStream } = require('node:stream/web');\nconst { Buffer } = require('node:buffer');\n\nasync function* asyncIterableGenerator() {\n  yield Buffer.from('a');\n  yield Buffer.from('b');\n  yield Buffer.from('c');\n}\n\nconst stream = ReadableStream.from(asyncIterableGenerator());\n\n(async () => {\n  await stream.pipeTo(createWritableStreamSomehow());\n})();\n```","summary":"A utility method that creates a new {ReadableStream} from an iterable.","examples":[{"language":"mjs","displayName":null,"code":"import { ReadableStream } from 'node:stream/web';\n\nasync function* asyncIterableGenerator() {\n  yield 'a';\n  yield 'b';\n  yield 'c';\n}\n\nconst stream = ReadableStream.from(asyncIterableGenerator());\n\nfor await (const chunk of stream)\n  console.log(chunk); // Prints: 'a', 'b', 'c'"},{"language":"cjs","displayName":null,"code":"const { ReadableStream } = require('node:stream/web');\n\nasync function* asyncIterableGenerator() {\n  yield 'a';\n  yield 'b';\n  yield 'c';\n}\n\n(async () => {\n  const stream = ReadableStream.from(asyncIterableGenerator());\n\n  for await (const chunk of stream)\n    console.log(chunk); // Prints: 'a', 'b', 'c'\n})();"},{"language":"mjs","displayName":null,"code":"import { ReadableStream } from 'node:stream/web';\nimport { Buffer } from 'node:buffer';\n\nasync function* asyncIterableGenerator() {\n  yield Buffer.from('a');\n  yield Buffer.from('b');\n  yield Buffer.from('c');\n}\n\nconst stream = ReadableStream.from(asyncIterableGenerator());\n\nawait stream.pipeTo(createWritableStreamSomehow());"},{"language":"cjs","displayName":null,"code":"const { ReadableStream } = require('node:stream/web');\nconst { Buffer } = require('node:buffer');\n\nasync function* asyncIterableGenerator() {\n  yield Buffer.from('a');\n  yield Buffer.from('b');\n  yield Buffer.from('c');\n}\n\nconst stream = ReadableStream.from(asyncIterableGenerator());\n\n(async () => {\n  await stream.pipeTo(createWritableStreamSomehow());\n})();"}],"children":[]},{"kind":"class","id":"class-readablestreamdefaultreader","name":"ReadableStreamDefaultReader","title":"Class: `ReadableStreamDefaultReader`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/42225","commit":null,"description":"This class is now exposed on the global object."}],"extends":null,"description":"By default, calling `readableStream.getReader()` with no arguments\nwill return an instance of `ReadableStreamDefaultReader`. The default\nreader treats the chunks of data passed through the stream as opaque\nvalues, which allows the {ReadableStream} to work with generally any\nJavaScript value.","summary":"By default, calling `readableStream.getReader()` with no arguments will return an instance of `ReadableStreamDefaultReader`. The default reader treats the chunks of data passed through the stream as opaque values, which allows the {ReadableStream} to work with generally any JavaScript value.","examples":[],"children":[{"kind":"constructor","id":"new-readablestreamdefaultreaderstream","name":"ReadableStreamDefaultReader","title":"`new ReadableStreamDefaultReader(stream)`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"stream","type":{"text":"ReadableStream","links":[{"name":"ReadableStream","href":"webstreams.html#class-readablestream","start":0,"end":14}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":null},"description":"Creates a new {ReadableStreamDefaultReader} that is locked to the\ngiven {ReadableStream}.","summary":"Creates a new {ReadableStreamDefaultReader} that is locked to the given {ReadableStream}.","examples":[],"children":[]},{"kind":"method","id":"readablestreamdefaultreadercancelreason","name":"cancel","title":"`readableStreamDefaultReader.cancel([reason])`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"reason","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":null,"description":"A promise fulfilled with `undefined`."}},"description":"Cancels the {ReadableStream} and returns a promise that is fulfilled\nwhen the underlying stream has been canceled.","summary":"Cancels the {ReadableStream} and returns a promise that is fulfilled when the underlying stream has been canceled.","examples":[],"children":[]},{"kind":"property","id":"readablestreamdefaultreaderclosed","name":"closed","title":"`readableStreamDefaultReader.closed`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"default":null,"description":"Fulfilled with `undefined` when the associated\n{ReadableStream} is closed or rejected if the stream errors or the reader's\nlock is released before the stream finishes closing.","summary":"","examples":[],"children":[]},{"kind":"method","id":"readablestreamdefaultreaderread","name":"read","title":"`readableStreamDefaultReader.read()`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":null,"description":"A promise fulfilled with an object:"}},"description":"Requests the next chunk of data from the underlying {ReadableStream}\nand returns a promise that is fulfilled with the data once it is\navailable.","summary":"Requests the next chunk of data from the underlying {ReadableStream} and returns a promise that is fulfilled with the data once it is available.","examples":[],"children":[]},{"kind":"method","id":"readablestreamdefaultreaderreleaselock","name":"releaseLock","title":"`readableStreamDefaultReader.releaseLock()`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":null},"description":"Releases this reader's lock on the underlying {ReadableStream}.","summary":"Releases this reader's lock on the underlying {ReadableStream}.","examples":[],"children":[]}]},{"kind":"class","id":"class-readablestreambyobreader","name":"ReadableStreamBYOBReader","title":"Class: `ReadableStreamBYOBReader`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/42225","commit":null,"description":"This class is now exposed on the global object."}],"extends":null,"description":"The `ReadableStreamBYOBReader` is an alternative consumer for\nbyte-oriented {ReadableStream}s (those that are created with\n`underlyingSource.type` set equal to `'bytes'` when the\n`ReadableStream` was created).\n\nThe `BYOB` is short for \"bring your own buffer\". This is a\npattern that allows for more efficient reading of byte-oriented\ndata that avoids extraneous copying.\n\n```mjs\nimport {\n  open,\n} from 'node:fs/promises';\n\nimport {\n  ReadableStream,\n} from 'node:stream/web';\n\nimport { Buffer } from 'node:buffer';\n\nclass Source {\n  type = 'bytes';\n  autoAllocateChunkSize = 1024;\n\n  async start(controller) {\n    this.file = await open(new URL(import.meta.url));\n    this.controller = controller;\n  }\n\n  async pull(controller) {\n    const view = controller.byobRequest?.view;\n    const {\n      bytesRead,\n    } = await this.file.read({\n      buffer: view,\n      offset: view.byteOffset,\n      length: view.byteLength,\n    });\n\n    if (bytesRead === 0) {\n      await this.file.close();\n      this.controller.close();\n    }\n    controller.byobRequest.respond(bytesRead);\n  }\n}\n\nconst stream = new ReadableStream(new Source());\n\nasync function read(stream) {\n  const reader = stream.getReader({ mode: 'byob' });\n\n  const chunks = [];\n  let result;\n  do {\n    result = await reader.read(Buffer.alloc(100));\n    if (result.value !== undefined)\n      chunks.push(Buffer.from(result.value));\n  } while (!result.done);\n\n  return Buffer.concat(chunks);\n}\n\nconst data = await read(stream);\nconsole.log(Buffer.from(data).toString());\n```","summary":"The `ReadableStreamBYOBReader` is an alternative consumer for byte-oriented {ReadableStream}s (those that are created with `underlyingSource.type` set equal to `'bytes'` when the `ReadableStream` was created).","examples":[{"language":"mjs","displayName":null,"code":"import {\n  open,\n} from 'node:fs/promises';\n\nimport {\n  ReadableStream,\n} from 'node:stream/web';\n\nimport { Buffer } from 'node:buffer';\n\nclass Source {\n  type = 'bytes';\n  autoAllocateChunkSize = 1024;\n\n  async start(controller) {\n    this.file = await open(new URL(import.meta.url));\n    this.controller = controller;\n  }\n\n  async pull(controller) {\n    const view = controller.byobRequest?.view;\n    const {\n      bytesRead,\n    } = await this.file.read({\n      buffer: view,\n      offset: view.byteOffset,\n      length: view.byteLength,\n    });\n\n    if (bytesRead === 0) {\n      await this.file.close();\n      this.controller.close();\n    }\n    controller.byobRequest.respond(bytesRead);\n  }\n}\n\nconst stream = new ReadableStream(new Source());\n\nasync function read(stream) {\n  const reader = stream.getReader({ mode: 'byob' });\n\n  const chunks = [];\n  let result;\n  do {\n    result = await reader.read(Buffer.alloc(100));\n    if (result.value !== undefined)\n      chunks.push(Buffer.from(result.value));\n  } while (!result.done);\n\n  return Buffer.concat(chunks);\n}\n\nconst data = await read(stream);\nconsole.log(Buffer.from(data).toString());"}],"children":[{"kind":"constructor","id":"new-readablestreambyobreaderstream","name":"ReadableStreamBYOBReader","title":"`new ReadableStreamBYOBReader(stream)`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"stream","type":{"text":"ReadableStream","links":[{"name":"ReadableStream","href":"webstreams.html#class-readablestream","start":0,"end":14}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":null},"description":"Creates a new `ReadableStreamBYOBReader` that is locked to the\ngiven {ReadableStream}.","summary":"Creates a new `ReadableStreamBYOBReader` that is locked to the given {ReadableStream}.","examples":[],"children":[]},{"kind":"method","id":"readablestreambyobreadercancelreason","name":"cancel","title":"`readableStreamBYOBReader.cancel([reason])`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"reason","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":null,"description":"A promise fulfilled with `undefined`."}},"description":"Cancels the {ReadableStream} and returns a promise that is fulfilled\nwhen the underlying stream has been canceled.","summary":"Cancels the {ReadableStream} and returns a promise that is fulfilled when the underlying stream has been canceled.","examples":[],"children":[]},{"kind":"property","id":"readablestreambyobreaderclosed","name":"closed","title":"`readableStreamBYOBReader.closed`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"default":null,"description":"Fulfilled with `undefined` when the associated\n{ReadableStream} is closed or rejected if the stream errors or the reader's\nlock is released before the stream finishes closing.","summary":"","examples":[],"children":[]},{"kind":"method","id":"readablestreambyobreaderreadview-options","name":"read","title":"`readableStreamBYOBReader.read(view[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v21.7.0","v20.17.0"],"prUrl":"https://github.com/nodejs/node/pull/50888","commit":null,"description":"Added `min` option."}],"signature":{"parameters":[{"name":"view","type":{"text":"Buffer | TypedArray | DataView","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":9,"end":19},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":22,"end":30}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"min","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"When set, the returned promise will only be\nfulfilled as soon as `min` number of elements are available.\nWhen not set, the promise fulfills when at least one element\nis available.","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":{"type":null,"description":"A promise fulfilled with an object:"}},"description":"Requests the next chunk of data from the underlying {ReadableStream}\nand returns a promise that is fulfilled with the data once it is\navailable.\n\nDo not pass a pooled {Buffer} object instance in to this method.\nPooled `Buffer` objects are created using `Buffer.allocUnsafe()`,\nor `Buffer.from()`, or are often returned by various `node:fs` module\ncallbacks. These types of `Buffer`s use a shared underlying\n{ArrayBuffer} object that contains all of the data from all of\nthe pooled `Buffer` instances. When a `Buffer`, {TypedArray},\nor {DataView} is passed in to `readableStreamBYOBReader.read()`,\nthe view's underlying `ArrayBuffer` is *detached*, invalidating\nall existing views that may exist on that `ArrayBuffer`. This\ncan have disastrous consequences for your application.","summary":"Requests the next chunk of data from the underlying {ReadableStream} and returns a promise that is fulfilled with the data once it is available.","examples":[],"children":[]},{"kind":"method","id":"readablestreambyobreaderreleaselock","name":"releaseLock","title":"`readableStreamBYOBReader.releaseLock()`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":null},"description":"Releases this reader's lock on the underlying {ReadableStream}.","summary":"Releases this reader's lock on the underlying {ReadableStream}.","examples":[],"children":[]}]},{"kind":"class","id":"class-readablestreamdefaultcontroller","name":"ReadableStreamDefaultController","title":"Class: `ReadableStreamDefaultController`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"extends":null,"description":"Every {ReadableStream} has a controller that is responsible for\nthe internal state and management of the stream's queue. The\n`ReadableStreamDefaultController` is the default controller\nimplementation for `ReadableStream`s that are not byte-oriented.","summary":"Every {ReadableStream} has a controller that is responsible for the internal state and management of the stream's queue. The `ReadableStreamDefaultController` is the default controller implementation for `ReadableStream`s that are not byte-oriented.","examples":[],"children":[{"kind":"method","id":"readablestreamdefaultcontrollerclose","name":"close","title":"`readableStreamDefaultController.close()`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":null},"description":"Closes the {ReadableStream} to which this controller is associated.","summary":"Closes the {ReadableStream} to which this controller is associated.","examples":[],"children":[]},{"kind":"property","id":"readablestreamdefaultcontrollerdesiredsize","name":"desiredSize","title":"`readableStreamDefaultController.desiredSize`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"default":null,"description":"Returns the amount of data remaining to fill the {ReadableStream}'s\nqueue.","summary":"Returns the amount of data remaining to fill the {ReadableStream}'s queue.","examples":[],"children":[]},{"kind":"method","id":"readablestreamdefaultcontrollerenqueuechunk","name":"enqueue","title":"`readableStreamDefaultController.enqueue([chunk])`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"chunk","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"","default":null,"optional":true,"rest":false,"properties":[]}],"returns":null},"description":"Appends a new chunk of data to the {ReadableStream}'s queue.","summary":"Appends a new chunk of data to the {ReadableStream}'s queue.","examples":[],"children":[]},{"kind":"method","id":"readablestreamdefaultcontrollererrorerror","name":"error","title":"`readableStreamDefaultController.error([error])`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"error","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"","default":null,"optional":true,"rest":false,"properties":[]}],"returns":null},"description":"Signals an error that causes the {ReadableStream} to error and close.","summary":"Signals an error that causes the {ReadableStream} to error and close.","examples":[],"children":[]}]},{"kind":"class","id":"class-readablebytestreamcontroller","name":"ReadableByteStreamController","title":"Class: `ReadableByteStreamController`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.10.0"],"prUrl":"https://github.com/nodejs/node/pull/44702","commit":null,"description":"Support handling a BYOB pull request from a released reader."}],"extends":null,"description":"Every {ReadableStream} has a controller that is responsible for\nthe internal state and management of the stream's queue. The\n`ReadableByteStreamController` is for byte-oriented `ReadableStream`s.","summary":"Every {ReadableStream} has a controller that is responsible for the internal state and management of the stream's queue. The `ReadableByteStreamController` is for byte-oriented `ReadableStream`s.","examples":[],"children":[{"kind":"property","id":"readablebytestreamcontrollerbyobrequest","name":"byobRequest","title":"`readableByteStreamController.byobRequest`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"ReadableStreamBYOBRequest","links":[{"name":"ReadableStreamBYOBRequest","href":"webstreams.html#class-readablestreambyobrequest","start":0,"end":25}]},"default":null,"description":"","summary":"","examples":[],"children":[]},{"kind":"method","id":"readablebytestreamcontrollerclose","name":"close","title":"`readableByteStreamController.close()`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":null},"description":"Closes the {ReadableStream} to which this controller is associated.","summary":"Closes the {ReadableStream} to which this controller is associated.","examples":[],"children":[]},{"kind":"property","id":"readablebytestreamcontrollerdesiredsize","name":"desiredSize","title":"`readableByteStreamController.desiredSize`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"default":null,"description":"Returns the amount of data remaining to fill the {ReadableStream}'s\nqueue.","summary":"Returns the amount of data remaining to fill the {ReadableStream}'s queue.","examples":[],"children":[]},{"kind":"method","id":"readablebytestreamcontrollerenqueuechunk","name":"enqueue","title":"`readableByteStreamController.enqueue(chunk)`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"chunk","type":{"text":"Buffer | TypedArray | DataView","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":9,"end":19},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":22,"end":30}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":null},"description":"Appends a new chunk of data to the {ReadableStream}'s queue.","summary":"Appends a new chunk of data to the {ReadableStream}'s queue.","examples":[],"children":[]},{"kind":"method","id":"readablebytestreamcontrollererrorerror","name":"error","title":"`readableByteStreamController.error([error])`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"error","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"","default":null,"optional":true,"rest":false,"properties":[]}],"returns":null},"description":"Signals an error that causes the {ReadableStream} to error and close.","summary":"Signals an error that causes the {ReadableStream} to error and close.","examples":[],"children":[]}]},{"kind":"class","id":"class-readablestreambyobrequest","name":"ReadableStreamBYOBRequest","title":"Class: `ReadableStreamBYOBRequest`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/42225","commit":null,"description":"This class is now exposed on the global object."}],"extends":null,"description":"When using `ReadableByteStreamController` in byte-oriented\nstreams, and when using the `ReadableStreamBYOBReader`,\nthe `readableByteStreamController.byobRequest` property\nprovides access to a `ReadableStreamBYOBRequest` instance\nthat represents the current read request. The object\nis used to gain access to the `ArrayBuffer`/`TypedArray`\nthat has been provided for the read request to fill,\nand provides methods for signaling that the data has\nbeen provided.","summary":"When using `ReadableByteStreamController` in byte-oriented streams, and when using the `ReadableStreamBYOBReader`, the `readableByteStreamController.byobRequest` property provides access to a `ReadableStreamBYOBRequest` instance that represents the current read request. The object is used to gain access to the `ArrayBuffer`/`TypedArray` that has been provided for the read request to fill, and provides methods for signaling that the data has been provided.","examples":[],"children":[{"kind":"method","id":"readablestreambyobrequestrespondbyteswritten","name":"respond","title":"`readableStreamBYOBRequest.respond(bytesWritten)`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"bytesWritten","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":null},"description":"Signals that a `bytesWritten` number of bytes have been written\nto `readableStreamBYOBRequest.view`.","summary":"Signals that a `bytesWritten` number of bytes have been written to `readableStreamBYOBRequest.view`.","examples":[],"children":[]},{"kind":"method","id":"readablestreambyobrequestrespondwithnewviewview","name":"respondWithNewView","title":"`readableStreamBYOBRequest.respondWithNewView(view)`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"view","type":{"text":"Buffer | TypedArray | DataView","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":9,"end":19},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":22,"end":30}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":null},"description":"Signals that the request has been fulfilled with bytes written\nto a new `Buffer`, `TypedArray`, or `DataView`.","summary":"Signals that the request has been fulfilled with bytes written to a new `Buffer`, `TypedArray`, or `DataView`.","examples":[],"children":[]},{"kind":"property","id":"readablestreambyobrequestview","name":"view","title":"`readableStreamBYOBRequest.view`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"Buffer | TypedArray | DataView","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":9,"end":19},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":22,"end":30}]},"default":null,"description":"","summary":"","examples":[],"children":[]}]},{"kind":"class","id":"class-writablestream","name":"WritableStream","title":"Class: `WritableStream`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/42225","commit":null,"description":"This class is now exposed on the global object."}],"extends":null,"description":"The `WritableStream` is a destination to which stream data is sent.\n\n```mjs\nimport {\n  WritableStream,\n} from 'node:stream/web';\n\nconst stream = new WritableStream({\n  write(chunk) {\n    console.log(chunk);\n  },\n});\n\nawait stream.getWriter().write('Hello World');\n```","summary":"The `WritableStream` is a destination to which stream data is sent.","examples":[{"language":"mjs","displayName":null,"code":"import {\n  WritableStream,\n} from 'node:stream/web';\n\nconst stream = new WritableStream({\n  write(chunk) {\n    console.log(chunk);\n  },\n});\n\nawait stream.getWriter().write('Hello World');"}],"children":[{"kind":"constructor","id":"new-writablestreamunderlyingsink-strategy","name":"WritableStream","title":"`new WritableStream([underlyingSink[, strategy]])`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"underlyingSink","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"start","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"A user-defined function that is invoked immediately when\nthe `WritableStream` is created.","default":null,"optional":false,"rest":false,"properties":[{"name":"controller","type":{"text":"WritableStreamDefaultController","links":[{"name":"WritableStreamDefaultController","href":"webstreams.html#class-writablestreamdefaultcontroller","start":0,"end":31}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"","type":null,"description":"`undefined` or a promise fulfilled with `undefined`.","default":null,"optional":false,"rest":false,"properties":[]}]},{"name":"write","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"A user-defined function that is invoked when a chunk of\ndata has been written to the `WritableStream`.","default":null,"optional":false,"rest":false,"properties":[{"name":"chunk","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"controller","type":{"text":"WritableStreamDefaultController","links":[{"name":"WritableStreamDefaultController","href":"webstreams.html#class-writablestreamdefaultcontroller","start":0,"end":31}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"","type":null,"description":"A promise fulfilled with `undefined`.","default":null,"optional":false,"rest":false,"properties":[]}]},{"name":"close","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"A user-defined function that is called when the\n`WritableStream` is closed.","default":null,"optional":false,"rest":false,"properties":[{"name":"","type":null,"description":"A promise fulfilled with `undefined`.","default":null,"optional":false,"rest":false,"properties":[]}]},{"name":"abort","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"A user-defined function that is called to abruptly close\nthe `WritableStream`.","default":null,"optional":false,"rest":false,"properties":[{"name":"reason","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"","type":null,"description":"A promise fulfilled with `undefined`.","default":null,"optional":false,"rest":false,"properties":[]}]},{"name":"type","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"The `type` option is reserved for future use and *must* be\nundefined.","default":null,"optional":false,"rest":false,"properties":[]}]},{"name":"strategy","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"highWaterMark","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"The maximum internal queue size before backpressure\nis applied.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"size","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"A user-defined function used to identify the size of each\nchunk of data.","default":null,"optional":false,"rest":false,"properties":[{"name":"chunk","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}]}],"returns":null},"description":"","summary":"","examples":[],"children":[]},{"kind":"method","id":"writablestreamabortreason","name":"abort","title":"`writableStream.abort([reason])`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"reason","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":null,"description":"A promise fulfilled with `undefined`."}},"description":"Abruptly terminates the `WritableStream`. All queued writes will be\ncanceled with their associated promises rejected.","summary":"Abruptly terminates the `WritableStream`. All queued writes will be canceled with their associated promises rejected.","examples":[],"children":[]},{"kind":"method","id":"writablestreamclose","name":"close","title":"`writableStream.close()`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":null,"description":"A promise fulfilled with `undefined`."}},"description":"Closes the `WritableStream` when no additional writes are expected.","summary":"Closes the `WritableStream` when no additional writes are expected.","examples":[],"children":[]},{"kind":"method","id":"writablestreamgetwriter","name":"getWriter","title":"`writableStream.getWriter()`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"WritableStreamDefaultWriter","links":[{"name":"WritableStreamDefaultWriter","href":"webstreams.html#class-writablestreamdefaultwriter","start":0,"end":27}]},"description":""}},"description":"Creates and returns a new writer instance that can be used to write\ndata into the `WritableStream`.","summary":"Creates and returns a new writer instance that can be used to write data into the `WritableStream`.","examples":[],"children":[]},{"kind":"property","id":"writablestreamlocked","name":"locked","title":"`writableStream.locked`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"default":null,"description":"The `writableStream.locked` property is `false` by default, and is\nswitched to `true` while there is an active writer attached to this\n`WritableStream`.","summary":"The `writableStream.locked` property is `false` by default, and is switched to `true` while there is an active writer attached to this `WritableStream`.","examples":[],"children":[]},{"kind":"section","id":"transferring-with-postmessage-1","name":"Transferring with postMessage()","title":"Transferring with postMessage()","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"A {WritableStream} instance can be transferred using a {MessagePort}.\n\n```js\nconst stream = new WritableStream(getWritableSinkSomehow());\n\nconst { port1, port2 } = new MessageChannel();\n\nport1.onmessage = ({ data }) => {\n  data.getWriter().write('hello');\n};\n\nport2.postMessage(stream, [stream]);\n```","summary":"A {WritableStream} instance can be transferred using a {MessagePort}.","examples":[{"language":"js","displayName":null,"code":"const stream = new WritableStream(getWritableSinkSomehow());\n\nconst { port1, port2 } = new MessageChannel();\n\nport1.onmessage = ({ data }) => {\n  data.getWriter().write('hello');\n};\n\nport2.postMessage(stream, [stream]);"}],"children":[]}]},{"kind":"class","id":"class-writablestreamdefaultwriter","name":"WritableStreamDefaultWriter","title":"Class: `WritableStreamDefaultWriter`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/42225","commit":null,"description":"This class is now exposed on the global object."}],"extends":null,"description":"","summary":"","examples":[],"children":[{"kind":"constructor","id":"new-writablestreamdefaultwriterstream","name":"WritableStreamDefaultWriter","title":"`new WritableStreamDefaultWriter(stream)`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"stream","type":{"text":"WritableStream","links":[{"name":"WritableStream","href":"webstreams.html#class-writablestream","start":0,"end":14}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":null},"description":"Creates a new `WritableStreamDefaultWriter` that is locked to the given\n`WritableStream`.","summary":"Creates a new `WritableStreamDefaultWriter` that is locked to the given `WritableStream`.","examples":[],"children":[]},{"kind":"method","id":"writablestreamdefaultwriterabortreason","name":"abort","title":"`writableStreamDefaultWriter.abort([reason])`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"reason","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":null,"description":"A promise fulfilled with `undefined`."}},"description":"Abruptly terminates the `WritableStream`. All queued writes will be\ncanceled with their associated promises rejected.","summary":"Abruptly terminates the `WritableStream`. All queued writes will be canceled with their associated promises rejected.","examples":[],"children":[]},{"kind":"method","id":"writablestreamdefaultwriterclose","name":"close","title":"`writableStreamDefaultWriter.close()`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":null,"description":"A promise fulfilled with `undefined`."}},"description":"Closes the `WritableStream` when no additional writes are expected.","summary":"Closes the `WritableStream` when no additional writes are expected.","examples":[],"children":[]},{"kind":"property","id":"writablestreamdefaultwriterclosed","name":"closed","title":"`writableStreamDefaultWriter.closed`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"default":null,"description":"Fulfilled with `undefined` when the associated\n{WritableStream} is closed or rejected if the stream errors or the writer's\nlock is released before the stream finishes closing.","summary":"","examples":[],"children":[]},{"kind":"property","id":"writablestreamdefaultwriterdesiredsize","name":"desiredSize","title":"`writableStreamDefaultWriter.desiredSize`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"default":null,"description":"The amount of data required to fill the {WritableStream}'s queue.","summary":"The amount of data required to fill the {WritableStream}'s queue.","examples":[],"children":[]},{"kind":"property","id":"writablestreamdefaultwriterready","name":"ready","title":"`writableStreamDefaultWriter.ready`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"default":null,"description":"Fulfilled with `undefined` when the writer is ready\nto be used.","summary":"","examples":[],"children":[]},{"kind":"method","id":"writablestreamdefaultwriterreleaselock","name":"releaseLock","title":"`writableStreamDefaultWriter.releaseLock()`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":null},"description":"Releases this writer's lock on the underlying {ReadableStream}.","summary":"Releases this writer's lock on the underlying {ReadableStream}.","examples":[],"children":[]},{"kind":"method","id":"writablestreamdefaultwriterwritechunk","name":"write","title":"`writableStreamDefaultWriter.write([chunk])`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"chunk","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":null,"description":"A promise fulfilled with `undefined`."}},"description":"Appends a new chunk of data to the {WritableStream}'s queue.","summary":"Appends a new chunk of data to the {WritableStream}'s queue.","examples":[],"children":[]}]},{"kind":"class","id":"class-writablestreamdefaultcontroller","name":"WritableStreamDefaultController","title":"Class: `WritableStreamDefaultController`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/42225","commit":null,"description":"This class is now exposed on the global object."}],"extends":null,"description":"The `WritableStreamDefaultController` manages the {WritableStream}'s\ninternal state.","summary":"The `WritableStreamDefaultController` manages the {WritableStream}'s internal state.","examples":[],"children":[{"kind":"method","id":"writablestreamdefaultcontrollererrorerror","name":"error","title":"`writableStreamDefaultController.error([error])`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"error","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"","default":null,"optional":true,"rest":false,"properties":[]}],"returns":null},"description":"Called by user-code to signal that an error has occurred while processing\nthe `WritableStream` data. When called, the {WritableStream} will be aborted,\nwith currently pending writes canceled.","summary":"Called by user-code to signal that an error has occurred while processing the `WritableStream` data. When called, the {WritableStream} will be aborted, with currently pending writes canceled.","examples":[],"children":[]},{"kind":"property","id":"writablestreamdefaultcontrollersignal","name":"signal","title":"`writableStreamDefaultController.signal`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"AbortSignal","links":[{"name":"AbortSignal","href":"globals.html#class-abortsignal","start":0,"end":11}]},"default":null,"description":"An `AbortSignal` that can be used to cancel pending\nwrite or close operations when a {WritableStream} is aborted.","summary":"","examples":[],"children":[]}]},{"kind":"class","id":"class-transformstream","name":"TransformStream","title":"Class: `TransformStream`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/42225","commit":null,"description":"This class is now exposed on the global object."}],"extends":null,"description":"A `TransformStream` consists of a {ReadableStream} and a {WritableStream} that\nare connected such that the data written to the `WritableStream` is received,\nand potentially transformed, before being pushed into the `ReadableStream`'s\nqueue.\n\n```mjs\nimport {\n  TransformStream,\n} from 'node:stream/web';\n\nconst transform = new TransformStream({\n  transform(chunk, controller) {\n    controller.enqueue(chunk.toUpperCase());\n  },\n});\n\nawait Promise.all([\n  transform.writable.getWriter().write('A'),\n  transform.readable.getReader().read(),\n]);\n```","summary":"A `TransformStream` consists of a {ReadableStream} and a {WritableStream} that are connected such that the data written to the `WritableStream` is received, and potentially transformed, before being pushed into the `ReadableStream`'s queue.","examples":[{"language":"mjs","displayName":null,"code":"import {\n  TransformStream,\n} from 'node:stream/web';\n\nconst transform = new TransformStream({\n  transform(chunk, controller) {\n    controller.enqueue(chunk.toUpperCase());\n  },\n});\n\nawait Promise.all([\n  transform.writable.getWriter().write('A'),\n  transform.readable.getReader().read(),\n]);"}],"children":[{"kind":"constructor","id":"new-transformstreamtransformer-writablestrategy-readablestrategy","name":"TransformStream","title":"`new TransformStream([transformer[, writableStrategy[, readableStrategy]]])`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v21.5.0","v20.14.0"],"prUrl":"https://github.com/nodejs/node/pull/50126","commit":null,"description":"Supports the `cancel` transformer callback."}],"signature":{"parameters":[{"name":"transformer","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"start","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"A user-defined function that is invoked immediately when\nthe `TransformStream` is created.","default":null,"optional":false,"rest":false,"properties":[{"name":"controller","type":{"text":"TransformStreamDefaultController","links":[{"name":"TransformStreamDefaultController","href":"webstreams.html#class-transformstreamdefaultcontroller","start":0,"end":32}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"","type":null,"description":"`undefined` or a promise fulfilled with `undefined`","default":null,"optional":false,"rest":false,"properties":[]}]},{"name":"transform","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"A user-defined function that receives, and\npotentially modifies, a chunk of data written to `transformStream.writable`,\nbefore forwarding that on to `transformStream.readable`.","default":null,"optional":false,"rest":false,"properties":[{"name":"chunk","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"controller","type":{"text":"TransformStreamDefaultController","links":[{"name":"TransformStreamDefaultController","href":"webstreams.html#class-transformstreamdefaultcontroller","start":0,"end":32}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"","type":null,"description":"A promise fulfilled with `undefined`.","default":null,"optional":false,"rest":false,"properties":[]}]},{"name":"flush","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"A user-defined function that is called immediately before\nthe writable side of the `TransformStream` is closed, signaling the end of\nthe transformation process.","default":null,"optional":false,"rest":false,"properties":[{"name":"controller","type":{"text":"TransformStreamDefaultController","links":[{"name":"TransformStreamDefaultController","href":"webstreams.html#class-transformstreamdefaultcontroller","start":0,"end":32}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"","type":null,"description":"A promise fulfilled with `undefined`.","default":null,"optional":false,"rest":false,"properties":[]}]},{"name":"cancel","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"A user-defined function that is called when either the\nreadable side of the `TransformStream` is canceled or the writable side is\naborted.","default":null,"optional":false,"rest":false,"properties":[{"name":"reason","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"","type":null,"description":"A promise fulfilled with `undefined`.","default":null,"optional":false,"rest":false,"properties":[]}]},{"name":"readableType","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"the `readableType` option is reserved for future use\nand *must* be `undefined`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"writableType","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"the `writableType` option is reserved for future use\nand *must* be `undefined`.","default":null,"optional":false,"rest":false,"properties":[]}]},{"name":"writableStrategy","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"highWaterMark","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"The maximum internal queue size before backpressure\nis applied.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"size","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"A user-defined function used to identify the size of each\nchunk of data.","default":null,"optional":false,"rest":false,"properties":[{"name":"chunk","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}]},{"name":"readableStrategy","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"highWaterMark","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"The maximum internal queue size before backpressure\nis applied.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"size","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"A user-defined function used to identify the size of each\nchunk of data.","default":null,"optional":false,"rest":false,"properties":[{"name":"chunk","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}]}],"returns":null},"description":"","summary":"","examples":[],"children":[]},{"kind":"property","id":"transformstreamreadable","name":"readable","title":"`transformStream.readable`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"ReadableStream","links":[{"name":"ReadableStream","href":"webstreams.html#class-readablestream","start":0,"end":14}]},"default":null,"description":"","summary":"","examples":[],"children":[]},{"kind":"property","id":"transformstreamwritable","name":"writable","title":"`transformStream.writable`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"WritableStream","links":[{"name":"WritableStream","href":"webstreams.html#class-writablestream","start":0,"end":14}]},"default":null,"description":"","summary":"","examples":[],"children":[]},{"kind":"section","id":"transferring-with-postmessage-2","name":"Transferring with postMessage()","title":"Transferring with postMessage()","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"A {TransformStream} instance can be transferred using a {MessagePort}.\n\n```js\nconst stream = new TransformStream();\n\nconst { port1, port2 } = new MessageChannel();\n\nport1.onmessage = ({ data }) => {\n  const { writable, readable } = data;\n  // ...\n};\n\nport2.postMessage(stream, [stream]);\n```","summary":"A {TransformStream} instance can be transferred using a {MessagePort}.","examples":[{"language":"js","displayName":null,"code":"const stream = new TransformStream();\n\nconst { port1, port2 } = new MessageChannel();\n\nport1.onmessage = ({ data }) => {\n  const { writable, readable } = data;\n  // ...\n};\n\nport2.postMessage(stream, [stream]);"}],"children":[]}]},{"kind":"class","id":"class-transformstreamdefaultcontroller","name":"TransformStreamDefaultController","title":"Class: `TransformStreamDefaultController`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/42225","commit":null,"description":"This class is now exposed on the global object."}],"extends":null,"description":"The `TransformStreamDefaultController` manages the internal state\nof the `TransformStream`.","summary":"The `TransformStreamDefaultController` manages the internal state of the `TransformStream`.","examples":[],"children":[{"kind":"property","id":"transformstreamdefaultcontrollerdesiredsize","name":"desiredSize","title":"`transformStreamDefaultController.desiredSize`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"default":null,"description":"The amount of data required to fill the readable side's queue.","summary":"The amount of data required to fill the readable side's queue.","examples":[],"children":[]},{"kind":"method","id":"transformstreamdefaultcontrollerenqueuechunk","name":"enqueue","title":"`transformStreamDefaultController.enqueue([chunk])`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"chunk","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"","default":null,"optional":true,"rest":false,"properties":[]}],"returns":null},"description":"Appends a chunk of data to the readable side's queue.","summary":"Appends a chunk of data to the readable side's queue.","examples":[],"children":[]},{"kind":"method","id":"transformstreamdefaultcontrollererrorreason","name":"error","title":"`transformStreamDefaultController.error([reason])`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"reason","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"","default":null,"optional":true,"rest":false,"properties":[]}],"returns":null},"description":"Signals to both the readable and writable side that an error has occurred\nwhile processing the transform data, causing both sides to be abruptly\nclosed.","summary":"Signals to both the readable and writable side that an error has occurred while processing the transform data, causing both sides to be abruptly closed.","examples":[],"children":[]},{"kind":"method","id":"transformstreamdefaultcontrollerterminate","name":"terminate","title":"`transformStreamDefaultController.terminate()`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":null},"description":"Closes the readable side of the transport and causes the writable side\nto be abruptly closed with an error.","summary":"Closes the readable side of the transport and causes the writable side to be abruptly closed with an error.","examples":[],"children":[]}]},{"kind":"class","id":"class-bytelengthqueuingstrategy","name":"ByteLengthQueuingStrategy","title":"Class: `ByteLengthQueuingStrategy`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/42225","commit":null,"description":"This class is now exposed on the global object."}],"extends":null,"description":"","summary":"","examples":[],"children":[{"kind":"constructor","id":"new-bytelengthqueuingstrategyinit","name":"ByteLengthQueuingStrategy","title":"`new ByteLengthQueuingStrategy(init)`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"init","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"highWaterMark","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"","summary":"","examples":[],"children":[]},{"kind":"property","id":"bytelengthqueuingstrategyhighwatermark","name":"highWaterMark","title":"`byteLengthQueuingStrategy.highWaterMark`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"default":null,"description":"","summary":"","examples":[],"children":[]},{"kind":"property","id":"bytelengthqueuingstrategysize","name":"size","title":"`byteLengthQueuingStrategy.size`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"default":null,"description":"","summary":"","examples":[],"children":[]}]},{"kind":"class","id":"class-countqueuingstrategy","name":"CountQueuingStrategy","title":"Class: `CountQueuingStrategy`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/42225","commit":null,"description":"This class is now exposed on the global object."}],"extends":null,"description":"","summary":"","examples":[],"children":[{"kind":"constructor","id":"new-countqueuingstrategyinit","name":"CountQueuingStrategy","title":"`new CountQueuingStrategy(init)`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"init","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"highWaterMark","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"","summary":"","examples":[],"children":[]},{"kind":"property","id":"countqueuingstrategyhighwatermark","name":"highWaterMark","title":"`countQueuingStrategy.highWaterMark`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"default":null,"description":"","summary":"","examples":[],"children":[]},{"kind":"property","id":"countqueuingstrategysize","name":"size","title":"`countQueuingStrategy.size`","scope":"module","overloadOf":null,"stability":null,"added":["v16.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"default":null,"description":"","summary":"","examples":[],"children":[]}]},{"kind":"class","id":"class-textencoderstream","name":"TextEncoderStream","title":"Class: `TextEncoderStream`","scope":"module","overloadOf":null,"stability":null,"added":["v16.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/42225","commit":null,"description":"This class is now exposed on the global object."}],"extends":null,"description":"","summary":"","examples":[],"children":[{"kind":"constructor","id":"new-textencoderstream","name":"TextEncoderStream","title":"`new TextEncoderStream()`","scope":"module","overloadOf":null,"stability":null,"added":["v16.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":null},"description":"Creates a new `TextEncoderStream` instance.","summary":"Creates a new `TextEncoderStream` instance.","examples":[],"children":[]},{"kind":"property","id":"textencoderstreamencoding","name":"encoding","title":"`textEncoderStream.encoding`","scope":"module","overloadOf":null,"stability":null,"added":["v16.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"default":null,"description":"The encoding supported by the `TextEncoderStream` instance.","summary":"The encoding supported by the `TextEncoderStream` instance.","examples":[],"children":[]},{"kind":"property","id":"textencoderstreamreadable","name":"readable","title":"`textEncoderStream.readable`","scope":"module","overloadOf":null,"stability":null,"added":["v16.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"ReadableStream","links":[{"name":"ReadableStream","href":"webstreams.html#class-readablestream","start":0,"end":14}]},"default":null,"description":"","summary":"","examples":[],"children":[]},{"kind":"property","id":"textencoderstreamwritable","name":"writable","title":"`textEncoderStream.writable`","scope":"module","overloadOf":null,"stability":null,"added":["v16.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"WritableStream","links":[{"name":"WritableStream","href":"webstreams.html#class-writablestream","start":0,"end":14}]},"default":null,"description":"","summary":"","examples":[],"children":[]}]},{"kind":"class","id":"class-textdecoderstream","name":"TextDecoderStream","title":"Class: `TextDecoderStream`","scope":"module","overloadOf":null,"stability":null,"added":["v16.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/42225","commit":null,"description":"This class is now exposed on the global object."}],"extends":null,"description":"","summary":"","examples":[],"children":[{"kind":"constructor","id":"new-textdecoderstreamencoding-options","name":"TextDecoderStream","title":"`new TextDecoderStream([encoding[, options]])`","scope":"module","overloadOf":null,"stability":null,"added":["v16.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"Identifies the `encoding` that this `TextDecoder` instance\nsupports.","default":"'utf-8'","optional":true,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"fatal","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"`true` if decoding failures are fatal.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"ignoreBOM","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"When `true`, the `TextDecoderStream` will include the\nbyte order mark in the decoded result. When `false`, the byte order mark\nwill be removed from the output. This option is only used when `encoding` is\n`'utf-8'`, `'utf-16be'`, or `'utf-16le'`.","default":"false","optional":true,"rest":false,"properties":[]}]}],"returns":null},"description":"Creates a new `TextDecoderStream` instance.","summary":"Creates a new `TextDecoderStream` instance.","examples":[],"children":[]},{"kind":"property","id":"textdecoderstreamencoding","name":"encoding","title":"`textDecoderStream.encoding`","scope":"module","overloadOf":null,"stability":null,"added":["v16.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"default":null,"description":"The encoding supported by the `TextDecoderStream` instance.","summary":"The encoding supported by the `TextDecoderStream` instance.","examples":[],"children":[]},{"kind":"property","id":"textdecoderstreamfatal","name":"fatal","title":"`textDecoderStream.fatal`","scope":"module","overloadOf":null,"stability":null,"added":["v16.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"default":null,"description":"The value will be `true` if decoding errors result in a `TypeError` being\nthrown.","summary":"The value will be `true` if decoding errors result in a `TypeError` being thrown.","examples":[],"children":[]},{"kind":"property","id":"textdecoderstreamignorebom","name":"ignoreBOM","title":"`textDecoderStream.ignoreBOM`","scope":"module","overloadOf":null,"stability":null,"added":["v16.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"default":null,"description":"The value will be `true` if the decoding result will include the byte order\nmark.","summary":"The value will be `true` if the decoding result will include the byte order mark.","examples":[],"children":[]},{"kind":"property","id":"textdecoderstreamreadable","name":"readable","title":"`textDecoderStream.readable`","scope":"module","overloadOf":null,"stability":null,"added":["v16.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"ReadableStream","links":[{"name":"ReadableStream","href":"webstreams.html#class-readablestream","start":0,"end":14}]},"default":null,"description":"","summary":"","examples":[],"children":[]},{"kind":"property","id":"textdecoderstreamwritable","name":"writable","title":"`textDecoderStream.writable`","scope":"module","overloadOf":null,"stability":null,"added":["v16.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"WritableStream","links":[{"name":"WritableStream","href":"webstreams.html#class-writablestream","start":0,"end":14}]},"default":null,"description":"","summary":"","examples":[],"children":[]}]},{"kind":"class","id":"class-compressionstream","name":"CompressionStream","title":"Class: `CompressionStream`","scope":"module","overloadOf":null,"stability":null,"added":["v17.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/42225","commit":null,"description":"This class is now exposed on the global object."}],"extends":null,"description":"","summary":"","examples":[],"children":[{"kind":"constructor","id":"new-compressionstreamformat","name":"CompressionStream","title":"`new CompressionStream(format)`","scope":"module","overloadOf":null,"stability":null,"added":["v17.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v24.7.0","v22.20.0"],"prUrl":"https://github.com/nodejs/node/pull/59464","commit":null,"description":"format now accepts `brotli` value."},{"versions":["v21.2.0","v20.12.0"],"prUrl":"https://github.com/nodejs/node/pull/50097","commit":null,"description":"format now accepts `deflate-raw` value."}],"signature":{"parameters":[{"name":"format","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"One of `'deflate'`, `'deflate-raw'`, `'gzip'`, or `'brotli'`.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":null},"description":"","summary":"","examples":[],"children":[]},{"kind":"property","id":"compressionstreamreadable","name":"readable","title":"`compressionStream.readable`","scope":"module","overloadOf":null,"stability":null,"added":["v17.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"ReadableStream","links":[{"name":"ReadableStream","href":"webstreams.html#class-readablestream","start":0,"end":14}]},"default":null,"description":"","summary":"","examples":[],"children":[]},{"kind":"property","id":"compressionstreamwritable","name":"writable","title":"`compressionStream.writable`","scope":"module","overloadOf":null,"stability":null,"added":["v17.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"WritableStream","links":[{"name":"WritableStream","href":"webstreams.html#class-writablestream","start":0,"end":14}]},"default":null,"description":"","summary":"","examples":[],"children":[]}]},{"kind":"class","id":"class-decompressionstream","name":"DecompressionStream","title":"Class: `DecompressionStream`","scope":"module","overloadOf":null,"stability":null,"added":["v17.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/42225","commit":null,"description":"This class is now exposed on the global object."}],"extends":null,"description":"","summary":"","examples":[],"children":[{"kind":"constructor","id":"new-decompressionstreamformat","name":"DecompressionStream","title":"`new DecompressionStream(format)`","scope":"module","overloadOf":null,"stability":null,"added":["v17.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v24.7.0","v22.20.0"],"prUrl":"https://github.com/nodejs/node/pull/59464","commit":null,"description":"format now accepts `brotli` value."},{"versions":["v21.2.0","v20.12.0"],"prUrl":"https://github.com/nodejs/node/pull/50097","commit":null,"description":"format now accepts `deflate-raw` value."}],"signature":{"parameters":[{"name":"format","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"One of `'deflate'`, `'deflate-raw'`, `'gzip'`, or `'brotli'`.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":null},"description":"","summary":"","examples":[],"children":[]},{"kind":"property","id":"decompressionstreamreadable","name":"readable","title":"`decompressionStream.readable`","scope":"module","overloadOf":null,"stability":null,"added":["v17.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"ReadableStream","links":[{"name":"ReadableStream","href":"webstreams.html#class-readablestream","start":0,"end":14}]},"default":null,"description":"","summary":"","examples":[],"children":[]},{"kind":"property","id":"decompressionstreamwritable","name":"writable","title":"`decompressionStream.writable`","scope":"module","overloadOf":null,"stability":null,"added":["v17.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"WritableStream","links":[{"name":"WritableStream","href":"webstreams.html#class-writablestream","start":0,"end":14}]},"default":null,"description":"","summary":"","examples":[],"children":[]}]},{"kind":"section","id":"utility-consumers","name":"Utility Consumers","title":"Utility Consumers","scope":"module","overloadOf":null,"stability":null,"added":["v16.7.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The utility consumer functions provide common options for consuming\nstreams.\n\nThey are accessed using:\n\n```mjs\nimport {\n  arrayBuffer,\n  blob,\n  buffer,\n  json,\n  text,\n} from 'node:stream/consumers';\n```\n\n```cjs\nconst {\n  arrayBuffer,\n  blob,\n  buffer,\n  json,\n  text,\n} = require('node:stream/consumers');\n```","summary":"The utility consumer functions provide common options for consuming streams.","examples":[{"language":"mjs","displayName":null,"code":"import {\n  arrayBuffer,\n  blob,\n  buffer,\n  json,\n  text,\n} from 'node:stream/consumers';"},{"language":"cjs","displayName":null,"code":"const {\n  arrayBuffer,\n  blob,\n  buffer,\n  json,\n  text,\n} = require('node:stream/consumers');"}],"children":[{"kind":"method","id":"streamconsumersarraybufferstream","name":"arrayBuffer","title":"`streamConsumers.arrayBuffer(stream)`","scope":"module","overloadOf":null,"stability":null,"added":["v16.7.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"stream","type":{"text":"ReadableStream | stream.Readable | AsyncIterator","links":[{"name":"ReadableStream","href":"webstreams.html#class-readablestream","start":0,"end":14},{"name":"stream.Readable","href":"stream.html#class-streamreadable","start":17,"end":32},{"name":"AsyncIterator","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/AsyncIterator","start":35,"end":48}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with an `ArrayBuffer` containing the full\ncontents of the stream."}},"description":"```mjs\nimport { arrayBuffer } from 'node:stream/consumers';\nimport { Readable } from 'node:stream';\nimport { TextEncoder } from 'node:util';\n\nconst encoder = new TextEncoder();\nconst dataArray = encoder.encode('hello world from consumers!');\n\nconst readable = Readable.from(dataArray);\nconst data = await arrayBuffer(readable);\nconsole.log(`from readable: ${data.byteLength}`);\n// Prints: from readable: 76\n```\n\n```cjs\nconst { arrayBuffer } = require('node:stream/consumers');\nconst { Readable } = require('node:stream');\nconst { TextEncoder } = require('node:util');\n\nconst encoder = new TextEncoder();\nconst dataArray = encoder.encode('hello world from consumers!');\nconst readable = Readable.from(dataArray);\narrayBuffer(readable).then((data) => {\n  console.log(`from readable: ${data.byteLength}`);\n  // Prints: from readable: 76\n});\n```","summary":"","examples":[{"language":"mjs","displayName":null,"code":"import { arrayBuffer } from 'node:stream/consumers';\nimport { Readable } from 'node:stream';\nimport { TextEncoder } from 'node:util';\n\nconst encoder = new TextEncoder();\nconst dataArray = encoder.encode('hello world from consumers!');\n\nconst readable = Readable.from(dataArray);\nconst data = await arrayBuffer(readable);\nconsole.log(`from readable: ${data.byteLength}`);\n// Prints: from readable: 76"},{"language":"cjs","displayName":null,"code":"const { arrayBuffer } = require('node:stream/consumers');\nconst { Readable } = require('node:stream');\nconst { TextEncoder } = require('node:util');\n\nconst encoder = new TextEncoder();\nconst dataArray = encoder.encode('hello world from consumers!');\nconst readable = Readable.from(dataArray);\narrayBuffer(readable).then((data) => {\n  console.log(`from readable: ${data.byteLength}`);\n  // Prints: from readable: 76\n});"}],"children":[]},{"kind":"method","id":"streamconsumersblobstream","name":"blob","title":"`streamConsumers.blob(stream)`","scope":"module","overloadOf":null,"stability":null,"added":["v16.7.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"stream","type":{"text":"ReadableStream | stream.Readable | AsyncIterator","links":[{"name":"ReadableStream","href":"webstreams.html#class-readablestream","start":0,"end":14},{"name":"stream.Readable","href":"stream.html#class-streamreadable","start":17,"end":32},{"name":"AsyncIterator","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/AsyncIterator","start":35,"end":48}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with a {Blob} containing the full contents\nof the stream."}},"description":"```mjs\nimport { blob } from 'node:stream/consumers';\n\nconst dataBlob = new Blob(['hello world from consumers!']);\n\nconst readable = dataBlob.stream();\nconst data = await blob(readable);\nconsole.log(`from readable: ${data.size}`);\n// Prints: from readable: 27\n```\n\n```cjs\nconst { blob } = require('node:stream/consumers');\n\nconst dataBlob = new Blob(['hello world from consumers!']);\n\nconst readable = dataBlob.stream();\nblob(readable).then((data) => {\n  console.log(`from readable: ${data.size}`);\n  // Prints: from readable: 27\n});\n```","summary":"","examples":[{"language":"mjs","displayName":null,"code":"import { blob } from 'node:stream/consumers';\n\nconst dataBlob = new Blob(['hello world from consumers!']);\n\nconst readable = dataBlob.stream();\nconst data = await blob(readable);\nconsole.log(`from readable: ${data.size}`);\n// Prints: from readable: 27"},{"language":"cjs","displayName":null,"code":"const { blob } = require('node:stream/consumers');\n\nconst dataBlob = new Blob(['hello world from consumers!']);\n\nconst readable = dataBlob.stream();\nblob(readable).then((data) => {\n  console.log(`from readable: ${data.size}`);\n  // Prints: from readable: 27\n});"}],"children":[]},{"kind":"method","id":"streamconsumersbufferstream","name":"buffer","title":"`streamConsumers.buffer(stream)`","scope":"module","overloadOf":null,"stability":null,"added":["v16.7.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"stream","type":{"text":"ReadableStream | stream.Readable | AsyncIterator","links":[{"name":"ReadableStream","href":"webstreams.html#class-readablestream","start":0,"end":14},{"name":"stream.Readable","href":"stream.html#class-streamreadable","start":17,"end":32},{"name":"AsyncIterator","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/AsyncIterator","start":35,"end":48}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with a {Buffer} containing the full\ncontents of the stream."}},"description":"```mjs\nimport { buffer } from 'node:stream/consumers';\nimport { Readable } from 'node:stream';\nimport { Buffer } from 'node:buffer';\n\nconst dataBuffer = Buffer.from('hello world from consumers!');\n\nconst readable = Readable.from(dataBuffer);\nconst data = await buffer(readable);\nconsole.log(`from readable: ${data.length}`);\n// Prints: from readable: 27\n```\n\n```cjs\nconst { buffer } = require('node:stream/consumers');\nconst { Readable } = require('node:stream');\nconst { Buffer } = require('node:buffer');\n\nconst dataBuffer = Buffer.from('hello world from consumers!');\n\nconst readable = Readable.from(dataBuffer);\nbuffer(readable).then((data) => {\n  console.log(`from readable: ${data.length}`);\n  // Prints: from readable: 27\n});\n```","summary":"","examples":[{"language":"mjs","displayName":null,"code":"import { buffer } from 'node:stream/consumers';\nimport { Readable } from 'node:stream';\nimport { Buffer } from 'node:buffer';\n\nconst dataBuffer = Buffer.from('hello world from consumers!');\n\nconst readable = Readable.from(dataBuffer);\nconst data = await buffer(readable);\nconsole.log(`from readable: ${data.length}`);\n// Prints: from readable: 27"},{"language":"cjs","displayName":null,"code":"const { buffer } = require('node:stream/consumers');\nconst { Readable } = require('node:stream');\nconst { Buffer } = require('node:buffer');\n\nconst dataBuffer = Buffer.from('hello world from consumers!');\n\nconst readable = Readable.from(dataBuffer);\nbuffer(readable).then((data) => {\n  console.log(`from readable: ${data.length}`);\n  // Prints: from readable: 27\n});"}],"children":[]},{"kind":"method","id":"streamconsumersbytesstream","name":"bytes","title":"`streamConsumers.bytes(stream)`","scope":"module","overloadOf":null,"stability":null,"added":["v25.6.0","v24.14.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"stream","type":{"text":"ReadableStream | stream.Readable | AsyncIterator","links":[{"name":"ReadableStream","href":"webstreams.html#class-readablestream","start":0,"end":14},{"name":"stream.Readable","href":"stream.html#class-streamreadable","start":17,"end":32},{"name":"AsyncIterator","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/AsyncIterator","start":35,"end":48}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with a {Uint8Array} containing the full\ncontents of the stream."}},"description":"```mjs\nimport { bytes } from 'node:stream/consumers';\nimport { Readable } from 'node:stream';\nimport { Buffer } from 'node:buffer';\n\nconst dataBuffer = Buffer.from('hello world from consumers!');\n\nconst readable = Readable.from(dataBuffer);\nconst data = await bytes(readable);\nconsole.log(`from readable: ${data.length}`);\n// Prints: from readable: 27\n```\n\n```cjs\nconst { bytes } = require('node:stream/consumers');\nconst { Readable } = require('node:stream');\nconst { Buffer } = require('node:buffer');\n\nconst dataBuffer = Buffer.from('hello world from consumers!');\n\nconst readable = Readable.from(dataBuffer);\nbytes(readable).then((data) => {\n  console.log(`from readable: ${data.length}`);\n  // Prints: from readable: 27\n});\n```","summary":"","examples":[{"language":"mjs","displayName":null,"code":"import { bytes } from 'node:stream/consumers';\nimport { Readable } from 'node:stream';\nimport { Buffer } from 'node:buffer';\n\nconst dataBuffer = Buffer.from('hello world from consumers!');\n\nconst readable = Readable.from(dataBuffer);\nconst data = await bytes(readable);\nconsole.log(`from readable: ${data.length}`);\n// Prints: from readable: 27"},{"language":"cjs","displayName":null,"code":"const { bytes } = require('node:stream/consumers');\nconst { Readable } = require('node:stream');\nconst { Buffer } = require('node:buffer');\n\nconst dataBuffer = Buffer.from('hello world from consumers!');\n\nconst readable = Readable.from(dataBuffer);\nbytes(readable).then((data) => {\n  console.log(`from readable: ${data.length}`);\n  // Prints: from readable: 27\n});"}],"children":[]},{"kind":"method","id":"streamconsumersjsonstream","name":"json","title":"`streamConsumers.json(stream)`","scope":"module","overloadOf":null,"stability":null,"added":["v16.7.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"stream","type":{"text":"ReadableStream | stream.Readable | AsyncIterator","links":[{"name":"ReadableStream","href":"webstreams.html#class-readablestream","start":0,"end":14},{"name":"stream.Readable","href":"stream.html#class-streamreadable","start":17,"end":32},{"name":"AsyncIterator","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/AsyncIterator","start":35,"end":48}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with the contents of the stream parsed as a\nUTF-8 encoded string that is then passed through `JSON.parse()`."}},"description":"```mjs\nimport { json } from 'node:stream/consumers';\nimport { Readable } from 'node:stream';\n\nconst items = Array.from(\n  {\n    length: 100,\n  },\n  () => ({\n    message: 'hello world from consumers!',\n  }),\n);\n\nconst readable = Readable.from(JSON.stringify(items));\nconst data = await json(readable);\nconsole.log(`from readable: ${data.length}`);\n// Prints: from readable: 100\n```\n\n```cjs\nconst { json } = require('node:stream/consumers');\nconst { Readable } = require('node:stream');\n\nconst items = Array.from(\n  {\n    length: 100,\n  },\n  () => ({\n    message: 'hello world from consumers!',\n  }),\n);\n\nconst readable = Readable.from(JSON.stringify(items));\njson(readable).then((data) => {\n  console.log(`from readable: ${data.length}`);\n  // Prints: from readable: 100\n});\n```","summary":"","examples":[{"language":"mjs","displayName":null,"code":"import { json } from 'node:stream/consumers';\nimport { Readable } from 'node:stream';\n\nconst items = Array.from(\n  {\n    length: 100,\n  },\n  () => ({\n    message: 'hello world from consumers!',\n  }),\n);\n\nconst readable = Readable.from(JSON.stringify(items));\nconst data = await json(readable);\nconsole.log(`from readable: ${data.length}`);\n// Prints: from readable: 100"},{"language":"cjs","displayName":null,"code":"const { json } = require('node:stream/consumers');\nconst { Readable } = require('node:stream');\n\nconst items = Array.from(\n  {\n    length: 100,\n  },\n  () => ({\n    message: 'hello world from consumers!',\n  }),\n);\n\nconst readable = Readable.from(JSON.stringify(items));\njson(readable).then((data) => {\n  console.log(`from readable: ${data.length}`);\n  // Prints: from readable: 100\n});"}],"children":[]},{"kind":"method","id":"streamconsumerstextstream","name":"text","title":"`streamConsumers.text(stream)`","scope":"module","overloadOf":null,"stability":null,"added":["v16.7.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"stream","type":{"text":"ReadableStream | stream.Readable | AsyncIterator","links":[{"name":"ReadableStream","href":"webstreams.html#class-readablestream","start":0,"end":14},{"name":"stream.Readable","href":"stream.html#class-streamreadable","start":17,"end":32},{"name":"AsyncIterator","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/AsyncIterator","start":35,"end":48}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with the contents of the stream parsed as a\nUTF-8 encoded string."}},"description":"```mjs\nimport { text } from 'node:stream/consumers';\nimport { Readable } from 'node:stream';\n\nconst readable = Readable.from('Hello world from consumers!');\nconst data = await text(readable);\nconsole.log(`from readable: ${data.length}`);\n// Prints: from readable: 27\n```\n\n```cjs\nconst { text } = require('node:stream/consumers');\nconst { Readable } = require('node:stream');\n\nconst readable = Readable.from('Hello world from consumers!');\ntext(readable).then((data) => {\n  console.log(`from readable: ${data.length}`);\n  // Prints: from readable: 27\n});\n```","summary":"","examples":[{"language":"mjs","displayName":null,"code":"import { text } from 'node:stream/consumers';\nimport { Readable } from 'node:stream';\n\nconst readable = Readable.from('Hello world from consumers!');\nconst data = await text(readable);\nconsole.log(`from readable: ${data.length}`);\n// Prints: from readable: 27"},{"language":"cjs","displayName":null,"code":"const { text } = require('node:stream/consumers');\nconst { Readable } = require('node:stream');\n\nconst readable = Readable.from('Hello world from consumers!');\ntext(readable).then((data) => {\n  console.log(`from readable: ${data.length}`);\n  // Prints: from readable: 27\n});"}],"children":[]}]}]}]}