Skip to content

Commit

Permalink
fix: only overwrite source if readbuffer has bytes (#105)
Browse files Browse the repository at this point in the history
There is no need to overwrite the source property of the passed
duplex if the readbuffer is empty.
  • Loading branch information
achingbrain committed Nov 20, 2023
1 parent 8c515f4 commit bc61c9a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/it-byte-stream/src/index.ts
Expand Up @@ -152,11 +152,13 @@ export function byteStream <Stream extends Duplex<any, any, any>> (duplex: Strea
}
},
unwrap: () => {
const originalStream = duplex.source
duplex.source = (async function * () {
yield * readBuffer
yield * originalStream
}())
if (readBuffer.byteLength > 0) {
const originalStream = duplex.source
duplex.source = (async function * () {
yield * readBuffer
yield * originalStream
}())
}

return duplex
}
Expand Down

0 comments on commit bc61c9a

Please sign in to comment.