diff --git a/lib/streams.ts b/lib/streams.ts index 2de7e7b798..99aa9abfab 100644 --- a/lib/streams.ts +++ b/lib/streams.ts @@ -248,7 +248,7 @@ export class ReadStream { byteCount = null; } await this.loadIntoBuffer(byteCount, true); - const out = this.peek(byteCount, encoding) as string | null; + const out = await this.peek(byteCount, encoding); if (byteCount === null || byteCount >= this.bufSize) { this.bufStart = 0; this.bufEnd = 0; @@ -260,7 +260,7 @@ export class ReadStream { async readBuffer(byteCount: number | null = null) { await this.loadIntoBuffer(byteCount, true); - const out = this.peekBuffer(byteCount); + const out = await this.peekBuffer(byteCount); if (byteCount === null || byteCount >= this.bufSize) { this.bufStart = 0; this.bufEnd = 0; @@ -650,6 +650,8 @@ export class ObjectReadStream { return this._destroy(); } + // eslint-disable-next-line no-restricted-globals + [Symbol.asyncIterator]() { return this; } async next() { const value = await this.read(); return {value, done: value === null};