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
@@ -88,7 +90,15 @@ You can pass `reviver` either as the second argument (`parseChunked(input, reviv
88
90
89
91
`options.onRootValue` is called when a root value is parsed and finalized. When `onRootValue` is specified, `parseChunked()` resolves to the number of processed root values (instead of returning parsed value(s)), which allows processing huge or infinite streams without accumulating all values in memory.
90
92
91
-
`options.onChunk` is called after each input chunk is processed and once at the end with `chunk = null`. It provides parsing progress and parser state (`consumed`, `parsed`, current mode and root values count).
93
+
`options.onChunk` is called after each input chunk is processed and once at the end with `chunk = null`. It provides parsing progress and parser state as chunks are processed.
94
+
95
+
The `state` object passed to `onRootValue` and `onChunk` callbacks has the following properties:
96
+
- `consumed` – number of characters consumed so far
97
+
- `parsed` – number of characters parsed so far (not necessarily the same when a chunk ends in the middle of a token)
98
+
- `mode` – current parsing mode (`json` or `jsonl`)
99
+
- `rootValuesCount` – number of root values parsed so far
100
+
- `currentRootValue` – current root value being parsed
101
+
- `returnValue` – current return value state, i.e. what `parseChunked()` will return when finished (either the parsed value or the number of root values, depending on whether `onRootValue` is specified)
0 commit comments