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=1225&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 16278 results for "function"(1210ms)

smallAndCuteSnakeGamemain.tsx3 matches

@jake•Updated 6 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 const [count, setCount] = useState(0);
7
55}
56
57function client() {
58 createRoot(document.getElementById("root")).render(<App />);
59}
63}
64
65export default async function server(request: Request): Promise<Response> {
66 return new Response(`
67 <!DOCTYPE html>

groceriesmain.tsx3 matches

@efoley•Updated 6 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 const [items, setItems] = useState([]);
7 const [newItem, setNewItem] = useState("");
75}
76
77function client() {
78 createRoot(document.getElementById("root")).render(<App />);
79}
83}
84
85export default async function server(request: Request): Promise<Response> {
86 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
87 const SCHEMA_VERSION = 1;

createFlashcardsValmain.tsx3 matches

@reginafoley•Updated 6 months ago
9cherry,a small round stone fruit with red skin`;
10
11function App() {
12 const [flashcards, setFlashcards] = useState([]);
13 const [currentCard, setCurrentCard] = useState(null);
95}
96
97function client() {
98 createRoot(document.getElementById("root")).render(<App />);
99}
103}
104
105export default async function server(request: Request): Promise<Response> {
106 const url = new URL(request.url);
107

browserbasePuppeteerExamplemain.tsx2 matches

@Joelsrubin•Updated 6 months ago
2import puppeteer from "npm:puppeteer-core";
3
4async function sendPDF() {
5 console.log("Initiating pdf sender");
6 const browser = await puppeteer.connect({
28}
29
30export default async function() {
31 console.log("RUnning");
32 await sendPDF();

generateDailyTwitterEmailmain.tsx3 matches

@Joelsrubin•Updated 6 months ago
1import { email } from "https://esm.town/v/std/email";
2
3async function fetchTweets(listId: string): Promise<any[]> {
4 const url = `https://news.ycombinator.com/`;
5 const response = await fetch(url);
17}
18
19function formatTweetsForEmail(tweets: any[]): string {
20 return tweets.map((tweet, index) => `
21 ${index + 1}. @${tweet.username} (${tweet.likes} likes)
25}
26
27export default async function(interval: Interval) {
28 const listId = "1359390628841480192";
29 const tweets = await fetchTweets(listId);

randomTextGeneratormain.tsx3 matches

@aleaf•Updated 6 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 const [paragraphs, setParagraphs] = useState(1);
7 const [text, setText] = useState("");
64}
65
66function client() {
67 createRoot(document.getElementById("root")).render(<App />);
68}
69if (typeof document !== "undefined") { client(); }
70
71export default async function server(request: Request): Promise<Response> {
72 const url = new URL(request.url);
73 const paragraphs = Number(url.searchParams.get("paragraphs")) || 1;

anthropicCachingmain.tsx8 matches

@jake•Updated 6 months ago
1/**
2 * This val creates an interactive webpage that demonstrates the functionality of the Anthropic API.
3 * It uses a React frontend with an input for the API key and buttons to trigger different operations.
4 * The Anthropic API key is stored in the frontend state and sent with each API request.
9import { createRoot } from "https://esm.sh/react-dom/client";
10
11function App() {
12 const [apiKey, setApiKey] = useState("");
13 const [outputs, setOutputs] = useState({
82}
83
84function client() {
85 createRoot(document.getElementById("root")).render(<App />);
86}
90}
91
92async function server(request: Request): Promise<Response> {
93 const url = new URL(request.url);
94
138}
139
140async function fetchContent(): Promise<string> {
141 const response = await fetch("https://www.gutenberg.org/cache/epub/1342/pg1342.txt");
142 const text = await response.text();
146}
147
148async function runNonCachedCall(apiKey: string): Promise<string> {
149 const { default: anthropic } = await import("npm:@anthropic-ai/sdk@0.26.1");
150 const client = new anthropic.Anthropic({ apiKey });
182}
183
184async function runCachedCall(apiKey: string): Promise<string> {
185 const { default: anthropic } = await import("npm:@anthropic-ai/sdk@0.26.1");
186 const client = new anthropic.Anthropic({ apiKey });
221}
222
223async function runMultiTurnConversation(apiKey: string): Promise<string> {
224 const { default: anthropic } = await import("npm:@anthropic-ai/sdk@0.26.1");
225 const client = new anthropic.Anthropic({ apiKey });

anthropicCachingmain.tsx8 matches

@stevekrouse•Updated 6 months ago
1/**
2 * This val creates an interactive webpage that demonstrates the functionality of the Anthropic API.
3 * It uses a React frontend with an input for the API key and buttons to trigger different operations.
4 * The Anthropic API key is stored in the frontend state and sent with each API request.
9import { createRoot } from "https://esm.sh/react-dom/client";
10
11function App() {
12 const [apiKey, setApiKey] = useState("");
13 const [outputs, setOutputs] = useState({
82}
83
84function client() {
85 createRoot(document.getElementById("root")).render(<App />);
86}
90}
91
92async function server(request: Request): Promise<Response> {
93 const url = new URL(request.url);
94
138}
139
140async function fetchContent(): Promise<string> {
141 const response = await fetch("https://www.gutenberg.org/cache/epub/1342/pg1342.txt");
142 const text = await response.text();
146}
147
148async function runNonCachedCall(apiKey: string): Promise<string> {
149 const { default: anthropic } = await import("npm:@anthropic-ai/sdk@0.26.1");
150 const client = new anthropic.Anthropic({ apiKey });
182}
183
184async function runCachedCall(apiKey: string): Promise<string> {
185 const { default: anthropic } = await import("npm:@anthropic-ai/sdk@0.26.1");
186 const client = new anthropic.Anthropic({ apiKey });
221}
222
223async function runMultiTurnConversation(apiKey: string): Promise<string> {
224 const { default: anthropic } = await import("npm:@anthropic-ai/sdk@0.26.1");
225 const client = new anthropic.Anthropic({ apiKey });

superiorHarlequinUrialmain.tsx1 match

@junkerman2004•Updated 6 months ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2
3export default async function(req: Request): Promise<Response> {
4 if (req.method === "OPTIONS") {
5 return new Response(null, {

wallpapermain.tsx1 match

@Phaeris•Updated 6 months ago
1export default async function(req: Request): Promise<Response> {
2 const url =
3 "https://global.bing.com/HPImageArchive.aspx?format=js&idx=0&n=9&pid=hp&FORM=BEHPTB&uhd=1&uhdwidth=3840&uhdheight=2160&setmkt=zh-CN&setlang=en";

getFileEmail4 file matches

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

tuna8 file matches

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