mirror of
https://codeberg.org/emersion/gamja.git
synced 2024-11-14 10:55:06 -05:00
Disallow var keyword
This commit is contained in:
parent
312c755c11
commit
07ae5f7167
2 changed files with 9 additions and 8 deletions
|
@ -20,6 +20,7 @@ export default [
|
|||
caughtErrorsIgnorePattern: "^_",
|
||||
destructuredArrayIgnorePattern: "^_",
|
||||
}],
|
||||
"no-var": "error",
|
||||
},
|
||||
},
|
||||
];
|
||||
|
|
|
@ -12,13 +12,13 @@ export function encode(data) {
|
|||
return btoa(data);
|
||||
}
|
||||
|
||||
var encoder = new TextEncoder();
|
||||
var bytes = encoder.encode(data);
|
||||
let encoder = new TextEncoder();
|
||||
let bytes = encoder.encode(data);
|
||||
|
||||
var trailing = bytes.length % 3;
|
||||
var out = "";
|
||||
for (var i = 0; i < bytes.length - trailing; i += 3) {
|
||||
var u24 = (bytes[i] << 16) + (bytes[i + 1] << 8) + bytes[i + 2];
|
||||
let trailing = bytes.length % 3;
|
||||
let out = "";
|
||||
for (let i = 0; i < bytes.length - trailing; i += 3) {
|
||||
let u24 = (bytes[i] << 16) + (bytes[i + 1] << 8) + bytes[i + 2];
|
||||
out += alphabet[(u24 >> 18) & 0x3F];
|
||||
out += alphabet[(u24 >> 12) & 0x3F];
|
||||
out += alphabet[(u24 >> 6) & 0x3F];
|
||||
|
@ -26,12 +26,12 @@ export function encode(data) {
|
|||
}
|
||||
|
||||
if (trailing == 1) {
|
||||
var u8 = bytes[bytes.length - 1];
|
||||
let u8 = bytes[bytes.length - 1];
|
||||
out += alphabet[u8 >> 2];
|
||||
out += alphabet[(u8 << 4) & 0x3F];
|
||||
out += "==";
|
||||
} else if (trailing == 2) {
|
||||
var u16 = (bytes[bytes.length - 2] << 8) + bytes[bytes.length - 1];
|
||||
let u16 = (bytes[bytes.length - 2] << 8) + bytes[bytes.length - 1];
|
||||
out += alphabet[u16 >> 10];
|
||||
out += alphabet[(u16 >> 4) & 0x3F];
|
||||
out += alphabet[(u16 << 2) & 0x3F];
|
||||
|
|
Loading…
Reference in a new issue