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=1373&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 18324 results for "function"(2170ms)

wittyTurquoiseDovemain.tsx12 matches

@all•Updated 6 months ago
12}
13
14function QuickCommand({ label, onClick }: { label: string; onClick: () => void }) {
15 return (
16 <button className="quick-command" onClick={onClick}>
20}
21
22function App() {
23 const [prompt, setPrompt] = useState("hello llamapalooza");
24 const [code, setCode] = useState("");
104 label: "Mobile-First Layout",
105 prompt:
106 "Design a Mobile-First Layout that prioritizes mobile device usability and performance, ensuring that the design scales up effectively for larger screens while maintaining functionality and aesthetics on smaller devices.",
107 },
108 {
208 }, []);
209
210 async function fetchSavedSnippets() {
211 const response = await fetch("/snippets");
212 const snippets = await response.json();
214 }
215
216 async function handleSave() {
217 if (!code) return;
218 const response = await fetch("/snippets", {
226 }
227
228 async function handleDelete(id: number) {
229 const response = await fetch(`/snippets/${id}`, { method: "DELETE" });
230 if (response.ok) {
233 }
234
235 async function handleSubmit(e: React.FormEvent) {
236 e.preventDefault();
237 setLoading(true);
257 }
258
259 function handleBack() {
260 if (currentIndex > 0) {
261 setCurrentIndex(currentIndex - 1);
264 }
265
266 function handleForward() {
267 if (currentIndex < history.length - 1) {
268 setCurrentIndex(currentIndex + 1);
391}
392
393function client() {
394 createRoot(document.getElementById("root")!).render(<App />);
395}
399}
400
401function extractCodeFromFence(text: string): string {
402 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
403 return htmlMatch ? htmlMatch[1].trim() : text;
404}
405
406export default async function server(req: Request): Response {
407 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
408 const KEY = "wittyTurquoiseDove";

zwiftPortalScheduleREADME.md1 match

@dazzag24•Updated 6 months ago
47import { email } from "https://esm.town/v/std/email";
48
49export default async function sendZwiftPortalSchedule(interval: Interval) {
50 console.log("Parsing Zwift portal road schedule...");
51

RobotBackupCallGraphmain.tsx15 matches

@EnergyAddict•Updated 6 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 });

createFileInputAppmain.tsx1 match

@maxencelav•Updated 6 months ago
1export default function server(req: Request): Response {
2 return new Response(`
3 <!DOCTYPE html>

png64main.tsx3 matches

@all•Updated 6 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 const [isDragging, setIsDragging] = useState(false);
7 const [jsonResult, setJsonResult] = useState(null);
124}
125
126function client() {
127 createRoot(document.getElementById("root")).render(<App />);
128}
130if (typeof document !== "undefined") { client(); }
131
132export default async function server(req: Request): Promise<Response> {
133 // Handle image processing
134 if (req.method === 'POST' && new URL(req.url).searchParams.get('process')) {

btcPriceAlertmain.tsx1 match

@whykay•Updated 6 months ago
4import { currency } from "https://esm.town/v/stevekrouse/currency";
5
6export async function btcPriceAlert() {
7 const lastBtcPrice: number = await blob.getJSON("lastBtcPrice");
8 let btcPrice = await currency("usd", "btc");

btcPriceAlertmain.tsx1 match

@luizhrios•Updated 6 months ago
4import { currency } from "https://esm.town/v/stevekrouse/currency";
5
6export async function btcPriceAlert() {
7 const lastBtcPrice: number = await blob.getJSON("lastBtcPrice");
8 let btcPrice = await currency("usd", "btc");

squishyformmain.tsx14 matches

@yawnxyz•Updated 6 months ago
39 let currentHistoryIndex = -1;
40
41 function updateStore(newData, source) {
42 const currentData = $parsedResult.get();
43 if (JSON.stringify(newData) !== JSON.stringify(currentData)) {
75
76
77 function undo() {
78 if (currentHistoryIndex > 0) {
79 currentHistoryIndex--;
83 }
84
85 function redo() {
86 if (currentHistoryIndex < history.length - 1) {
87 currentHistoryIndex++;
105 });
106
107 function debounce(func, delay) {
108 return function() {
109 const context = this;
110 const args = arguments;
118 inputText.addEventListener('input', debouncedSubmit);
119
120 function startTimer() {
121 startTime = Date.now();
122 stopTimer(); // Ensure any existing timer is stopped
124 }
125
126 function stopTimer() {
127 clearInterval(timerInterval);
128 timerInterval = null; // Clear the interval reference
132 }
133
134 function updateTimer() {
135 const elapsedTime = ((Date.now() - startTime) / 1000).toFixed(2);
136 timerDisplay.textContent = elapsedTime + 's llama3-groq-8b-8192';
137 }
138
139 async function submitForm() {
140 const input = inputText.value.trim();
141 const system = systemText.value.trim();
209 let isEditorFocused = false;
210
211 function updateResultText(data) {
212 const existingMonacoEditor = result.querySelector('#monaco-editor');
213
220
221 require.config({ paths: { 'vs': 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.30.1/min/vs' }});
222 require(['vs/editor/editor.main'], function() {
223 editor = monaco.editor.create(editorContainer, {
224 value: JSON.stringify(data, null, 2),
289 }
290
291 function updateTable(data) {
292 if (!result.querySelector('#resultTable')) {
293 const table = document.createElement('table');
359 }
360
361 function createEmptyRow() {
362 const row = document.createElement('tr');
363 const keyCell = document.createElement('td');
379 }
380
381 function createEditableInput(value, key, type) {
382 const input = document.createElement('input');
383 input.type = 'text';

qrCodeWebhookmain.tsx5 matches

@d17e•Updated 6 months ago
7}
8
9function generateQrSVGPaths(
10 qrData: boolean[][],
11 penWidth: number,
20 const overlap = true;
21
22 function createPath(
23 startX: number,
24 startY: number,
30 }
31
32 function visitRow(visited: boolean[][], y: number, startX: number, endX: number) {
33 for (let x = startX; x <= endX; x++) {
34 visited[y][x] = true;
36 }
37
38 function visitColumn(visited: boolean[][], x: number, startY: number, endY: number) {
39 for (let y = startY; y <= endY; y++) {
40 visited[y][x] = true;
113}
114
115export default async function(request: Request): Promise<Response> {
116 if (request.method !== "POST" && request.method !== "GET") {
117 return new Response("Method Not Allowed", { status: 405 });

webdavServermain.tsx1 match

@pomdtr•Updated 6 months ago
7};
8
9export function serveVals(
10 req: Request,
11 options?: WebdavOptions,

getFileEmail4 file matches

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

tuna8 file matches

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