Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
webdev03 committed Oct 24, 2023
1 parent 283fe4c commit f6e268b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
8 changes: 5 additions & 3 deletions src/classes/Studio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,11 @@ class Studio {
}
}
);
if(!req.ok) {
throw Error(`Could not join studio -- did you get an invite? ${req.statusText}`);
};
if (!req.ok) {
throw Error(
`Could not join studio -- did you get an invite? ${req.statusText}`
);
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/classes/cloud/PacketCloud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class PacketCloud extends events.EventEmitter {
const decoder = decode(data.value);
const name = decoder.next().value;
const value = decoder.next().value;
if(!name || !value) return;
if (!name || !value) return;
this.emit(this.onRequest, name, value);
this.emit(name, value);
}
Expand Down
19 changes: 11 additions & 8 deletions src/classes/cloud/utils.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
export const CHARSET = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`~1234567890! @#$%^&*()_-.\";:'?><,/".split("");
export const CHARSET =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`~1234567890! @#$%^&*()_-.\";:'?><,/".split(
""
);
export function encode(string: string) {
let result = "";
for(let i = 0; i < string.length; i++) {
result += CHARSET.findIndex(x => x === string[i]) + 10;
};
for (let i = 0; i < string.length; i++) {
result += CHARSET.findIndex((x) => x === string[i]) + 10;
}
return result + "00";
};
}
export function* decode(string: string) {
let value = "";
for(let i = 1; i < string.length; i += 2) {
const idx = Number(string[i-1] + string[i]) - 10;
if(idx < 0) {
for (let i = 1; i < string.length; i += 2) {
const idx = Number(string[i - 1] + string[i]) - 10;
if (idx < 0) {
yield value;
value = "";
} else value += CHARSET[idx];
Expand Down

0 comments on commit f6e268b

Please sign in to comment.