Enable the no-var rule in the src/core/stream.js file

This commit is contained in:
Jonas Jenwald 2021-04-27 16:32:26 +02:00
parent b11f012e52
commit 29cf415a69

View File

@ -12,11 +12,10 @@
* 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 { stringToBytes } from "../shared/util.js"; import { stringToBytes } from "../shared/util.js";
var Stream = (function StreamClosure() { const Stream = (function StreamClosure() {
// eslint-disable-next-line no-shadow // eslint-disable-next-line no-shadow
function Stream(arrayBuffer, start, length, dict) { function Stream(arrayBuffer, start, length, dict) {
this.bytes = this.bytes =
@ -45,32 +44,32 @@ var Stream = (function StreamClosure() {
return this.bytes[this.pos++]; return this.bytes[this.pos++];
}, },
getUint16: function Stream_getUint16() { getUint16: function Stream_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 Stream_getInt32() { getInt32: function Stream_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;
}, },
// Returns subarray of original buffer, should only be read. // Returns subarray of original buffer, should only be read.
getBytes(length, forceClamped = false) { getBytes(length, forceClamped = false) {
var bytes = this.bytes; const bytes = this.bytes;
var pos = this.pos; const pos = this.pos;
var strEnd = this.end; const strEnd = this.end;
if (!length) { if (!length) {
const subarray = bytes.subarray(pos, strEnd); const subarray = bytes.subarray(pos, strEnd);
// `this.bytes` is always a `Uint8Array` here. // `this.bytes` is always a `Uint8Array` here.
return forceClamped ? new Uint8ClampedArray(subarray) : subarray; return forceClamped ? new Uint8ClampedArray(subarray) : subarray;
} }
var end = pos + length; let end = pos + length;
if (end > strEnd) { if (end > strEnd) {
end = strEnd; end = strEnd;
} }
@ -80,14 +79,14 @@ var Stream = (function StreamClosure() {
return forceClamped ? new Uint8ClampedArray(subarray) : subarray; return forceClamped ? new Uint8ClampedArray(subarray) : subarray;
}, },
peekByte: function Stream_peekByte() { peekByte: function Stream_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;
}, },
@ -122,7 +121,7 @@ var Stream = (function StreamClosure() {
return Stream; return Stream;
})(); })();
var StringStream = (function StringStreamClosure() { const StringStream = (function StringStreamClosure() {
// eslint-disable-next-line no-shadow // eslint-disable-next-line no-shadow
function StringStream(str) { function StringStream(str) {
const bytes = stringToBytes(str); const bytes = stringToBytes(str);
@ -134,7 +133,7 @@ var StringStream = (function StringStreamClosure() {
return StringStream; return StringStream;
})(); })();
var NullStream = (function NullStreamClosure() { const NullStream = (function NullStreamClosure() {
// eslint-disable-next-line no-shadow // eslint-disable-next-line no-shadow
function NullStream() { function NullStream() {
Stream.call(this, new Uint8Array(0)); Stream.call(this, new Uint8Array(0));