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/$%7Burl%7D?q=function&page=2603&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 31472 results for "function"(25634ms)

lastloginmain.tsx4 matches

@stevekrouse•Updated 6 months ago
1/** @jsxImportSource npm:hono/jsx */
2async function createSession(email: string, hostname: string) {
3 const { zip } = await import("https://esm.town/v/pomdtr/sql");
4 const { sqlite } = await import("https://esm.town/v/std/sqlite");
23}
24
25async function getSession(sessionID: string, hostname: string) {
26 const { zip } = await import("https://esm.town/v/pomdtr/sql");
27 const { sqlite } = await import("https://esm.town/v/std/sqlite");
52}
53
54async function deleteSession(sessionID: string) {
55 const { sqlite } = await import("https://esm.town/v/std/sqlite");
56
64const OAUTH_COOKIE = "oauth_store";
65
66export function lastlogin(
67 handler: (req: Request) => Response | Promise<Response>,
68) {

FetchBasicmain.tsx1 match

@stevekrouse•Updated 6 months ago
1export default async function(req: Request): Promise<Response> {
2 // Pick a random greeting
3 const greetings = ["Hello!", "Welcome!", "Hi!", "Heya!", "Hoi!"];

googleiframeembedmain.tsx1 match

@yawnxyz•Updated 6 months ago
1export default async function (req: Request): Promise<Response> {
2 const html = `
3 <!DOCTYPE html>

emilrdlemain.tsx10 matches

@stevekrouse•Updated 6 months ago
10const SOLUTION_WORDS = ["WILLY", "YOUTH", "MARRY", "METER"];
11
12function Modal({ isOpen, onClose, children }) {
13 if (!isOpen) return null;
14
22}
23
24function WinModal({ isOpen, onPlay }) {
25 return (
26 <Modal isOpen={isOpen}>
36}
37
38function ProposalModal({ isOpen }) {
39 return (
40 <Modal isOpen={isOpen}>
47}
48
49function App() {
50 const [games, setGames] = useState(SOLUTION_WORDS.map(word => ({
51 word,
188}
189
190function GameBoard(
191 {
192 word,
272}
273
274function Keyboard({ usedLetters, onKeyPress, disabled }) {
275 const rows = [
276 ["Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P"],
339}
340
341function client() {
342 createRoot(document.getElementById("root")).render(<App />);
343}
345if (typeof document !== "undefined") { client(); }
346
347export default async function server(request: Request): Promise<Response> {
348 const { blob } = await import("https://esm.town/v/std/blob");
349 const wordList = await (await blob.get("quordle")).text();
393 }
394 @keyframes bounce {
395 0%, 100% { transform: translateY(-25%); animation-timing-function: cubic-bezier(0.8, 0, 1, 1); }
396 50% { transform: translateY(0); animation-timing-function: cubic-bezier(0, 0, 0.2, 1); }
397 }
398 .animate-bounce { animation: bounce 1s infinite; }

cerebras_codermain.tsx10 matches

@ruudzon•Updated 6 months ago
15 "recipe ingredient converter and scaler",
16 "morse code translator with audio output",
17 "random quote generator with tweet functionality",
18 "personal finance tracker with basic charts",
19 "multiplayer rock-paper-scissors game",
20];
21
22function Dashboard() {
23 const [stats, setStats] = useState<{
24 totalGenerations: number;
36
37 useEffect(() => {
38 async function fetchStats() {
39 const response = await fetch("/dashboard-stats");
40 const data = await response.json();
97}
98
99function App() {
100 const [prompt, setPrompt] = useState(
101 STARTER_PROMPTS[Math.floor(Math.random() * STARTER_PROMPTS.length)],
128
129 useEffect(() => {
130 async function fetchUsageStats() {
131 const response = await fetch("/usage-stats");
132 const data = await response.json();
136 }, []);
137
138 async function handleSubmit(e: React.FormEvent) {
139 e.preventDefault();
140 setLoading(true);
170 }
171
172 function handleVersionChange(direction: "back" | "forward") {
173 const { currentVersionIndex, versions } = versionHistory;
174
271}
272
273function client() {
274 const path = window.location.pathname;
275 const root = createRoot(document.getElementById("root")!);
286}
287
288function extractCodeFromFence(text: string): string {
289 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
290 return htmlMatch ? htmlMatch[1].trim() : text;
291}
292
293export default async function server(req: Request): Promise<Response> {
294 // Dynamic import for SQLite to avoid client-side import
295 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");

lazyCookmain.tsx5 matches

@karkowg•Updated 6 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 const [numPeople, setNumPeople] = useState(4);
7 const [numRecipes, setNumRecipes] = useState(1);
229}
230
231function client() {
232 createRoot(document.getElementById("root")).render(<App />);
233}
234if (typeof document !== "undefined") { client(); }
235
236function extractJSONFromMarkdown(markdown: string): string {
237 const jsonMatch = markdown.match(/```json\n([\s\S]*?)\n```/);
238 return jsonMatch ? jsonMatch[1] : "";
239}
240
241export default async function server(request: Request): Promise<Response> {
242 if (request.method === "POST" && new URL(request.url).pathname === "/recipes") {
243 const { OpenAI } = await import("https://esm.town/v/std/openai");
338}
339
340async function generateImage(recipeName: string): Promise<string> {
341 const response = await fetch(`https://maxm-imggenurl.web.val.run/${encodeURIComponent(recipeName)}`);
342 if (!response.ok) {

RepresentingAJokemain.tsx1 match

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

btcPriceAlertmain.tsx1 match

@kbarienti•Updated 6 months ago
4import { currency } from "https://esm.town/v/stevekrouse/currency";
5
6export async function btcPriceAlert() {
7 const lastBtcPrice: number = await blob.getJSON("lastBtcPrice");
8 let btcPrice = await currency("usd", "btc");

aqimain.tsx1 match

@kbarienti•Updated 6 months ago
2import { easyAQI } from "https://esm.town/v/stevekrouse/easyAQI?v=5";
3
4export async function aqi(interval: Interval) {
5 const location = "region Hannover "; // <-- change to place, city, or zip code
6 const data = await easyAQI({ location });

extutilmain.tsx5 matches

@gloodata•Updated 6 months ago
1export function replyJSON(data: any, status: number) {
2 return new Response(JSON.stringify(data), {
3 status,
6}
7
8export function replyText(data: string, status: number) {
9 return new Response(data, {
10 status,
13}
14
15export function opNotFoundError(opName: string) {
16 return {
17 ok: false,
21 };
22}
23function formatGetBody(url: string, info: ExtInfo) {
24 const { ns = "?", title = "?" } = info ?? {};
25 return `# ${title} (${ns})
44type HandleRequestFn = (info: any) => Promise<any>;
45
46export function makeExtServer(getInfo: GetInfoFn, handleRequest: HandleRequestFn) {
47 return async (req: Request) => {
48 if (req.method === "GET") {
tuna

tuna9 file matches

@jxnblk•Updated 2 weeks ago
Simple functional CSS library for Val Town

getFileEmail4 file matches

@shouser•Updated 1 month ago
A helper function to build a file's email
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.