2022-10-18 09:16:51 -04:00
|
|
|
import { base64, io } from "./deps.ts";
|
|
|
|
|
|
|
|
|
|
const stdinLines = io.readLines(Deno.stdin);
|
2022-10-18 08:08:26 -04:00
|
|
|
|
|
|
|
|
export function urlBase64Encode(data: ArrayBuffer) {
|
|
|
|
|
return base64.encode(data)
|
|
|
|
|
.replaceAll("+", "_")
|
|
|
|
|
.replaceAll("/", "-")
|
|
|
|
|
.replaceAll("=", "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function urlBase64Decode(data: string) {
|
|
|
|
|
return base64.decode(
|
|
|
|
|
data
|
|
|
|
|
.replaceAll("_", "+")
|
|
|
|
|
.replaceAll("-", "/"),
|
|
|
|
|
);
|
|
|
|
|
}
|
2022-10-18 09:16:51 -04:00
|
|
|
|
|
|
|
|
export async function readline() {
|
|
|
|
|
for await (const line of stdinLines) {
|
|
|
|
|
if (line !== "") {
|
|
|
|
|
return line;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|