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=754&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 7802 results for "function"(562ms)

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 });

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();

bsky_rss_pollmain.tsx1 match

@stevekrouse•Updated 5 months ago
3import { fetch } from "https://esm.town/v/std/fetch";
4
5export async function bsky_rss_poll() {
6 const { parseFeed } = await import("https://deno.land/x/rss/mod.ts");
7 const res = await fetch("https://v8.dev/blog.atom")

bsky_rss_pollREADME.md2 matches

@stevekrouse•Updated 5 months ago
4It's split into three parts:
51. [`bsky_rss_poll`](https://val.town/@jordan.bsky_rss_poll)
6 - This function runs every hour and polls the provided RSS feed, turns it into XML and runs the check. If there *is* a new post, it tell `rss_to_bsky`to post a link (and the title) to Bluesky
72. [`latest_rss`](https://val.town/@jordan.latest_rss)
8 - This is a stored object that keeps the latest object for the poll to test against
93. [`rss_to_bsky`](https://val.town/@jordan.rss_to_bsky)
10 - This function turns the text post into a rich text post and posts it to Bluesky
11
12Migrated from folder: Archive/bsky_rss_poll

reqEvaltownmain.tsx4 matches

@maxm•Updated 6 months ago
1import net, { AddressInfo } from "node:net";
2
3export default async function(req: Request): Promise<Response> {
4 return serveRequest(
5 req,
6 `data:text/tsx,${
7 encodeURIComponent(`
8export default async function(req: Request): Promise<Response> {
9 return Response.json("I am within a worker!")
10}
14}
15
16export async function serveRequest(req: Request, importUrl: string): Promise<Response> {
17 let port = await getFreePort();
18 const worker = new Worker(`https://esm.town/v/maxm/evaltownWorker?cachebust=${crypto.randomUUID()}`, {
55 });
56
57export async function isPortListening(port: number): Promise<boolean> {
58 let isListening = false;
59 const maxWaitTime = 2000; // ms

valtowntownmain.tsx5 matches

@maxm•Updated 6 months ago
48await contentStore.init();
49
50function Town() {
51 return (
52 <div
69}
70
71function HomePage() {
72 return (
73 <html>
82 <form method="POST" action="/submit">
83 <textarea name="handler" rows={10} cols={50} autoFocus>
84 {`export default async function(req: Request) {
85 return Response.json("Hello, world!");
86}`}
95}
96
97function ContentPage({ handler, id }: { handler: string; id: string }) {
98 return (
99 <html>
122 let originalContent = textarea.value;
123
124 textarea.addEventListener('input', function() {
125 if (textarea.value !== originalContent) {
126 submitButton.style.display = 'inline-block';

evalUImain.tsx1 match

@maxm•Updated 6 months ago
5import safeJsonValue from "npm:safe-json-value";
6
7export default async function(req: Request): Promise<Response> {
8 if (req.method === "GET") {
9 return new Response(indexHTML, {

evalmain.tsx2 matches

@maxm•Updated 6 months ago
1import safeJsonValue from "npm:safe-json-value";
2
3export async function evalCode(
4 code: string,
5): Promise<{ error: { message: string; name: string; stack: string } } | any> {
43}
44
45function getMainExport(
46 mod: any,
47): { ok: true; value: any } | { ok: false; error: Error } {

falDemoAppmain.tsx3 matches

@stevekrouse•Updated 6 months ago
5import { falProxyRequest } from "https://esm.town/v/stevekrouse/falProxyRequest";
6
7function App() {
8 const [prompt, setPrompt] = useState("");
9 const [imageUrl, setImageUrl] = useState("");
103}
104
105function client() {
106 createRoot(document.getElementById("root")).render(<App />);
107}
108if (typeof document !== "undefined") { client(); }
109
110export default async function server(req: Request): Promise<Response> {
111 const url = new URL(req.url);
112 if (url.pathname === "/") {

getFileEmail4 file matches

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

TwilioHelperFunctions

@vawogbemi•Updated 2 months ago