Skip to content

Commit f4eb250

Browse files
committed
Updated docs.
1 parent aa8949d commit f4eb250

6 files changed

Lines changed: 10 additions & 11 deletions

File tree

AGENTS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ stream-chain/
4040
│ ├── defs.d.ts # TypeScript definitions for defs
4141
│ ├── gen.js # Creates async generator pipeline from functions
4242
│ ├── gen.d.ts # TypeScript definitions for gen
43-
│ ├── fun.js # Creates async function pipeline from functions
43+
│ ├── fun.js # Creates function pipeline from functions (sync-first)
4444
│ ├── fun.d.ts # TypeScript definitions for fun
4545
│ ├── asStream.js # Converts a function into a Duplex stream
4646
│ ├── asStream.d.ts # TypeScript definitions for asStream
@@ -95,7 +95,7 @@ stream-chain/
9595
- `chain(fns, options)` is the main entry point. It accepts an array of functions, streams, or arrays (which are flattened). Returns a `Duplex` stream with `.streams`, `.input`, `.output` properties.
9696
- Functions in the chain are grouped together using `gen()` for efficiency (unless `noGrouping: true`).
9797
- `gen(...fns)` creates an async generator pipeline from a list of functions. It handles all special return values (`none`, `stop`, `many()`, `finalValue()`, flushable functions).
98-
- `fun(...fns)` is like `gen()` but returns an async function instead of a generator.
98+
- `fun(...fns)` is like `gen()` but returns a function instead of a generator. Returns sync results for sync pipelines, `Promise` for async.
9999
- `asStream(fn)` wraps any function as a `Duplex` stream.
100100
- Special return values are defined in `defs.js`: `none` (skip), `stop` (terminate), `many(values)` (emit multiple), `finalValue(value)` (skip rest of chain), `flushable(fn)` (called at stream end).
101101
- Web streams (`ReadableStream`, `WritableStream`, duplex `{readable, writable}`) are automatically adapted to Node streams.

ARCHITECTURE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ src/ # Source code
1313
├── defs.d.ts # TypeScript declarations for defs
1414
├── gen.js # Async generator pipeline from a list of functions
1515
├── gen.d.ts # TypeScript declarations for gen
16-
├── fun.js # Async function pipeline from a list of functions
16+
├── fun.js # Function pipeline from a list of functions (sync-first)
1717
├── fun.d.ts # TypeScript declarations for fun
1818
├── asStream.js # Wraps any function as a Duplex stream
1919
├── asStream.d.ts # TypeScript declarations for asStream
@@ -84,9 +84,9 @@ Functions in a chain can return special values to control flow:
8484
4. Calls flushable functions with `none` when the input is exhausted.
8585
5. Tags the result with a function list (`fListSymbol`) so `chain()` can inline it.
8686

87-
### fun() — async function pipeline
87+
### fun() — function pipeline (sync-first)
8888

89-
`fun(...fns)` is like `gen()` but returns an async function instead of a generator. Generator results are collected into `many()` arrays.
89+
`fun(...fns)` is like `gen()` but returns a function instead of a generator. Generator results are collected into `many()` arrays. For purely synchronous pipelines it returns a synchronous result; for asynchronous pipelines it returns a `Promise`.
9090

9191
### asStream() — function to Duplex
9292

dev-docs/underlying-ideas.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Core ideas:
8080
- A pipeline is an array of processing units applied sequentially.
8181
- Each unit can be a function (sync/async), a generator (sync/async), a stream (Node or Web), or another pipeline.
8282
- Functional sub-pipelines group consecutive functions without stream overhead:
83-
- `fun()` — takes a list of functions, returns an async function. Handles `none`, `stop`, `many()`, and `finalValue()` returns.
83+
- `fun()` — takes a list of functions, returns a function (sync-first: returns sync results for sync pipelines, `Promise` for async). Handles `none`, `stop`, `many()`, and `finalValue()` returns.
8484
- `gen()` — takes a list of functions, returns an async generator. It handles `none`, `many()`, and other special values internally, but never produces them — a generator naturally yields zero, one, or many values.
8585
- `asStream()` wraps any function as a Duplex stream.
8686

llms-full.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ for await (const v of pipeline(3)) {
261261

262262
## fun(...fns)
263263

264-
Like `gen()` but returns an async function. Values from generators are collected into `many()` arrays. Like `gen()`, passes `null`/`undefined` through the pipeline (unlike `asStream()`/`chain()`).
264+
Like `gen()` but returns a function instead of a generator. Values from generators are collected into `many()` arrays. For purely synchronous pipelines it returns a synchronous result; for asynchronous pipelines it returns a `Promise`. Like `gen()`, passes `null`/`undefined` through the pipeline (unlike `asStream()`/`chain()`).
265265

266266
```js
267267
import fun from 'stream-chain/fun.js';

src/fun.d.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@ export = fun;
99
declare function fun(): (arg: unknown) => Many<unknown> | Promise<Many<unknown>>;
1010

1111
/**
12-
* Returns a function that applies the given functions in sequence wrapping them as
13-
* an asynchronous function.
12+
* Returns a function that applies the given functions in sequence.
1413
* @param fns functions to be wrapped
15-
* @returns an asynchronous function
14+
* @returns a function that returns a synchronous result or a `Promise`
1615
* @remarks It collects values and returns them as a {@link Many}.
1716
*/
1817
declare function fun<L extends unknown[]>(

wiki

Submodule wiki updated from fcf15fa to 2799443

0 commit comments

Comments
 (0)