Ensure that the length property won't be *accidentally* accessed on a DecodeStream-instance

For these streams, compared to `Stream` and `ChunkedStream`, there's no well defined concept of length and consequently no `length` getter.[1] However, attempting to access the non-existent `length` won't currently error, but just return `undefined`, which could thus easily lead to bugs elsewhere in the code-base.

---
[1] However, note that *all* stream implementations have an `isEmpty` getter which can be used instead.
This commit is contained in:
Jonas Jenwald 2020-09-11 13:11:40 +02:00
parent aef3fedc29
commit a11b7341a1

View File

@ -167,6 +167,11 @@ var DecodeStream = (function DecodeStreamClosure() {
}
DecodeStream.prototype = {
// eslint-disable-next-line getter-return
get length() {
unreachable("Should not access DecodeStream.length");
},
get isEmpty() {
while (!this.eof && this.bufferLength === 0) {
this.readBlock();