4import { gfm } from "https://esm.town/v/pomdtr/gfm";
5
6export async function ideaList(author: string, name: string) {
7 const { code, readme } = await api(`/v1/alias/${author}/${name}`);
8 const title = extractMetadata("title", code);
1import trackingParams from "https://esm.town/v/nbbaier/utilities/urlTools/trackingParams";
2
3function removeTrackingParams(url: URL, customParams: string[] = []): URL {
4 const paramsToRemove = [...new Set([...customParams, ...trackingParams])];
5 const params = new URLSearchParams(url.search.replace(/amp;/g, "&"));
1export async function paginatedResponse(req: Request, data: any[], defaultLimit: number = 20): Promise<Response> {
2 const url = new URL(req.url);
3 const searchParams = Object.fromEntries(url.searchParams.entries());
3## Fetch Paginated Data
4
5This val exports a function that loops through paginated API responses and returns the combined data as an array. It expects pagination with `next` and there to be a `data` property in the API response. This conforms to the Val Town API, so this function is useful when fetching paginated Val Town API responses for creating custom folders in [pomdtr's vscode extension](https://github.com/pomdtr/valtown-vscode).
6
7Usage:
17## Return a paginated response
18
19A helper function to take an array and return a paginated response. This is useful when defining one's own folders for [pomdtr's vscode extension](https://github.com/pomdtr/valtown-vscode).
20
21Usage:
24const data = [...]
25
26export default async function(req: Request): Promise<Response> {
27 return paginatedResponse(req, data);
28}
1import { fetch } from "https://esm.town/v/std/fetch?v=4";
2
3export async function fetchPaginatedData(url: string, init?: RequestInit, limit: number = 100) {
4 let u = new URL(url);
5 u.searchParams.set("limit", String(limit));
3import React, { useState } from "https://esm.sh/react@18.2.0";
4
5function Calculator() {
6 const [display, setDisplay] = useState("0");
7 const [previousValue, setPreviousValue] = useState(null);
80}
81
82function client() {
83 createRoot(document.getElementById("root")).render(<Calculator />);
84}
85if (typeof document !== "undefined") { client(); }
86
87export default async function server(request: Request): Promise<Response> {
88 return new Response(
89 `
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function VoiceCalculator() {
6 const [result, setResult] = useState('0');
7 const [isListening, setIsListening] = useState(false);
132}
133
134function client() {
135 createRoot(document.getElementById("root")).render(<VoiceCalculator />);
136}
138if (typeof document !== "undefined") { client(); }
139
140export default async function server(request: Request): Promise<Response> {
141 return new Response(`
142 <html>
12const lock = new SqliteLock(projectVal.name, twoMinutes);
13
14export default async function(interval: Interval) {
15 await lock.lock()
16}
6const lock = new SqliteLock(projectVal.name, twoMinutes);
7
8export default async function(interval: Interval) {
9 console.log(await lock.lock());
10}
1export default async function (req: Request): Promise<Response> {
2 return Response.json({ ok: true })
3}
Simple functional CSS library for Val Town
A helper function to build a file's email
import { OpenAI } from "https://esm.town/v/std/openai";
export default async function(req: Request): Promise<Response> {
if (req.method === "OPTIONS") {
return new Response(null, {
headers: {
"Access-Control-Allow-Origin": "*",
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.