Skip to content

Commit

Permalink
Converted to type-safe inequals.
Browse files Browse the repository at this point in the history
  • Loading branch information
PoneyClairDeLune committed Feb 20, 2025
1 parent 8968a95 commit faf4990
Show file tree
Hide file tree
Showing 15 changed files with 98 additions and 98 deletions.
2 changes: 1 addition & 1 deletion src/basic/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ let RootDisplay = class extends CustomEventSource {
upThis.#noteNomin = data[0];
upThis.#noteDenom = 1 << data[1];
let metroClick = 24 * (32 / data[3]) / data[2];
if (oldNomin != upThis.#noteNomin) {
if (oldNomin !== upThis.#noteNomin) {
let targetBar = curBar;
upThis.#noteBarOffset -= targetBar * (upThis.#noteNomin - oldNomin);
if (curBeat + 1 >= oldNomin) {
Expand Down
4 changes: 2 additions & 2 deletions src/basic/mxReader.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ let MxBm256 = class {
text.split("\n").forEach(function (e, i) {
if (i > 0 && e?.length > 0) {
let arr = e.split("\t");
if (arr[1][0] != "@") {
if (arr[1][0] !== "@") {
let bm = new Uint8Array(256);
Array.from(arr[1]).forEach(function (e, i) {
let iOff = i * 4,
Expand Down Expand Up @@ -231,7 +231,7 @@ let MxBmDef = class {
text.split("\n").forEach(function (e, i) {
if (i > 0 && e?.length > 0) {
let arr = e.split("\t");
if (arr[1][0] != "@") {
if (arr[1][0] !== "@") {
let bmWidth = parseInt(arr[1].slice(0, 4), 16),
bmHeight = parseInt(arr[1].slice(4, 8), 16);
let bm = new Uint8Array(bmWidth * bmHeight);
Expand Down
10 changes: 5 additions & 5 deletions src/cambiare/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ let Cambiare = class extends RootDisplay {
};
} else {
context.setLineDash(lineDash[0]);
if (range != 4 && self?.document?.mozFullScreen) {
if (range !== 4 && self?.document?.mozFullScreen) {
sx += 0.5;
ex += 0.5;
};
Expand Down Expand Up @@ -736,7 +736,7 @@ let Cambiare = class extends RootDisplay {
// Render the old pixel display buffers
upThis.#bufBo.forEach((e, i) => {
let y = i >> 5, x = i & 31;
if (upThis.#bufBm[i] != e) {
if (upThis.#bufBm[i] !== e) {
ccxt.clearRect(252 + (x << 2), y << 2, 3, 3);
if (e) {
ccxt.fillStyle = `#${upThis.#foreground}${e.toString(16).padStart(2, "0")}`;
Expand All @@ -753,7 +753,7 @@ let Cambiare = class extends RootDisplay {
upThis.#bufLo.forEach((e, i) => {
let y = Math.floor(i / 80), x = i % 80;
x += Math.floor(x / 5);
if (upThis.#bufLm[i] != e) {
if (upThis.#bufLm[i] !== e) {
ccxt.clearRect(x << 2, (y | 16) << 2, 3, 3);
if (e) {
ccxt.fillStyle = `#${upThis.#foreground}${e.toString(16).padStart(2, "0")}`;
Expand Down Expand Up @@ -902,7 +902,7 @@ let Cambiare = class extends RootDisplay {
upThis.#canvas.classList.remove(className);
};
};
if (mode != "?") {
if (mode !== "?") {
upThis.#canvas.classList.add(`cambiare-mode-${mode}`);
};
};
Expand All @@ -915,7 +915,7 @@ let Cambiare = class extends RootDisplay {
partViewer.root.classList.remove(className);
};
};
if (mode != "?") {
if (mode !== "?") {
partViewer.root.classList.add(`part-mode-${mode}`);
};
};
Expand Down
6 changes: 3 additions & 3 deletions src/disp/disp_mu.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,13 @@ let MuDisplay = class extends RootDisplay {
upThis.demoInfo = false;
});
upThis.addEventListener("portrange", (ev) => {
if (ev && ev.data != 1 << Math.log2(ev.data)) {
if (ev && ev.data !== 1 << Math.log2(ev.data)) {
console.debug(`MU display rejected port range value ${ev.data}.`);
};
upThis.#range = ev.data;
});
upThis.addEventListener("portstart", (ev) => {
if (ev != 255 && ev >= allocated.port) {
if (ev !== 255 && ev >= allocated.port) {
console.debug(`MU display rejected port range value ${ev.data}.`);
};
upThis.#start = ev.data;
Expand Down Expand Up @@ -649,7 +649,7 @@ let MuDisplay = class extends RootDisplay {
paintTriDown(ctx, 800, 170, false);
// Paint right triangles
let modeSel = modeGroup[sum.mode];
if (modeSel?.constructor != Number) {
if (modeSel?.constructor !== Number) {
modeSel = -1;
};
paintTriRight(ctx, 826, 170, modeSel === 0);
Expand Down
12 changes: 6 additions & 6 deletions src/disp/disp_n5.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ let Ns5rDisplay = class extends RootDisplay {
for (let c = 0; c < 21; c ++) {
let pX = c % 7, pY = Math.floor(c / 7),
pcY = pY + (9 - convertedValue);
if (pY != 1 || pX === 0 || pX === 6) {
if (pY !== 1 || pX === 0 || pX === 6) {
upThis.#nmdb[pcY * 144 + pX + startX + 2] = upThis.#pixelLit;
} else {
upThis.#nmdb[pcY * 144 + pX + startX + 2] = upThis.#pixelOff;
Expand Down Expand Up @@ -420,7 +420,7 @@ let Ns5rDisplay = class extends RootDisplay {
// Screen buffer write finish.
// Determine if full render is required.
let drawPixMode = false;
if (upThis.#lastTrue != trueMode) {
if (upThis.#lastTrue !== trueMode) {
upThis.#refreshed = true;
};
if (upThis.#refreshed) {
Expand Down Expand Up @@ -465,19 +465,19 @@ let Ns5rDisplay = class extends RootDisplay {
cap = 48;
if (Math.abs(diff) > cap) {
upThis.#dmdb[i] += Math.sign(diff) * cap;
} else if (diff != 0) {
} else if (diff !== 0) {
upThis.#dmdb[i] = e;
};
} else {
if (upThis.#dmdb[i] != e) {
if (upThis.#dmdb[i] !== e) {
upThis.#dmdb[i] = e;
};
};
});
// Commit to display accordingly.
upThis.#dmdb.forEach((e, i) => {
let pixX = i % 144, pixY = Math.floor(i / 144);
let hasDifference = upThis.#omdb[i] != e;
let hasDifference = upThis.#omdb[i] !== e;
if (!drawPixMode && hasDifference) {
ctx.fillStyle = upThis.#backlight.slice(0, 7);
ctx.fillRect(6 * pixX + 1, 12 + 6 * pixY, 6, 6);
Expand All @@ -498,7 +498,7 @@ let Ns5rDisplay = class extends RootDisplay {
});
// Commit to old display buffer.
upThis.#dmdb.forEach((e, i) => {
if (upThis.#omdb[i] != e) {
if (upThis.#omdb[i] !== e) {
upThis.#omdb[i] = e;
};
});
Expand Down
12 changes: 6 additions & 6 deletions src/disp/disp_psr.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ let PsrDisplay = class extends RootDisplay {
});
ctx.resetTransform();
// Scrolling text
if (longString && Math.floor(timeNow / 60) != upThis.#lastRefreshTime) {
if (longString && Math.floor(timeNow / 60) !== upThis.#lastRefreshTime) {
if (upThis.#letterCoolDown > 0) {
upThis.#letterCoolDown--;
} else if (upThis.#letterShift > originalLength + 1) {
Expand Down Expand Up @@ -398,11 +398,11 @@ let PsrDisplay = class extends RootDisplay {
else {
if (rhythmView) {
let currentCursorPos = Math.round(sum.noteBeat * 2 - 0.5);
if (sum.noteBar != upThis.#lastFrameBar) {
if (sum.noteBar !== upThis.#lastFrameBar) {
upThis.#rhythmTextBuffer = " "; // cleat text buffer upon bar changing
}
// upThis.#rhythmTextBuffer += upThis.#kana;
if (upThis.#kana != "") {
if (upThis.#kana !== "") {
let arr = Array.from(upThis.#rhythmTextBuffer);
// arr[currentCursorPos] = upThis.#kana;
arr.splice(currentCursorPos, upThis.#kana.length, upThis.#kana);
Expand Down Expand Up @@ -520,7 +520,7 @@ let PsrDisplay = class extends RootDisplay {
this.#nkdb.forEach((e, i) => {
ctx.fillStyle = [inactivePixel, mediumPixel, activePixel][e];
let octave = Math.floor(i / 12), note = i % 12;
if (i != 60) {
if (i !== 60) {
isBlackKey[note] ? ctx.fillRect(keyboardData[note] + 163 * octave, 321, 12, 26) : ctx.fillRect(keyboardData[note] + 163 * octave, 355, 14, 21);
}
else {
Expand Down Expand Up @@ -560,12 +560,12 @@ let PsrDisplay = class extends RootDisplay {
// Commit to old display buffer.
/*
this.#nkdb.forEach((e, i) => {
if (this.#okdb[i] != e) {
if (this.#okdb[i] !== e) {
this.#okdb[i] = e;
};
});
this.#nsdb.forEach((e, i) => {
if (this.#osdb[i] != e) {
if (this.#osdb[i] !== e) {
this.#osdb[i] = e;
};
});
Expand Down
6 changes: 3 additions & 3 deletions src/disp/disp_qy.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ let QyDisplay = class extends RootDisplay {
upThis.#nmdb[4227 + x + (y << 7)] = e;
});
// The tempo pill
if (sum.tempo != 120) {
if (sum.tempo !== 120) {
upThis.qyRsrc.getBm("ActPill")?.render((e, x, y) => {
upThis.#nmdb[5141 + x + (y << 7)] = e;
});
Expand Down Expand Up @@ -513,7 +513,7 @@ let QyDisplay = class extends RootDisplay {
// Commit to display accordingly.
this.#nmdb.forEach((e, i) => {
let pixX = i & 127, pixY = i >> 7;
let hasDifference = this.#omdb[i] != e;
let hasDifference = this.#omdb[i] !== e;
if (!drawPixMode && hasDifference) {
ctx.fillStyle = this.#backlight.slice(0, 7);
ctx.fillRect(6 * pixX + 7, 7 + (pixY << 3), 6, 8);
Expand All @@ -528,7 +528,7 @@ let QyDisplay = class extends RootDisplay {
});
// Commit to old display buffer.
this.#nmdb.forEach((e, i) => {
if (this.#omdb[i] != e) {
if (this.#omdb[i] !== e) {
this.#omdb[i] = e;
};
});
Expand Down
12 changes: 6 additions & 6 deletions src/disp/disp_sc.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ let ScDisplay = class extends RootDisplay {
upThis.#nmdb[textMultiTable[pY] + pX] = e1 ? upThis.#pixelLit : upThis.#pixelOff;
});
});
} else if (timeNow <= sum.letter.expire && ((sum.mode != "gs" && sum.mode != "sc") || sum.letter.text?.length <= 16)) {
} else if (timeNow <= sum.letter.expire && ((sum.mode !== "gs" && sum.mode !== "sc") || sum.letter.text?.length <= 16)) {
infoTxt = isTextNull;
let original = sum.letter.text,
leftTrim = original.length - original.trimLeft().length,
Expand Down Expand Up @@ -417,7 +417,7 @@ let ScDisplay = class extends RootDisplay {
} else {
upThis.#linger[i] = (((e >> 4) << 4) + 15) << 8;
};
if (scConf.peakHold != 3 || upThis.#noteOn[i] > 0) {
if (scConf.peakHold !== 3 || upThis.#noteOn[i] > 0) {
upThis.#keep[i] = 56;
};
} else if (upThis.#keep[i] > 15) {
Expand All @@ -443,7 +443,7 @@ let ScDisplay = class extends RootDisplay {
if (scConf.peakHold === 3) {
//console.debug(`Tendency: ${Math.sign((upThis.#linger[i] >> 8) - upThis.#lingerOld[i])}`);
if (upThis.#keep[i] < 16) {
if (upThis.#peak[i] != 0 && (upThis.#linger[i] >> 8) <= upThis.#lingerOld[i]) {
if (upThis.#peak[i] !== 0 && (upThis.#linger[i] >> 8) <= upThis.#lingerOld[i]) {
//console.debug(`Float!`);
let val = upThis.#peak[i];
val += (384 << rendMode);
Expand Down Expand Up @@ -572,7 +572,7 @@ let ScDisplay = class extends RootDisplay {
};
// Guide the drawn matrix
upThis.#nmdb.forEach((e, i) => {
if (upThis.#dmdb[i] != e) {
if (upThis.#dmdb[i] !== e) {
if (upThis.useBlur) {
let diff = e - upThis.#dmdb[i],
cap = 80;
Expand All @@ -588,7 +588,7 @@ let ScDisplay = class extends RootDisplay {
});
// Do the actual drawing
upThis.#dmdb.forEach((e, oi) => {
if (fullRefresh || upThis.#omdb[oi] != e) {
if (fullRefresh || upThis.#omdb[oi] !== e) {
let startX, startY, width = mspWidth, height = mspWidth;
// Position the pixels
if (oi < 665) {
Expand Down Expand Up @@ -640,7 +640,7 @@ let ScDisplay = class extends RootDisplay {
});
// Store the historical draws
upThis.#dmdb.forEach((e, i) => {
if (upThis.#omdb[i] != e) {
if (upThis.#omdb[i] !== e) {
upThis.#omdb[i] = e;
};
});
Expand Down
18 changes: 9 additions & 9 deletions src/disp/disp_sc8850.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ let Sc8850Display = class extends RootDisplay {
upThis.#ch = ev.data;
});
upThis.addEventListener("portrange", (ev) => {
if (ev && ev.data != 1 << Math.log2(ev.data)) {
if (ev && ev.data !== 1 << Math.log2(ev.data)) {
console.debug(`MU display rejected port range value ${ev.data}.`);
};
upThis.#range = ev.data;
});
upThis.addEventListener("portstart", (ev) => {
if (ev != 255 && ev >= allocated.port) {
if (ev !== 255 && ev >= allocated.port) {
console.debug(`MU display rejected port range value ${ev.data}.`);
};
upThis.#start = ev.data;
Expand Down Expand Up @@ -296,7 +296,7 @@ let Sc8850Display = class extends RootDisplay {
break;
};
};
if (scLetterMode != 0) {
if (scLetterMode !== 0) {
upThis.font7a.getStr(displayText).forEach((e0, i0) => {
let offsetX = i0 * 8;
e0.forEach((e1, i1) => {
Expand Down Expand Up @@ -392,7 +392,7 @@ let Sc8850Display = class extends RootDisplay {
};
});
});
if (voiceObject.standard != "GM" && mode != voiceObject.standard) {
if (voiceObject.standard !== "GM" && mode !== voiceObject.standard) {
upThis.font56.getStr(voiceObject.standard).forEach((e0, i0) => {
let offsetX = i0 * 6;
e0.forEach((e1, i1) => {
Expand Down Expand Up @@ -431,12 +431,12 @@ let Sc8850Display = class extends RootDisplay {
if (scConf.peakHold === 3 && upThis.#lingerPress[i]) {
upThis.#lingerPress[i] --;
upThis.#lingerExtra[i] = 127;
if (e != upThis.#linger[i]) {
if (e !== upThis.#linger[i]) {
upThis.#linger[i] = e;
};
};
if (e > upThis.#linger[i]) {
if (scConf.peakHold != 3 && upThis.#lingerPress[i]) {
if (scConf.peakHold !== 3 && upThis.#lingerPress[i]) {
upThis.#linger[i] = e;
upThis.#lingerExtra[i] = 127;
};
Expand Down Expand Up @@ -607,7 +607,7 @@ let Sc8850Display = class extends RootDisplay {
};
// Guide the drawn matrix
upThis.#nmdb.forEach((e, i) => {
if (upThis.#dmdb[i] != e) {
if (upThis.#dmdb[i] !== e) {
if (upThis.useBlur) {
let diff = e - upThis.#dmdb[i],
cap = 48;
Expand All @@ -624,7 +624,7 @@ let Sc8850Display = class extends RootDisplay {
// Do the actual drawing
upThis.#dmdb.forEach((e, i) => {
let pX = i % totalWidth, pY = Math.floor(i / totalWidth);
if (fullRefresh || upThis.#omdb[i] != e) {
if (fullRefresh || upThis.#omdb[i] !== e) {
let posX = 4 + 5 * pX, posY = 4 + 5 * pY;
ctx.clearRect(posX, posY, 5, 5);
ctx.fillStyle = backlight.orange;
Expand All @@ -642,7 +642,7 @@ let Sc8850Display = class extends RootDisplay {
});
// Store the historical draws
upThis.#dmdb.forEach((e, i) => {
if (upThis.#omdb[i] != e) {
if (upThis.#omdb[i] !== e) {
upThis.#omdb[i] = e;
};
});
Expand Down
4 changes: 2 additions & 2 deletions src/fakeMu/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ let useMidiBus = false;

// Generate Octavia channel switch SysEx
self.generateSwitch = function (ch = 0, min, max) {
if (min != undefined && max === undefined) {
if (min !== undefined && max === undefined) {
console.warn(`Invalid bounds for channel switch generation.`);
return;
};
let data = [67, 16, 73, 11, 0, 0, ch];
if (min != undefined) {
if (min !== undefined) {
data.push(Math.floor(Math.log2(max - min + 1)), min);
};
return {
Expand Down
6 changes: 3 additions & 3 deletions src/fakePsr/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ let demoId = 0;

// Generate Octavia channel switch SysEx
let generateSwitch = function (ch = 0, min, max) {
if (min != undefined && max === undefined) {
if (min !== undefined && max === undefined) {
console.warn(`Invalid bounds for channel switch generation.`);
return;
};
let data = [67, 16, 73, 11, 0, 0, ch];
if (min != undefined) {
if (min !== undefined) {
data.push(Math.floor(Math.log2(max - min + 1)), min);
};
return {
Expand Down Expand Up @@ -200,7 +200,7 @@ visualizer.addEventListener("reset", function (e) {
// Listen to mode switches
visualizer.addEventListener("mode", function (ev) {
stSwitch.to(stSwitchMode.indexOf(ev.data));
if (visualizer.getMode() != "?") {
if (visualizer.getMode() !== "?") {
let textCmd = [67, 16, 76, 6, 0, 0, 77, 79, 68, 69, 58, 32];
let modeText = {
gm: [71, 77],
Expand Down
Loading

0 comments on commit faf4990

Please sign in to comment.