---
url: >-
  https://adk.nht.io/api/@nhtio/adk/batteries/llm/claude_code_cli/wire/functions/createNdjsonLineReader.md
---

# Function: createNdjsonLineReader()

```ts
function createNdjsonLineReader<T>(
  onLine: (raw: string) => T | undefined,
  opts?: {
    maxLineBytes?: number;
  },
): {
  end: void;
  push: void;
};
```

Defined in: [src/batteries/llm/claude\_code\_cli/wire.ts:308](https://github.com/NHTIO/ADK/blob/v1.20260827.0/src/src/batteries/llm/claude_code_cli/wire.ts#L308)

Create an incremental, byte-oriented NDJSON line reader. Generalizes
`local_diffusion/protocol.ts`'s `createFrameReader` discipline (bounded memory via a hard
`maxLineBytes` cap enforced while consuming, fatal-UTF8-decode, malformed-line-is-non-fatal) for
pure JSON-per-line framing with no tag-prefixed grammar. `onLine` receives each decoded line and
returns the parsed value, or `undefined` for a line that failed to parse — the reader itself
never throws and never classifies content, it only frames bytes into lines.

## Type Parameters

| Type Parameter |
| -------------- |
| `T`            |

## Parameters

| Parameter            | Type                                    |
| -------------------- | --------------------------------------- |
| `onLine`             | (`raw`: `string`) => `T` | `undefined` |
| `opts?`              | { `maxLineBytes?`: `number`; }        |
| `opts.maxLineBytes?` | `number`                                |

## Returns

```ts
{
  end: void;
  push: void;
}
```

| Name     | Type                              | Defined in                                                                                                                                          |
| -------- | --------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| `end()`  | () => `void`                      | [src/batteries/llm/claude\_code\_cli/wire.ts:311](https://github.com/NHTIO/ADK/blob/v1.20260827.0/src/src/batteries/llm/claude_code_cli/wire.ts#L311) |
| `push()` | (`chunk`: `Uint8Array`) => `void` | [src/batteries/llm/claude\_code\_cli/wire.ts:311](https://github.com/NHTIO/ADK/blob/v1.20260827.0/src/src/batteries/llm/claude_code_cli/wire.ts#L311) |

## Throws

RangeError if `maxLineBytes` is provided but is not a positive, finite, safe integer.
