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=876&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 10292 results for "function"(601ms)

simpleWikipediaInstantSearchmain.tsx2 matches

@maxm•Updated 5 months ago
166 });
167
168 async function fetchResults(query) {
169 try {
170 const response = await fetch(\`/search?q=\${encodeURIComponent(query)}\`);
176 }
177
178 function displayResults(results) {
179 searchResults.innerHTML = '';
180 if (results.length > 0) {

falDemoAppmain.tsx3 matches

@d0ccc•Updated 5 months ago
5import { falProxyRequest } from "https://esm.town/v/stevekrouse/falProxyRequest";
6
7function App() {
8 const [prompt, setPrompt] = useState("");
9 const [imageUrls, setImageUrls] = useState<string[]>([]);
125}
126
127function client() {
128 createRoot(document.getElementById("root")).render(<App />);
129}
130if (typeof document !== "undefined") { client(); }
131
132export default async function server(req: Request): Promise<Response> {
133 const url = new URL(req.url);
134 if (url.pathname === "/") {

multilingualchatroommain.tsx9 matches

@ireneg•Updated 5 months ago
93};
94
95function Banner({ message, isVisible, language }) {
96 if (!isVisible) return null;
97 return <div className="banner">{message[language] || message.en}</div>;
98}
99
100function UserList({ users, t }) {
101 return (
102 <div className="user-list">
113}
114
115function Sidebar({ users, language, handleLanguageChange, roomUrl, copyToClipboard, copied, t }) {
116 return (
117 <div className="sidebar">
149}
150
151function TypingIndicator({ typingUsers, t }) {
152 if (typingUsers.length === 0) return null;
153
164}
165
166function App() {
167 const [messages, setMessages] = useState([]);
168 const [inputMessage, setInputMessage] = useState("");
490}
491
492function client() {
493 createRoot(document.getElementById("root")).render(<App />);
494}
495if (typeof document !== "undefined") { client(); }
496
497export default async function server(request: Request): Promise<Response> {
498 const url = new URL(request.url);
499 const { blob } = await import("https://esm.town/v/std/blob");
508 const TIME_WINDOW = 60 * 1000; // 1 minute
509
510 async function checkRateLimit() {
511 const now = Date.now();
512 const rateLimit = await blob.getJSON(RATE_LIMIT_KEY) || { count: 0, timestamp: now };
523 }
524
525 async function translateText(text: string, targetLanguage: string, sourceLanguage: string): Promise<string> {
526 const cacheKey = `${KEY}_translation_${sourceLanguage}_${targetLanguage}_${text}`;
527 const cachedTranslation = await blob.getJSON(cacheKey);

solanaPayDemomain.tsx3 matches

@vawogbemi•Updated 5 months ago
19import { createRoot } from "https://esm.sh/react-dom/client";
20
21function Home() {
22 const [storeName, setStoreName] = useState("");
23 const [description, setDescription] = useState("");
238}
239
240function client() {
241 createRoot(document.getElementById("root")).render(<Home />);
242}
243if (typeof document !== "undefined") { client(); }
244
245export default async function server(request: Request): Promise<Response> {
246 return new Response(
247 `

RobotBackupCallGraphmain.tsx15 matches

@maxm•Updated 5 months ago
2import { thisWebURL } from "https://esm.town/v/stevekrouse/thisWebURL?v=2";
3
4export default async function server(req: Request): Promise<Response> {
5 // Handle GET requests
6 if (req.method === "GET") {
288 layout: {
289 name: 'preset',
290 positions: function(node) {
291 return { x: 0, y: 0 }; // Initial positions, will be overwritten
292 }
297 });
298
299 // Custom layout function
300 function customLayout() {
301 const mainGraph = cy.elements().not('#isolated, #isolated > node');
302 const isolatedGraph = cy.getElementById('isolated');
349
350 // Add event listeners for highlighting
351 cy.on('mouseover', 'node', function(e) {
352 const node = e.target;
353 highlightNodeChildrenAndParents(node);
354 });
355
356 cy.on('mouseout', 'node', function(e) {
357 unhighlightAll();
358 });
359
360 cy.on('click', 'node', function(e) {
361 const node = e.target;
362 if (node.hasClass('highlighted') || node.hasClass('parent-highlighted')) {
368 });
369
370 function highlightNodeChildrenAndParents(node) {
371 const children = node.outgoers();
372 const parents = node.incomers();
376 }
377
378 function unhighlightAll() {
379 cy.elements().removeClass('highlighted');
380 cy.elements().removeClass('parent-highlighted');
529 let match;
530 while ((match = callRegex.exec(line)) !== null) {
531 const calledFunction = match[1].toLowerCase();
532 relationships.get(caller).add(calledFunction);
533 allNodes.add(calledFunction);
534 }
535 });
545
546 const edges = [];
547 relationships.forEach((calledFunctions, file) => {
548 calledFunctions.forEach(calledFunction => {
549 edges.push({
550 data: {
551 source: file,
552 target: calledFunction,
553 },
554 });

welcomingPinkAlligatormain.tsx9 matches

@problem•Updated 5 months ago
4import { createRoot } from "https://esm.sh/react-dom/client";
5
6function debounce(func: Function, wait: number) {
7 let timeout: number | undefined;
8 return function executedFunction(...args: any[]) {
9 const later = () => {
10 clearTimeout(timeout);
16}
17
18function App() {
19 const [prompt, setPrompt] = useState("Generate a colorful gradient shader");
20 const [code, setCode] = useState(`
79 }, [code, debouncedRenderShader, retryCount]);
80
81 async function handleSubmit(e: React.FormEvent, shaderErrorMessage?: string) {
82 if (e) e.preventDefault();
83 setLoading(true);
149}
150
151function client() {
152 createRoot(document.getElementById("root")!).render(<App />);
153}
157}
158
159function renderShader(canvas: HTMLCanvasElement, fragmentShaderSource: string, time: number) {
160 const gl = canvas.getContext("webgl");
161 if (!gl) {
171 `;
172
173 function createShader(gl: WebGLRenderingContext, type: number, source: string) {
174 const shader = gl.createShader(type);
175 if (!shader) return null;
240}
241
242function extractGLSLCode(text: string): string {
243 const glslMatch = text.match(/```glsl\n([\s\S]*?)\n```/);
244 return glslMatch
247}
248
249export default async function server(req: Request): Promise<Response> {
250 if (req.method === "POST") {
251 const client = new Cerebras();

dailyDadJokemain.tsx1 match

@problem•Updated 5 months ago
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3
4export async function dailyDadJoke() {
5 let { setup, punchline } = await fetchJSON("https://official-joke-api.appspot.com/random_joke");
6 return email({

seamlessBlushSwallowmain.tsx9 matches

@stevekrouse•Updated 5 months ago
4import { createRoot } from "https://esm.sh/react-dom/client";
5
6function debounce(func: Function, wait: number) {
7 let timeout: number | undefined;
8 return function executedFunction(...args: any[]) {
9 const later = () => {
10 clearTimeout(timeout);
16}
17
18function App() {
19 const [prompt, setPrompt] = useState("Generate a colorful gradient shader");
20 const [code, setCode] = useState(`
61 }, [code, debouncedRenderShader]);
62
63 async function handleSubmit(e: React.FormEvent) {
64 e.preventDefault();
65 setLoading(true);
121}
122
123function client() {
124 createRoot(document.getElementById("root")!).render(<App />);
125}
129}
130
131function renderShader(canvas: HTMLCanvasElement, fragmentShaderSource: string, time: number) {
132 const gl = canvas.getContext("webgl");
133 if (!gl) {
143 `;
144
145 function createShader(gl: WebGLRenderingContext, type: number, source: string) {
146 const shader = gl.createShader(type);
147 if (!shader) return null;
218}
219
220function extractGLSLCode(text: string): string {
221 const glslMatch = text.match(/```glsl\n([\s\S]*?)\n```/);
222 return glslMatch
225}
226
227export default async function server(req: Request): Promise<Response> {
228 if (req.method === "POST") {
229 const anthropic = new Anthropic();

welcomingPinkAlligatormain.tsx9 matches

@stevekrouse•Updated 5 months ago
4import { createRoot } from "https://esm.sh/react-dom/client";
5
6function debounce(func: Function, wait: number) {
7 let timeout: number | undefined;
8 return function executedFunction(...args: any[]) {
9 const later = () => {
10 clearTimeout(timeout);
16}
17
18function App() {
19 const [prompt, setPrompt] = useState("Generate a colorful gradient shader");
20 const [code, setCode] = useState(`
79 }, [code, debouncedRenderShader, retryCount]);
80
81 async function handleSubmit(e: React.FormEvent, shaderErrorMessage?: string) {
82 if (e) e.preventDefault();
83 setLoading(true);
149}
150
151function client() {
152 createRoot(document.getElementById("root")!).render(<App />);
153}
157}
158
159function renderShader(canvas: HTMLCanvasElement, fragmentShaderSource: string, time: number) {
160 const gl = canvas.getContext("webgl");
161 if (!gl) {
171 `;
172
173 function createShader(gl: WebGLRenderingContext, type: number, source: string) {
174 const shader = gl.createShader(type);
175 if (!shader) return null;
240}
241
242function extractGLSLCode(text: string): string {
243 const glslMatch = text.match(/```glsl\n([\s\S]*?)\n```/);
244 return glslMatch
247}
248
249export default async function server(req: Request): Promise<Response> {
250 if (req.method === "POST") {
251 const client = new Cerebras();

welcomingPinkAlligatormain.tsx9 matches

@stevekrouse•Updated 5 months ago
4import { createRoot } from "https://esm.sh/react-dom/client";
5
6function debounce(func: Function, wait: number) {
7 let timeout: number | undefined;
8 return function executedFunction(...args: any[]) {
9 const later = () => {
10 clearTimeout(timeout);
16}
17
18function App() {
19 const [prompt, setPrompt] = useState("Generate a colorful gradient shader");
20 const [code, setCode] = useState(`
79 }, [code, debouncedRenderShader, retryCount]);
80
81 async function handleSubmit(e: React.FormEvent, shaderErrorMessage?: string) {
82 if (e) e.preventDefault();
83 setLoading(true);
149}
150
151function client() {
152 createRoot(document.getElementById("root")!).render(<App />);
153}
157}
158
159function renderShader(canvas: HTMLCanvasElement, fragmentShaderSource: string, time: number) {
160 const gl = canvas.getContext("webgl");
161 if (!gl) {
171 `;
172
173 function createShader(gl: WebGLRenderingContext, type: number, source: string) {
174 const shader = gl.createShader(type);
175 if (!shader) return null;
240}
241
242function extractGLSLCode(text: string): string {
243 const glslMatch = text.match(/```glsl\n([\s\S]*?)\n```/);
244 return glslMatch
247}
248
249export default async function server(req: Request): Promise<Response> {
250 if (req.method === "POST") {
251 const client = new Cerebras();

getFileEmail4 file matches

@shouser•Updated 1 week ago
A helper function to build a file's email

TwilioHelperFunctions

@vawogbemi•Updated 2 months ago