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=639&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 17289 results for "function"(1908ms)

Valmain.tsx1 match

@jackgreenwald•Updated 3 weeks ago
2
3// Fetches a random joke.
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",
Snake

Snakeindex.html6 matches

@yamoodles•Updated 3 weeks ago
1export default async function(req) {
2 return new Response(
3 `<!DOCTYPE html>
125 });
126
127 function draw() {
128 ctx.clearRect(0, 0, canvasSize, canvasSize);
129
139 }
140
141 function update() {
142 const head = { x: snake[0].x + direction.x, y: snake[0].y + direction.y };
143 snake.unshift(head);
168 }
169
170 function resetGame() {
171 clearInterval(gameInterval);
172 snake = [{ x: 5, y: 5 }];
181 }
182
183 function startGame() {
184 document.querySelector('.start-button').style.display = 'none';
185 resetGame();
186 }
187
188 function changeDirection(event) {
189 switch (event.code) {
190 case 'ArrowUp':

CS1200main.tsx1 match

@NathanChen32•Updated 3 weeks ago
6
7// Fetches a random joke.
8async function fetchRandomJoke() {
9 const response = await fetch(
10 "https://official-joke-api.appspot.com/random_joke",

reactHonoStarterApp.tsx1 match

@tezlm•Updated 3 weeks ago
2import { useState } from "https://esm.sh/react@18.2.0";
3
4export function App() {
5 const [clicked, setClicked] = useState(0);
6 return (

polishedPeachMeadowlarkmain.tsx1 match

@mbalboni•Updated 3 weeks ago
2
3// Fetches a random joke.
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",

exceptionalAmberSpoonbillmain.tsx1 match

@mbalboni•Updated 3 weeks ago
2
3// Fetches a random joke.
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",

happyPlumKoiDive1 match

@JerryA•Updated 3 weeks ago
1export default async function (req: Request): Promise<Response> {
2 return Response.json({ ok: true })
3}

blog12025-04-07-blog.md2 matches

@charmaine•Updated 3 weeks ago
122We didn't. We left them where they are, and proxy to them.
123
124Writing a proxy in Val Town (or any functions platform with the ['fetch handler' interface](https://blog.val.town/blog/the-api-we-forgot-to-name/)) is always a delight:
125
126```ts
127const OLD_BLOG_HOST = "https://val-town-blog.pages.dev/";
128export async function proxy(req: Request): Promise<Response> {
129 const url = new URL(req.url);
130 return fetch(OLD_BLOG_HOST + url.pathname + url.search, {

blog1util.tsx2 matches

@charmaine•Updated 3 weeks ago
1export function formatDate(dateString: string): string {
2 try {
3 const date = new Date(dateString);
12}
13
14export function dayOfWeek(dateString: string): string {
15 try {
16 return new Date(dateString).toLocaleDateString("en-US", {

blog1SocialLinks.tsx1 match

@charmaine•Updated 3 weeks ago
2import { BlueskyIcon, DiscordIcon, GitHubIcon, RSSIcon, TwitterIcon } from "./icons.tsx";
3
4export default function SocialLinks() {
5 return (
6 <div className="social-links">

getFileEmail4 file matches

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

tuna8 file matches

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