mirror of
https://codeberg.org/emersion/gamja.git
synced 2024-11-14 19:05:01 -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: "^_",
|
caughtErrorsIgnorePattern: "^_",
|
||||||
destructuredArrayIgnorePattern: "^_",
|
destructuredArrayIgnorePattern: "^_",
|
||||||
}],
|
}],
|
||||||
|
"no-var": "error",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
|
@ -12,13 +12,13 @@ export function encode(data) {
|
||||||
return btoa(data);
|
return btoa(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
var encoder = new TextEncoder();
|
let encoder = new TextEncoder();
|
||||||
var bytes = encoder.encode(data);
|
let bytes = encoder.encode(data);
|
||||||
|
|
||||||
var trailing = bytes.length % 3;
|
let trailing = bytes.length % 3;
|
||||||
var out = "";
|
let out = "";
|
||||||
for (var i = 0; i < bytes.length - trailing; i += 3) {
|
for (let i = 0; i < bytes.length - trailing; i += 3) {
|
||||||
var u24 = (bytes[i] << 16) + (bytes[i + 1] << 8) + bytes[i + 2];
|
let u24 = (bytes[i] << 16) + (bytes[i + 1] << 8) + bytes[i + 2];
|
||||||
out += alphabet[(u24 >> 18) & 0x3F];
|
out += alphabet[(u24 >> 18) & 0x3F];
|
||||||
out += alphabet[(u24 >> 12) & 0x3F];
|
out += alphabet[(u24 >> 12) & 0x3F];
|
||||||
out += alphabet[(u24 >> 6) & 0x3F];
|
out += alphabet[(u24 >> 6) & 0x3F];
|
||||||
|
@ -26,12 +26,12 @@ export function encode(data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trailing == 1) {
|
if (trailing == 1) {
|
||||||
var u8 = bytes[bytes.length - 1];
|
let u8 = bytes[bytes.length - 1];
|
||||||
out += alphabet[u8 >> 2];
|
out += alphabet[u8 >> 2];
|
||||||
out += alphabet[(u8 << 4) & 0x3F];
|
out += alphabet[(u8 << 4) & 0x3F];
|
||||||
out += "==";
|
out += "==";
|
||||||
} else if (trailing == 2) {
|
} 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 >> 10];
|
||||||
out += alphabet[(u16 >> 4) & 0x3F];
|
out += alphabet[(u16 >> 4) & 0x3F];
|
||||||
out += alphabet[(u16 << 2) & 0x3F];
|
out += alphabet[(u16 << 2) & 0x3F];
|
||||||
|
|
Loading…
Reference in a new issue