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=665&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 7804 results for "function"(471ms)

cerebras_coderindex2 matches

@Armanitown•Updated 1 month 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

@Armanitown•Updated 1 month 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

@Armanitown•Updated 1 month 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) {

stevekrouse_dot_comproposal.tsx1 match

@aginfer08•Updated 1 month ago
3import { Link } from "../helpers.tsx";
4
5export default async function(request: Request) {
6 return new Response(
7 renderToString(

stevekrouse_dot_comhomepage.tsx3 matches

@aginfer08•Updated 1 month ago
6const dateClass = "text-xs text-gray-400 font-mono mr-1 hidden sm:inline-block";
7
8export async function Homepage(request: Request) {
9 let monthHits, todayHits;
10 try {
179 <li className="pb-2 sm:pb-1">
180 <span className={dateClass}>2016 Jul -</span>
181 <Link href="https://medium.com/@stevekrouse/the-trick-to-teach-anonymous-functions-to-11-year-olds-558b697d7a53">
182 The Trick to Teach Anonymous Functions to 11-Year-Olds
183 </Link>
184 </li>

stevekrouse_dot_comanalytics.ts1 match

@aginfer08•Updated 1 month ago
1import { sqlite } from "https://esm.town/v/std/sqlite?v=5";
2
3export async function getHits() {
4 const [, , { rows: [[monthHits]] }, { rows: [[todayHits]] }] = await sqlite.batch([
5 "CREATE TABLE IF NOT EXISTS stevekrouse_com_hits (timestamp DATETIME DEFAULT CURRENT_TIMESTAMP)",

reactHonoExampleApp.tsx3 matches

@stevekrouse•Updated 1 month ago
4import { MessageInput } from "./MessageInput.tsx";
5
6export function App(
7 { initialMessages = [], thisProjectURL }: { initialMessages?: Message[]; thisProjectURL?: string },
8) {
41}
42
43function MessageList({ messages }: { messages: Message[] }) {
44 const displayedMessages = messages.slice(0, MESSAGE_LIMIT);
45 return (
50}
51
52function MessageItem({ message }) {
53 const formattedDate = new Date(message.timestamp).toLocaleString();
54

devstatsmain.tsx3 matches

@tmcw•Updated 1 month ago
113}).toString().split("\n").slice(1).slice(0, -1).join("\n");
114
115async function getRows() {
116 const result = await sqlite.execute(`SELECT * FROM ${TABLE_NAME}`);
117 const rows = result.rows.map(r => ({
126type Rows = Awaited<ReturnType<typeof getRows>>;
127
128app.get("/api", async function apiRoute(c) {
129 try {
130 return c.json(await getRows());
160});
161
162export default async function(req: Request): Promise<Response> {
163 await sqlite.execute(`
164 CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (

formatHrefmain.tsx1 match

@shouser•Updated 1 month ago
5const APP_URL = "https://val.town/";
6
7export function formatHref(href: string) {
8 if (href.startsWith(MODULE_URL)) {
9 const redirected = href.replace(MODULE_URL, APP_URL);

companymain.tsx1 match

@charmaine•Updated 1 month ago
22];
23
24export default async function(e: Email) {
25 console.log(JSON.stringify(e, null, 2));
26

getFileEmail4 file matches

@shouser•Updated 6 days ago
A helper function to build a file's email

TwilioHelperFunctions

@vawogbemi•Updated 2 months ago