ethers.js/packages/base64/lib.esm/browser.js
2020-07-13 08:03:56 -04:00

19 lines
521 B
JavaScript

"use strict";
import { arrayify } from "@ethersproject/bytes";
export function decode(textData) {
textData = atob(textData);
const data = [];
for (let i = 0; i < textData.length; i++) {
data.push(textData.charCodeAt(i));
}
return arrayify(data);
}
export function encode(data) {
data = arrayify(data);
let textData = "";
for (let i = 0; i < data.length; i++) {
textData += String.fromCharCode(data[i]);
}
return btoa(textData);
}
//# sourceMappingURL=browser.js.map