Skip to content

Commit

Permalink
feat: var => let and fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
xhayper committed Dec 2, 2023
1 parent 8b82cb7 commit 1d9fe83
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/internal/syntacticAnalysis/deserializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ export class Deserializer {
case -1:
return (startLocation.index + 2) % 8 >= 4 ? SlideType.RingCw : SlideType.RingCcw;
default:
var difference = endLocation.index - startLocation.index;
let difference = endLocation.index - startLocation.index;

var rotation = difference >= 0 ? (difference > 4 ? -1 : 1) : difference < -4 ? 1 : -1;
let rotation = difference >= 0 ? (difference > 4 ? -1 : 1) : difference < -4 ? 1 : -1;

return rotation > 0 ? SlideType.RingCw : SlideType.RingCcw;
}
Expand Down
2 changes: 1 addition & 1 deletion src/internal/syntacticAnalysis/states/noteReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class NoteReader {
let manuallyMoved = false;

while (!parent.endOfFile && (manuallyMoved || parent.moveNext())) {
const token = parent.enumerator.current;
const token = parent.enumerator.current!;
manuallyMoved = false;

switch (token.type) {
Expand Down
6 changes: 3 additions & 3 deletions src/internal/syntacticAnalysis/states/slideReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class SlideReader {
let manuallyMoved = true;

while (!parent.endOfFile && (manuallyMoved || parent.moveNext())) {
var token = parent.enumerator.current;
const token = parent.enumerator.current!;
manuallyMoved = false;

switch (token.type) {
Expand Down Expand Up @@ -144,11 +144,11 @@ export class SlideReader {
do {
if (!parent.moveNext()) throw new UnsupportedSyntaxException(identityToken.line, identityToken.character);

const current = parent.enumerator.current;
const current = parent.enumerator.current!;

const [isLocationToken, location] = Deserializer.tryReadLocation(current);
if (isLocationToken) segment.vertices.push(location);
} while (parent.enumerator.current.type === TokenType.Location);
} while (parent.enumerator.current!.type === TokenType.Location);
}

private static readDuration(timing: TimingChange, token: Token, path: SlidePath) {
Expand Down
12 changes: 6 additions & 6 deletions src/internal/utility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ export class Utility {

const threshold = 0.1; // proportion of chars step 2 which must be zeroed to be diagnosed as utf-16. 0.1 = 10%

var count = 0;
for (var n = 0; n < taster; n += 2) if (textBytes[n] == 0) count++;
let count = 0;
for (let n = 0; n < taster; n += 2) if (textBytes[n] == 0) count++;
if (count / taster > threshold) return "unicodebe"; // (big-endian)

count = 0;
for (var n = 1; n < taster; n += 2) if (textBytes[n] == 0) count++;
for (let n = 1; n < taster; n += 2) if (textBytes[n] == 0) count++;
if (count / taster > threshold) return "unicode"; // (little-endian)

for (var n = 0; n < taster - 9; n++) {
for (let n = 0; n < taster - 9; n++) {
if (
((String.fromCharCode(textBytes[n + 0]) !== "c" && String.fromCharCode(textBytes[n + 0]) !== "C") ||
(String.fromCharCode(textBytes[n + 1]) !== "h" && String.fromCharCode(textBytes[n + 1]) !== "H") ||
Expand Down Expand Up @@ -133,10 +133,10 @@ export class Utility {
// )
// n++;

// var nb = new byte[n - oldN]();
// let nb = new byte[n - oldN]();
// Array.Copy(textBytes, oldN, nb, 0, n - oldN);
// try {
// var internalEnc = Encoding.ASCII.GetString(nb);
// let internalEnc = Encoding.ASCII.GetString(nb);
// return Encoding.GetEncoding(internalEnc);
// } catch {
// // If C# doesn't recognize the name of the encoding, break.
Expand Down
2 changes: 1 addition & 1 deletion src/structures/note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class Note {
}

public getVisibleDuration(): number {
var baseValue = this.length ?? 0;
let baseValue = this.length ?? 0;

if (this.slidePaths.length > 0) baseValue = Math.max(...this.slidePaths.map((s) => s.delay + s.duration));

Expand Down

0 comments on commit 1d9fe83

Please sign in to comment.