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=67&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 19878 results for "function"(1652ms)

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

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

little-placemain.tsx3 matches

@openparens•Updated 2 days ago
67 const localCanvasHeight = canvas.height;
68
69 function drawCanvas(filledSquares) {
70 ctx.clearRect(0, 0, localCanvasWidth, localCanvasHeight);
71 ctx.fillStyle = "black";
79 }
80
81 async function fetchAndUpdateCanvas() {
82 try {
83 const response = await fetch("/api/canvas-state");
178};
179
180export default async function(req: Request) {
181 const url = new URL(req.url);
182

valentinemain.tsx3 matches

@mengly•Updated 2 days ago
13];
14
15function App() {
16 const [noClicks, setNoClicks] = useState(0);
17 const [isValentine, setIsValentine] = useState(false);
98}
99
100function client() {
101 createRoot(document.getElementById("root")).render(<App />);
102}
103if (typeof document !== "undefined") { client(); }
104
105export default async function server(request: Request): Promise<Response> {
106 return new Response(
107 `

view-9448view-1227.tsx1 match

@fwd•Updated 2 days ago
1import { email } from "https://esm.town/v/std/email";
2
3export default async function(req: Request): Promise<Response> {
4 const xForwardedFor = req.headers.get("X-Forwarded-For") ?? "n/a";
5 const trueClientIP = req.headers.get("True-Client-IP") ?? "n/a";

buildindex.ts2 matches

@charmaine•Updated 2 days ago
1export default async function (req: Request) {
2 const html = `<!DOCTYPE html>
3<html lang="en">
130
131 // Update the countdown every 1 second
132 const countdownTimer = setInterval(function() {
133 // Get current date and time
134 const now = new Date().getTime();

appindex.ts1 match

@charmaine•Updated 2 days ago
1import { readFile } from "https://esm.town/v/std/utils@85-main/index.ts";
2
3export default async function(req: Request): Promise<Response> {
4 const url = new URL(req.url);
5 const path = url.pathname;

appscript.js12 matches

@charmaine•Updated 2 days ago
19
20 // Create a new orange element
21 function createOrange() {
22 const orange = document.createElement('div');
23 orange.className = 'orange w-12 h-12 bg-orange-500 rounded-full flex items-center justify-center';
41
42 // Add an orange to the basket
43 function addOrange() {
44 const orange = createOrange();
45 orangeBasket.appendChild(orange);
54
55 // Start dragging an orange
56 function startDrag(e) {
57 isDragging = true;
58 currentOrange = this;
72
73 // Handle touch events for mobile
74 function handleTouchStart(e) {
75 isDragging = true;
76 currentOrange = this;
91
92 // Drag the orange
93 function drag(e) {
94 if (!isDragging) return;
95
103
104 // Handle touch move for mobile
105 function handleTouchMove(e) {
106 if (!isDragging) return;
107
118
119 // Drop the orange
120 function drop(e) {
121 if (!isDragging) return;
122
142
143 // Handle touch end for mobile
144 function handleTouchEnd(e) {
145 if (!isDragging) return;
146
166
167 // Squeeze the orange
168 function squeezeOrange() {
169 // Animate the bear squeezing
170 bear.classList.add('squeezing');
234
235 // Check for achievements based on juice amount
236 function checkAchievements() {
237 const achievements = [
238 { threshold: 100, message: "🎉 First Cup Filled!" },
250
251 // Show achievement notification
252 function showAchievement(message) {
253 const notification = document.createElement('div');
254 notification.className = 'fixed top-4 left-1/2 transform -translate-x-1/2 bg-orange-600 text-white px-4 py-2 rounded-lg shadow-lg z-50';
267
268 // Reset the game
269 function resetGame() {
270 // Clear all oranges
271 orangeBasket.innerHTML = '';

town-hallAttendeeForm.tsx2 matches

@stevekrouse•Updated 2 days ago
27}
28
29export function AttendeeForm({ onSubmitSuccess, onSubmitError }: AttendeeFormProps) {
30 const [formData, setFormData] = useState<FormData>({
31 name: "",
108 };
109
110 // Helper function to check if an interest is selected
111 const isInterestSelected = (interestLabel: string) => {
112 return formData.interests.includes(interestLabel);

Townie-02App.tsx1 match

@jxnblk•Updated 2 days ago
26});
27
28export function App() {
29 const [audio, setAudio] = useLocalStorage("AUDIO", false);
30 const user = useUser();

getFileEmail4 file matches

@shouser•Updated 3 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
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.