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/$%7Bsuccess?q=function&page=2300&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 28557 results for "function"(8153ms)

strategiesHelpersmain.tsx2 matches

@nmsilvaUpdated 5 months ago
777 }
778
779 function predictDraw(teamA, teamB, tournament) {
780 if (!teamA || !teamB) return 0;
781
782 // Helper function to calculate draw rate
783 const calculateDrawRate = (team) =>
784 team.results.draws / team.totalMatches;

calmRoseCaterpillarmain.tsx11 matches

@hameedUpdated 5 months ago
39);
40
41function App() {
42 const [functionInput, setFunctionInput] = useState("");
43 const [mermaidDiagram, setMermaidDiagram] = useState("");
44 const [error, setError] = useState("");
70 "Content-Type": "application/json",
71 },
72 body: JSON.stringify({ function: functionInput }),
73 });
74
102 },
103 body: JSON.stringify({
104 functionDescription: functionInput,
105 currentMermaidCode: `\`\`\`mermaid\n${mermaidDiagram}\n\`\`\``,
106 }),
148 <div style={styles.container}>
149 <div style={styles.header}>
150 <h1 style={styles.title}>🔍 Function Diagram Generator</h1>
151 <p style={styles.subtitle}>Transform code into visual flowcharts</p>
152 </div>
154 <form onSubmit={handleSubmit} style={styles.form}>
155 <textarea
156 value={functionInput}
157 onChange={(e) => setFunctionInput(e.target.value)}
158 placeholder="Paste your function here... (JavaScript/TypeScript)"
159 style={styles.textarea}
160 rows={10}
334};
335
336function client() {
337 createRoot(document.getElementById("root")).render(<App />);
338}
339if (typeof document !== "undefined") { client(); }
340
341export default async function server(request: Request): Promise<Response> {
342 if (request.method === "PUT") {
343 try {
372 <html>
373 <head>
374 <title>Function Mermaid Diagram Generator</title>
375 <meta name="viewport" content="width=device-width, initial-scale=1">
376 <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600&display=swap" rel="stylesheet">

pythonHTTPValmain.tsx1 match

@iamseeleyUpdated 5 months ago
1import { runPythonCode } from "https://deno.land/x/py_town@v0.0.8/mod.ts";
2
3export default async function handler(req: Request): Promise<Response> {
4 const pythonCode = `
5import numpy as np

postMessageButtonGamemain.tsx3 matches

@edenhUpdated 5 months ago
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function App() {
6 const handlePostMessage = () => {
7 window.parent.postMessage('{"data": "foo", "field": "expected", "type": "update"}', '*');
29}
30
31function client() {
32 createRoot(document.getElementById("root")).render(<App />);
33}
34if (typeof document !== "undefined") { client(); }
35
36export default async function server(request: Request): Promise<Response> {
37 return new Response(`
38 <html>

wholeFoodsRSSmain.tsx1 match

@GlenchUpdated 5 months ago
2import { wholefoodssales } from "https://esm.town/v/Glench/wholefoodssales";
3
4export default async function(req: Request): Promise<Response> {
5 return new Response(dataToRSS(await wholefoodssales(), {
6 title: "Whole Foods Sales — Personal",

tvshowsmain.tsx2 matches

@GlenchUpdated 5 months ago
3import process from "node:process";
4
5export const tvshows = async function() {
6 const TV_SHOWS_WATCHED = [
7 // Ted Lasso
28 data.push(show);
29 }
30 data.sort(function(a, b) {
31 if (a.last_air_date > b.last_air_date)
32 return -1;

blob_adminmain.tsx8 matches

@stevekrouse1Updated 5 months ago
13}
14
15function Tooltip({ children, content }: TooltipProps) {
16 const [isVisible, setIsVisible] = useState(false);
17 const tooltipRef = useRef<HTMLDivElement>(null);
52}
53
54function formatBytes(bytes: number, decimals = 2) {
55 if (bytes === 0) return "0 Bytes";
56 const k = 1024;
61}
62
63function copyToClipboard(text: string) {
64 navigator.clipboard.writeText(text).then(() => {
65 console.log("Text copied to clipboard");
69}
70
71function ActionMenu({ blob, onDownload, onRename, onDelete, onMoveToPublic, onMoveOutOfPublic }) {
72 const [isOpen, setIsOpen] = useState(false);
73 const menuRef = useRef(null);
76
77 useEffect(() => {
78 function handleClickOutside(event) {
79 if (menuRef.current && !menuRef.current.contains(event.target)) {
80 event.stopPropagation();
158}
159
160function BlobItem({ blob, onSelect, isSelected, onDownload, onRename, onDelete, onMoveToPublic, onMoveOutOfPublic }) {
161 const [isLoading, setIsLoading] = useState(false);
162 const decodedKey = decodeURIComponent(blob.key);
219}
220
221function App({ initialEmail, initialProfile }) {
222 const encodeKey = (key: string) => encodeURIComponent(key);
223 const decodeKey = (key: string) => decodeURIComponent(key);
645}
646
647function client() {
648 const initialEmail = document.getElementById("root").getAttribute("data-email");
649 const initialProfile = JSON.parse(document.getElementById("root").getAttribute("data-profile"));

pyodideSetupmain.tsx1 match

@iamseeleyUpdated 5 months ago
1const pyodideUrl = "https://cdn.jsdelivr.net/pyodide/v0.26.4/full/";
2
3export async function initializePyodide() {
4 // Set up the global objects that Pyodide expects
5 (globalThis as any).window = globalThis;

marpmain.tsx1 match

@pomdtrUpdated 5 months ago
3import { Marp } from "npm:@marp-team/marp-core";
4
5export default async function() {
6 const { author, name } = extractValInfo(import.meta.url);
7 const { readme } = await api(`/v1/alias/${author}/${name}`);

weatherGPTmain.tsx1 match

@rohanchoudhary15Updated 5 months ago
31console.log(text);
32
33export async function weatherGPT() {
34 await email({ subject: "Weather Today", text });
35}

getFileEmail4 file matches

@shouserUpdated 1 month ago
A helper function to build a file's email
tuna

tuna8 file matches

@jxnblkUpdated 1 month 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": "*",
webup
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.