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%22Optional%20title%22?q=function&page=35&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 18895 results for "function"(676ms)

untitled-1471new-file-8788.tsx20 matches

@kamenxrider•Updated 2 days 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 2 days 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 2 days 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 2 days 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}

ga4-eventrl.tsx1 match

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

ga4-eventtk.tsx1 match

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

replicache-forknew-file-8157.tsx1 match

@jeffreyyoung•Updated 2 days ago
1export default async function(req: Request): Promise<Response> {
2 const url = new URL(req.url);
3 if (url.pathname === "/v1") {

linkInBioTemplatemain.tsx1 match

@jflores•Updated 2 days ago
2import { renderToString } from "npm:react-dom/server";
3
4export default async function(req: Request) {
5 return new Response(
6 renderToString(

hedgeupdateTable1 match

@gaimeri17•Updated 2 days ago
2
3export const TABLE_NAME = "pondiverse_creations_v4";
4export default async function(req: Request): Promise<Response> {
5 await sqlite.execute(
6 `CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (

hedgemain1 match

@gaimeri17•Updated 2 days ago
6import updateTable from "./updateTable";
7
8export default async function(req: Request): Promise<Response> {
9 let url = new URL(req.url);
10 const path = url.pathname.toLowerCase();

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": "*",