UNPKG

@benev/slate

Version:
17 lines 557 B
import { Bytes } from "./bytes.js"; export const Base64 = { string(bytes) { return (typeof btoa === "function") ? btoa(String.fromCharCode(...bytes)) : Buffer.from(bytes).toString("base64"); }, bytes(string) { return (typeof atob === "function") ? Uint8Array.from(atob(string), char => char.charCodeAt(0)) : Uint8Array.from(Buffer.from(string, "base64")); }, random(count = 32) { return this.string(Bytes.random(count)); }, }; //# sourceMappingURL=base64.js.map