AI Summary<!-- Canonical source: AGENTS.md — keep this file in sync --> stream-chain creates a chain of streams out of regular functions, asynchronous functions, generators, and existing streams, while properly handling backpressure. The result is a Duplex stream. It is a lightweight, zero-dependency micro-pa
Install
Copy this and paste it into Claude Code, Cursor, or any AI assistant:
I want to add the "stream-chain — Windsurf Rules" prompt rules to my project. Repository: https://github.com/uhop/stream-chain Please read the repo to find the rules/prompt file, then: 1. Download it to the correct location (.cursorrules, .windsurfrules, .github/prompts/, or project root — based on the file type) 2. If there's an existing rules file, merge the new rules in rather than overwriting 3. Confirm what was added
Description
Chain functions, generators, and streams into a pipeline with backpressure support.
Project identity
stream-chain creates a chain of streams out of regular functions, asynchronous functions, generators, and existing streams, while properly handling backpressure. The result is a Duplex stream. It is a lightweight, zero-dependency micro-package. The npm package name is stream-chain. Internal symbols use Symbol.for('object-stream.*').
Critical rules
• CommonJS. The project is "type": "commonjs". Use require() in source, import in tests (.mjs/.mts). • No transpilation. Code runs directly. • No runtime dependencies. Never add packages to dependencies. Only devDependencies are allowed. • Do not modify or delete test expectations without understanding why they changed. • Do not add comments or remove comments unless explicitly asked. • Keep src/index.js and src/index.d.ts in sync. All public API is exported from index.js and typed in index.d.ts. • Keep .js and .d.ts files in sync for all modules under src/. • Object mode by default. chain() defaults to {writableObjectMode: true, readableObjectMode: true}. • Backpressure must be handled correctly. This is a core concern of the library.
Code style
• Prettier: 100 char width, single quotes, no bracket spacing, no trailing commas, arrow parens "avoid" (see .prettierrc). • 2-space indentation. • Semicolons are enforced by Prettier (default semi: true).
Architecture quick reference
• chain(fns, options) is the main entry point. Accepts array of functions, streams, or arrays (flattened). Returns a Duplex with .streams, .input, .output. • Functions are grouped via gen() for efficiency (unless noGrouping: true). • gen(...fns) creates an async generator pipeline. Handles none, stop, many(), finalValue(), flushable. • fun(...fns) is like gen() but returns an async function. • asStream(fn) wraps any function as a Duplex stream. • Special values in defs.js: none (skip), stop (terminate), many(values) (emit multiple), finalValue(value) (skip rest), flushable(fn) (called at end). • Web streams are automatically adapted to Node streams. • JSONL support in src/jsonl/ — parser and stringer. • Utilities in src/utils/ — take, skip, fold, scan, batch, lines, etc.
Discussion
Health Signals
My Fox Den
Community Rating
Sign in to rate this booster
Works With
Any AI assistant that accepts custom rules or system prompts