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=1460&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 19200 results for "function"(1587ms)

usageAlertmain.tsx1 match

@stevekrouse•Updated 6 months ago
2import { email } from "https://esm.town/v/std/email?v=13";
3
4export function usageAlert(handler: (req: Request) => Promise<Response>) {
5 const requestCounts: number[] = [];
6 const LIMIT = 1000;

usageAlertREADME.md1 match

@stevekrouse•Updated 6 months ago
9import { usageAlert } from "https://esm.town/v/stevekrouse/usageAlert"
10
11async function sampleHandler(req: Request): Promise<Response> {
12 return new Response("Hello, World!");
13}

fastCoffeeLizardmain.tsx2 matches

@mvmattgray•Updated 6 months ago
4 const secret = "cfbd87a697526bf25127f998fe6388684b80524be46062a1a79d6dd26b5a6b90";
5
6 async function verifySignature(bodyText, receivedSignature) {
7 const encoder = new TextEncoder();
8 const keyData = encoder.encode(secret);
126
127 <script>
128 async function fetchData() {
129 try {
130 const response = await fetch(window.location.href, { headers: { 'accept': 'application/json' } });

sqliteExplorerAppREADME.md1 match

@robaggio•Updated 6 months ago
33- [x] fix wonky sidebar separator height problem (thanks to @stevekrouse)
34- [x] make result tables scrollable
35- [x] add export to CSV, and JSON (CSV and JSON helper functions written in [this val](https://www.val.town/v/nbbaier/sqliteExportHelpers). Thanks to @pomdtr for merging the initial version!)
36- [x] add listener for cmd+enter to submit query
37

whoIsHiringmain.tsx3 matches

@lowlu•Updated 6 months ago
7import About from "https://esm.town/v/vawogbemi/whoIsHiringAbout";
8
9function App() {
10 const tabs = { "/": "Home", "/about": "About" };
11 const [activeTab, setActiveTab] = useState("/");
362}
363
364function ServerApp() {
365 return (
366 <html>
385}
386
387export default async function(req: Request): Promise<Response> {
388 const url = new URL(req.url);
389 if (url.pathname === "/api/stories") {

diligentSapphireOrcamain.tsx5 matches

@gigmx•Updated 6 months ago
1export default async function(req: Request): Response {
2 const url = new URL(req.url);
3
136 const connectionStatus = document.querySelector("#connection-status");
137
138 // Dropdown menu functionality
139 const menuButton = document.getElementById('menuButton');
140 const menuDropdown = document.getElementById('menuDropdown');
209 });
210
211 function parseResponse(text) {
212 const parts = [];
213 let currentText = "";
256 });
257
258 document.getElementById("input").addEventListener("submit", async function(event) {
259 event.preventDefault();
260 const userMessage = event.target.message.value;
359
360 document.querySelectorAll(".suggestion-button").forEach((button)=>{
361 button.addEventListener("click", function() {
362 const input = document.querySelector("input[name=\\"message\\"]");
363 input.value = this.textContent;

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>

getFileEmail4 file matches

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