it-pipe is a JavaScript/TypeScript utility for composing asynchronous iterables into pipelines, simplifying stream processing in Node.js and browser environments. The library, currently at version 3.0.1, maintains an active release cadence with recent updates in early 2023. Its core `pipe` function efficiently connects sources, transforms, and sinks, automatically wrapping initial iterable sources into functions as needed. A key differentiator for `it-pipe` is its explicit support for duplex streams, enabling more complex bidirectional data flows. It leverages the `it-` ecosystem pattern for async iterables, offering a robust and type-safe solution for orchestrating sequential asynchronous operations. This package requires Node.js version 16 or newer.
npm install it-pipeVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `it-pipe` to chain an iterable source, an asynchronous transform function, and an asynchronous sink function, showcasing both number and string processing pipelines.
Ensure your code correctly handles both Promise and direct return values from `pipe` when dealing with potentially synchronous pipelines. Await the result if unsure, as `await` handles both synchronously resolved values and Promises.
Update all imports from `const pipe = require('it-pipe')` to `import { pipe } from 'it-pipe'`. Ensure your project is configured to handle ES Modules (e.g., `"type": "module"` in `package.json` for Node.js, or using a bundler for browsers).Review TypeScript usage and adjust type annotations as necessary, especially for source, transform, and sink functions, which now benefit from explicit `AsyncIterable<T>` typing.
Implement `try...catch` blocks within your async generator functions and async functions used as transforms and sinks to gracefully handle errors and either re-throw them or manage them appropriately to prevent pipeline stalls or unhandled promise rejections.
Change your import statement from `const pipe = require('it-pipe')` to `import { pipe } from 'it-pipe'`. If in a browser, ensure you are using a bundler that handles ESM, or load via a script tag (e.g., `<script src="https://unpkg.com/it-pipe/dist/index.min.js"></script>`).Ensure you are using named import syntax: `import { pipe } from 'it-pipe'`. If using CommonJS, which is not supported since v2.0.0, migrate to ESM.Explicitly type your asynchronous generators and functions to return `AsyncIterable<T>` or `Promise<AsyncIterable<T>>` for sources and transforms, and `Promise<R>` for sinks, where `T` is the type of the yielded elements and `R` is the final return type of the sink.
No dependency data recorded yet.