테스트 환경
import * as dotenv from "https://deno.land/[email protected]/dotenv/mod.ts" | |
import { basename } from "https://deno.land/[email protected]/path/mod.ts" | |
import { Command } from "https://deno.land/x/[email protected]/command/mod.ts" | |
import { z } from "https://deno.land/x/[email protected]/mod.ts" | |
import { asynciter } from "https://deno.land/x/[email protected]/mod.ts" | |
import { difference } from "https://deno.land/x/[email protected]/mod.ts" | |
import { match, P } from "npm:ts-pattern@^5.0.3" | |
const cookieKey = "AOC_SESSION" | |
const cookieSchema = z.string().min(1, "Session cannot be empty!") |
import { initContract, ServerInferResponseBody, ServerInferResponses } from "npm:@ts-rest/core" | |
import z, { boolean } from "npm:zod" | |
import { createExpressEndpoints, initServer } from "npm:@ts-rest/express" | |
// @deno-types=npm:@types/express | |
import express from "npm:express" | |
const dataSchema = z.object({ data: z.boolean().default(false) }) | |
type DataInfer = z.infer<typeof dataSchema> | |
type DataInput = z.input<typeof dataSchema> |
#!/usr/bin/env -S deno run --allow-run --allow-read --no-config --no-check --no-npm | |
import clipboard from "https://deno.land/x/[email protected]/mod.ts" | |
import { readAll } from "https://deno.land/[email protected]/streams/mod.ts" | |
const filename = Deno.args[0] | |
if (filename) { | |
const text = await Deno.readTextFile(filename) | |
await clipboard.writeText(text) | |
} else if (!Deno.isatty(Deno.stdin.rid)) { |
#!/usr/bin/env bash | |
readonly GREEN='\033[32m' | |
readonly NC='\033[0m' | |
header() { printf "${GREEN}$@${NC}"; } | |
readonly LOCATION=$(pwd)/bash-in-a-jar | |
header "installation location:\n" | |
echo ${LOCATION} |
export const mapEntries = <T, U>( | |
obj: Record<string, T>, | |
fn: (entry: [string, T]) => [string, U], | |
) => Object.fromEntries(Object.entries(obj).map(fn)) |
const getUrl = (elem: Element) => elem.getAttribute("href")!.split("?")[0] | |
const setQuery = (selector: string, query: string) => () => { | |
const elem = document.querySelector(selector) | |
if (!elem) { | |
console.log(`elem with ${selector} not found`) | |
return | |
} | |
const newSearchParams = new URLSearchParams({ q: query }) | |
elem.setAttribute("href", `${getUrl(elem)}?${newSearchParams}`) |
테스트 환경
#!/usr/bin/env -S deno run --allow-read --allow-write --allow-run --allow-env --unstable | |
import { Command } from "https://deno.land/x/[email protected]/command/mod.ts" | |
import { dirname, join } from "https://deno.land/[email protected]/path/mod.ts" | |
import { c, p } from "https://deno.land/x/[email protected]/mod.ts" | |
const mapKeys = | |
<A>(f: (k: string) => string) => (record: Readonly<Record<string, A>>): Record<string, A> => | |
Object.fromEntries(Object.entries(record).map(([k, v]) => [f(k), v])) |
import { | |
bgBrightRed, | |
bold, | |
brightGreen, | |
brightRed, | |
brightWhite, | |
brightYellow, | |
} from "https://deno.land/[email protected]/fmt/colors.ts" | |
import { c, p } from "https://deno.land/x/[email protected]/mod.ts" | |
import { match } from "npm:ts-pattern" |
declare global { | |
interface PromiseConstructor { | |
resolve<const T>(value: T): Promise<Awaited<T>> | |
} | |
} |