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=10&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 24448 results for "function"(594ms)

todo-appApp.tsx1 match

@diegoivoโ€ขUpdated 9 hours ago
15}
16
17export default function App({ initialData }: AppProps) {
18 const [user, setUser] = useState<User | null>(initialData.user);
19 const [todos, setTodos] = useState<Todo[]>(initialData.user?.todos || []);

ChatMessage.tsx3 matches

@c15rโ€ขUpdated 9 hours ago
20/* โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ */
21
22export default function MessageComponent({ message }: MessageProps) {
23 const [expandedSections, setExpandedSections] = useState<Set<string>>(
24 new Set(),
204
205 // Tool calls
206 if (line.includes("tool_use") || line.includes("function_call")) {
207 emitPlain();
208 try {
219
220 // Tool results
221 if (line.includes("tool_result") || line.includes("function_result")) {
222 emitPlain();
223 try {

todo-appindex.ts6 matches

@diegoivoโ€ขUpdated 9 hours ago
16app.get("/shared/*", c => serveFile(c.req.path, import.meta.url));
17
18// Helper function to get user data from blob storage
19async function getUserData(email: string): Promise<User> {
20 const userData = await blob.getJSON(`user:${email}`);
21 return userData || { email, todos: [] };
22}
23
24// Helper function to save user data to blob storage
25async function saveUserData(user: User): Promise<void> {
26 await blob.setJSON(`user:${user.email}`, user);
27}
28
29// Helper function to generate unique ID
30function generateId(): string {
31 return Date.now().toString(36) + Math.random().toString(36).substr(2);
32}

eink-frameapod.ts1 match

@michaelwschultzโ€ขUpdated 9 hours ago
13const NASA_API_KEY = Deno.env.get("NASA_API_KEY");
14
15export default async function GetAPOD(req: Request): Promise<Response> {
16 const url = `https://api.nasa.gov/planetary/apod?api_key=${NASA_API_KEY}&thumbs=true`;
17 const cacheKey = "nasa_apod";

eink-framegithub.tsx5 matches

@michaelwschultzโ€ขUpdated 9 hours ago
5import { BodyWrapper, Content, Footer, Header, Headline } from "../components.tsx";
6
7function getContributionLevel(count: number): string {
8 if (count === 0) return "bg-gray-100";
9 if (count <= 3) return "bg-red-200";
13}
14
15function getWeekNumber(date: Date): number {
16 const startOfYear = new Date(date.getFullYear(), 0, 1);
17 const pastDaysOfYear = (date.getTime() - startOfYear.getTime()) / 86400000;
19}
20
21function GitHubCommitGraph({ data }: { data: GitHubContributionsResponse }) {
22 if (!data || !data.contributions) {
23 return <div className="text-xl">Unable to load GitHub data</div>;
119}
120
121function Render({ githubData }: { githubData: GitHubContributionsResponse | null }) {
122 return (
123 <html>
152}
153
154export default async function(req: Request): Promise<Response> {
155 // You can customize the username here or pass it as a query parameter
156 const username = "michaelwschultz"; // Change this to your GitHub username

eink-framehemolog.tsx2 matches

@michaelwschultzโ€ขUpdated 10 hours ago
6
7// NOTE: Hemolog.com is a medication logging app for poeople with Hemophilia, like me ๐Ÿ‘‹.
8function Render({ data }: { data: HEMOLOG_TREATMENT[] }) {
9 return (
10 <html>
66}
67
68export default async function(req: Request): Promise<Response> {
69 const data: HEMOLOG_TREATMENT[] = await GetLogs(req).then((res: any) => res.json());
70 const html = renderToString(<Render data={data} />);

ChatStreamingChat.tsx7 matches

@c15rโ€ขUpdated 10 hours ago
16
17/** Merge a delta into its parent block (unchanged logic) */
18function mergeDelta(block: any, delta: any) {
19 if (!delta) return;
20 switch (delta.type) {
33
34/** Build request body (handles MCP) */
35function buildBody(
36 config: AppConfig,
37 history: Message[],
62
63/** Build headers */
64function buildHeaders(apiKey: string, usingMCP: boolean): Record<string, string> {
65 const headers: Record<string, string> = {
66 "x-api-key": apiKey,
74
75/** Produce final assistant message identical to legacy implementation */
76function assembleMessage(blocks: Record<number, any>): AssistantMsg {
77 Object.values(blocks).forEach((b) => {
78 if (b._input_json_str !== undefined) {
102/* โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ useAnthropicStream โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ */
103
104function useAnthropicStream(config: AppConfig) {
105 const [status, setStatus] = useState<Status>("idle");
106 const [liveBlocks, setLiveBlocks] = useState<any[] | null>(null); // structured preview
115 }, []);
116
117 /** Main send/stream function */
118 const send = useCallback(
119 async (history: Message[], userText: string): Promise<AssistantMsg> => {
241}
242
243export default function StreamingChat({
244 config,
245 messages,

discord-random-botmain.tsx3 matches

@stabbylambdaโ€ขUpdated 10 hours ago
218}
219
220// Export default function for Val Town
221export default async function() {
222 const bot = new TeamDivisionBot();
223
228 // Keep the bot running
229 return new Promise(() => {
230 // This keeps the function alive
231 });
232 } catch (error) {

eink-framecomponents.tsx7 matches

@michaelwschultzโ€ขUpdated 10 hours ago
4
5// Display components can be used to change the look and feel of each frame.
6export function Header({ title = "Eink" }) {
7 return (
8 <head>
39}
40
41export function Footer() {
42 const currentDate = new Date().toLocaleDateString("en-US", {
43 timeZone: "America/Los_Angeles",
62}
63
64export function Headline({ text = "Headline missing" }: { text: string }) {
65 return (
66 <div className="flex justify-between items-center p-5">
70}
71
72export function Content(props: any) {
73 return <div className="relative flex-1 px-5 pt-3 overflow-none">{props.children}</div>;
74}
75
76export function BodyWrapper(props: any) {
77 return (
78 <body className="bg-black p-0 m-0">
84}
85
86export function App() {
87 return (
88 <html>
99}
100
101export default async function(): Promise<Response> {
102 const html = renderToString(<App />);
103

reactHonoStarterApp.tsx1 match

@notmartโ€ขUpdated 10 hours ago
13import { useEffect, useState } from "https://esm.sh/react@18.2.0";
14
15export function App() {
16 const [clicked, setClicked] = useState(0);
17 const [myIp, setMyIp] = useState("");

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.