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=2409&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 30165 results for "function"(13946ms)

generateFunctionmain.tsx7 matches

@wolf•Updated 5 months ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2
3function extractCode(str: string): string {
4 const regex = /```[a-z]+\n([\s\S]*?)\n```/;
5 const match = str.match(regex);
11}
12
13export async function generateFunction(
14 functionName: string,
15 parameters: string,
16): Promise<string> {
17 if (!functionName) {
18 return "Please provide a function name";
19 }
20
21 const openai = new OpenAI();
22 const prompt =
23 `Generate a TypeScript function named "${functionName}" with the following parameters: ${parameters}. ONLY RETURN VALID JAVASCRIPT DO NOT INCLUDE ANY CONTEXT.`;
24 const completion = await openai.chat.completions.create({
25 messages: [
27 role: "system",
28 content:
29 "You are a helpful assistant that generates JAVASCRIPT functions. Be fuzzy with typing since you do not know what the types of the function inputs will be, but assum the number of arguments is reasonable (e.g. addTwoNumbers will take two numbers).",
30 },
31 { role: "user", content: prompt },

ciceroAISiteDesignmain.tsx5 matches

@arthrod•Updated 5 months ago
218`;
219
220function AnimatedHeadline() {
221 const [animationStarted, setAnimationStarted] = useState(false);
222 const contentRef = useRef(null);
421`;
422
423function FeatureCarousel() {
424 const features = [
425 { icon: "âš¡", title: "Speed", description: "Draft in minutes, not hours" },
445}
446
447function App() {
448 const [isNavOpen, setIsNavOpen] = React.useState(false);
449
505}
506
507function client() {
508 const root = document.getElementById("root");
509 if (root) {
527}
528
529export default async function server(request: Request): Promise<Response> {
530 return new Response(`
531 <!DOCTYPE html>

laudableCrimsonCoyotemain.tsx7 matches

@slinfo•Updated 5 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function LoadingSpinner() {
6 return (
7 <div className="loading-spinner">
12}
13
14function cleanText(text: string) {
15 return text
16 .replace(/\*+/g, '')
19}
20
21function App() {
22 const [storyParts, setStoryParts] = useState({
23 title: null,
133}
134
135function client() {
136 createRoot(document.getElementById("root")).render(<App />);
137}
138if (typeof document !== "undefined") { client(); }
139
140// Utility function to implement timeout
141async function withTimeout<T>(promise: Promise<T>, timeoutMs: number): Promise<T> {
142 let timeoutHandle: number;
143 const timeoutPromise = new Promise<never>((_, reject) => {
152}
153
154export default async function server(request: Request): Promise<Response> {
155 if (request.method === 'POST' && new URL(request.url).pathname === '/generate-story') {
156 const formData = await request.formData();

versatileAquamarineBoarmain.tsx4 matches

@slinfo•Updated 5 months ago
3import React, { useEffect, useState } from "https://esm.sh/react@18.2.0";
4
5function TransactionParser() {
6 const [inputLog, setInputLog] = useState("");
7 const [transactions, setTransactions] = useState([]);
264};
265
266function App() {
267 return <TransactionParser />;
268}
269
270function client() {
271 createRoot(document.getElementById("root")).render(<App />);
272}
273if (typeof document !== "undefined") { client(); }
274
275export default async function server(request: Request): Promise<Response> {
276 return new Response(
277 `

Storyweavermain.tsx7 matches

@slinfo•Updated 5 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function LoadingSpinner() {
6 return (
7 <div className="loading-spinner">
12}
13
14function cleanText(text: string) {
15 return text
16 .replace(/\*+/g, '')
19}
20
21function App() {
22 const [storyParts, setStoryParts] = useState({
23 title: null,
133}
134
135function client() {
136 createRoot(document.getElementById("root")).render(<App />);
137}
138if (typeof document !== "undefined") { client(); }
139
140// Utility function to implement timeout
141async function withTimeout<T>(promise: Promise<T>, timeoutMs: number): Promise<T> {
142 let timeoutHandle: number;
143 const timeoutPromise = new Promise<never>((_, reject) => {
152}
153
154export default async function server(request: Request): Promise<Response> {
155 if (request.method === 'POST' && new URL(request.url).pathname === '/generate-story') {
156 const formData = await request.formData();

appmain.tsx2 matches

@slinfo•Updated 5 months ago
8};
9
10function App() {
11 const [isPending, startTransition] = useTransition();
12 const [likes, setLikes] = useState(0);
43}
44
45export default async function server(request: Request): Promise<Response> {
46 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
47 const KEY = "app";

readySilverMandrillmain.tsx11 matches

@cqbcg•Updated 5 months 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">

parseTransactionsmain.tsx4 matches

@slinfo•Updated 5 months ago
3import React, { useEffect, useState } from "https://esm.sh/react@18.2.0";
4
5function TransactionParser() {
6 const [inputLog, setInputLog] = useState("");
7 const [transactions, setTransactions] = useState([]);
264};
265
266function App() {
267 return <TransactionParser />;
268}
269
270function client() {
271 createRoot(document.getElementById("root")).render(<App />);
272}
273if (typeof document !== "undefined") { client(); }
274
275export default async function server(request: Request): Promise<Response> {
276 return new Response(
277 `

cerebras_codermain.tsx11 matches

@cqbcg•Updated 5 months 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">

interview_practicemain.tsx3 matches

@slinfo•Updated 5 months ago
14}
15
16function App() {
17 const [intervieweeResponse, setIntervieweeResponse] = useState("");
18 const [response, setResponse] = useState("");
225}
226
227function client() {
228 createRoot(document.getElementById("root")).render(<App />);
229}
230if (typeof document !== "undefined") { client(); }
231
232export default async function server(request: Request): Promise<Response> {
233 if (request.method === "POST" && new URL(request.url).pathname === "/ask") {
234 try {
tuna

tuna9 file matches

@jxnblk•Updated 6 days ago
Simple functional CSS library for Val Town

getFileEmail4 file matches

@shouser•Updated 1 month ago
A helper function to build a file's email
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.