Skip to content

Commit fae47fe

Browse files
committed
refactor: remove the need to push char by chare
1 parent 1a48c4a commit fae47fe

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const res = await axios.get('streaming-json-endpoint', {
2828
const stream = res.data;
2929

3030
stream.on('data', chunk => {
31-
queue.push(...chunk); // push character by character, very important
31+
queue.push(chunk);
3232
// current gets name and description properties dynamically populated as more chunks are received.
3333
const current = await jsonStream.resolve();
3434
});

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class JsonParser<T> {
3939
#stream: Promise<JSONStreamResult<JSONStreamValue>>;
4040

4141
constructor(queue: Queue<string>) {
42-
this.queue = queue;
42+
this.queue = queue.pipe(r => [...r]).flat();
4343
this.#stream = this.parseValue();
4444
}
4545

0 commit comments

Comments
 (0)