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=1070&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 17298 results for "function"(2086ms)

graciousAmaranthMackerelmain.tsx3 matches

@imnk•Updated 3 months ago
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function App() {
6 const [image, setImage] = useState<File | null>(null);
7 const [analysis, setAnalysis] = useState<string | null>(null);
199}
200
201function client() {
202 createRoot(document.getElementById("root")).render(<App />);
203}
204if (typeof document !== "undefined") { client(); }
205
206export default async function server(request: Request): Promise<Response> {
207 if (request.method === 'POST' && new URL(request.url).pathname === '/analyze') {
208 const { OpenAI } = await import("https://esm.town/v/std/openai");

medicineLabelAnalyzerAppmain.tsx3 matches

@imnk•Updated 3 months ago
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function App() {
6 const [image, setImage] = useState<File | null>(null);
7 const [analysis, setAnalysis] = useState<string | null>(null);
93}
94
95function client() {
96 createRoot(document.getElementById("root")).render(<App />);
97}
98if (typeof document !== "undefined") { client(); }
99
100export default async function server(request: Request): Promise<Response> {
101 if (request.method === 'POST' && new URL(request.url).pathname === '/analyze') {
102 const { OpenAI } = await import("https://esm.town/v/std/openai");

tastefulIvoryWormmain.tsx1 match

@maxm•Updated 3 months ago
4 console.log("after 1s");
5});
6export default async function() {
7 console.log("from within export");
8}

Skyfallmain.tsx17 matches

@qkiii•Updated 3 months ago
3import React, { useEffect, useRef, useState } from "https://esm.sh/react@18.2.0";
4
5function CeilingEscapeGame() {
6 // Game state variables
7 const [gameState, setGameState] = useState("waiting"); // Current game state (waiting, playing, escaped, gameOver, highScore)
44 }, []);
45
46 // Function to save a new high score
47 const saveHighScore = (newScore) => {
48 const currentScores = JSON.parse(
62 };
63
64 // Function to start the game
65 const startGame = () => {
66 // Randomize game duration between 2 - 5 seconds
75 };
76
77 // Cubic Bezier easing function
78 function cubicBezier(p1x, p1y, p2x, p2y) {
79 return function(t) {
80 const k = 1 - t;
81 return 3 * k * k * t * p1y + 3 * k * t * t * p2y + t * t * t;
83 }
84
85 // Custom easing function using cubicBezier
86 function customEasing(t) {
87 return cubicBezier(0.13, 0.00, 0.85, 0.51)(t);
88 }
89
90 // Animate the ceiling's movement (unchanged, but uses the corrected customEasing)
91 function animateCeiling() {
92 const currentTime = Date.now();
93 const elapsedTime = currentTime - startTimeRef.current;
96 const progress = elapsedTime / gameDurationRef.current;
97
98 // Apply custom easing function to the progress
99 const easedProgress = customEasing(progress);
100
142 intervalRef.current = setInterval(animate, 16);
143
144 // Cleanup function to cancel animation and clear interval
145 return () => {
146 if (animationRef.current) {
154 }, [gameState]);
155
156 // Function to end the game
157 const endGame = (survived) => {
158 // Cancel any ongoing animations or intervals
206 window.addEventListener("touchstart", handleTap);
207
208 // Cleanup function to remove event listeners
209 return () => {
210 window.removeEventListener("keydown", handleKeyPress);
264
265 useEffect(() => {
266 // Function to generate confetti particles
267 const generateConfetti = () => {
268 const newConfetti = Array.from({ length: 50 }, () => ({
501
502// Root component for the app
503function App() {
504 return (
505 <div
520
521// Client-side rendering
522function client() {
523 createRoot(document.getElementById("root")).render(<App />);
524}
530
531// Server-side rendering (for potential future use)
532export default async function server(request: Request): Promise<Response> {
533 return new Response(
534 `

Touristmain.tsx5 matches

@vawogbemi•Updated 3 months ago
3import React, { useState, useEffect, useRef } from "https://esm.sh/react@18.2.0";
4
5function Map({ center, zoom, markers }) {
6 const ref = useRef();
7 const [map, setMap] = useState(null);
42}
43
44function App() {
45 const [messages, setMessages] = useState([]);
46 const [input, setInput] = useState("");
146}
147
148function client() {
149 const script = document.createElement('script');
150 script.src = `https://maps.googleapis.com/maps/api/js?key=${window.GOOGLE_MAPS_API_KEY}`;
161}
162
163async function makeGoogleMapsApiCall(endpoint, params) {
164 const baseUrl = "https://maps.googleapis.com/maps/api";
165 const url = new URL(`${baseUrl}${endpoint}`);
177}
178
179export default async function server(request: Request): Promise<Response> {
180 if (request.method === "POST" && new URL(request.url).pathname === "/chat") {
181 const { messages, location } = await request.json();

AlwaysHere_migratedmain.tsx3 matches

@varun1352•Updated 3 months ago
9}
10
11function App() {
12 const [name, setName] = useState("");
13 const [isNameEntered, setIsNameEntered] = useState(false);
263}
264
265function client() {
266 createRoot(document.getElementById("root")).render(<App />);
267}
271}
272
273export default async function server(request: Request): Promise<Response> {
274 // Handle voice processing
275 if (request.method === "POST" && new URL(request.url).pathname === "/process-voice") {

cerebras_codermain.tsx11 matches

@LionMonkey•Updated 3 months ago
73const PoweredByInfo = "";
74
75function Hero({
76 prompt,
77 setPrompt,
94
95 <p className="text-[#bababa] text-center max-w-[25ch] mx-auto my-4 font-dm-sans">
96 Turn your ideas into fully functional apps in{" "}
97 <span className="relative w-fit text-fuchsia-400 z-10 italic font-semibold rounded-full">
98 less than a second
168}
169
170function App() {
171 const previewRef = React.useRef<HTMLDivElement>(null);
172 const [prompt, setPrompt] = useState("");
222 });
223
224 function handleStarterPromptClick(promptItem: typeof prompts[number]) {
225 setLoading(true);
226 setTimeout(() => handleSubmit(promptItem.prompt), 0);
227 }
228
229 async function handleSubmit(e: React.FormEvent | string) {
230 if (typeof e !== "string") {
231 e.preventDefault();
278 }
279
280 function handleVersionChange(direction: "back" | "forward") {
281 const { currentVersionIndex, versions } = versionHistory;
282 if (direction === "back" && currentVersionIndex > 0) {
994);
995
996function client() {
997 const path = window.location.pathname;
998 const root = createRoot(document.getElementById("root")!);
1030}
1031
1032function extractCodeFromFence(text: string): string {
1033 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
1034 return htmlMatch ? htmlMatch[1].trim() : text;
1035}
1036
1037async function generateCode(prompt: string, currentCode: string) {
1038 const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
1039 if (starterPrompt) {
1080}
1081
1082export default async function cerebras_coder(req: Request): Promise<Response> {
1083 // Dynamic import for SQLite to avoid client-side import
1084 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
1183 <meta property="og:site_name" content="Cerebras Coder">
1184 <meta property="og:url" content="https://cerebrascoder.com"/>
1185 <meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
1186 <meta property="og:type" content="website">
1187 <meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">

oneshotdemopromptedmain.tsx4 matches

@Apache0ne•Updated 3 months ago
238}
239
240function GameSimulator() {
241 const [player, setPlayer] = useState(new Creature(20, 5, 3, Rarity.Rare, ElementType.Fire));
242 const [enemies, setEnemies] = useState([
353}
354
355function App() {
356 return <GameSimulator />;
357}
358
359function client() {
360 createRoot(document.getElementById("root")).render(<App />);
361}
362if (typeof document !== "undefined") { client(); }
363
364export default async function server(request: Request): Promise<Response> {
365 return new Response(
366 `

bedtimeStoryMakermain.tsx1 match

@tmcw•Updated 3 months ago
36// );
37
38function parseStory(text) {
39 // Split the text into lines and remove empty lines
40 const lines = text.split("\n").filter(line => line.trim() !== "")

cerebras_codermain.tsx11 matches

@npn•Updated 3 months ago
73const PoweredByInfo = "";
74
75function Hero({
76 prompt,
77 setPrompt,
94
95 <p className="text-[#bababa] text-center max-w-[25ch] mx-auto my-4 font-dm-sans">
96 Turn your ideas into fully functional apps in{" "}
97 <span className="relative w-fit text-fuchsia-400 z-10 italic font-semibold rounded-full">
98 less than a second
168}
169
170function App() {
171 const previewRef = React.useRef<HTMLDivElement>(null);
172 const [prompt, setPrompt] = useState("");
222 });
223
224 function handleStarterPromptClick(promptItem: typeof prompts[number]) {
225 setLoading(true);
226 setTimeout(() => handleSubmit(promptItem.prompt), 0);
227 }
228
229 async function handleSubmit(e: React.FormEvent | string) {
230 if (typeof e !== "string") {
231 e.preventDefault();
278 }
279
280 function handleVersionChange(direction: "back" | "forward") {
281 const { currentVersionIndex, versions } = versionHistory;
282 if (direction === "back" && currentVersionIndex > 0) {
994);
995
996function client() {
997 const path = window.location.pathname;
998 const root = createRoot(document.getElementById("root")!);
1030}
1031
1032function extractCodeFromFence(text: string): string {
1033 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
1034 return htmlMatch ? htmlMatch[1].trim() : text;
1035}
1036
1037async function generateCode(prompt: string, currentCode: string) {
1038 const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
1039 if (starterPrompt) {
1080}
1081
1082export default async function cerebras_coder(req: Request): Promise<Response> {
1083 // Dynamic import for SQLite to avoid client-side import
1084 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
1183 <meta property="og:site_name" content="Cerebras Coder">
1184 <meta property="og:url" content="https://cerebrascoder.com"/>
1185 <meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
1186 <meta property="og:type" content="website">
1187 <meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">

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": "*",