bare-stream provides a lightweight and performant abstraction for handling streaming data in JavaScript environments, building upon the well-established `streamx` API. It is currently at version 2.13.0, with regular updates indicated by recent minor version bumps, suggesting an active development cadence. The "bare" prefix implies a focus on minimal overhead and core functionality, making it suitable for environments where resource efficiency is critical, such as low-resource servers or specialized applications. Unlike Node.js's built-in streams, bare-stream aims for broader compatibility and a more streamlined API, leveraging the `streamx` pattern. Its primary differentiator is its minimal dependency footprint and its explicit design for efficient data flow, providing a robust foundation for implementing custom streaming logic without the overhead of larger alternatives.
npm install bare-streamVerified import paths — ran on the pinned version, not inferred.
This example demonstrates creating a basic streaming pipeline using `bare-stream`. It shows a `Readable` stream generating data, a `Transform` stream processing it, and a `Writable` stream consuming and logging the final output, including basic error handling.
Consult the `streamx` documentation for precise API details and migration guides. Be mindful of differences in `highWaterMark` behavior and `_read` implementation.
Upgrade to `bare-stream@2.13.0` or higher to leverage improved Web TransformStream compatibility. Thoroughly test stream implementations in target browser environments.
Always attach an 'error' event listener to every stream in your pipeline. For complex pipelines, consider using `pipeline` from 'node:stream/promises' (or a compatible utility) for automatic error propagation and resource cleanup.
Ensure your custom `_read` and `_write` implementations correctly respect the `callback` argument. For `Readable` streams, `_read` should only push data when `push` returns `true` or when explicitly called after a `_read` trigger. For `Writable` streams, `callback` should be invoked only after the chunk is fully processed.
Ensure that the object you are calling `.pipe()` on is an instance of `bare-stream.Readable` or `bare-stream.Transform`. Verify imports and constructor calls.
Check your logic for when data is being written to the stream. Ensure that no `write()` calls occur after `stream.end()` or after `this.push(null)` in a `Transform` stream, unless specifically designed for that behavior.
Add `import { Readable } from 'bare-stream'` (for ESM) or `const { Readable } = require('bare-stream')` (for CJS) at the top of your file to make the class available.