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=1101&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 17971 results for "function"(2071ms)

textToImagePlaygroundmain.tsx2 matches

@AIWB•Updated 2 months ago
59 <script type="module" src="https://esm.town/v/iamseeley/realtimeFormLogic"></script>
60 <script>
61 document.getElementById('generationType').addEventListener('change', function() {
62 const type = this.value;
63 if (type === 'regular') {
81`;
82
83export default async function handler(req: Request): Promise<Response> {
84 const url = new URL(req.url);
85

cerebras_codermain.tsx11 matches

@Bne44•Updated 2 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">

tsEvaldummyHTTP1 match

@maxm•Updated 2 months ago
1export default async function (req: Request): Promise<Response> {
2 return Response.json({ ok: true })
3}

tsEvalpatchConsoleLog2 matches

@maxm•Updated 2 months ago
1type ConsoleMethod = (...args: any[]) => void;
2
3export function patch(cb: (message: string) => void) {
4 const consoleHandler: ProxyHandler<Console> = {
5 get(target: Console, prop: keyof Console) {
6 let originalMethod = target[prop] as ConsoleMethod;
7 if (typeof originalMethod !== "function") {
8 return originalMethod;
9 }

brainrotdbmain.tsx5 matches

@stainless_em•Updated 2 months ago
6
7// Ensure table exists
8async function ensureTable() {
9 await sqlite.execute(`
10 CREATE TABLE IF NOT EXISTS ${KEY}_regex_explanations_${SCHEMA_VERSION} (
18
19// Save a new regex explanation, returns the ULID
20export async function saveRegexExplanation(regex: string, explanation: string): Promise<string> {
21 await ensureTable();
22
35
36// Get a random explanation for a specific regex
37export async function getRandomRegexExplanation(
38 regex: string,
39): Promise<{ id: string; explanation: string; shares: number } | null> {
55
56// Get a specific explanation by ID
57export async function getRegexExplanationById(
58 id: string,
59): Promise<{ regex: string; explanation: string; shares: number } | null> {
73
74// Increment share count for a specific explanation
75export async function incrementRegexExplanationShares(id: string): Promise<void> {
76 await ensureTable();
77

reactRouter7server.tsx1 match

@charmaine•Updated 2 months ago
1import { handler } from "./entry.server.tsx";
2
3export default async function(request: Request) {
4 const url = new URL(request.url);
5 if (url.pathname == "/js/entry.client.js") {

reactRouter7layout.tsx1 match

@charmaine•Updated 2 months ago
8import { type loader } from "./layout.server.ts";
9
10export default function Layout() {
11 let data = useLoaderData<typeof loader>();
12 return (

reactRouter7layout.server.ts4 matches

@charmaine•Updated 2 months ago
1import {
2 ActionFunctionArgs,
3 type LoaderFunctionArgs,
4} from "https://esm.sh/react-router@7.1.3?deps=react@18.2.0,react-dom@18.2.0";
5
6let db = { message: "Hello world!" };
7
8export async function loader(args: LoaderFunctionArgs) {
9 await new Promise(resolve => setTimeout(resolve, 200));
10 return { message: db.message };
11}
12
13export async function action({ request }: ActionFunctionArgs) {
14 let formData = await request.formData();
15 db.message = String(formData.get("message"));

reactRouter7layout.client.ts3 matches

@charmaine•Updated 2 months ago
1import { type LoaderFunctionArgs } from "https://esm.sh/react-router@7.1.3?deps=react@18.2.0,react-dom@18.2.0";
2
3export async function loader({ request }: LoaderFunctionArgs) {
4 let url = new URL(request.url);
5 let res = await fetch(url, {
12}
13
14export async function action({ request }: LoaderFunctionArgs) {
15 let url = new URL(request.url);
16 // call the server action

reactRouter7index.ts4 matches

@charmaine•Updated 2 months ago
1import {
2 ActionFunctionArgs,
3 LoaderFunctionArgs,
4} from "https://esm.sh/react-router@7.1.3?deps=react@18.2.0,react-dom@18.2.0";
5import aboutLoader from "./about.loader.ts";
18 // imports the correct one to avoid putting the server code in client
19 // bundles
20 async loader(args: LoaderFunctionArgs) {
21 let mod = await (isServer
22 ? import("./layout.server.ts")
26 // same with the action, you'll probably want to abstract this kind of stuff
27 // in a createRoute() kind of thing
28 async action(args: ActionFunctionArgs) {
29 let mod = await (isServer
30 ? import("./layout.server.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
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": "*",