Skip to content

Commit

Permalink
Fix error in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Faleij committed Mar 9, 2024
1 parent cbdcf88 commit ec71d61
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "json-stream-stringify",
"description": "JSON.Stringify as a readable stream",
"version": "3.1.2",
"version": "3.1.3",
"license": "MIT",
"author": "Faleij <[email protected]> (https://github.com/faleij)",
"repository": {
Expand Down Expand Up @@ -71,7 +71,7 @@
"typescript": "^4.7.4"
},
"volta": {
"node": "18.16.0"
"node": "16.20.2"
},
"engines": {
"node": ">=7.10.1"
Expand Down
4 changes: 3 additions & 1 deletion src/JsonStreamStringify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,11 +494,12 @@ export class JsonStreamStringify extends Readable {
this.readState = ReadState.Reading;
this.pushCalled = false;
let p;
while (!this.pushCalled && this.item !== this.root && !this.destroyed) {
while (!this.pushCalled && this.item !== this.root && this.buffer !== undefined) {
p = this.item.read(size);
// eslint-disable-next-line no-await-in-loop
if (p) await p;
}
if (this.buffer === undefined) return;
if (this.item === this.root) {
if (this.buffer.length) this.push(this.buffer);
this.push(null);
Expand All @@ -513,6 +514,7 @@ export class JsonStreamStringify extends Readable {
}

private cleanup() {
this.readState = ReadState.Consumed;
this.buffer = undefined;
this.visited = undefined;
this.item = undefined;
Expand Down

0 comments on commit ec71d61

Please sign in to comment.