2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-05 16:42:32 +03:00

Making btoa polyfill more standard

This commit is contained in:
Matt Zabriskie
2015-12-14 12:16:11 -07:00
parent c566567420
commit 77b8966b47
+3 -2
View File
@@ -8,6 +8,7 @@ function InvalidCharacterError(message) {
this.message = message;
}
InvalidCharacterError.prototype = new Error;
InvalidCharacterError.prototype.code = 5;
InvalidCharacterError.prototype.name = 'InvalidCharacterError';
function btoa (input) {
@@ -24,11 +25,11 @@ function btoa (input) {
) {
charCode = str.charCodeAt(idx += 3/4);
if (charCode > 0xFF) {
throw new InvalidCharacterError('\'btoa\' failed: The string to be encoded contains characters outside of the Latin1 range.');
throw new InvalidCharacterError('INVALID_CHARACTER_ERR: DOM Exception 5');
}
block = block << 8 | charCode;
}
return output;
};
module.exports = btoa
module.exports = btoa;