Val Town Code SearchReturn to Val Town

API Access

You can access search results via JSON API by adding format=json to your query:

https://codesearch.val.run/?q=function&page=2631&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=function

Returns an array of strings in format "username" or "username/projectName"

Found 28726 results for "function"(7484ms)

creativity_quotesmain.tsx1 match

@generatecoll•Updated 1 year ago
1import process from "node:process";
2
3export async function creativity_quote(request: Request): Promise<Response> {
4 const postgres = await import("https://deno.land/x/postgres/mod.ts");
5 const client = new postgres.Client(process.env.neon_url);

TodoAppmain.tsx6 matches

@summerboys•Updated 1 year ago
5import { Form, hydrate } from "https://esm.town/v/stevekrouse/ssr_react_mini?v=75";
6
7export async function loader(req: Request) {
8 const { sqlite } = await import("https://esm.town/v/std/sqlite?v=4");
9 const [, { columns, rows }] = await sqlite.batch([
20}
21
22export async function action(req: Request) {
23 const { sqlite } = await import("https://esm.town/v/std/sqlite?v=4");
24 const formData = await req.formData();
47}
48
49export function Component({ initialTodos, initialLogs }) {
50 const [todos, setTodos] = useState(initialTodos);
51 const [logs, setLogs] = useState(initialLogs);
54 useEffect(() => addLog(`Client rendered`), []);
55
56 function addTodo() {
57 setTodos([...todos, { text: newTodo }]);
58 setNewTodo("");
64 }
65
66 function toggleTodo(e) {
67 const formData = new FormData(e.target);
68 const id = parseInt(formData.get("id") as string);
71 }
72
73 function deleteTodo(e) {
74 const formData = new FormData(e.target);
75 const id = parseInt(formData.get("id") as string);

pollRSSFeedsmain.tsx1 match

@summerboys•Updated 1 year ago
3import { rssFeeds } from "https://esm.town/v/stevekrouse/rssFeeds";
4
5export async function pollRSSFeeds({ lastRunAt }: Interval) {
6 return Promise.all(
7 Object.entries(rssFeeds).map(async ([name, url]) => {

htmlExamplemain.tsx1 match

@summerboys•Updated 1 year ago
1// View at https://andreterron-htmlExample.web.val.run?name=Andre
2export default async function(req: Request): Promise<Response> {
3 const query = new URL(req.url).searchParams;
4

upload_urlmain.tsx2 matches

@stevekrouse•Updated 1 year ago
1// Function to upload data using Wormhole API and return the URL
2async function uploadToFileIo(file) {
3 const formData = new FormData();
4 formData.append("file", file);

uploadTo0x0main.tsx1 match

@stevekrouse•Updated 1 year ago
1export async function uploadTo0x0(data, name) {
2 const blob = new Blob([data]);
3 const formData = new FormData();

dailyDadJokemain.tsx1 match

@bomberstudios•Updated 1 year ago
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3
4export async function dailyDadJoke() {
5 let { setup, punchline } = await fetchJSON("https://official-joke-api.appspot.com/random_joke");
6 return email({

hnResumemain.tsx1 match

@cocodrilette•Updated 1 year ago
1import { email } from "https://esm.town/v/std/email?v=9";
2
3export default async function(interval: Interval) {
4 const ntfyURL = `https://ntfy.sh/${Deno.env.get("NTFY_ID")}`;
5 const hnTopStoriesURL = "https://hacker-news.firebaseio.com/v0/topstories.json";

blob_editormain.tsx4 matches

@pomdtr•Updated 1 year ago
3import { useEffect, useRef } from "https://esm.sh/hono/jsx/dom";
4
5export function BlobEditor(props: { blob: { language?: string; text: string } }) {
6 const ref = useRef();
7 const saveBlob = async () => {
43}
44
45export function blobEditor(key: string, options?: { title?: string }) {
46 return async (req: Request) => {
47 const { html } = await import("https://esm.town/v/pomdtr/gfm");
53 const { extractValInfo } = await import("https://esm.town/v/pomdtr/extractValInfo");
54
55 async function readBlob(key: string) {
56 const resp = await blob.get(key);
57 if (resp.status == 200) {
162}
163
164export default async function(req: Request) {
165 const { modifyFetchHandler } = await import("https://esm.town/v/andreterron/codeOnValTown?v=50");
166 return modifyFetchHandler(blobEditor("blob_editor_demo.md"))(req);

dailyDadJokemain.tsx1 match

@sieteunoseis•Updated 1 year ago
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3
4export async function dailyDadJoke() {
5 let { setup, punchline } = await fetchJSON("https://official-joke-api.appspot.com/random_joke");
6 return punchline;

getFileEmail4 file matches

@shouser•Updated 1 month ago
A helper function to build a file's email
tuna

tuna8 file matches

@jxnblk•Updated 1 month ago
Simple functional CSS library for Val Town
lost1991
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": "*",
webup
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.