mirror of
https://github.com/tenrok/axios.git
synced 2026-06-14 18:42:33 +03:00
Using more strict eslint rules
This commit is contained in:
+5
-4
@@ -11,11 +11,12 @@ InvalidCharacterError.prototype = new Error;
|
||||
InvalidCharacterError.prototype.code = 5;
|
||||
InvalidCharacterError.prototype.name = 'InvalidCharacterError';
|
||||
|
||||
function btoa (input) {
|
||||
function btoa(input) {
|
||||
var str = String(input);
|
||||
var output = '';
|
||||
for (
|
||||
// initialize result and counter
|
||||
var block, charCode, idx = 0, map = chars, output = '';
|
||||
var block, charCode, idx = 0, map = chars;
|
||||
// if the next str index does not exist:
|
||||
// change the mapping table to "="
|
||||
// check if d has no fractional digits
|
||||
@@ -23,13 +24,13 @@ function btoa (input) {
|
||||
// "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8
|
||||
output += map.charAt(63 & block >> 8 - idx % 1 * 8)
|
||||
) {
|
||||
charCode = str.charCodeAt(idx += 3/4);
|
||||
charCode = str.charCodeAt(idx += 3 / 4);
|
||||
if (charCode > 0xFF) {
|
||||
throw new InvalidCharacterError('INVALID_CHARACTER_ERR: DOM Exception 5');
|
||||
}
|
||||
block = block << 8 | charCode;
|
||||
}
|
||||
return output;
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = btoa;
|
||||
|
||||
Reference in New Issue
Block a user