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=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 31478 results for "function"(1247ms)

workingNotWorkingBoardweekUtils.ts2 matches

@dcm31•Updated 13 hours ago
1export function getCurrentWeekString() {
2 const now = new Date();
3 const monday = new Date(now);
10}
11
12export function checkForNewWeek(savedData) {
13 if (!savedData) return null;
14

workingNotWorkingBoardCards.ts2 matches

@dcm31•Updated 13 hours ago
1export function ItemCard({ item, category, confirmItem, moveItem, removeItem }) {
2 return (
3 <div className={`card ${item.needsConfirmation ? 'needs-confirmation' : ''}`}>
111}
112
113export function AddForm({ category, newItemText, setNewItemText, addItem, onCancel }) {
114 return (
115 <div className="new-card-form">

tip-calculatorscript.js1 match

@ivobg•Updated 13 hours ago
15});
16
17function calculate() {
18 if (billInpElem.value && tipInpElem.value) {
19 const bill = parseFloat(billInpElem.value);

ChatApp.tsx1 match

@c15r•Updated 14 hours ago
38export { DEFAULT_SYSTEM_PROMPT };
39
40export default function App() {
41 const [config, setConfig] = useState<AppConfig>({
42 anthropicApiKey: "",

ChatHTMLRenderer.tsx6 matches

@c15r•Updated 14 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);
134 },
135
136 // Utility functions
137 log: (level: "debug" | "info" | "warning" | "error", message: string, data?: any) => {
138 console[level](`[HTMLRenderer] ${message}`, data);
156 }, [mcpClients, isFullscreen]);
157
158 // Fullscreen functionality
159 const enterFullscreen = useCallback(() => {
160 const container = containerRef.current;
185 const methodFunc = (mcpContext as any)[method];
186
187 if (typeof methodFunc !== "function") {
188 throw new Error(`Unknown MCP API method: ${method}`);
189 }
338 <script>
339 // Update fullscreen controls based on state
340 async function updateFullscreenControls() {
341 const controls = document.getElementById('fullscreenControls');
342 const isFs = await window.mcpContext.isFullscreen();

stravachattestDailyBrief.ts1 match

@katzenj•Updated 15 hours ago
4import { DateTime } from "https://esm.sh/luxon@3.4.4";
5
6export async function testDailyBrief() {
7 try {
8 const testChatId = Deno.env.get("TEST_TELEGRAM_CHAT_ID");

stravachatsetupTelegramChatDb.ts1 match

@katzenj•Updated 15 hours ago
2// Run this script manually to create the database table
3
4export default async function setupTelegramChatDb() {
5 try {
6 // Import SQLite module

stravachatsendDailyBrief.ts6 matches

@katzenj•Updated 15 hours ago
13} from "../memoryUtils.ts";
14
15async function generateBriefingContent(anthropic, memories, today, isSunday) {
16 try {
17 const weekdaysHelp = generateWeekDays(today);
96}
97
98export async function sendDailyBriefing(chatId?: string, today?: DateTime) {
99 // Get API keys from environment
100 const apiKey = Deno.env.get("ANTHROPIC_API_KEY");
135 const lastSunday = today.startOf("week").minus({ days: 1 });
136
137 // Fetch relevant memories using the utility function
138 const memories = await getRelevantMemories();
139
216}
217
218function generateWeekDays(today) {
219 let output = [];
220
239// console.log(weekDays);
240
241// Export a function that calls sendDailyBriefing with no parameters
242// This maintains backward compatibility with existing cron jobs
243export default async function (overrideToday?: DateTime) {
244 return await sendDailyBriefing(undefined, overrideToday);
245}

stravachatREADME.md2 matches

@katzenj•Updated 15 hours ago
16In a normal server environment, you would likely use a middleware [like this one](https://hono.dev/docs/getting-started/nodejs#serve-static-files) to serve static files. Some frameworks or deployment platforms automatically make any content inside a `public/` folder public.
17
18However in Val Town you need to handle this yourself, and it can be suprisingly difficult to read and serve files in a Val Town Project. This template uses helper functions from [stevekrouse/utils/serve-public](https://www.val.town/x/stevekrouse/utils/branch/main/code/serve-public/README.md), which handle reading project files in a way that will work across branches and forks, automatically transpiles typescript to javascript, and assigns content-types based on the file's extension.
19
20### `index.html`
26## CRUD API Routes
27
28This app has two CRUD API routes: for reading and inserting into the messages table. They both speak JSON, which is standard. They import their functions from `/backend/database/queries.ts`. These routes are called from the React app to refresh and update data.
29
30## Errors

stravachatREADME.md2 matches

@katzenj•Updated 15 hours ago
4
5* `migrations.ts` - code to set up the database tables the app needs
6* `queries.ts` - functions to run queries against those tables, which are imported and used in the main Hono server in `/backend/index.ts`
7
8## Migrations
18The queries file is where running the migrations happen in this app. It'd also be reasonable for that to happen in index.ts, or as is said above, for that line to be commented out, and only run when actual changes are made to your database schema.
19
20The queries file exports functions to get and write data. It relies on shared types and data imported from the `/shared` directory.
tuna

tuna9 file matches

@jxnblk•Updated 2 weeks 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.