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=87&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 34573 results for "function"(4710ms)

noirmain.tsx6 matches

@join•Updated 6 days ago
50
51// --- HTML & FRONTEND GENERATION ---
52function generateHtml(sourceUrl: string) {
53 return `<!DOCTYPE html>
54<html lang="en">
182 const killerName = "Alistair Finch";
183
184 async function fetchNextCredit() {
185 try {
186 const response = await fetch(API_URL, {
211 }
212
213 function displayCredit(data) {
214 body.style.backgroundColor = data.lighting.background_color;
215 spotlight.style.setProperty('--spotlight-color', data.lighting.spotlight_color);
236 }
237
238 async function sequence() {
239 const credit = await fetchNextCredit();
240 displayCredit(credit);
265}
266
267// --- MAIN SERVERLESS FUNCTION ---
268export default async function(req: Request) {
269 const sourceUrl = `https://${new URL(req.url).hostname}${new URL(req.url).pathname}`;
270

rushmain.tsx14 matches

@join•Updated 6 days ago
18
19// --- HTML & FRONTEND GENERATION ---
20function generateHtml(topicsData: object) {
21 const initialTopic = Object.keys(topicsData)[0];
22 const initialFacts = topicsData[initialTopic];
157 let elements = [];
158
159 function getNextFact() {
160 return currentFacts[factIndex++ % currentFacts.length];
161 }
186 });
187
188 function normalizeText(txt) {
189 return txt.replace(/\\s+/g, ' ').trim();
190 }
191
192 function checkSentenceMatch() {
193 const normalizedInput = normalizeText(currentPlayerInput);
194 const targetElement = elements.find(el => normalizeText(el.textContent) === normalizedInput && parseFloat(el.style.opacity) !== 0);
210 }
211
212 function levelUp() {
213 level++;
214 scoreToNextLevel += 50 * level; // Increase difficulty for next level
224 }
225
226 function selectTopic(topic) {
227 currentFacts = allTopicsData[topic];
228 factIndex = 0;
235 }
236
237 function updatePlayerInput() { playerInputEl.textContent = currentPlayerInput; }
238 function updateHUD() {
239 scoreEl.textContent = \`Score: \${score}\`;
240 levelEl.textContent = \`Level: \${level}\`;
242 }
243
244 function loseLife() {
245 if (isGameOver) return;
246 lives--;
249 }
250
251 function endGame() {
252 isGameOver = true;
253 finalScoreEl.textContent = \`Your Final Score: \${score}\`;
255 }
256
257 function recycleElement(element, success = false) {
258 if (!success && !isGameOver) loseLife();
259 if(isGameOver) { element.style.opacity = 0.05; return; }
269 let simulatedScrollY = 0, scrollSpeed = 0.8;
270
271 function animate(time) {
272 if (!isGameOver && !isPaused) {
273 simulatedScrollY += scrollSpeed;
300}
301
302// --- MAIN SERVERLESS FUNCTION ---
303export default async function(req: Request) {
304 let topicsData = {
305 "GENERAL KNOWLEDGE": [

TownieValTownLogo.tsx1 match

@chadparker•Updated 6 days ago
1/** @jsxImportSource https://esm.sh/react@18.2.0?dev */
2
3export function ValTownLogo () {
4 return (
5 <svg

Townieval-summary.ts1 match

@chadparker•Updated 6 days ago
5 * Get usage data for a specific val
6 */
7export async function getValSummary(valId: string) {
8 // Get summary data for the val from the usage table
9 const usageSummaryResult = await sqlite.execute(`

Townieval-detail.ts1 match

@chadparker•Updated 6 days ago
36}
37
38export function renderValDetail(valId: string, summary: ValSummary, requests: UsageRequest[] = []): string {
39 // Generate the content
40 const content = `

TownieuseUser.tsx1 match

@chadparker•Updated 6 days ago
3const USER_ENDPOINT = "/api/user";
4
5export function useUser() {
6 const [data, setData] = useState<any>(null);
7 const [loading, setLoading] = useState(true);

TownieuseUsageStats.ts1 match

@chadparker•Updated 6 days ago
1import { useEffect } from "react";
2
3export function useUsageStats(messages: any[], usages: any[]) {
4 useEffect(() => {
5 if (!messages?.length) return;

TownieuseScrollToBottom.tsx3 matches

@chadparker•Updated 6 days ago
7 *
8 * @param {Array} dependencies - Array of dependencies that trigger scrolling when changed
9 * @returns {Object} An object containing containerRef and scrollToBottom function
10 */
11export function useScrollToBottomContainer(dependencies = []) {
12 const containerRef = useRef(null);
13
28
29// body scroll version
30export function useScrollToBottom(dependencies = []) {
31 const bottomRef = useRef(null);
32

Townieuser-summary.ts1 match

@chadparker•Updated 6 days ago
6 * This includes a fallback to inference calls data when usage data is missing
7 */
8export async function getUserSummary(userId?: string) {
9 // First, get the standard grouped data from the usage table
10 let query = `

Townieuser-detail.ts1 match

@chadparker•Updated 6 days ago
36}
37
38export function renderUserDetail(data: UserSummaryRow[], userId: string, requests: UsageRequest[] = [], creditAdditions: CreditAddition[] = []): string {
39 // User data should only have one row if we're filtering by user ID
40 const userData = data[0] || {

discordWebhook2 file matches

@stevekrouse•Updated 2 weeks ago
Helper function to send Discord messages
tuna

tuna9 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.