1// Times how long an execution takes
2// usage: @stevekrouse.panphoraDistanceTimed
3export async function timed(f) {
4 const start = Date.now();
5 const res = await f();
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export function discordMessages({ botToken, channelId }) {
4 return fetchJSON(
5 `https://discord.com/api/channels/${channelId}/messages`,
1export function proj(ll: Pos2): Pos2 {
2 // Arbitrary.
3 const D2R = Math.PI / 180;
1let { untitled_test_state } = await import("https://esm.town/v/stevekrouse/untitled_test_state");
2
3export function untitled_mutate_test_state(newState) {
4 return (untitled_test_state = newState);
5}
4 );
5 const html = htm.bind(h);
6 function Component() {
7 const [count, setCount] = useState(0);
8 return html`<div class="foo">${count}</div>`;
1import { h as h2 } from "https://esm.town/v/tmcw/h";
2
3export function h(tagName: string, attrsPlus?: any, ...children: any[]) {
4 if (!attrsPlus) attrsPlus = {};
5 if (attrsPlus.isEl || typeof attrsPlus === "string")
28 .join("");
29 const attrsToEmit = Object.entries(attrsPlus).reduce((acc: any, [k, v]) => {
30 if (k.startsWith("on") && typeof v === "function") return acc; // Skip events
31 if (v === null || v === undefined) return acc; // Skip null/undefined
32 if (typeof v === "function") v = v(); // Allow dynamic stuff (continue to rest of function)
33 if (k === "innerHTML") innerHtml = String(v);
34 else if (k === "innerText") innerHtml = text2Html(String(v));
1import { jsJamMessages } from "https://esm.town/v/stevekrouse/jsJamMessages";
2
3export function jsJamHTML(req, res) {
4 res.send(`<h1>${JSON.stringify(jsJamMessages)}</h1>`);
5}
1export function question() {
2 return "hello";
3}
28
29 console.log(
30 `average e2e user function time: ${(
31 userFuncTimes.reduce((a, b) => a + b, 0) / count
32 ).toFixed(0)}ms (fastest was ${userFuncTimes
1export function double(x: number) {
2 return 2 * x;
3}