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/$%7BsvgDataUrl%7D?q=function&page=5&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 30462 results for "function"(2588ms)

tanstackReactHonoExampleApp.tsx3 matches

@neverstew•Updated 7 hours ago
5import { useMessages } from "../lib/queries.ts";
6
7export function App(
8 { initialMessages = [], thisProjectURL }: { initialMessages?: Message[]; thisProjectURL?: string },
9) {
48}
49
50function MessageList({ messages }: { messages: Message[] }) {
51 const displayedMessages = messages.slice(0, MESSAGE_LIMIT);
52 return (
57}
58
59function MessageItem({ message }) {
60 const formattedDate = new Date(message.timestamp).toLocaleString();
61

ChatHTMLRenderer.tsx6 matches

@c15r•Updated 8 hours ago
22 readResource: (serverName: string, uri: string) => Promise<string>;
23
24 // Utility functions
25 log: (level: "debug" | "info" | "warning" | "error", message: string, data?: any) => void;
26
40 * - Handles iframe communication via postMessage
41 */
42export default function HTMLRenderer({ html, mcpClients = [], className = "" }: HTMLRendererProps) {
43 const iframeRef = useRef<HTMLIFrameElement>(null);
44 const containerRef = useRef<HTMLDivElement>(null);
132 },
133
134 // Utility functions
135 log: (level: "debug" | "info" | "warning" | "error", message: string, data?: any) => {
136 console[level](`[HTMLRenderer] ${message}`, data);
154 }, [mcpClients, isFullscreen]);
155
156 // Fullscreen functionality
157 const enterFullscreen = useCallback(() => {
158 const container = containerRef.current;
218 const methodFunc = (mcpContext as any)[method];
219
220 if (typeof methodFunc !== "function") {
221 throw new Error(`Unknown MCP API method: ${method}`);
222 }
365 <script>
366 // Update fullscreen controls based on state
367 async function updateFullscreenControls() {
368 const controls = document.getElementById('fullscreenControls');
369 const isFs = await window.mcpContext.isFullscreen();

Work_Time_Calculator_2main.tsx7 matches

@willthereader•Updated 9 hours ago
1function parseTimeRanges(daySchedule) {
2 // console.log(`Parsing schedule: ${daySchedule}`);
3 const timeRanges = daySchedule.match(/(\d{1,2}(?::\d{2})?(?:am|pm)?)/g);
53}
54
55function convertTo24HourFormat(time) {
56 if (!time) {
57 throw new Error("Invalid time input: time is undefined or empty");
91}
92
93function calculateDuration(day, startTime, endTime) {
94 console.log(`calculateDuration: Calculating duration on ${day} from ${startTime} to ${endTime}`);
95 const start24 = convertTo24HourFormat(startTime);
112}
113
114function calculateDailyTotal(day, parsedSchedule) {
115 console.log(`calculateDailyTotal: Calculating daily total for ${day}`, parsedSchedule);
116 let totalMinutes = 0;
130}
131
132function calculateWeeklyTotal(day, dailyTotals) {
133 console.log(`calculateWeeklyTotal: Calculating weekly total for daily totals for ${day} is`, dailyTotals);
134 let totalHours = 0;
148}
149
150function isValidDay(day) {
151 const validDays = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];
152 return validDays.includes(day.charAt(0).toUpperCase() + day.slice(1).toLowerCase());
153}
154
155function calculateWorkTime(schedule) {
156 const dailyTotals = [];
157 const scheduleArray = schedule.split("\n").filter(Boolean);

Todomain.tsx22 matches

@svc•Updated 9 hours ago
54 }.`;
55
56function generateHtmlShell(sourceUrl: string): string {
57 return `
58<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>AuraTask - AI Todo</title>
72<div class="modal-overlay" id="chat-modal"><div class="modal-content"><div class="chat-header"><h3>Chat with Aura</h3></div><div id="chat-log"></div><form id="chat-form"><input type="text" id="chat-input" placeholder="Ask Aura to do something..." required><button type="submit" class="btn btn-primary">Send</button></form></div></div>
73<script>
74(function() {
75 const API_URL = '${sourceUrl}';
76 const STORE_KEYS = { projects: 'aura_projects_v1', tasks: 'aura_tasks_v1' };
83 const genId = () => Date.now().toString(36) + Math.random().toString(36).substr(2, 9);
84
85 function checkTaskLoad() {
86 if (tasks.filter(t => !t.isCompleted).length >= ACTIVE_TASK_WARNING_THRESHOLD) {
87 return confirm("You have a lot of active tasks. Are you sure you want to add more? It might be a good time to complete some items first.");
90 }
91
92 function loadState() {
93 projects = getStore(STORE_KEYS.projects);
94 tasks = getStore(STORE_KEYS.tasks);
99 }
100
101 function render() {
102 renderSidebar();
103 renderTaskList();
105 }
106
107 function toggleLoading(btn, show) {
108 if (!btn) return;
109 isLoading = show;
112 }
113
114 function updateUIElements() {
115 const todayStr = new Date().toISOString().split("T")[0];
116 const todayTasks = tasks.filter(t => !t.isCompleted && t.dueDate === todayStr);
126 }
127
128 function renderSidebar() {
129 const mainViews = [
130 {id:'today',name:'Today',icon:'M6 2a1 1 0 00-1 1v1H4a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V6a2 2 0 00-2-2h-1V3a1 1 0 10-2 0v1H7V3a1 1 0 00-1-1z'},
135 }
136
137 function renderTaskList() {
138 const container = $("#task-list");
139 let filteredTasks = [], title = 'Tasks';
158 }
159
160 function renderChatLog() {
161 const log = $("#chat-log");
162 log.innerHTML = conversationHistory.map((msg, idx) => {
170 }
171
172 function addMessageToChat(sender, text, plan = null, requiresConfirmation = false) {
173 conversationHistory.push({ sender, text, plan, requiresConfirmation });
174 renderChatLog();
175 }
176
177 function executePlan(plan) {
178 plan.forEach(action => {
179 if (action.operation === 'CREATE_TASK') {
191 }
192
193 function handleAddTask(e) {
194 e.preventDefault();
195 if (!checkTaskLoad()) return;
204 }
205
206 function handleTaskClick(e) {
207 const target = e.target, taskItem = target.closest(".task-item");
208 if (!taskItem) return;
223 }
224
225 function openEditModal(task) {
226 $("#edit-task-id").value = task.id;
227 $("#edit-task-content").value = task.content;
232 }
233
234 function handleUpdateTask(e) {
235 e.preventDefault();
236 const taskId = $("#edit-task-id").value, task = tasks.find(t => t.id === taskId);
245 }
246
247 async function handleChatSubmit(e) {
248 e.preventDefault();
249 const input = $("#chat-input"), userMessage = input.value.trim();
268 }
269
270 function handlePlanConfirm(e) {
271 const action = e.target.dataset.planAction, idx = e.target.dataset.planIdx;
272 if (!action || !idx) return;
277 }
278
279 async function triggerProjectSynthesis() {
280 if (!checkTaskLoad()) return;
281 const goal = $("#synthesis-goal-input").value.trim();
307 }
308
309 async function triggerDailyRebalance() {
310 const todayStr = new Date().toISOString().split("T")[0];
311 const todayTasks = tasks.filter(t => !t.isCompleted && t.dueDate === todayStr);
339 }
340
341 function bindEventListeners() {
342 document.body.addEventListener('click', e => {
343 if (e.target.closest('[data-view]')) {
371}
372
373export default async function(req: Request): Promise<Response> {
374 const openai = new OpenAI();
375 const url = new URL(req.url);

anthropicProxymain.tsx1 match

@maddy•Updated 10 hours ago
1import Anthropic from "npm:@anthropic-ai/sdk@0.24.3";
2
3export default async function(req: Request): Promise<Response> {
4 if (req.method === "OPTIONS") {
5 return new Response(null, {

cardamonRecipeForm.tsx1 match

@connnolly•Updated 10 hours ago
9}
10
11export default function RecipeForm({ recipe, onRecipeSaved, onCancel }: RecipeFormProps) {
12 const [formData, setFormData] = useState<Partial<Recipe>>({
13 title: recipe?.title || '',

brokenLinkCrawlercheckLink.tsx1 match

@willthereader•Updated 10 hours ago
1export async function checkLink(link) {
2 const linksMetaData = await fetch(link, {
3 method: "HEAD",

cardamonqueries.ts5 matches

@connnolly•Updated 10 hours ago
3import type { Recipe, Ingredient, RecipeFilters } from "../../shared/types.ts";
4
5export async function createRecipe(recipe: Omit<Recipe, 'id' | 'createdAt' | 'updatedAt'>): Promise<Recipe> {
6 const { ingredients, steps, tags, ...recipeData } = recipe;
7
71}
72
73export async function getRecipeById(id: number): Promise<Recipe | null> {
74 const recipeResult = await sqlite.execute(`
75 SELECT * FROM ${RECIPES_TABLE} WHERE id = ?
114}
115
116export async function getAllRecipes(filters?: RecipeFilters): Promise<Recipe[]> {
117 let query = `SELECT * FROM ${RECIPES_TABLE}`;
118 const params: any[] = [];
158}
159
160export async function updateRecipe(id: number, updates: Partial<Recipe>): Promise<Recipe | null> {
161 const { ingredients, steps, tags, ...recipeData } = updates;
162
221}
222
223export async function deleteRecipe(id: number): Promise<boolean> {
224 const result = await sqlite.execute(`DELETE FROM ${RECIPES_TABLE} WHERE id = ?`, [id]);
225

brokenLinkCrawlermainFunction.tsx1 match

@willthereader•Updated 10 hours ago
1import { checkLink } from "./checkLink.tsx";
2import { urlGetter } from "./urlGetter.tsx";
3async function brokenLinkCheckerMainFuction(url) {
4 const urlList = await urlGetter(url);
5 const checkedLink = await Promise.all(urlList.map(checkLink));

brokenLinkCrawlerurlGetter.tsx1 match

@willthereader•Updated 11 hours ago
1export async function urlGetter(sourceURl) {
2 const response = await fetch(sourceURl);
3 const html = await response.text();
tuna

tuna9 file matches

@jxnblk•Updated 1 week ago
Simple functional CSS library for Val Town

getFileEmail4 file matches

@shouser•Updated 1 month ago
A helper function to build a file's email
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.