Skip to content

Commit

Permalink
Fix: Readable Stream read 16,384 objects (#42)
Browse files Browse the repository at this point in the history
* Fix: Readable Stream read 16,384 objects in ObjectMode #41

---------

Co-authored-by: Vyacheslav Skakun <[email protected]>
  • Loading branch information
SlavikPr and Vyacheslav Skakun authored Mar 30, 2024
1 parent ec71d61 commit 1555b22
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/JsonStreamStringify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ function quoteString(string: string) {
return str;
}

function readAsPromised(stream, size) {
function readAsPromised(stream, size?) {
const value = stream.read(size);
if (value === null) {
return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -327,10 +327,10 @@ export class JsonStreamStringify extends Readable {
let i = 0;
const item = <any>{
type: 'readable object',
async read(size: number) {
async read() {
try {
let out = '';
const data = await readAsPromised(input, size);
const data = await readAsPromised(input);
if (data === null) {
if (i && that.indent) {
out += `\n${parent.indent}`;
Expand Down

0 comments on commit 1555b22

Please sign in to comment.