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/$%7Bart_info.art.src%7D?q=function&page=1563&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 20222 results for "function"(4435ms)

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,

publicKeyPem_examplemain.tsx2 matches

@vladimyr•Updated 6 months ago
50console.log(rsaPublicKeyPem);
51
52function parsePem(pem: string) {
53 pem = pem.replace(/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g, "");
54 return base64pad.baseDecode(pem);
55}
56
57function wrap(input: string, columns = 64) {
58 const reLines = new RegExp(`.{${columns}}`, "g");
59 return input.replace(reLines, (line) => line + "\n");

avidPeachBoamain.tsx3 matches

@vladimyr•Updated 6 months ago
49console.log(publicKeyPem);
50
51function pkiFromPkcs1(pkcs1: ArrayBuffer) {
52 return new pki.PublicKeyInfo({
53 // algorithm: publicKeyInfo.algorithm,
60}
61
62function parsePem(pem: string) {
63 pem = pem.replace(/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g, "");
64 return base64pad.baseDecode(pem);
65}
66
67function wrap(input: string, columns = 64) {
68 const reLines = new RegExp(`.{${columns}}`, "g");
69 return input.replace(reLines, (line) => line + "\r\n");

getFileEmail4 file matches

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

tuna8 file matches

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