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/image-url.jpg%20%22Image%20title%22?q=function&page=19&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 18743 results for "function"(480ms)

my-first-val03_cron.tsx1 match

@Slade_Corp•Updated 18 hours ago
2// Configure the timer with the 🕒 icon in the top right.
3// This example just logs the current time.
4export function scheduledHandler() {
5 const timestamp = new Date().toISOString();
6 console.log(`Cron val executed at: ${timestamp}`);

my-first-val02_http.tsx1 match

@Slade_Corp•Updated 18 hours ago
2// Access it via its public URL (you can also pick a nicer subdomain).
3// Try adding ?name=YourName to the URL!
4export default function httpHandler(req: Request): Response {
5 const url = new URL(req.url);
6 const name = url.searchParams.get("name") || "Friend";

my-first-val01_script.tsx1 match

@Slade_Corp•Updated 18 hours ago
1// This script returns a random fun fact
2// You can run scripts manually in this view or call it from other vals.
3export default function getRandomFact() {
4 const funFacts = [
5 "Honey never spoils.",

HHGtoMyDaygetTodoist.ts4 matches

@lm3m•Updated 19 hours ago
30}
31
32async function deleteExistingTodoistEvents() {
33 await sqlite.execute(
34 `
43 * @returns Array of Todoist tasks due today or overdue
44 */
45async function fetchTodoistTasks(): Promise<TodoistTask[]> {
46 const apiToken = Deno.env.get("TODOIST_API_TOKEN");
47
87 * @returns Memory object
88 */
89function convertTodoistTaskToMemory(task: TodoistTask): Memory {
90 return {
91 id: task.id.toString(),
101 * Stores Todoist tasks in SQLite database
102 */
103export default async function storeTodoistTasksToMemories() {
104 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
105

HHGtoMyDaysendDailyBrief.ts6 matches

@lm3m•Updated 19 hours ago
8import { formatMemoriesForPrompt, getRelevantMemories } from "../memoryUtils.ts";
9
10async function generateBriefingContent(anthropic, memories, today, isSunday) {
11 try {
12 const weekdaysHelp = generateWeekDays(today);
92}
93
94export async function sendDailyBriefing(today?: DateTime) {
95 // Get API keys from environment
96 const apiKey = Deno.env.get("ANTHROPIC_API_KEY");
131 const lastSunday = today.startOf("week").minus({ days: 1 });
132
133 // Fetch relevant memories using the utility function
134 const memories = await getRelevantMemories();
135
222}
223
224function generateWeekDays(today) {
225 let output = [];
226
245// console.log(weekDays);
246
247// Export a function that calls sendDailyBriefing with no parameters
248// This maintains backward compatibility with existing cron jobs
249export default async function(overrideToday?: DateTime) {
250 return await sendDailyBriefing(undefined, overrideToday);
251}

telegramBotStartertestBot.tsx2 matches

@asdfg•Updated 20 hours ago
5import { sendTelegramMessage } from "https://esm.town/v/asdfg/telegramBotStarter/sendTelegramMessage.tsx";
6
7async function testBot() {
8 const ownerChatId = process.env.OWNER_CHAT_ID;
9
26}
27
28// console log testBot function
29// console.log(await testBot);
30

untitled-1471new-file-8788.tsx20 matches

@kamenxrider•Updated 20 hours ago
150 // --- AUDIO CONTEXT for UI Sounds ---
151 let audioCtx;
152 function initAudio() {
153 if (!audioCtx) {
154 audioCtx = new (window.AudioContext || window.webkitAudioContext)();
155 }
156 }
157 function playSound(type = 'click') {
158 if (!audioCtx) return;
159 const oscillator = audioCtx.createOscillator();
272 });
273
274 // --- Game Logic Functions ---
275 function loadGameState() {
276 try {
277 const savedData = localStorage.getItem(CONFIG.SAVE_KEY);
288 }
289 }
290 function saveGameState() {
291 try {
292 localStorage.setItem(CONFIG.SAVE_KEY, JSON.stringify(gameState));
295 }
296 }
297 function applyShake() {
298 if (shakeDuration > 0) {
299 const dx = (Math.random() - 0.5) * shakeIntensity * 2;
307 }
308 }
309 function triggerShake(intensity, duration) {
310 shakeIntensity = Math.max(shakeIntensity, intensity);
311 shakeDuration = Math.max(shakeDuration, duration);
312 }
313 function getDistance(x1, y1, x2, y2) {
314 const dx = x2 - x1; const dy = y2 - y1; return Math.sqrt(dx * dx + dy * dy);
315 }
316 function createFloatingText(text, x, y, color = 'white', size = 16) {
317 floatingTexts.push({ text, x, y, color, size, opacity: 1, yOffset: 0, creationTime: Date.now() });
318 }
596 }
597
598 // --- Game Flow & UI Functions ---
599 function startNewWave() {
600 currentWave++;
601 ui.wave.textContent = currentWave;
611 }
612 }
613 function spawnMenForWave(count, isBossWave = false) {
614 const numToSpawn = Math.min(count, menToSpawnThisWave - menSpawnedThisWave);
615 const currentPercentRanged = Math.min(CONFIG.MAX_PERCENT_RANGED, CONFIG.PERCENT_RANGED_MEN_BASE + (currentWave - 1) * CONFIG.PERCENT_RANGED_INCREMENT_PER_WAVE);
632 }
633 }
634 function initGame() {
635 resizeCanvas();
636 loadGameState();
653 canvas.focus();
654 }
655 function updateUI() {
656 displayedScore += (currentScore - displayedScore) * TWEEN_FACTOR;
657 displayedBananas += (gameState.totalBananas - displayedBananas) * TWEEN_FACTOR;
675 }
676
677 function gameLoop(timestamp) {
678 if (!gameRunning) { animationFrameId = null; return; }
679 if (gamePaused) { animationFrameId = requestAnimationFrame(gameLoop); return; }
715 animationFrameId = requestAnimationFrame(gameLoop);
716 }
717 function endGame(gorillaWins) {
718 gameRunning = false; gamePaused = false;
719 cancelAnimationFrame(animationFrameId); animationFrameId = null;
734
735 // --- Shop Logic ---
736 function getUpgradeCost(level) {
737 return Math.floor(CONFIG.UPGRADE_BASE_COST * Math.pow(CONFIG.UPGRADE_COST_INCREASE_FACTOR, level));
738 }
739 function updateShopUI() {
740 ui.shopBananasDisplay.textContent = gameState.totalBananas;
741 ui.hpUpgradeLevel.textContent = gameState.upgrades.maxHpLvl;
750 ui.atkUpgradeCost.textContent = getUpgradeCost(gameState.upgrades.attackPowerLvl);
751 }
752 function purchaseUpgrade(type) {
753 playSound('click');
754 let levelKey = type + 'Lvl';
807 clearTimeout(window.resizeTimeout); window.resizeTimeout = setTimeout(resizeCanvas, 100);
808 });
809 function resizeCanvas() {
810 const container = document.querySelector('.game-container');
811 if (!container) return;

glastonewsindex.ts1 match

@bensomething•Updated 20 hours ago
2import { BskyAgent } from "npm:@atproto/api";
3
4async function main() {
5 try {
6 const agent = new BskyAgent({

ga4-eventga4-util.tsx1 match

@sprout•Updated 20 hours ago
1// ga4-util.tsx
2export async function trackGA4Event(req, clientPrefix) {
3 const GA4_MEASUREMENT_ID = Deno.env.get(`${clientPrefix}_GA4_MEASUREMENT_ID`);
4 const GA4_API_SECRET = Deno.env.get(`${clientPrefix}_GA4_API_KEY`);

ga4-eventblo.tsx1 match

@sprout•Updated 21 hours ago
1import { trackGA4Event } from "https://esm.town/v/sprout/ga4-event/ga4-util.tsx";
2
3export default async function(req) {
4 return trackGA4Event(req, "BLO");
5}

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 2 weeks ago
Simple functional CSS library for Val Town
webup
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.
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": "*",