From 2bd7fa59b72494fd16456268d043b1bf63229a47 Mon Sep 17 00:00:00 2001 From: Will Scullin Date: Wed, 18 May 2022 08:19:45 -0700 Subject: [PATCH] Enforce strict equality (#115) --- .eslintrc.json | 1 + js/apple2io.ts | 8 +++---- js/applesoft/compiler.ts | 4 ++-- js/base64.ts | 4 ++-- js/canvas.ts | 44 ++++++++++++++++++------------------- js/cards/disk2.ts | 8 +++---- js/cards/smartport.ts | 10 ++++----- js/cards/videoterm.ts | 2 +- js/formats/create_disk.ts | 2 +- js/formats/format_utils.ts | 8 +++---- js/gl.ts | 26 +++++++++++----------- js/intbasic/decompiler.ts | 2 +- js/mmu.ts | 4 ++-- js/roms/rom.ts | 2 +- js/ui/apple2.ts | 18 +++++++-------- js/ui/joystick.ts | 4 ++-- js/ui/keyboard.ts | 14 ++++++------ js/ui/tape.ts | 2 +- test/cpu.spec.ts | 2 +- test/js/formats/d13.spec.ts | 2 +- test/js/formats/do.spec.ts | 2 +- test/js/formats/po.spec.ts | 2 +- test/js/formats/util.ts | 6 ++--- test/js/util.test.ts | 8 +++---- 24 files changed, 93 insertions(+), 92 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 22ba101..a2dee4a 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -17,6 +17,7 @@ "error", "unix" ], + "eqeqeq": ["error", "smart"], "prefer-const": [ "error" ], diff --git a/js/apple2io.ts b/js/apple2io.ts index f1a059e..07e8a09 100644 --- a/js/apple2io.ts +++ b/js/apple2io.ts @@ -217,7 +217,7 @@ export default class Apple2IO implements MemoryPages, Restorable } break; case LOC.TAPEIN: - if (this._tapeOffset == -1) { + if (this._tapeOffset === -1) { this._tapeOffset = 0; this._tapeNext = now; } @@ -248,7 +248,7 @@ export default class Apple2IO implements MemoryPages, Restorable } if (this._buffer.length > 0) { let val = this._buffer.shift() as string; - if (val == '\n') { + if (val === '\n') { val = '\r'; } this._key = val.charCodeAt(0) | 0x80; @@ -343,7 +343,7 @@ export default class Apple2IO implements MemoryPages, Restorable case 0xc7: slot = page & 0x0f; card = this._slot[slot]; - if (this._auxRom != card) { + if (this._auxRom !== card) { // _debug('Setting auxRom to slot', slot); this._auxRom = card; } @@ -379,7 +379,7 @@ export default class Apple2IO implements MemoryPages, Restorable case 0xc7: slot = page & 0x0f; card = this._slot[slot]; - if (this._auxRom != card) { + if (this._auxRom !== card) { // _debug('Setting auxRom to slot', slot); this._auxRom = card; } diff --git a/js/applesoft/compiler.ts b/js/applesoft/compiler.ts index 5ffba6c..2fff0fc 100644 --- a/js/applesoft/compiler.ts +++ b/js/applesoft/compiler.ts @@ -178,7 +178,7 @@ export default class ApplesoftCompiler { let foundToken = ''; let tokenIdx = -1; for (const possibleToken in TOKENS) { - if (possibleToken.charAt(0) == character) { + if (possibleToken.charAt(0) === character) { tokenIdx = curChar + 1; let idx = 1; while (idx < possibleToken.length) { @@ -234,7 +234,7 @@ export default class ApplesoftCompiler { break; case STATES.STRING: result.push(character.charCodeAt(0)); - if (character == '"') { + if (character === '"') { state = STATES.NORMAL; } curChar++; diff --git a/js/base64.ts b/js/base64.ts index 7a8566c..74feabe 100644 --- a/js/base64.ts +++ b/js/base64.ts @@ -111,10 +111,10 @@ export function base64_decode(data: string | null | undefined): memory | undefin o3 = bits & 0xff; tmp_arr[ac++] = o1; - if (h3 != 64) { + if (h3 !== 64) { tmp_arr[ac++] = o2; } - if (h4 != 64) { + if (h4 !== 64) { tmp_arr[ac++] = o3; } } while (i < data.length); diff --git a/js/canvas.ts b/js/canvas.ts index ba1b6e1..2769aa8 100644 --- a/js/canvas.ts +++ b/js/canvas.ts @@ -148,7 +148,7 @@ export class LoresPage2D implements LoresPage { let inverse = false; if (this.e) { if (!this.vm._80colMode && !this.vm.altCharMode) { - inverse = ((val & 0xc0) == 0x40) && this._blink; + inverse = ((val & 0xc0) === 0x40) && this._blink; } } else { inverse = !((val & 0x80) || (val & 0x40) && this._blink); @@ -192,7 +192,7 @@ export class LoresPage2D implements LoresPage { const base = addr & 0x3FF; let fore, back; - if (this._buffer[bank][base] == val && !this._refreshing) { + if (this._buffer[bank][base] === val && !this._refreshing) { return; } this._buffer[bank][base] = val; @@ -288,7 +288,7 @@ export class LoresPage2D implements LoresPage { let color; if (colorMode) { if (b & 0x80) { - if ((b & 0x1c0) != 0x80) { + if ((b & 0x1c0) !== 0x80) { color = whiteCol; } else { color = odd ? violetCol : greenCol; @@ -395,7 +395,7 @@ export class LoresPage2D implements LoresPage { this._blink = !this._blink; for (let idx = 0; idx < 0x400; idx++, addr++) { const b = this._buffer[0][idx]; - if ((b & 0xC0) == 0x40) { + if ((b & 0xC0) === 0x40) { this._write(addr >> 8, addr & 0xff, this._buffer[0][idx], 0); } } @@ -575,7 +575,7 @@ export class HiresPage2D implements HiresPage { const addr = (page << 8) | off; const base = addr & 0x1FFF; - if (this._buffer[bank][base] == val && !this._refreshing) { + if (this._buffer[bank][base] === val && !this._refreshing) { return; } this._buffer[bank][base] = val; @@ -695,16 +695,16 @@ export class HiresPage2D implements HiresPage { } else if (this.colorDHRMode) { this._drawHalfPixel(data, offset, dcolor); } else if ( - ((c[idx] != c[idx - 1]) && (c[idx] != c[idx + 1])) && - (((bits & 0x1c) == 0x1c) || - ((bits & 0x70) == 0x70) || - ((bits & 0x38) == 0x38)) + ((c[idx] !== c[idx - 1]) && (c[idx] !== c[idx + 1])) && + (((bits & 0x1c) === 0x1c) || + ((bits & 0x70) === 0x70) || + ((bits & 0x38) === 0x38)) ) { this._drawHalfPixel(data, offset, whiteCol); } else if ( (bits & 0x38) || - (c[idx] == c[idx + 1]) || - (c[idx] == c[idx - 1]) + (c[idx] === c[idx + 1]) || + (c[idx] === c[idx - 1]) ) { this._drawHalfPixel(data, offset, dcolor); } else if (bits & 0x28) { @@ -786,9 +786,9 @@ export class HiresPage2D implements HiresPage { refresh() { this.highColorHGRMode = !this.vm.an3State && this.vm.hiresMode && !this.vm._80colMode; - this.oneSixtyMode = this.vm.flag == 1 && this.vm.doubleHiresMode; - this.mixedDHRMode = this.vm.flag == 2 && this.vm.doubleHiresMode; - this.monoDHRMode = this.vm.flag == 3 && this.vm.doubleHiresMode; + this.oneSixtyMode = this.vm.flag === 1 && this.vm.doubleHiresMode; + this.mixedDHRMode = this.vm.flag === 2 && this.vm.doubleHiresMode; + this.monoDHRMode = this.vm.flag === 3 && this.vm.doubleHiresMode; let addr = 0x2000 * this.page; this._refreshing = true; @@ -922,7 +922,7 @@ export class VideoModes2D implements VideoModes { if (on) { this.flag = 0; } - if (old != on) { + if (old !== on) { this._refresh(); } } @@ -933,7 +933,7 @@ export class VideoModes2D implements VideoModes { const old = this._80colMode; this._80colMode = on; - if (old != on) { + if (old !== on) { this._refresh(); } } @@ -943,7 +943,7 @@ export class VideoModes2D implements VideoModes { const old = this.altCharMode; this.altCharMode = on; - if (old != on) { + if (old !== on) { this._refresh(); } } @@ -955,7 +955,7 @@ export class VideoModes2D implements VideoModes { this.flag = 0; } - if (old != on) { + if (old !== on) { this._refresh(); } } @@ -970,7 +970,7 @@ export class VideoModes2D implements VideoModes { this.flag = ((this.flag << 1) | (this._80colMode ? 0x0 : 0x1)) & 0x3; } - if (old != on) { + if (old !== on) { this._refresh(); } } @@ -982,7 +982,7 @@ export class VideoModes2D implements VideoModes { mixed(on: boolean) { const old = this.mixedMode; this.mixedMode = on; - if (old != on) { + if (old !== on) { this._refresh(); } } @@ -990,7 +990,7 @@ export class VideoModes2D implements VideoModes { page(pageNo: pageNo) { const old = this.pageMode; this.pageMode = pageNo; - if (old != pageNo) { + if (old !== pageNo) { this._refresh(); } } @@ -1004,7 +1004,7 @@ export class VideoModes2D implements VideoModes { } isPage2() { - return this.pageMode == 2; + return this.pageMode === 2; } isHires() { diff --git a/js/cards/disk2.ts b/js/cards/disk2.ts index a0d717b..2664477 100644 --- a/js/cards/disk2.ts +++ b/js/cards/disk2.ts @@ -387,8 +387,8 @@ export default class DiskII implements Card { this.debug('Disk ]['); this.lastCycles = this.io.cycles(); - this.bootstrapRom = this.sectors == 16 ? BOOTSTRAP_ROM_16 : BOOTSTRAP_ROM_13; - this.sequencerRom = this.sectors == 16 ? SEQUENCER_ROM_16 : SEQUENCER_ROM_13; + this.bootstrapRom = this.sectors === 16 ? BOOTSTRAP_ROM_16 : BOOTSTRAP_ROM_13; + this.sequencerRom = this.sectors === 16 ? SEQUENCER_ROM_16 : SEQUENCER_ROM_13; this.initWorker(); } @@ -413,7 +413,7 @@ export default class DiskII implements Card { while (workCycles-- > 0) { let pulse: number = 0; - if (this.clock == 4) { + if (this.clock === 4) { pulse = track[this.cur.head]; if (!pulse) { // More that 2 zeros can not be read reliably. @@ -463,7 +463,7 @@ export default class DiskII implements Card { } this.state = (command >> 4 & 0xF) as nibble; - if (this.clock == 4) { + if (this.clock === 4) { if (this.on) { if (this.q7) { track[this.cur.head] = this.state & 0x8 ? 0x01 : 0x00; diff --git a/js/cards/smartport.ts b/js/cards/smartport.ts index 8432af5..b450540 100644 --- a/js/cards/smartport.ts +++ b/js/cards/smartport.ts @@ -125,7 +125,7 @@ export default class SmartPort implements Card, MassStorage, Restorable= 0x20 && b < 0x7f) { @@ -355,7 +355,7 @@ export default class SmartPort implements Card, MassStorage, Restorable { const startPos = this.regs[REGS.STARTPOS_HI] << 8 | this.regs[REGS.STARTPOS_LO]; - if (this.startPos != startPos) { + if (this.startPos !== startPos) { this.startPos = startPos; this.shouldRefresh = true; } diff --git a/js/formats/create_disk.ts b/js/formats/create_disk.ts index f0ff47b..5dc884d 100644 --- a/js/formats/create_disk.ts +++ b/js/formats/create_disk.ts @@ -50,7 +50,7 @@ export function createDiskFromJsonDisk(disk: JSONDisk): FloppyDisk | null { if (includes(NIBBLE_FORMATS, fmt)) { let trackData: memory[][]; - if (disk.encoding == 'base64') { + if (disk.encoding === 'base64') { trackData = []; for (let t = 0; t < disk.data.length; t++) { trackData[t] = []; diff --git a/js/formats/format_utils.ts b/js/formats/format_utils.ts index 15cf433..7f66534 100644 --- a/js/formats/format_utils.ts +++ b/js/formats/format_utils.ts @@ -330,7 +330,7 @@ export function explodeSector13(volume: byte, track: byte, sector: byte, data: m * @returns An array of sector data bytes. */ export function readSector(disk: NibbleDisk, track: byte, sector: byte): memory { - const _sector = disk.format == 'po' ? _PO[sector] : _DO[sector]; + const _sector = disk.format === 'po' ? _PO[sector] : _DO[sector]; let val, state = 0; let idx = 0; let retry = 0; @@ -372,7 +372,7 @@ export function readSector(disk: NibbleDisk, track: byte, sector: byte): memory t = defourXfour(_readNext(), _readNext()); s = defourXfour(_readNext(), _readNext()); checkSum = defourXfour(_readNext(), _readNext()); - if (checkSum != (v ^ t ^ s)) { + if (checkSum !== (v ^ t ^ s)) { debug('Invalid header checksum:', toHex(v), toHex(t), toHex(s), toHex(checkSum)); } _skipBytes(3); // Skip footer @@ -471,7 +471,7 @@ export function jsonDecode(data: string): NibbleDisk { for (let t = 0; t < json.data.length; t++) { let track: byte[] = []; for (let s = 0; s < json.data[t].length; s++) { - const _s = json.type == 'po' ? PO[s] : DO[s]; + const _s = json.type === 'po' ? PO[s] : DO[s]; const sector: string = json.data[t][_s]; const d = base64_decode(sector); track = track.concat(explodeSector16(v, t, s, d)); @@ -532,7 +532,7 @@ export function analyseDisk(disk: NibbleDisk) { t = defourXfour(_readNext(), _readNext()); s = defourXfour(_readNext(), _readNext()); checkSum = defourXfour(_readNext(), _readNext()); - if (checkSum != (v ^ t ^ s)) { + if (checkSum !== (v ^ t ^ s)) { debug('Invalid header checksum:', toHex(v), toHex(t), toHex(s), toHex(checkSum)); } else { outStr += toHex(s, 1); diff --git a/js/gl.ts b/js/gl.ts index 4596438..aea2638 100644 --- a/js/gl.ts +++ b/js/gl.ts @@ -75,7 +75,7 @@ export class LoresPageGL implements LoresPage { let inverse = false; if (this.e) { if (!this.vm._80colMode && !this.vm.altCharMode) { - inverse = ((val & 0xc0) == 0x40) && this._blink; + inverse = ((val & 0xc0) === 0x40) && this._blink; } } else { inverse = !((val & 0x80) || (val & 0x40) && this._blink); @@ -119,7 +119,7 @@ export class LoresPageGL implements LoresPage { const base = addr & 0x3FF; let fore, back; - if (this._buffer[bank][base] == val && !this._refreshing) { + if (this._buffer[bank][base] === val && !this._refreshing) { return; } this._buffer[bank][base] = val; @@ -264,7 +264,7 @@ export class LoresPageGL implements LoresPage { this._blink = !this._blink; for (let idx = 0; idx < 0x400; idx++, addr++) { const b = this._buffer[0][idx]; - if ((b & 0xC0) == 0x40) { + if ((b & 0xC0) === 0x40) { this._write(addr >> 8, addr & 0xff, this._buffer[0][idx], 0); } } @@ -418,7 +418,7 @@ export class HiresPageGL implements HiresPage { const addr = (page << 8) | off; const base = addr & 0x1FFF; - if (this._buffer[bank][base] == val && !this._refreshing) { + if (this._buffer[bank][base] === val && !this._refreshing) { return; } this._buffer[bank][base] = val; @@ -476,7 +476,7 @@ export class HiresPageGL implements HiresPage { } let bits = val; for (let idx = 0; idx < 7; idx++, offset += 8) { - const drawPixel = cropLastPixel && idx == 6 + const drawPixel = cropLastPixel && idx === 6 ? this._drawHalfPixel : this._drawPixel; if (bits & 0x01) { @@ -666,7 +666,7 @@ export class VideoModesGL implements VideoModes { const old = this.textMode; this.textMode = on; - if (old != on) { + if (old !== on) { this._refresh(); } } @@ -677,7 +677,7 @@ export class VideoModesGL implements VideoModes { const old = this._80colMode; this._80colMode = on; - if (old != on) { + if (old !== on) { this._refresh(); } } @@ -687,7 +687,7 @@ export class VideoModesGL implements VideoModes { const old = this.altCharMode; this.altCharMode = on; - if (old != on) { + if (old !== on) { this._refresh(); } } @@ -696,7 +696,7 @@ export class VideoModesGL implements VideoModes { const old = this.hiresMode; this.hiresMode = on; - if (old != on) { + if (old !== on) { this._refresh(); } } @@ -707,7 +707,7 @@ export class VideoModesGL implements VideoModes { const old = this.an3State; this.an3State = on; - if (old != on) { + if (old !== on) { this._refresh(); } } @@ -719,7 +719,7 @@ export class VideoModesGL implements VideoModes { mixed(on: boolean) { const old = this.mixedMode; this.mixedMode = on; - if (old != on) { + if (old !== on) { this._refresh(); } } @@ -727,7 +727,7 @@ export class VideoModesGL implements VideoModes { page(pageNo: pageNo) { const old = this.pageMode; this.pageMode = pageNo; - if (old != pageNo) { + if (old !== pageNo) { this._refresh(); } } @@ -741,7 +741,7 @@ export class VideoModesGL implements VideoModes { } isPage2() { - return this.pageMode == 2; + return this.pageMode === 2; } isHires() { diff --git a/js/intbasic/decompiler.ts b/js/intbasic/decompiler.ts index 60958fa..dfc7866 100644 --- a/js/intbasic/decompiler.ts +++ b/js/intbasic/decompiler.ts @@ -179,7 +179,7 @@ export default class IntBasicDump } else if (val > 0x80) str += LETTERS[val - 0x80]; - } while (val != 0x01); + } while (val !== 0x01); str += '\n'; } while (addr < himem); diff --git a/js/mmu.ts b/js/mmu.ts index f214977..fb47ed8 100644 --- a/js/mmu.ts +++ b/js/mmu.ts @@ -101,11 +101,11 @@ class AuxRom implements Memory { private readonly rom: ROM) { } _access(page: byte, off: byte) { - if (page == 0xc3) { + if (page === 0xc3) { this.mmu._setIntc8rom(true); this.mmu._updateBanks(); } - if (page == 0xcf && off == 0xff) { + if (page === 0xcf && off === 0xff) { this.mmu._setIntc8rom(false); this.mmu._updateBanks(); } diff --git a/js/roms/rom.ts b/js/roms/rom.ts index 9be7841..36fc2a5 100644 --- a/js/roms/rom.ts +++ b/js/roms/rom.ts @@ -9,7 +9,7 @@ export default class ROM implements MemoryPages, Restorable { private readonly endPage: byte, private readonly rom: rom) { const expectedLength = (endPage-startPage+1) * 256; - if (rom.length != expectedLength) { + if (rom.length !== expectedLength) { throw Error(`rom does not have the correct length: expected ${expectedLength} was ${rom.length}`); } } diff --git a/js/ui/apple2.ts b/js/ui/apple2.ts index 113ba6f..4812664 100644 --- a/js/ui/apple2.ts +++ b/js/ui/apple2.ts @@ -181,10 +181,10 @@ export function handleDrop(drive: number, event: DragEvent) { } } const dt = event.dataTransfer!; - if (dt.files.length == 1) { + if (dt.files.length === 1) { const runOnLoad = event.shiftKey; doLoadLocal(drive as DriveNumber, dt.files[0], { runOnLoad }); - } else if (dt.files.length == 2) { + } else if (dt.files.length === 2) { doLoadLocal(1, dt.files[0]); doLoadLocal(2, dt.files[1]); } else { @@ -255,7 +255,7 @@ export function doLoad(event: MouseEvent|KeyboardEvent) { const urls = select.value; let url; if (urls && urls.length) { - if (typeof (urls) == 'string') { + if (typeof (urls) === 'string') { url = urls; } else { url = urls[0]; @@ -264,15 +264,15 @@ export function doLoad(event: MouseEvent|KeyboardEvent) { const localFile = document.querySelector('#local_file')!; const files = localFile.files; - if (files && files.length == 1) { + if (files && files.length === 1) { const runOnLoad = event.shiftKey; doLoadLocal(_currentDrive, files[0], { runOnLoad }); } else if (url) { let filename; MicroModal.close('load-modal'); - if (url.substr(0, 6) == 'local:') { + if (url.substr(0, 6) === 'local:') { filename = url.substr(6); - if (filename == '__manage') { + if (filename === '__manage') { openManage(); } else { loadLocalStorage(_currentDrive, filename); @@ -711,7 +711,7 @@ function buildDiskIndex() { if (file.e && !_e) { continue; } - if (cat != oldCat) { + if (cat !== oldCat) { option = document.createElement('option'); option.value = cat; option.innerText = cat; @@ -751,7 +751,7 @@ function processHash(hash: string) { if (file.indexOf('://') > 0) { const parts = file.split('.'); const ext = parts[parts.length - 1].toLowerCase(); - if (ext == 'json') { + if (ext === 'json') { loadAjax(drive, file); } else { doLoadHTTP(drive, file); @@ -763,7 +763,7 @@ function processHash(hash: string) { } export function updateUI() { - if (document.location.hash != hashtag) { + if (document.location.hash !== hashtag) { hashtag = document.location.hash; const hash = hup(); if (hash) { diff --git a/js/ui/joystick.ts b/js/ui/joystick.ts index 56ae0e9..72f5165 100644 --- a/js/ui/joystick.ts +++ b/js/ui/joystick.ts @@ -24,13 +24,13 @@ export class JoyStick implements OptionHandler { document.querySelectorAll('canvas').forEach((canvas) => { canvas.addEventListener('mousedown', (evt) => { if (!this.gamepad && !mouseMode) { - io.buttonDown(evt.which == 1 ? 0 : 1); + io.buttonDown(evt.which === 1 ? 0 : 1); } evt.preventDefault(); }); canvas.addEventListener('mouseup', (evt) => { if (!this.gamepad && !mouseMode) { - io.buttonUp(evt.which == 1 ? 0 : 1); + io.buttonUp(evt.which === 1 ? 0 : 1); } }); canvas.addEventListener('contextmenu', (evt) => { diff --git a/js/ui/keyboard.ts b/js/ui/keyboard.ts index a5bc5af..016d865 100644 --- a/js/ui/keyboard.ts +++ b/js/ui/keyboard.ts @@ -240,7 +240,7 @@ export default class KeyBoard { } else if (isKeyboardCode(code)) { key = keymap[code][evt.shiftKey ? 2 : (evt.ctrlKey ? 1 : 0)]; - if (code != 20 && this.capslockKeyUsed) { + if (code !== 20 && this.capslockKeyUsed) { this.capslockKey(evt.getModifierState('CapsLock')); } @@ -251,7 +251,7 @@ export default class KeyBoard { debug('Unhandled key = ' + toHex(code)); } - if (key == 0x7F && evt.shiftKey && evt.ctrlKey) { + if (key === 0x7F && evt.shiftKey && evt.ctrlKey) { this.cpu.reset(); key = 0xff; } @@ -321,7 +321,7 @@ export default class KeyBoard { capslockKey(down?: boolean | undefined) { const capsLock = this.kb.querySelector('.key-LOCK'); - if (arguments.length == 0) { + if (arguments.length === 0) { if (this.capslockKeyUsed) { this.capslocked = !this.capslocked; } else { @@ -354,7 +354,7 @@ export default class KeyBoard { const buildLabel = (k: string) => { const span = document.createElement('span'); span.innerHTML = k; - if (k.length > 1 && k.substr(0, 1) != '&') + if (k.length > 1 && k.substr(0, 1) !== '&') span.classList.add('small'); return span; }; @@ -377,17 +377,17 @@ export default class KeyBoard { key.classList.add('key-' + key1.replace(/[&#;]/g, '')); if (key1.length > 1) { - if (key1 == 'LOCK') + if (key1 === 'LOCK') key.classList.add('v-center2'); else key.classList.add('v-center'); } - if (key1 != key2) { + if (key1 !== key2) { key.classList.add('key-' + key2.replace(/[&;]/g, '')); label.append(label2); label.append(document.createElement('br')); } - if (key1 == 'LOCK') { + if (key1 === 'LOCK') { key.classList.add('active'); } diff --git a/js/ui/tape.ts b/js/ui/tape.ts index 30dbfb9..8e63886 100644 --- a/js/ui/tape.ts +++ b/js/ui/tape.ts @@ -38,7 +38,7 @@ export default class Tape { datum = data[idx]; if ((datum > 0.1) || (datum < -0.1)) { current = (datum > 0.0); - if (current != old) { + if (current !== old) { delta = idx - last; if (delta > 2000000) { delta = 2000000; diff --git a/test/cpu.spec.ts b/test/cpu.spec.ts index 3c52555..1001830 100644 --- a/test/cpu.spec.ts +++ b/test/cpu.spec.ts @@ -12,7 +12,7 @@ describe('CPU', function () { function traceCB() { const pc = cpu.getPC(); - done = lastPC == pc; + done = lastPC === pc; lastPC = pc; } diff --git a/test/js/formats/d13.spec.ts b/test/js/formats/d13.spec.ts index 7d3334d..5818eba 100644 --- a/test/js/formats/d13.spec.ts +++ b/test/js/formats/d13.spec.ts @@ -59,7 +59,7 @@ describe('DOS-13 format', () => { // From Beneith Apple DOS, GAP 1 should have 12-85 0xFF bytes const track = disk.tracks[0]; let numFF = 0; - while (track[numFF] == 0xFF && numFF < 0x100) { + while (track[numFF] === 0xFF && numFF < 0x100) { numFF++; } expect(numFF).toBeGreaterThanOrEqual(40); diff --git a/test/js/formats/do.spec.ts b/test/js/formats/do.spec.ts index 94dc20c..9590b6f 100644 --- a/test/js/formats/do.spec.ts +++ b/test/js/formats/do.spec.ts @@ -58,7 +58,7 @@ describe('DOS format', () => { // From Beneith Apple DOS, GAP 1 should have 12-85 0xFF bytes const track = disk.tracks[0]; let numFF = 0; - while (track[numFF] == 0xFF && numFF < 0x100) { + while (track[numFF] === 0xFF && numFF < 0x100) { numFF++; } expect(numFF).toBeGreaterThanOrEqual(40); diff --git a/test/js/formats/po.spec.ts b/test/js/formats/po.spec.ts index fa86d7a..268fc07 100644 --- a/test/js/formats/po.spec.ts +++ b/test/js/formats/po.spec.ts @@ -58,7 +58,7 @@ describe('ProDOS format', () => { // From Beneith Apple DOS, GAP 1 should have 12-85 0xFF bytes const track = disk.tracks[0]; let numFF = 0; - while (track[numFF] == 0xFF && numFF < 0x100) { + while (track[numFF] === 0xFF && numFF < 0x100) { numFF++; } expect(numFF).toBeGreaterThanOrEqual(40); diff --git a/test/js/formats/util.ts b/test/js/formats/util.ts index b1ced14..47f2193 100644 --- a/test/js/formats/util.ts +++ b/test/js/formats/util.ts @@ -3,10 +3,10 @@ import { memory } from 'js/types'; export function skipGap(track: memory, start: number = 0): number { const end = start + 0x100; // no gap is this big let i = start; - while (i < end && track[i] == 0xFF) { + while (i < end && track[i] === 0xFF) { i++; } - if (i == end) { + if (i === end) { fail(`found more than 0x100 0xFF bytes after ${start}`); } return i; @@ -14,7 +14,7 @@ export function skipGap(track: memory, start: number = 0): number { export function compareSequences(track: memory, bytes: number[], pos: number): boolean { for (let i = 0; i < bytes.length; i++) { - if (track[i + pos] != bytes[i]) { + if (track[i + pos] !== bytes[i]) { return false; } } diff --git a/test/js/util.test.ts b/test/js/util.test.ts index c47cd7d..cfdb1df 100644 --- a/test/js/util.test.ts +++ b/test/js/util.test.ts @@ -26,10 +26,10 @@ describe('allocMem', () => { it('has garbage in the right places', () => { const memory = allocMem(0x800); for (let i = 0; i < 0x800; i += 0x200) { - const passed = memory[i + 0x28] != 0xff - && memory[i + 0x29] != 0xff - && memory[i + 0x68] != 0xff - && memory[i + 0x69] != 0xff; + const passed = memory[i + 0x28] !== 0xff + && memory[i + 0x29] !== 0xff + && memory[i + 0x68] !== 0xff + && memory[i + 0x69] !== 0xff; if (passed) { return; }