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/$%7Burl%7D?q=function&page=1990&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 30402 results for "function"(2993ms)

energycommunityshowcasemain.tsx3 matches

@nikko•Updated 2 months ago
3import React, { useState } from "https://esm.sh/react@18.2.0";
4
5function EnergyCommunityApp() {
6 const steps = [
7 {
127}
128
129function client() {
130 createRoot(document.getElementById("root")).render(<EnergyCommunityApp />);
131}
133if (typeof document !== "undefined") { client(); }
134
135export default async function server(request: Request): Promise<Response> {
136 return new Response(
137 `

UTC_Memain.tsx3 matches

@hunterparks•Updated 2 months ago
3import React, { useEffect, useState } from "https://esm.sh/react@18.2.0";
4
5function App() {
6 const [currentTime, setCurrentTime] = useState(new Date());
7
58}
59
60function client() {
61 const rootElement = document.getElementById("root");
62 if (rootElement) {
69if (typeof document !== "undefined") { client(); }
70
71export default async function server(request: Request): Promise<Response> {
72 return new Response(
73 `

logoWorkshop_migratedmain.tsx2 matches

@dcm31•Updated 2 months ago
253};
254
255function client() {
256 createRoot(document.getElementById("root")).render(<SimpleLogoGenerator />);
257}
261}
262
263export default async function server(request: Request): Promise<Response> {
264 return new Response(`
265 <!DOCTYPE html>

campycardsmain.tsx11 matches

@Learn•Updated 2 months ago
6const LOCAL_STORAGE_KEY = "aiCardGradingResults_v1"; // Change version if structure changes
7
8// --- Helper Functions ---
9function generateTimestamp() {
10 // Note: Using Chandler, AZ time as requested. For server-side consistency, UTC is often preferred.
11 // This example uses the browser's local time formatted, which might vary.
18}
19
20function getRandomGrade() { // Used by ScoreRevealAnimation if needed
21 const grades = ["A", "B", "C", "D", "F"];
22 return grades[Math.floor(Math.random() * grades.length)];
23}
24
25function getGradeColorClass(grade) { // Used by ScoreRevealAnimation
26 switch (grade) {
27 case "A":
40}
41
42function formatNumber(num) { // Used by ScoreRevealAnimation
43 return Math.round(num).toString();
44}
45
46// --- Score Reveal Animation Component ---
47function ScoreRevealAnimation({ startSignal, gradeData, onComplete }) {
48 // --- State ---
49 const [phase, setPhase] = useState("idle"); // 'idle', 'anticipating', 'stamping', 'fading', 'report', 'finished'
94 }
95
96 // --- Cleanup function ---
97 const clearTimers = useCallback(() => {
98 clearInterval(scoreIntervalRef.current);
256
257// --- Card Grader Frontend Component ---
258function CardGraderApp() {
259 const [imageFile, setImageFile] = useState(null);
260 const [imageBase64, setImageBase64] = useState(null);
421 };
422
423 // --- Render Functions ---
424 const renderReport = (report) => {
425 if (!report) return null;
553
554// --- Client-side Rendering ---
555function client() {
556 const rootElement = document.getElementById("root");
557 if (rootElement) {
566
567// --- Backend Server (Val Town) ---
568export default async function server(request: Request): Promise<Response> {
569 const { OpenAI } = await import("https://esm.town/v/std/openai");
570

Cardvaluemain.tsx7 matches

@find•Updated 2 months ago
6const LOCAL_STORAGE_KEY = "aiCardGradingResults_v1"; // Change version if structure changes
7
8// --- Helper Function ---
9function generateTimestamp() {
10 return new Date().toLocaleString();
11}
12
13// --- Frontend Component ---
14function CardGraderApp() {
15 const [imageFile, setImageFile] = useState(null);
16 const [imageBase64, setImageBase64] = useState(null);
141 };
142
143 // --- Render Functions ---
144
145 const renderReport = (report) => {
257
258// --- Client-side Rendering ---
259function client() {
260 const rootElement = document.getElementById("root");
261 if (rootElement) {
270
271// --- Backend Server (Val Town) ---
272export default async function server(request: Request): Promise<Response> {
273 const { OpenAI } = await import("https://esm.town/v/std/openai");
274
411}
412
413// --- HTML Content --- (Moved outside the server function for clarity)
414const htmlContent = `
415<!DOCTYPE html>

Learningmain.tsx7 matches

@find•Updated 2 months ago
13];
14
15function LearningApp() {
16 const [state, setState] = useState({
17 topics: INITIAL_TOPICS,
29 });
30
31 // --- Helper Functions ---
32 const setLoading = (message) => setState(prev => ({ ...prev, loadingMessage: message, error: null }));
33 const setError = (errorMessage) => setState(prev => ({ ...prev, loadingMessage: null, error: errorMessage }));
34 const clearLoadingError = () => setState(prev => ({ ...prev, loadingMessage: null, error: null }));
35
36 // --- API Interaction Functions ---
37
38 const fetchStudyMaterial = useCallback(async (topic) => {
64 setState(prev => ({ ...prev, stage: "topic-selection", selectedTopic: null }));
65 }
66 }, []); // Empty dependency array means this function is created once
67
68 const startQuiz = useCallback(async () => {
384
385// --- Client-side Rendering ---
386function client() {
387 const rootElement = document.getElementById("root");
388 if (rootElement) {
399
400// --- Backend Server (Val Town) ---
401export default async function server(request: Request): Promise<Response> {
402 // Standard Val Town imports (ensure these versions are suitable)
403 const { OpenAI } = await import("http://esm.town/v/std/openai"); // Use npm import for better version control if needed
590}
591
592// --- CSS Styling (moved outside main function for clarity) ---
593const css = `
594:root {

homerepairmain.tsx5 matches

@Learn•Updated 2 months ago
57 | { type: "RESET_STATE" };
58
59function appReducer(state: AppState, action: AppAction): AppState {
60 switch (action.type) {
61 case "SELECT_AGENT":
119}
120
121function HomeRepairAssistants() {
122 const initialAgents: Agent[] = [
123 {
199 {
200 name: "fix-light-switch",
201 description: "Fix a malfunctioning light switch",
202 inputs: [
203 {
517
518// Client-side rendering
519function client() {
520 // Inject styles
521 const styleElement = document.createElement("style");
528if (typeof document !== "undefined") { client(); }
529
530export default async function server(request: Request): Promise<Response> {
531 const { OpenAI } = await import("https://esm.town/v/std/openai");
532 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
13}
14
15export function ProjectForm({ onSubmit, onCancel, initialValues = {} }: ProjectFormProps) {
16 const [formData, setFormData] = useState({
17 name: initialValues.name || '',
8}
9
10export function SubscribersList({ subscribers, projects }: SubscribersListProps) {
11 const [searchTerm, setSearchTerm] = useState('');
12
11}
12
13export function ProjectsList({
14 projects,
15 loading,
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.