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/$1?q=function&page=21&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 28553 results for "function"(1230ms)

TowniecalculateCost.tsx1 match

@PrincessJossy•Updated 13 hours ago
5const CACHE_WRITE_RATE = 3.75; // $3.75 per M cache-write tokens
6
7export function calculateCost({
8 input_tokens,
9 output_tokens,

TownieBranchSelect.tsx1 match

@PrincessJossy•Updated 13 hours ago
7const NEW_BRANCH_VAL = "__NEW_BRANCH__";
8
9export function BranchSelect() {
10 const { projectId, branchId } = useParams() as {
11 projectId: string;

Townieauth.ts1 match

@PrincessJossy•Updated 13 hours ago
5 * Returns null if authentication is successful, or a Response if it fails
6 */
7export async function basicAuthMiddleware(req: Request): Promise<Response | null> {
8 const realm = "Usage Dashboard";
9 const unauthorizedResponse = new Response("Unauthorized", {

TownieApp.tsx1 match

@PrincessJossy•Updated 13 hours ago
17});
18
19export function App() {
20 const [audio, setAudio] = useLocalStorage("AUDIO", false);
21 const user = useUser();

ipv4-counterindex.html4 matches

@maxm•Updated 14 hours ago
101 .replace("ems.sh", "val.town");
102
103 // Function to format dates nicely
104 function formatDate(dateString) {
105 const date = new Date(dateString);
106 return date.toLocaleString();
107 }
108
109 // Function to update the UI with visit data
110 function updateUI(data) {
111 // Update total visits
112 document.getElementById("total-visits").textContent =

cerebras_coderv2index.ts7 matches

@etomberg391•Updated 14 hours ago
23);
24
25function Hero({
26 prompt,
27 setPrompt,
44
45 <p className="text-[#bababa] text-center max-w-[25ch] mx-auto my-4 font-dm-sans">
46 Turn your ideas into fully functional apps in{" "}
47 <span className="relative w-fit text-fuchsia-400 z-10 italic font-semibold rounded-full">
48 less than a second
115}
116
117function App() {
118 const previewRef = React.useRef<HTMLDivElement>(null);
119 const [prompt, setPrompt] = useState("");
169 });
170
171 function handleStarterPromptClick(promptItem: typeof prompts[number]) {
172 setLoading(true);
173 setTimeout(() => handleSubmit(promptItem.prompt), 0);
174 }
175
176 async function handleSubmit(e: React.FormEvent | string) {
177 if (typeof e !== "string") {
178 e.preventDefault();
225 }
226
227 function handleVersionChange(direction: "back" | "forward") {
228 const { currentVersionIndex, versions } = versionHistory;
229 if (direction === "back" && currentVersionIndex > 0) {
973);
974
975function client() {
976 const path = window.location.pathname;
977 const root = createRoot(document.getElementById("root")!);

cerebras_coderv2index.html1 match

@etomberg391•Updated 14 hours ago
19 <meta property="og:site_name" content="Cerebras Coder">
20 <meta property="og:url" content="https://cerebrascoder.com"/>
21 <meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Qwen-3-32B on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
22 <meta property="og:type" content="website">
23 <meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">

cerebras_coderv2generate-code.ts3 matches

@etomberg391•Updated 14 hours ago
2import STARTER_PROMPTS from "../public/starter-prompts.js";
3
4function extractCodeFromFence(text: string): string {
5 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
6 return htmlMatch ? htmlMatch[1].trim() : text;
7}
8
9function filterThinkingTokens(text: string): string {
10 // Find the last occurrence of </think>
11 const lastThinkEndIndex = text.lastIndexOf("</think>");
20}
21
22export async function generateCode(prompt: string, currentCode: string) {
23 const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
24 if (starterPrompt) {

Lawyersmain.tsx12 matches

@Get•Updated 14 hours ago
133}
134
135// --- HTML Generation Function (With Dashboard Grid Background & New Input) ---
136// --- HTML Generation Function (With Luxe-inspired Dashboard Style) ---
137function generateHtmlShell(initialUrl, initialText, initialQuery, sourceUrl) {
138 const escapedUrl = initialUrl.replace(/"/g, "&quot;");
139 const escapedText = initialText.replace(/</g, "&lt;").replace(/>/g, "&gt;");
504 // --- Client-side PDF text extraction (basic example, consider robust library like pdf.js for production)
505    // This is a placeholder. Full PDF.js integration is more involved.
506    async function extractTextFromPdfClientSide(file) {
507        return new Promise((resolve, reject) => {
508            const reader = new FileReader();
544    const submitButtonText = submitButton.querySelector('span');
545
546    function escapeHtml(unsafe) {
547        if (unsafe === null || typeof unsafe === 'undefined') return '';
548        return String(unsafe)
554    }
555
556    function addStatusMessage(message, type = 'info') { // types: info, error, progress
557 const initialStatusP = statusContainer.querySelector('p');
558 if (initialStatusP && initialStatusP.textContent === 'Awaiting input...') {
566    }
567
568    function displayAnalysisResults(data) {
569        structuredResultsContainer.innerHTML = '';
570
811
812// --- Main Request Handler (Server Code) ---
813export default async function(req: Request) {
814 // --- Dynamic Imports (Inside Handler) ---
815 const { OpenAI } = await import("https://esm.town/v/std/openai");
833
834 // --- Helper: Extract Text using pdf.js-extract (Server-side) ---
835 async function extractPdfTextNative(data: ArrayBuffer, fileName: string, log: LogEntry[]): Promise<string | null> {
836 const agent = "PDF Extraction Agent (Val Server)";
837 log.push({ agent, type: "step", message: `Processing PDF: ${fileName} using npm:pdf.js-extract` });
855 }
856
857 // --- Helper Function: Call OpenAI API ---
858 async function callOpenAI(
859 openai: OpenAI,
860 systemPrompt: string,
898
899 // --- Main Agent Flow Logic (Modified for single Legal AI Agent) ---
900 async function runLegalAnalysisFlow(
901 input: {
902 legalTaskQuery: string;

leglmain.tsx11 matches

@Get•Updated 14 hours ago
133}
134
135// --- HTML Generation Function (With Dashboard Grid Background & New Input) ---
136function generateHtmlShell(initialUrl, initialText, initialQuery, sourceUrl) {
137 const escapedUrl = initialUrl.replace(/"/g, "&quot;");
138 const escapedText = initialText.replace(/</g, "&lt;").replace(/>/g, "&gt;");
238 // Client-side PDF text extraction (basic example, consider robust library like pdf.js for production)
239 // This is a placeholder. Full PDF.js integration is more involved.
240 async function extractTextFromPdfClientSide(file) {
241 return new Promise((resolve, reject) => {
242 const reader = new FileReader();
278 const submitButtonText = submitButton.querySelector('span');
279
280 function escapeHtml(unsafe) {
281 if (unsafe === null || typeof unsafe === 'undefined') return '';
282 return String(unsafe)
288 }
289
290 function addStatusMessage(message, type = 'info') { // types: info, error, progress
291 const entry = document.createElement('div');
292 entry.className = \`status-entry \${type}\`;
296 }
297
298 function displayAnalysisResults(data) {
299 structuredResultsContainer.innerHTML = ''; // Clear previous results
300
504
505// --- Main Request Handler (Server Code) ---
506export default async function(req: Request) {
507 // --- Dynamic Imports (Inside Handler) ---
508 const { OpenAI } = await import("https://esm.town/v/std/openai");
526
527 // --- Helper: Extract Text using pdf.js-extract (Server-side) ---
528 async function extractPdfTextNative(data: ArrayBuffer, fileName: string, log: LogEntry[]): Promise<string | null> {
529 const agent = "PDF Extraction Agent (Val Server)";
530 log.push({ agent, type: "step", message: `Processing PDF: ${fileName} using npm:pdf.js-extract` });
548 }
549
550 // --- Helper Function: Call OpenAI API ---
551 async function callOpenAI(
552 openai: OpenAI,
553 systemPrompt: string,
591
592 // --- Main Agent Flow Logic (Modified for single Legal AI Agent) ---
593 async function runLegalAnalysisFlow(
594 input: {
595 legalTaskQuery: string;

getFileEmail4 file matches

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

tuna8 file matches

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