Web Stream Tools (available as `@openpgp/web-stream-tools` on npm) is a JavaScript utility library designed to simplify working with WhatWG Streams. It provides a comprehensive set of functions for common stream operations, including reading to completion (`readToEnd`), concatenating streams (`concat`), slicing parts of streams (`slice`), cloning streams (`clone`), and facilitating conversion between Node.js streams and Web Streams (`webToNode`, `nodeToWeb`). The library also features advanced capabilities for transforming stream data, either directly (`transform`) or in chunks with backpressure handling (`transformPair`), and for parsing structured data from streams (`parse`) with functions like `readByte`, `readBytes`, and `readLine`. The current stable version is 0.3.0. Developed by the OpenPGP.js team, it maintains an active development status, with updates generally released as needed. A key differentiator is its explicit focus on the WhatWG Streams API, providing a consistent interface across browser and modern Node.js environments, streamlining complex stream manipulations that often involve manual reader/writer management.
npm install web-stream-toolsVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to use the `stream.transform` function to encrypt data flowing through a WhatWG ReadableStream, including setup for an imaginary encryptor and reading the output.
Update your `package.json` dependencies and all import statements in your code from `web-stream-tools` to `@openpgp/web-stream-tools`.
For Node.js environments, ensure you are using Node.js v17+ which provides built-in utilities like `Readable.toWeb()` for converting native Node streams to Web Streams, or `Readable.fromWeb()` for the reverse. Alternatively, transform your data into `Uint8Array` or `String` before passing to functions like `transform` if stream-to-stream conversion is not feasible.
Always prefer `import * as stream from '@openpgp/web-stream-tools';` or named imports in ES Modules. If CommonJS is strictly required, ensure your build tool (e.g., Webpack, Rollup) or Node.js configuration (e.g., `"type": "module"` in `package.json`) handles ESM to CJS interoperability correctly.
Change the dependency in `package.json` and all import paths in your code to `@openpgp/web-stream-tools`.
Ensure you are using `import * as stream from '@openpgp/web-stream-tools';` (for namespace import) or `import { transform } from '@openpgp/web-stream-tools';` (for named import).If in Node.js v17+, convert your Node stream using `myNodeStream.toWeb()` before passing it to `web-stream-tools` functions. For older Node.js versions, you may need to manually wrap the Node stream or use a polyfill.
No dependency data recorded yet.