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=73&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 31568 results for "function"(1853ms)

val-to-textValOutput.tsx1 match

@tkneisly•Updated 4 days ago
3import type { ValOutputProps } from "../types.ts";
4
5export function ValOutput({
6 text,
7 files,

val-to-textValForm.tsx1 match

@tkneisly•Updated 4 days ago
3import type { ValFormProps } from "../types.ts";
4
5export function ValForm({
6 username,
7 valName,

val-to-textutils.ts3 matches

@tkneisly•Updated 4 days ago
10type File = ValTown.Vals.Files.FileRetrieveResponse;
11
12export function formatOutput({
13 username,
14 valname,
42}
43
44export async function getTreeAndContent(id: string): Promise<{
45 filesWithContent: { name: string; content: string }[];
46 tree: FileTree;
71}
72
73export async function getFilesWithContent(
74 files: File[],
75 valId: string,

val-to-textuseValExport.ts1 match

@tkneisly•Updated 4 days ago
1import { useState } from "https://esm.sh/react@18.2.0";
2
3export function useValExport() {
4 const [text, setText] = useState<undefined | string>();
5 const [files, setFiles] = useState<number>(0);

val-to-textApp.tsx1 match

@tkneisly•Updated 4 days ago
5import { useValExport } from "../hooks/useValExport.ts";
6
7export function App() {
8 const [name, setName] = React.useState("val-to-text");
9 const [username, setUsername] = React.useState("nbbaier");

autonomous-valdemo.tsx7 matches

@tkneisly•Updated 4 days ago
1import agent from "./agent.tsx";
2
3export default async function(req: Request) {
4 // Default objective as fallback
5 let objective = `Buy 100 shares of MSFT and 100 shares of NVDA.`;
89}
90
91// Function to generate HTML for tool calls
92function generateToolCallsHtml(results: any): string {
93 if (!results || !results.steps) {
94 return "";
146}
147
148// Function to generate the HTML page with the form and optional results
149function generateHtmlPage(objective?: string, results?: any, errorMessage?: string): string {
150 const defaultObjective = objective || `What is the current temperature in Tokyo?`;
151
233 </style>
234 <script>
235 // Function to populate the textarea with the selected prompt
236 function setPrompt(value) {
237 if (value) {
238 document.getElementById('objective').value = value;

autonomous-valagent.tsx1 match

@tkneisly•Updated 4 days ago
16import { formatResult, parseStatusToolResult } from "./utils.tsx";
17
18export default async function POST(req: Request) {
19 if (req.headers.get("Authorization") !== `Bearer ${Deno.env.get("AGENT_API_KEY")}`) {
20 return new Response("Unauthorized", { status: 401 });

RequirementsWriterApp.tsx1 match

@tkneisly•Updated 4 days ago
2import { useState } from "https://esm.sh/react@18.2.0";
3
4export function App() {
5 const [clicked, setClicked] = useState(0);
6 return (

untitled-6069main.tsx19 matches

@masterpiece•Updated 4 days ago
296
297 <script>
298 // Data loading functions
299 async function fetchData(endpoint) {
300 try {
301 const response = await fetch(`/Repository/docrepo/backend/api/${endpoint}.php`);
371
372 // Toggle loading spinner
373 function toggleLoading(elementId, show) {
374 const element = document.getElementById(elementId);
375 if (element) {
378 }
379
380 // Render functions for each section
381 function renderWebinars(webinars) {
382 const container = document.getElementById('webinarsContainer');
383 if (!container) return;
399 }
400
401 function renderResearch(featured, recent) {
402 const featuredContainer = document.getElementById('featuredResearch');
403 const recentContainer = document.getElementById('recentResearch');
431 }
432
433 // Additional render functions would follow the same pattern...
434 // (renderInnovations, renderConferences, renderDepartments, etc.)
435
436 // Helper function to display time since
437 function timeSince(date) {
438 const seconds = Math.floor((new Date() - date) / 1000);
439 let interval = Math.floor(seconds / 31536000);
451 }
452
453 // Authentication functions
454 function checkAuthStatus() {
455 fetch('/Repository/docrepo/backend/api/auth/session.php')
456 .then(res => res.json())
463 }
464
465 function updateUIForLoggedInUser(user) {
466 const loginBtn = document.getElementById('loginToggle');
467 const registerBtn = document.getElementById('registerToggle');
478 }
479
480 async function handleLogout() {
481 try {
482 const response = await fetch('/Repository/docrepo/backend/api/auth/logout.php', {
498 const registerModal = document.getElementById('registerModal');
499
500 function toggleModal(show, hide) {
501 show.classList.remove('hidden');
502 hide.classList.add('hidden');
504 }
505
506 function clearMessages() {
507 document.getElementById('loginError').textContent = '';
508 document.getElementById('loginError').classList.add('hidden');
542 // Smooth scrolling for navigation links
543 document.querySelectorAll('a[href^="#"]').forEach(anchor => {
544 anchor.addEventListener('click', function (e) {
545 e.preventDefault();
546 const target = document.querySelector(this.getAttribute('href'));
614 });
615
616 function renderDepartments(departments) {
617 const container = document.getElementById('departmentsContainer');
618 if (!container || !departments) return;
639
640
641function renderDepartmentsDropdown(departments) {
642 const dropdown = document.getElementById('departmentsDropdown');
643 if (!dropdown || !departments) return;
650}
651
652async function fetchData(endpoint) {
653 const loadingElement = document.getElementById(`${endpoint}Loading`);
654 if (loadingElement) loadingElement.style.display = 'block';

GlancergenerateHTML.tsx28 matches

@lightweight•Updated 4 days ago
8 let heightSent = false;
9
10 function notifyParentOfHeight() {
11 // Only send height once and only if we're in an iframe
12 if (!heightSent && window.parent !== window) {
55}
56
57function escapeHtml(text: string): string {
58 return text
59 .replace(/&/g, "&amp;")
64}
65
66function extractYouTubeId(url: string): string | null {
67 const patterns = [
68 /(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([^&\n?#]+)/,
77}
78
79function extractVimeoId(url: string): string | null {
80 const match = url.match(/vimeo\.com\/(?:video\/)?(\d+)/);
81 return match ? match[1] : null;
82}
83
84function extractLoomId(url: string): string | null {
85 const match = url.match(/loom\.com\/share\/([a-zA-Z0-9]+)/);
86 return match ? match[1] : null;
87}
88
89function extractDomain(url: string): string {
90 try {
91 const urlObj = new URL(url);
96}
97
98export function GenerateHTML({ data }: any) {
99 if (!data || !data.results) {
100 return <div>No content available</div>;
156}
157
158function renderChildBlocks(children: NotionBlock[]): string {
159 if (!children || !Array.isArray(children) || children.length === 0) {
160 return "";
164}
165
166function renderBlock(block: NotionBlock): string {
167 const { type } = block;
168
217}
218
219function renderRichText(richTextArray: NotionRichText[]): string {
220 if (!richTextArray || !Array.isArray(richTextArray)) {
221 return "";
250}
251
252function renderParagraph(block: NotionBlock): string {
253 const content = renderRichText(block.paragraph?.rich_text || []);
254 return content ? `<p>${content}</p>` : "<p></p>";
255}
256
257function renderHeading(block: NotionBlock, level: number): string {
258 const headingData = block[`heading_${level}`];
259 const content = renderRichText(headingData?.rich_text || []);
261}
262
263function renderListItem(block: NotionBlock, listType: "ul" | "ol"): string {
264 const itemData =
265 block[listType === "ul" ? "bulleted_list_item" : "numbered_list_item"];
275}
276
277function renderTodo(block: NotionBlock): string {
278 const todoData = block.to_do;
279 const content = renderRichText(todoData?.rich_text || []);
289}
290
291function renderToggle(block: NotionBlock): string {
292 const toggleData = block.toggle;
293 const content = renderRichText(toggleData?.rich_text || []);
304}
305
306function renderCode(block: NotionBlock): string {
307 const codeData = block.code;
308 const content = renderRichText(codeData?.rich_text || []);
312}
313
314function renderQuote(block: NotionBlock): string {
315 const quoteData = block.quote;
316 const content = renderRichText(quoteData?.rich_text || []);
325}
326
327function renderCallout(block: NotionBlock): string {
328 const calloutData = block.callout;
329 const content = renderRichText(calloutData?.rich_text || []);
346}
347
348function renderImage(block: NotionBlock): string {
349 const imageData = block.image;
350 let imageUrl = "";
366}
367
368function renderVideo(block: NotionBlock): string {
369 const videoData = block.video;
370 let videoUrl = "";
427}
428
429function renderFile(block: NotionBlock): string {
430 const fileData = block.file;
431 let fileUrl = "";
447}
448
449function renderBookmark(block: NotionBlock): string {
450 const bookmarkData = block.bookmark;
451 const url = bookmarkData?.url || "";
474}
475
476function renderLinkPreview(block: NotionBlock): string {
477 const linkData = block.link_preview;
478 const url = linkData?.url || "";
494}
495
496function renderEmbed(block: NotionBlock): string {
497 const embedData = block.embed;
498 const url = embedData?.url || "";
588}
589
590function renderTable(block: NotionBlock): string {
591 // Tables in Notion are complex and would need child blocks to be fully rendered
592 return '<table class="notion-table"><tbody><!-- Table rows would be rendered here --></tbody></table>';
593}
594
595function renderTableRow(block: NotionBlock): string {
596 const rowData = block.table_row;
597 const cells = rowData?.cells || [];
607}
608
609function renderColumnList(block: NotionBlock): string {
610 return '<div class="column-list"><!-- Columns would be rendered here --></div>';
611}
612
613function renderColumn(block: NotionBlock): string {
614 return '<div class="column"><!-- Column content would be rendered here --></div>';
615}
tuna

tuna9 file matches

@jxnblk•Updated 2 weeks ago
Simple functional CSS library for Val Town

getFileEmail4 file matches

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