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=2411&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 28772 results for "function"(2030ms)

multilingualchatroommain.tsx9 matches

@ireneg•Updated 7 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 7 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 `

Update_Wise_Old_Manmain.tsx1 match

@evanrh•Updated 7 months ago
1import { WOMClient } from "npm:@wise-old-man/utils";
2
3export default async function(interval: Interval) {
4 const rawUsers = Deno.env.get("OSRS_USERS") ?? "";
5 const users: string[] = rawUsers.split(",");

countGithubLOCStreamingConceptmain.tsx2 matches

@g•Updated 7 months ago
23}
24
25function onfile(file: UnzipFile) {
26 const { name } = file;
27 file.ondata = (err, data, final) => {
37}
38
39function ondone() {
40 console.log(`${repo}: Found ${loc} lines of code.`);
41}

multilingualchatroommain.tsx9 matches

@trob•Updated 7 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);

MoonCatWalkmain.tsx6 matches

@midnightlightning•Updated 7 months ago
40}
41
42function parseGoal(x: number, y: number, goalX: number, goalY: number) {
43 const parsed: { x: number; y: number; animation: AnimationLabel } = {
44 x: x,
92}
93
94function VirtualPet({ spriteNum }: { spriteNum: number }) {
95 const [petState, setPetState] = useState<PetState>({
96 behavior: "idle",
173
174 useEffect(() => {
175 function handleMouseMove(e) {
176 const now = Date.now();
177 if (now - mousePos.current.moveTime > 2000) {
202 useEffect(() => {
203 let ignore = false;
204 function doTick() {
205 if (ignore) return;
206 tick();
229}
230
231function client() {
232 const root = document.getElementById("root");
233 if (root) {
241}
242
243export default async function server(req: Request): Promise<Response> {
244 const pathSegment = new URL(req.url).pathname.split("/")[1];
245 const spriteNum = pathSegment && /^\d+$/.test(pathSegment)

serveAudiomain.tsx1 match

@milesfalk•Updated 7 months ago
1export default async function serveAudio(req: Request): Promise<Response> {
2 const { blob } = await import("https://esm.town/v/std/blob");
3

RobotBackupCallGraphmain.tsx15 matches

@maxm•Updated 7 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 7 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 7 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({

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 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.