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/$%7Bart_info.art.src%7D?q=function&page=2325&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 28709 results for "function"(4373ms)

ThankYouNoteGeneratormain.tsx6 matches

@prashamtrivedi•Updated 6 months ago
5import { createRoot } from "https://esm.sh/react-dom/client";
6
7function ThankYouCard({ note, theme, font, recipientName, senderName }) {
8 const [firstHalf, secondHalf] = splitNote(note);
9
30}
31
32function splitNote(note) {
33 const words = note.split(" ");
34 const midpoint = Math.ceil(words.length / 2);
39}
40
41function capitalizeName(name) {
42 if (!name) return "";
43 return name
50}
51
52function App() {
53 const [recipientName, setRecipientName] = useState("");
54 const [senderName, setSenderName] = useState("");
295}
296
297function client() {
298 createRoot(document.getElementById("root")).render(<App />);
299}
303}
304
305export default async function server(request: Request): Promise<Response> {
306 console.log(`Received ${request.method} request to ${request.url}`);
307

adventurousApricotGophermain.tsx5 matches

@deffgod•Updated 6 months ago
127];
128
129function VideoPlayer({ course }: { course: Course }) {
130 const [currentVideo, setCurrentVideo] = useState<CourseVideo | null>(null);
131 const [progress, setProgress] = useState(0);
206}
207
208function CourseCatalog() {
209 const [selectedCourse, setSelectedCourse] = useState<Course | null>(null);
210 const [filter, setFilter] = useState<string | null>(null);
290}
291
292function App() {
293 return <CourseCatalog />;
294}
295
296function client() {
297 createRoot(document.getElementById("root")).render(<App />);
298}
299if (typeof document !== "undefined") { client(); }
300
301export default async function server(request: Request): Promise<Response> {
302 return new Response(`
303 <html>

rssSummarizermain.tsx3 matches

@jamiedubs•Updated 6 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 const [feedUrl, setFeedUrl] = React.useState("https://usv.com/feed/");
7 const [results, setResults] = React.useState(null);
94}
95
96function client() {
97 createRoot(document.getElementById("root")).render(<App />);
98}
102}
103
104export default async function server(request: Request): Promise<Response> {
105 const url = new URL(request.url);
106

runGlifmain.tsx1 match

@jamiedubs•Updated 6 months ago
9}
10
11export async function runGlif({
12 id,
13 inputs,

BTCPriceCheckermain.tsx4 matches

@ericxyz86•Updated 6 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function CryptoPriceApp() {
6 const [prices, setPrices] = useState<{
7 bitcoin: { current: number | null, previous: number | null },
15
16 useEffect(() => {
17 async function fetchCryptoPrices() {
18 try {
19 // Fetch Bitcoin price from CoinDesk
195}
196
197function client() {
198 createRoot(document.getElementById("root")).render(<CryptoPriceApp />);
199}
200if (typeof document !== "undefined") { client(); }
201
202export default async function server(request: Request): Promise<Response> {
203 return new Response(`
204 <html>

brokenCountVowelsmain.tsx1 match

@willthereader•Updated 6 months ago
1export function brokenCountVowels(str) {
2 const lowerStr = str.toLowerCase();
3 const vowels = ["a", "e"]; // Still broken - only counting 'a' and 'e'

helpfulFuchsiaAmphibianmain.tsx6 matches

@Handlethis•Updated 6 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 const [generatedImage, setGeneratedImage] = useState("");
7 const [audioDescription, setAudioDescription] = useState("AI continues to revolutionize audio generation with innovative technologies in music composition, voice synthesis, and sound design.");
9
10 useEffect(() => {
11 async function fetchContent() {
12 try {
13 // Generate AI audio description
60• Text Generation: Crafting coherent and contextually relevant responses for creative writing, communication, or educational purposes.
61• Coding Assistance: Offering explanations, code snippets, and debugging help for developers.
62• Learning and Experimentation: Helping users explore AI's capabilities and understand how language models function.
63
64Val Town
65Val Town empowers users by simplifying the process of creating and deploying small programs and scripts. Its intuitive platform enables developers and hobbyists to:
66
67• Build Functional Programs: Create code for tasks such as automations, integrations, or unique applications.
68• Coding Support: Generate, test, and refine code in an interactive environment, making it accessible for learning and experimentation.
69• Rapid Prototyping: Develop and share scripts or apps quickly without the need for extensive setup.
144}
145
146function client() {
147 createRoot(document.getElementById("root")).render(<App />);
148}
152}
153
154export default async function server(request: Request): Promise<Response> {
155 return new Response(
156 `

test_explorermain.tsx9 matches

@willthereader•Updated 6 months ago
4
5const exampleTests = {
6 basic: `// Test a simple addition function
7const result = module.add(2, 3);
8if (result !== 5) {
10}
11return "Basic addition test passed!";`,
12 async: `// Test an async function that fetches data
13const data = await module.fetchData();
14if (!Array.isArray(data) || data.length === 0) {
25 return "Error handling test passed!";
26}
27throw new Error("Expected function to throw an error");`,
28};
29
30function App() {
31 const [valUrl, setValUrl] = useState("");
32 const [testCode, setTestCode] = useState("");
117}
118
119function client() {
120 createRoot(document.getElementById("root")).render(<App />);
121}
125}
126
127async function runTests(valUrl: string, testCode: string) {
128 try {
129 const module = await import(valUrl);
130 const testFunction = new Function('module', testCode);
131 const testResults = testFunction(module);
132 return { success: true, results: testResults };
133 } catch (error) {
143}
144
145export default async function server(request: Request): Promise<Response> {
146 if (request.method === "POST" && new URL(request.url).pathname === "/run-tests") {
147 const { valUrl, testCode } = await request.json();

unsubscribeFromNewslettermain.tsx1 match

@petermillspaugh•Updated 6 months ago
2import { sqlite } from "https://esm.town/v/std/sqlite?v=4";
3
4export async function unsubscribe(req: Request) {
5 const searchParams = new URL(req.url).searchParams;
6 const emailAddress = searchParams.get("email");

lastloginmain.tsx4 matches

@stevekrouse•Updated 6 months ago
1/** @jsxImportSource npm:hono/jsx */
2async function createSession(email: string, hostname: string) {
3 const { zip } = await import("https://esm.town/v/pomdtr/sql");
4 const { sqlite } = await import("https://esm.town/v/std/sqlite");
23}
24
25async function getSession(sessionID: string, hostname: string) {
26 const { zip } = await import("https://esm.town/v/pomdtr/sql");
27 const { sqlite } = await import("https://esm.town/v/std/sqlite");
52}
53
54async function deleteSession(sessionID: string) {
55 const { sqlite } = await import("https://esm.town/v/std/sqlite");
56
64const OAUTH_COOKIE = "oauth_store";
65
66export function lastlogin(
67 handler: (req: Request) => Response | Promise<Response>,
68) {

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.