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/?q=function&page=1464&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 19142 results for "function"(1306ms)

whackaghostmain.tsx12 matches

@Ttt•Updated 6 months ago
44 * HomeButton component - Renders a button to return to the home screen
45 * @param {Object} props - Component props
46 * @param {Function} props.onClick - Function to handle button click
47 */
48function HomeButton({ onClick }) {
49 return (
50 <button className="home-button" onClick={onClick}>
57 * SpookyMessage component - Displays a game over message with a ghost animation
58 * @param {Object} props - Component props
59 * @param {Function} props.onHomeClick - Function to handle home button click
60 * @param {boolean} props.isTimeOut - Whether the game ended due to timeout
61 * @param {number} props.score - The player's final score
63 * @param {boolean} props.isWin - Whether the player has won the game
64 */
65function SpookyMessage({ onHomeClick, isTimeOut, score, isTooManyWrongClicks, isWin }) {
66 console.log("SpookyMessage rendered. isWin:", isWin, "score:", score);
67 return (
83 * GameDescription component - Displays game instructions and rules
84 */
85function GameDescription() {
86 return (
87 <div className="game-description">
109 * Main App component for the Whack-a-Ghost game
110 */
111function App() {
112 const [score, setScore] = useState(0);
113 const [activeGhost, setActiveGhost] = useState(-1);
314
315/**
316 * Client-side rendering function
317 */
318export function client() {
319 const rootElement = document.getElementById("root");
320 if (rootElement) {
328
329/**
330 * Server-side rendering function
331 * @param {Request} request - The incoming request object
332 * @returns {Promise<Response>} The response object with the HTML content
333 */
334export default async function server(request: Request): Promise<Response> {
335 return new Response(
336 `
350 import { client } from "${import.meta.url}";
351 window.addEventListener("load", () => {
352 if (typeof client === "function") {
353 client();
354 } else {
355 console.error("Client function not found");
356 }
357 });

dateme_react_hydratedmain.tsx1 match

@jacobhthomas•Updated 6 months ago
10import { html } from "https://esm.town/v/stevekrouse/html";
11
12export default async function(req: Request) {
13 let handler = createStaticHandler(routes);
14 let context = await handler.query(req);

runescapeWoodCuttingmain.tsx4 matches

@charmaine•Updated 6 months ago
9};
10
11function LoginScreen({ onLogin }) {
12 const [name, setName] = useState("");
13
36}
37
38function App() {
39 const [playerName, setPlayerName] = useState("");
40 const [skill, setSkill] = useState("woodcutting");
107}
108
109function client() {
110 createRoot(document.getElementById("root")).render(<App />);
111}
115}
116
117export default async function server(request: Request): Promise<Response> {
118 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
119 const SCHEMA_VERSION = 2;

denoGameHTMLmain.tsx9 matches

@jongreer•Updated 6 months ago
27 };
28
29 function setup() {
30 createCanvas(800, 300);
31 resetGame();
32 }
33
34 function resetGame() {
35 dino = new Dino();
36 obstacles = [];
41 }
42
43 function draw() {
44 if (isGameOver) {
45 showGameOver();
94 }
95
96 function keyPressed() {
97 if (keyCode === 32) {
98 if (isGameOver) {
107 }
108
109 function gameOver() {
110 isGameOver = true;
111 let name = prompt("Enter your name (max 16 characters, no spaces):");
113 scoreboard.push({ name, score });
114
115 // Call the function to update the scoreboard on the Val Town API
116 updateScoreboard(name, score);
117 }
118
119 function updateScoreboard(name, score) {
120 const apiUrl =
121 "https://api.val.town/v1/run/rodrigotello.updateDinoScoreboard";
147 }
148
149 function showGameOver() {
150 background(255);
151 textAlign(CENTER);
176 }
177
178 function showGamePaused() {
179 background(255);
180 textAlign(CENTER);

smallAndCuteSnakeGamemain.tsx3 matches

@jake•Updated 6 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 const [count, setCount] = useState(0);
7
55}
56
57function client() {
58 createRoot(document.getElementById("root")).render(<App />);
59}
63}
64
65export default async function server(request: Request): Promise<Response> {
66 return new Response(`
67 <!DOCTYPE html>

mortgageDeductionCalculatormain.tsx5 matches

@mikaello•Updated 6 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function formatNumber(num: number): string {
6 return num.toLocaleString("no-NO", { minimumFractionDigits: 2, maximumFractionDigits: 2 });
7}
8
9function QuestionMarkIcon() {
10 return (
11 <svg width="16" height="16" xmlns="http://www.w3.org/2000/svg" className="question-mark-icon">
16}
17
18function App() {
19 const [mortgage, setMortgage] = useState<number | undefined>(undefined);
20 const [rentPercentage, setRentPercentage] = useState<number | undefined>(undefined);
197}
198
199function client() {
200 createRoot(document.getElementById("root")).render(<App />);
201}
202if (typeof document !== "undefined") { client(); }
203
204export default async function server(request: Request): Promise<Response> {
205 return new Response(
206 `

groceriesmain.tsx3 matches

@efoley•Updated 6 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 const [items, setItems] = useState([]);
7 const [newItem, setNewItem] = useState("");
75}
76
77function client() {
78 createRoot(document.getElementById("root")).render(<App />);
79}
83}
84
85export default async function server(request: Request): Promise<Response> {
86 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
87 const SCHEMA_VERSION = 1;

createFlashcardsValmain.tsx3 matches

@reginafoley•Updated 6 months ago
9cherry,a small round stone fruit with red skin`;
10
11function App() {
12 const [flashcards, setFlashcards] = useState([]);
13 const [currentCard, setCurrentCard] = useState(null);
95}
96
97function client() {
98 createRoot(document.getElementById("root")).render(<App />);
99}
103}
104
105export default async function server(request: Request): Promise<Response> {
106 const url = new URL(request.url);
107

browserbasePuppeteerExamplemain.tsx2 matches

@Joelsrubin•Updated 6 months ago
2import puppeteer from "npm:puppeteer-core";
3
4async function sendPDF() {
5 console.log("Initiating pdf sender");
6 const browser = await puppeteer.connect({
28}
29
30export default async function() {
31 console.log("RUnning");
32 await sendPDF();

generateDailyTwitterEmailmain.tsx3 matches

@Joelsrubin•Updated 6 months ago
1import { email } from "https://esm.town/v/std/email";
2
3async function fetchTweets(listId: string): Promise<any[]> {
4 const url = `https://news.ycombinator.com/`;
5 const response = await fetch(url);
17}
18
19function formatTweetsForEmail(tweets: any[]): string {
20 return tweets.map((tweet, index) => `
21 ${index + 1}. @${tweet.username} (${tweet.likes} likes)
25}
26
27export default async function(interval: Interval) {
28 const listId = "1359390628841480192";
29 const tweets = await fetchTweets(listId);

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 3 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": "*",