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/image-url.jpg%20%22Image%20title%22?q=function&page=51&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 33110 results for "function"(4562ms)

flipswitchreversemain.tsx5 matches

@joinUpdated 4 days ago
38
39/**
40 * HTML GENERATOR FUNCTION
41 */
42function generateHtml(sourceUrl: string, defaultProjects: ProjectItem[] = []) {
43 return `<!DOCTYPE html>
44<html lang="en">
226const API_URL = '${sourceUrl}';
227
228function ripple(type) {
229 layers.forEach(layer => {
230 const ripple = document.createElement('div');
248});
249
250function moveToLayer(type) {
251 const {rx,ry,z} = CORNER_TO_ROTATE[type] || {rx:0,ry:0,z:0};
252 stack.style.transform = \`rotateX(\${rx}deg) rotateY(\${ry}deg) translateZ(\${z}px)\`;
296 * SERVERLESS HANDLER FOR VAL TOWN
297 */
298export default async function(req: Request) {
299 const url = new URL(req.url);
300 const action = url.searchParams.get("action");

DayOldCalculatorindex.tsx2 matches

@samlrobertsUpdated 4 days ago
40}
41
42function getQueryParams() {
43 const params = new URLSearchParams(window.location.search)
44 const milestonesParam = params.get("milestones")
72}
73
74function setQueryParams(
75 birthday: string,
76 name: string,

revamp-ncfmain.tsx19 matches

@ncfUpdated 4 days ago
3var sections;
4
5function initDarkNavSwitch() {
6 // script pour navbar Negative on dark section
7 sections = document.querySelectorAll("[bg-theme]"); // adjust if needed
11}
12
13function GoDark() {
14 navElements.forEach(element => {
15 const classToAdd = element.getAttribute("darkMode");
21}
22
23function GoLight() {
24 navElements.forEach(element => {
25 const classToAdd = element.getAttribute("darkMode");
31}
32
33function checkNavbarSection() {
34 for (const section of sections) {
35 const rect = section.getBoundingClientRect();
50});
51
52document.addEventListener("DOMContentLoaded", function() {
53 initDarkNavSwitch();
54});
58/* */
59/* */
60document.addEventListener("DOMContentLoaded", function() {
61 // S'assurer que GSAP est chargé
62 if (typeof gsap === "undefined") {
79
80 // Au survol du déclencheur
81 startElement.addEventListener("mouseenter", function() {
82 const targetElements = document.querySelectorAll(`[load-nav-menu="${menuName}"]`);
83
94
95 // Quand on quitte le déclencheur
96 startElement.addEventListener("mouseleave", function() {
97 const targetElements = document.querySelectorAll(`[load-nav-menu="${menuName}"]`);
98
113/* */
114/* */
115document.addEventListener("DOMContentLoaded", function() {
116 // Vérification si l'appareil est mobile
117 const isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)
151
152 // Fonction d'animation
153 function animate() {
154 // Position actuelle
155 let currentX = parseFloat(shape.style.left);
186/* */
187/* */
188document.addEventListener("DOMContentLoaded", function() {
189 // Vérifier si nous devons initialiser l'animation lettre par lettre
190 const allTexts = document.querySelectorAll(".startup-txt, .pme-txt, .scaleup-txt, .grandgroupe-txt");
217
218 // Fonction pour désactiver tous les textes
219 function resetAllTexts() {
220 allTexts.forEach(text => text.classList.remove("text-active"));
221 }
223 // Event listeners pour chaque carte
224 if (cardStartup) {
225 cardStartup.addEventListener("mouseenter", function() {
226 resetAllTexts();
227 txtStartup.classList.add("text-active");
230
231 if (cardPme) {
232 cardPme.addEventListener("mouseenter", function() {
233 resetAllTexts();
234 txtPme.classList.add("text-active");
237
238 if (cardScaleup) {
239 cardScaleup.addEventListener("mouseenter", function() {
240 resetAllTexts();
241 txtScaleup.classList.add("text-active");
244
245 if (cardGrandgroupe) {
246 cardGrandgroupe.addEventListener("mouseenter", function() {
247 resetAllTexts();
248 txtGrandgroupe.classList.add("text-active");
253 const cardsContainer = document.querySelector(".cards-container");
254 if (cardsContainer) {
255 cardsContainer.addEventListener("mouseleave", function() {
256 resetAllTexts();
257 });
271
272// Fonction pour mettre à jour la position du curseur
273function updateCursorPosition(e) {
274 customCursor.style.left = `${e.clientX}px`;
275 customCursor.style.top = `${e.clientY}px`;
299}
300
301function animateCurrentSlide() {
302 document.querySelectorAll("[cascade-animate]").forEach((el, index) => {
303 const grandparent = el.parentElement?.parentElement;
1export default async function (req: Request): Promise<Response> {
2 return Response.json({ ok: true })
3}

ChatclientTools.ts13 matches

@c15rUpdated 4 days ago
32}
33
34// Tool handler function type
35export type ToolHandler = (
36 input: any,
42) => Promise<string>;
43
44// AsyncFunction constructor for safe code execution
45const AsyncFunction = async function() {}.constructor;
46
47/* ──────────────────────────── Tool Definitions ─────────────────────────── */
107 type: "string",
108 description:
109 "JavaScript/TypeScript code that defines an async execute function: `const execute = async (input, tools) => {}`. The 'tools' parameter contains all available tool handlers (client-side + MCP tools) that can be called directly. Return value will be JSON stringified.",
110 },
111 key: {
112 type: "string",
113 description:
114 "Key of file containing source code (from MCP or local) that exports an async execute function: `const execute = async (input, tools) => {}`. The 'tools' parameter provides access to all available tool handlers.",
115 },
116 input: {
117 type: "object",
118 description: "Input parameter passed to the execute function as the first argument",
119 },
120 },
156 const expression = input.expression || "";
157
158 // Enhanced safety check - allow more math functions
159 const safeExpression = expression
160 .replace(/[^0-9+\-*/().\s]/g, "") // Remove unsafe characters
165 }
166
167 // Use Function constructor for safe evaluation (limited scope)
168 const result = new Function("return " + safeExpression)();
169
170 if (typeof result === "number" && !isNaN(result) && isFinite(result)) {
223
224 // Execute the code with tools parameter
225 const result = await new AsyncFunction(`${code}\n\nreturn await execute(arguments[0], arguments[1]);`)(
226 input.input,
227 tools || {},
802 * Get all available tools (client-side + MCP tools)
803 */
804export async function getAllAvailableTools(mcpClientPool: MCPClientPool): Promise<ClientTool[]> {
805 const allTools: ClientTool[] = [...CLIENT_TOOLS];
806 return allTools;
838 * Get all available tool handlers (client-side + MCP handlers)
839 */
840export async function getAllToolHandlers(
841 mcpClientPool: MCPClientPool,
842 affordanceManager: any,
896 * Execute a tool by name with the appropriate handler
897 */
898export async function executeTool(
899 toolName: string,
900 input: any,

cerebras_codermain.tsx11 matches

@yusufbotcyberUpdated 4 days ago
24);
25
26function Hero({
27 prompt,
28 setPrompt,
45
46 <p className="text-[#bababa] text-center max-w-[25ch] mx-auto my-4 font-dm-sans">
47 Turn your ideas into fully functional apps in{" "}
48 <span className="relative w-fit text-fuchsia-400 z-10 italic font-semibold rounded-full">
49 less than a second
116}
117
118function App() {
119 const previewRef = React.useRef<HTMLDivElement>(null);
120 const [prompt, setPrompt] = useState("");
170 });
171
172 function handleStarterPromptClick(promptItem: typeof prompts[number]) {
173 setLoading(true);
174 setTimeout(() => handleSubmit(promptItem.prompt), 0);
175 }
176
177 async function handleSubmit(e: React.FormEvent | string) {
178 if (typeof e !== "string") {
179 e.preventDefault();
226 }
227
228 function handleVersionChange(direction: "back" | "forward") {
229 const { currentVersionIndex, versions } = versionHistory;
230 if (direction === "back" && currentVersionIndex > 0) {
974);
975
976function client() {
977 const path = window.location.pathname;
978 const root = createRoot(document.getElementById("root")!);
1010}
1011
1012function extractCodeFromFence(text: string): string {
1013 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
1014 return htmlMatch ? htmlMatch[1].trim() : text;
1015}
1016
1017async function generateCode(prompt: string, currentCode: string) {
1018 const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
1019 if (starterPrompt) {
1060}
1061
1062export default async function cerebras_coder(req: Request): Promise<Response> {
1063 // Dynamic import for SQLite to avoid client-side import
1064 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
1163 <meta property="og:site_name" content="Cerebras Coder">
1164 <meta property="og:url" content="https://cerebrascoder.com"/>
1165 <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."">
1166 <meta property="og:type" content="website">
1167 <meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">

yunwumain.tsx2 matches

@wizosUpdated 4 days ago
1// 写法一
2// export default async function(request: Request): Promise<Response> {}
3// 写法二
4// export default (req: Request) => handle(req);
52 * @returns {Promise<Response>}
53 */
54async function handle(request: Request) {
55 // 只处理 POST 请求和特定路径
56 const url = new URL(request.url);

untitled-2001main.tsx4 matches

@joinUpdated 4 days ago
17
18// --- HTML & FRONTEND ---
19function generateHtml(sourceUrl: string) {
20 return `<!DOCTYPE html>
21<html lang="en">
150 };
151
152 function createCardElement(imageData, index) {
153 const { prompt } = imageData;
154 const encodedPrompt = encodeURIComponent(prompt);
172 }
173
174 async function fetchAndRenderGallery() {
175 dom.grid.innerHTML = '';
176 dom.loader.classList.remove('hidden');
214
215// --- VAL TOWN EXPORT ---
216export default async function(req: Request) {
217 const url = new URL(req.url);
218 const action = url.searchParams.get("action");

untitled-1968http.ts1 match

@pomdtrUpdated 4 days ago
1export default async function (req: Request): Promise<Response> {
2 return Response.json({ ok: true })
3}

untitled-1768main.tsx1 match

@pomdtrUpdated 4 days ago
1export default async function (_req: Request): Promise<Response> {
2 return Response.json({ ok: true });
3}

discordWebhook2 file matches

@stevekrouseUpdated 3 days ago
Helper function to send Discord messages
tuna

tuna9 file matches

@jxnblkUpdated 4 weeks 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.