Enable the no-var
rule in the src/core/decode_stream.js
file
This commit is contained in:
parent
30a22a168d
commit
8ce2cae4a7
@ -12,18 +12,17 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
/* eslint-disable no-var */
|
|
||||||
|
|
||||||
import { Stream } from "./stream.js";
|
import { Stream } from "./stream.js";
|
||||||
import { unreachable } from "../shared/util.js";
|
import { unreachable } from "../shared/util.js";
|
||||||
|
|
||||||
// super class for the decoding streams
|
// super class for the decoding streams
|
||||||
var DecodeStream = (function DecodeStreamClosure() {
|
const DecodeStream = (function DecodeStreamClosure() {
|
||||||
// Lots of DecodeStreams are created whose buffers are never used. For these
|
// Lots of DecodeStreams are created whose buffers are never used. For these
|
||||||
// we share a single empty buffer. This is (a) space-efficient and (b) avoids
|
// we share a single empty buffer. This is (a) space-efficient and (b) avoids
|
||||||
// having special cases that would be required if we used |null| for an empty
|
// having special cases that would be required if we used |null| for an empty
|
||||||
// buffer.
|
// buffer.
|
||||||
var emptyBuffer = new Uint8Array(0);
|
const emptyBuffer = new Uint8Array(0);
|
||||||
|
|
||||||
// eslint-disable-next-line no-shadow
|
// eslint-disable-next-line no-shadow
|
||||||
function DecodeStream(maybeMinBufferLength) {
|
function DecodeStream(maybeMinBufferLength) {
|
||||||
@ -55,20 +54,20 @@ var DecodeStream = (function DecodeStreamClosure() {
|
|||||||
return this.bufferLength === 0;
|
return this.bufferLength === 0;
|
||||||
},
|
},
|
||||||
ensureBuffer: function DecodeStream_ensureBuffer(requested) {
|
ensureBuffer: function DecodeStream_ensureBuffer(requested) {
|
||||||
var buffer = this.buffer;
|
const buffer = this.buffer;
|
||||||
if (requested <= buffer.byteLength) {
|
if (requested <= buffer.byteLength) {
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
var size = this.minBufferLength;
|
let size = this.minBufferLength;
|
||||||
while (size < requested) {
|
while (size < requested) {
|
||||||
size *= 2;
|
size *= 2;
|
||||||
}
|
}
|
||||||
var buffer2 = new Uint8Array(size);
|
const buffer2 = new Uint8Array(size);
|
||||||
buffer2.set(buffer);
|
buffer2.set(buffer);
|
||||||
return (this.buffer = buffer2);
|
return (this.buffer = buffer2);
|
||||||
},
|
},
|
||||||
getByte: function DecodeStream_getByte() {
|
getByte: function DecodeStream_getByte() {
|
||||||
var pos = this.pos;
|
const pos = this.pos;
|
||||||
while (this.bufferLength <= pos) {
|
while (this.bufferLength <= pos) {
|
||||||
if (this.eof) {
|
if (this.eof) {
|
||||||
return -1;
|
return -1;
|
||||||
@ -78,23 +77,23 @@ var DecodeStream = (function DecodeStreamClosure() {
|
|||||||
return this.buffer[this.pos++];
|
return this.buffer[this.pos++];
|
||||||
},
|
},
|
||||||
getUint16: function DecodeStream_getUint16() {
|
getUint16: function DecodeStream_getUint16() {
|
||||||
var b0 = this.getByte();
|
const b0 = this.getByte();
|
||||||
var b1 = this.getByte();
|
const b1 = this.getByte();
|
||||||
if (b0 === -1 || b1 === -1) {
|
if (b0 === -1 || b1 === -1) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return (b0 << 8) + b1;
|
return (b0 << 8) + b1;
|
||||||
},
|
},
|
||||||
getInt32: function DecodeStream_getInt32() {
|
getInt32: function DecodeStream_getInt32() {
|
||||||
var b0 = this.getByte();
|
const b0 = this.getByte();
|
||||||
var b1 = this.getByte();
|
const b1 = this.getByte();
|
||||||
var b2 = this.getByte();
|
const b2 = this.getByte();
|
||||||
var b3 = this.getByte();
|
const b3 = this.getByte();
|
||||||
return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
|
return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
|
||||||
},
|
},
|
||||||
getBytes(length, forceClamped = false) {
|
getBytes(length, forceClamped = false) {
|
||||||
var end,
|
const pos = this.pos;
|
||||||
pos = this.pos;
|
let end;
|
||||||
|
|
||||||
if (length) {
|
if (length) {
|
||||||
this.ensureBuffer(pos + length);
|
this.ensureBuffer(pos + length);
|
||||||
@ -103,7 +102,7 @@ var DecodeStream = (function DecodeStreamClosure() {
|
|||||||
while (!this.eof && this.bufferLength < end) {
|
while (!this.eof && this.bufferLength < end) {
|
||||||
this.readBlock();
|
this.readBlock();
|
||||||
}
|
}
|
||||||
var bufEnd = this.bufferLength;
|
const bufEnd = this.bufferLength;
|
||||||
if (end > bufEnd) {
|
if (end > bufEnd) {
|
||||||
end = bufEnd;
|
end = bufEnd;
|
||||||
}
|
}
|
||||||
@ -122,14 +121,14 @@ var DecodeStream = (function DecodeStreamClosure() {
|
|||||||
: subarray;
|
: subarray;
|
||||||
},
|
},
|
||||||
peekByte: function DecodeStream_peekByte() {
|
peekByte: function DecodeStream_peekByte() {
|
||||||
var peekedByte = this.getByte();
|
const peekedByte = this.getByte();
|
||||||
if (peekedByte !== -1) {
|
if (peekedByte !== -1) {
|
||||||
this.pos--;
|
this.pos--;
|
||||||
}
|
}
|
||||||
return peekedByte;
|
return peekedByte;
|
||||||
},
|
},
|
||||||
peekBytes(length, forceClamped = false) {
|
peekBytes(length, forceClamped = false) {
|
||||||
var bytes = this.getBytes(length, forceClamped);
|
const bytes = this.getBytes(length, forceClamped);
|
||||||
this.pos -= bytes.length;
|
this.pos -= bytes.length;
|
||||||
return bytes;
|
return bytes;
|
||||||
},
|
},
|
||||||
@ -139,7 +138,7 @@ var DecodeStream = (function DecodeStreamClosure() {
|
|||||||
this.readBlock();
|
this.readBlock();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var end = start + length;
|
const end = start + length;
|
||||||
while (this.bufferLength <= end && !this.eof) {
|
while (this.bufferLength <= end && !this.eof) {
|
||||||
this.readBlock();
|
this.readBlock();
|
||||||
}
|
}
|
||||||
@ -171,7 +170,7 @@ var DecodeStream = (function DecodeStreamClosure() {
|
|||||||
return DecodeStream;
|
return DecodeStream;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
var StreamsSequenceStream = (function StreamsSequenceStreamClosure() {
|
const StreamsSequenceStream = (function StreamsSequenceStreamClosure() {
|
||||||
// eslint-disable-next-line no-shadow
|
// eslint-disable-next-line no-shadow
|
||||||
function StreamsSequenceStream(streams) {
|
function StreamsSequenceStream(streams) {
|
||||||
this.streams = streams;
|
this.streams = streams;
|
||||||
@ -191,24 +190,24 @@ var StreamsSequenceStream = (function StreamsSequenceStreamClosure() {
|
|||||||
StreamsSequenceStream.prototype = Object.create(DecodeStream.prototype);
|
StreamsSequenceStream.prototype = Object.create(DecodeStream.prototype);
|
||||||
|
|
||||||
StreamsSequenceStream.prototype.readBlock = function streamSequenceStreamReadBlock() {
|
StreamsSequenceStream.prototype.readBlock = function streamSequenceStreamReadBlock() {
|
||||||
var streams = this.streams;
|
const streams = this.streams;
|
||||||
if (streams.length === 0) {
|
if (streams.length === 0) {
|
||||||
this.eof = true;
|
this.eof = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var stream = streams.shift();
|
const stream = streams.shift();
|
||||||
var chunk = stream.getBytes();
|
const chunk = stream.getBytes();
|
||||||
var bufferLength = this.bufferLength;
|
const bufferLength = this.bufferLength;
|
||||||
var newLength = bufferLength + chunk.length;
|
const newLength = bufferLength + chunk.length;
|
||||||
var buffer = this.ensureBuffer(newLength);
|
const buffer = this.ensureBuffer(newLength);
|
||||||
buffer.set(chunk, bufferLength);
|
buffer.set(chunk, bufferLength);
|
||||||
this.bufferLength = newLength;
|
this.bufferLength = newLength;
|
||||||
};
|
};
|
||||||
|
|
||||||
StreamsSequenceStream.prototype.getBaseStreams = function StreamsSequenceStream_getBaseStreams() {
|
StreamsSequenceStream.prototype.getBaseStreams = function StreamsSequenceStream_getBaseStreams() {
|
||||||
var baseStreams = [];
|
const baseStreams = [];
|
||||||
for (var i = 0, ii = this.streams.length; i < ii; i++) {
|
for (let i = 0, ii = this.streams.length; i < ii; i++) {
|
||||||
var stream = this.streams[i];
|
const stream = this.streams[i];
|
||||||
if (stream.getBaseStreams) {
|
if (stream.getBaseStreams) {
|
||||||
baseStreams.push(...stream.getBaseStreams());
|
baseStreams.push(...stream.getBaseStreams());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user