Prefer const vs let for variables that are only declared once
Requires that variable declarations use `const` instead of `let` and `var` if possible. This is mostly for code readability, performance wins are debatable.
This commit is contained in:
@@ -12,7 +12,7 @@ import { ParserState, ParserAction, IParsingState, IDcsHandler, IEscapeSequenceP
|
||||
*/
|
||||
function r(low: number, high: number): number[] {
|
||||
let c = high - low;
|
||||
let arr = new Array(c);
|
||||
const arr = new Array(c);
|
||||
while (c--) {
|
||||
arr[c] = --high;
|
||||
}
|
||||
@@ -62,8 +62,8 @@ export class TransitionTable {
|
||||
/**
|
||||
* Default definitions for the VT500_TRANSITION_TABLE.
|
||||
*/
|
||||
let PRINTABLES = r(0x20, 0x7f);
|
||||
let EXECUTABLES = r(0x00, 0x18);
|
||||
const PRINTABLES = r(0x20, 0x7f);
|
||||
const EXECUTABLES = r(0x00, 0x18);
|
||||
EXECUTABLES.push(0x19);
|
||||
EXECUTABLES.concat(r(0x1c, 0x20));
|
||||
const DEFAULT_TRANSITION = ParserAction.ERROR << 4 | ParserState.GROUND;
|
||||
@@ -73,9 +73,9 @@ const DEFAULT_TRANSITION = ParserAction.ERROR << 4 | ParserState.GROUND;
|
||||
* Taken from https://vt100.net/emu/dec_ansi_parser.
|
||||
*/
|
||||
export const VT500_TRANSITION_TABLE = (function (): TransitionTable {
|
||||
let table: TransitionTable = new TransitionTable(4095);
|
||||
const table: TransitionTable = new TransitionTable(4095);
|
||||
|
||||
let states: number[] = r(ParserState.GROUND, ParserState.DCS_PASSTHROUGH + 1);
|
||||
const states: number[] = r(ParserState.GROUND, ParserState.DCS_PASSTHROUGH + 1);
|
||||
let state: any;
|
||||
|
||||
// table with default transition [any] --> DEFAULT_TRANSITION
|
||||
@@ -421,7 +421,7 @@ export class EscapeSequenceParser implements IEscapeSequenceParser {
|
||||
}
|
||||
// if we end up here a real error happened
|
||||
if (error) {
|
||||
let inject: IParsingState = this._errorHandler(
|
||||
const inject: IParsingState = this._errorHandler(
|
||||
{
|
||||
position: i,
|
||||
code,
|
||||
@@ -499,15 +499,15 @@ export class EscapeSequenceParser implements IEscapeSequenceParser {
|
||||
if (osc && code !== 0x18 && code !== 0x1a) {
|
||||
// NOTE: OSC subparsing is not part of the original parser
|
||||
// we do basic identifier parsing here to offer a jump table for OSC as well
|
||||
let idx = osc.indexOf(';');
|
||||
const idx = osc.indexOf(';');
|
||||
if (idx === -1) {
|
||||
this._oscHandlerFb(-1, osc); // this is an error (malformed OSC)
|
||||
} else {
|
||||
// Note: NaN is not handled here
|
||||
// either catch it with the fallback handler
|
||||
// or with an explicit NaN OSC handler
|
||||
let identifier = parseInt(osc.substring(0, idx));
|
||||
let content = osc.substring(idx + 1);
|
||||
const identifier = parseInt(osc.substring(0, idx));
|
||||
const content = osc.substring(idx + 1);
|
||||
callback = this._oscHandlers[identifier];
|
||||
if (callback) callback(content);
|
||||
else this._oscHandlerFb(identifier, content);
|
||||
|
||||
Reference in New Issue
Block a user