You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: AGENTS.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,7 +40,7 @@ stream-chain/
40
40
│ ├── defs.d.ts # TypeScript definitions for defs
41
41
│ ├── gen.js # Creates async generator pipeline from functions
42
42
│ ├── 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)
44
44
│ ├── fun.d.ts # TypeScript definitions for fun
45
45
│ ├── asStream.js # Converts a function into a Duplex stream
46
46
│ ├── asStream.d.ts # TypeScript definitions for asStream
@@ -95,7 +95,7 @@ stream-chain/
95
95
-`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.
96
96
- Functions in the chain are grouped together using `gen()` for efficiency (unless `noGrouping: true`).
97
97
-`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.
99
99
-`asStream(fn)` wraps any function as a `Duplex` stream.
100
100
- 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).
101
101
- Web streams (`ReadableStream`, `WritableStream`, duplex `{readable, writable}`) are automatically adapted to Node streams.
Copy file name to clipboardExpand all lines: ARCHITECTURE.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ src/ # Source code
13
13
├── defs.d.ts # TypeScript declarations for defs
14
14
├── gen.js # Async generator pipeline from a list of functions
15
15
├── 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)
17
17
├── fun.d.ts # TypeScript declarations for fun
18
18
├── asStream.js # Wraps any function as a Duplex stream
19
19
├── asStream.d.ts # TypeScript declarations for asStream
@@ -84,9 +84,9 @@ Functions in a chain can return special values to control flow:
84
84
4. Calls flushable functions with `none` when the input is exhausted.
85
85
5. Tags the result with a function list (`fListSymbol`) so `chain()` can inline it.
86
86
87
-
### fun() — async function pipeline
87
+
### fun() — function pipeline (sync-first)
88
88
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`.
Copy file name to clipboardExpand all lines: dev-docs/underlying-ideas.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -80,7 +80,7 @@ Core ideas:
80
80
- A pipeline is an array of processing units applied sequentially.
81
81
- Each unit can be a function (sync/async), a generator (sync/async), a stream (Node or Web), or another pipeline.
82
82
- 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.
84
84
-`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.
85
85
-`asStream()` wraps any function as a Duplex stream.
Copy file name to clipboardExpand all lines: llms-full.txt
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -261,7 +261,7 @@ for await (const v of pipeline(3)) {
261
261
262
262
## fun(...fns)
263
263
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()`).
0 commit comments