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=971&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 14904 results for "function"(1635ms)

contentTemplateAppmain.tsx10 matches

@awhitter•Updated 3 months ago
44}
45
46function ContentTemplateApp() {
47 const [content, setContent] = useState<AirtableRecord[]>([]);
48 const [loading, setLoading] = useState(true);
229}
230
231function client() {
232 createRoot(document.getElementById("root")).render(<ContentTemplateApp />);
233}
237}
238
239export default async function server(req: Request): Promise<Response> {
240 const url = new URL(req.url);
241
356import ContentTemplateApp from 'https://esm.town/v/awhitter/contentTemplateApp';
357
358export default function MyCustomApp() {
359 return (
360 <div>
368// Example 2: Making an API call to /api/content endpoint
369/*
370async function fetchContent() {
371 try {
372 const response = await fetch('https://awhitter-contenttemplateapp.web.val.run/api/content');
388import ContentTemplateApp from 'https://esm.town/v/awhitter/contentTemplateApp';
389
390function CustomLayout() {
391 return (
392 <div>
433import { Data, animate, Override, Animatable } from "framer"
434
435// This function fetches the content from the API
436async function fetchContent() {
437 try {
438 const response = await fetch('https://awhitter-contenttemplateapp.web.val.run/api/content')
446
447// This is your Framer component
448export function ContentDisplay(): Override {
449 const [content, setContent] = Data.useState([])
450
473}
474
475function ContentItem({ title, description, image }) {
476 return {
477 width: 300,

aimain.tsx2 matches

@goode_bye•Updated 3 months ago
299
300 if (toolResults && toolResults.length > 0) {
301 // we have to do this bc the AI SDK doesn't seem to let you carry over function calling results,
302 // so we pretend to be the user instead of using the official role: tool API, which breaks everything
303 for (const toolResult of toolResults) {
781};
782
783function test() {
784 console.log("test!");
785}

aiREADME.md1 match

@goode_bye•Updated 3 months ago
8
9```
10async function calculateEmbeddings(text) {
11 const url = `https://yawnxyz-ai.web.val.run/generate?embed=true&value=${encodeURIComponent(text)}`;
12

utmostGreenJellyfishmain.tsx1 match

@johndevor•Updated 3 months ago
3const client = new ValTown();
4
5async function main() {
6 const profile = await client.me.profile.retrieve();
7

sqlitemain.tsx5 matches

@awhitter•Updated 3 months ago
31
32// ------------
33// Functions
34// ------------
35
36async function execute(statement: InStatement): Promise<ResultSet> {
37 const res = await fetch(`${API_URL}/v1/sqlite/execute`, {
38 method: "POST",
48}
49
50async function batch(statements: InStatement[], mode?: TransactionMode): Promise<ResultSet[]> {
51 const res = await fetch(`${API_URL}/v1/sqlite/batch`, {
52 method: "POST",
62}
63
64function createResError(body: string) {
65 try {
66 const e = zLibsqlError.parse(JSON.parse(body));
113 *
114 * The types are currently shown for types declared in a SQL table. For
115 * column types of function calls, for example, an empty string is
116 * returned.
117 */

cerebras_codermain.tsx11 matches

@awhitter•Updated 3 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">

shiningCyanMuskoxmain.tsx2 matches

@steveruizok•Updated 3 months ago
64};
65
66export default async function(req: Request): Promise<Response> {
67 if (req.method === "GET") {
68 // handle a GET request
116}
117
118async function fetchGoogleSheetAsCSV(sheetId: string) {
119 const url = `https://docs.google.com/spreadsheets/d/${sheetId}/pub?output=csv`;
120

savvyEmeraldTahrmain.tsx1 match

@anders_b•Updated 3 months ago
1export default async function(req: Request): Promise<Response> {
2 const headers = Array.from(req.headers.entries()).reduce((r, [k, v]) => ({ ...r, [k]: v }), {});
3 const query = req.url;

cloneChatGPTmain.tsx3 matches

@uniquebengal•Updated 3 months ago
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function App() {
6 const [messages, setMessages] = useState([]);
7 const [input, setInput] = useState("");
84}
85
86function client() {
87 createRoot(document.getElementById("root")).render(<App />);
88}
89if (typeof document !== "undefined") { client(); }
90
91export default async function server(request: Request): Promise<Response> {
92 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
93 const { OpenAI } = await import("https://esm.town/v/std/openai");

fashionableJadeCatfishmain.tsx1 match

@trihatmaja•Updated 3 months ago
6);
7
8export async function uptimeCheck(url: string) {
9 let reason: string, status: number, end: number;
10 let ok = true;

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