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=856&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 14691 results for "function"(2065ms)

cerebras_coderindex2 matches

@SKULLFUNKIE13•Updated 2 months ago
3import { createProject, getCode, getNextVersionNumber, insertVersion } from "./database/queries";
4
5async function servePublicFile(path: string): Promise<Response> {
6 const url = new URL("./public/" + path, import.meta.url);
7 const text = await (await fetch(url, {
20await createTables();
21
22export default async function cerebras_coder(req: Request): Promise<Response> {
23 if (req.method === "POST") {
24 let { prompt, currentCode, versionHistory, projectId } = await req.json();

cerebras_coderindex7 matches

@SKULLFUNKIE13•Updated 2 months ago
23);
24
25function Hero({
26 prompt,
27 setPrompt,
44
45 <p className="text-[#bababa] text-center max-w-[25ch] mx-auto my-4 font-dm-sans">
46 Turn your ideas into fully functional apps in{" "}
47 <span className="relative w-fit text-fuchsia-400 z-10 italic font-semibold rounded-full">
48 less than a second
115}
116
117function App() {
118 const previewRef = React.useRef<HTMLDivElement>(null);
119 const [prompt, setPrompt] = useState("");
169 });
170
171 function handleStarterPromptClick(promptItem: typeof prompts[number]) {
172 setLoading(true);
173 setTimeout(() => handleSubmit(promptItem.prompt), 0);
174 }
175
176 async function handleSubmit(e: React.FormEvent | string) {
177 if (typeof e !== "string") {
178 e.preventDefault();
225 }
226
227 function handleVersionChange(direction: "back" | "forward") {
228 const { currentVersionIndex, versions } = versionHistory;
229 if (direction === "back" && currentVersionIndex > 0) {
973);
974
975function client() {
976 const path = window.location.pathname;
977 const root = createRoot(document.getElementById("root")!);

cerebras_codergenerate-code2 matches

@SKULLFUNKIE13•Updated 2 months ago
2import STARTER_PROMPTS from "../public/starter-prompts.js";
3
4function extractCodeFromFence(text: string): string {
5 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
6 return htmlMatch ? htmlMatch[1].trim() : text;
7}
8
9export async function generateCode(prompt: string, currentCode: string) {
10 const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
11 if (starterPrompt) {

IbnehelpforwomensublimeGreenSilkworm1 match

@Ibne_75•Updated 2 months ago
1import { consoleEmailEx } from "https://esm.town/v/rodrigotellovaltown/consoleEmailEx?v=2";
2
3export default async function (e: Email) {
4
5}

valentinemain.tsx3 matches

@nicogiro•Updated 2 months ago
13];
14
15function App() {
16 const [noClicks, setNoClicks] = useState(0);
17 const [isValentine, setIsValentine] = useState(false);
98}
99
100function client() {
101 createRoot(document.getElementById("root")).render(<App />);
102}
103if (typeof document !== "undefined") { client(); }
104
105export default async function server(request: Request): Promise<Response> {
106 return new Response(
107 `

CRMmain.tsx6 matches

@arthrod•Updated 2 months ago
3import React, { useEffect, useRef, useState } from "https://esm.sh/react@18.2.0";
4
5function LoginScreen({ onLogin }) {
6 const [password, setPassword] = useState("");
7 const [error, setError] = useState("");
46}
47
48function CustomerInteractionForm({ onSubmit }) {
49 const [email, setEmail] = useState("");
50 const [firstName, setFirstName] = useState("");
240}
241
242function InteractionList() {
243 const [customerInteractions, setCustomerInteractions] = useState({});
244 const [copiedEmail, setCopiedEmail] = useState(null);
470}
471
472function App() {
473 const [isAuthenticated, setIsAuthenticated] = useState(false);
474 const [refreshList, setRefreshList] = useState(0);
517}
518
519function client() {
520 createRoot(document.getElementById("root")).render(<App />);
521}
522if (typeof document !== "undefined") { client(); }
523
524export default async function server(request: Request): Promise<Response> {
525 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
526 const KEY = "CRM";

valentinemain.tsx3 matches

@ExtraOlive635•Updated 2 months ago
13];
14
15function App() {
16 const [noClicks, setNoClicks] = useState(0);
17 const [isValentine, setIsValentine] = useState(false);
100}
101
102function client() {
103 createRoot(document.getElementById("root")).render(<App />);
104}
105if (typeof document !== "undefined") { client(); }
106
107export default async function server(request: Request): Promise<Response> {
108 return new Response(
109 `

getWeathermain.tsx1 match

@geoffreylitt•Updated 2 months ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export async function getWeather(location: string): Promise<WeatherResponse> {
4 return fetchJSON(`https://wttr.in/${location}?format=j1`);
5}

LanguageTranslatormain.tsx4 matches

@juleeyet•Updated 2 months ago
4
5// Spinner Component
6function Spinner({ theme }) {
7 const spinnerStyle = {
8 display: "flex",
40}
41
42function App() {
43 const [theme, setTheme] = useState(() => {
44 const savedTheme = localStorage.getItem("app-theme");
373}
374
375function client() {
376 createRoot(document.getElementById("root")).render(<App />);
377}
381}
382
383export default function server(request: Request): Response {
384 return new Response(`
385 <html>

getWeatherREADME.md1 match

@geoffreylitt•Updated 2 months ago
1## Get Weather
2
3Simple function to get weather data from the free [wttr.in](https://wttr.in/:help) service.
4
5```ts

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