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/$1?q=function&page=2455&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 28783 results for "function"(5351ms)

naughtyRedTunamain.tsx4 matches

@maxjoygit•Updated 8 months ago
3import { email } from "https://esm.town/v/std/email";
4
5async function fetchStories(type: string, count: number) {
6 const response = await fetch(`https://hacker-news.firebaseio.com/v0/${type}stories.json`);
7 const storyIds = await response.json();
15}
16
17function createStoryHTML(story: any) {
18 return `
19 <li>
28}
29
30function createEmailContent(
31 topStories: any[],
32 newStories: any[],
118}
119
120export default async function server(req: Request) {
121 try {
122 const topStories = await fetchStories("top", 10);

hackerNewsDigestmain.tsx4 matches

@maxjoygit•Updated 8 months ago
3import { email } from "https://esm.town/v/std/email";
4
5async function fetchStories(type: string, count: number) {
6 const response = await fetch(`https://hacker-news.firebaseio.com/v0/${type}stories.json`);
7 const storyIds = await response.json();
15}
16
17function createStoryHTML(story: any) {
18 return `
19 <li>
28}
29
30function createEmailContent(
31 topStories: any[],
32 newStories: any[],
118}
119
120export default async function server(req: Request) {
121 try {
122 const topStories = await fetchStories("top", 10);

bonsaimain.tsx12 matches

@loading•Updated 8 months ago
3import { renderToString } from "https://esm.sh/react-dom/server";
4
5function createScreenBuffer(width: number, height: number): string[][] {
6 const buffer: string[][] = [];
7 for (let y = 0; y < height; y++) {
150};
151
152function bufferToHtml(buffer: string[][], colors: any): string {
153 let html = "<pre style=\"line-height: 1; font-family: monospace;\">";
154 for (let y = 0; y < buffer.length; y++) {
212}
213
214function App() {
215 return (
216 <div>
228}
229
230export default async function server(request: Request): Promise<Response> {
231 const app = renderToString(<App />);
232
349 let screensaverInterval;
350
351 function applyTheme(theme) {
352 document.body.style.backgroundColor = theme.background;
353 document.body.style.color = theme.text;
362 }
363
364 function changeTheme() {
365 currentThemeIndex = (currentThemeIndex + 1) % themeNames.length;
366 const newTheme = themes[themeNames[currentThemeIndex]];
369 }
370
371 function bufferToHtml() {
372 let html = '<pre style="line-height: 1; font-family: monospace;">';
373 const currentTheme = themes[themeNames[currentThemeIndex]];
432 }
433
434 function growTreePart(y, x, type, life, direction = 0) {
435 if (life <= 0) return null;
436
480 }
481
482 function growTree() {
483 buffer = Array(height).fill().map(() => Array(width).fill(" "));
484 growQueue = [{ x: Math.floor(width / 2), y: height - 1, type: 0, life: 32, direction: 0 }];
485
486 function grow() {
487 if (growQueue.length === 0) return;
488
523 }
524
525 function updateTree() {
526 document.getElementById('tree-container').innerHTML = bufferToHtml();
527 setTimeout(() => {
534 }
535
536 function toggleScreensaver() {
537 screensaverMode = !screensaverMode;
538 document.body.classList.toggle('screensaver-mode', screensaverMode);

hackerNewsDigestmain.tsx4 matches

@citizen428•Updated 8 months ago
3import { email } from "https://esm.town/v/std/email";
4
5async function fetchStories(type: string, count: number) {
6 const response = await fetch(`https://hacker-news.firebaseio.com/v0/${type}stories.json`);
7 const storyIds = await response.json();
15}
16
17function createStoryHTML(story: any) {
18 return `
19 <li>
28}
29
30function createEmailContent(
31 topStories: any[],
32 newStories: any[],
118}
119
120export default async function server(req: Request) {
121 try {
122 const topStories = await fetchStories("top", 10);

netsaur_xorREADME.md1 match

@loading•Updated 8 months ago
1# Approximate the XOR function using netsaur
2
30 xor 0 = 0.003461432410404086 (should be close to 0)

spottySilverHawkmain.tsx3 matches

@all•Updated 8 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 const [activeButton, setActiveButton] = useState(null);
7
75}
76
77function client() {
78 createRoot(document.getElementById("root")).render(<App />);
79}
81if (typeof document !== "undefined") { client(); }
82
83export default async function server(request: Request): Promise<Response> {
84 return new Response(`
85 <!DOCTYPE html>

bellTrackermain.tsx3 matches

@all•Updated 8 months ago
12const GRID_SIZE = 8;
13
14function App() {
15 const [audioEnabled, setAudioEnabled] = useState(false);
16 const [audioState, setAudioState] = useState("Initializing");
248}
249
250function client() {
251 createRoot(document.getElementById("root")).render(<App />);
252}
253if (typeof document !== "undefined") { client(); }
254
255export default async function server(request: Request): Promise<Response> {
256 return new Response(
257 `

brokenBellsmain.tsx3 matches

@all•Updated 8 months ago
25];
26
27function App() {
28 const [audioEnabled, setAudioEnabled] = useState(false);
29 const [timeline, setTimeline] = useState([]);
230}
231
232function client() {
233 createRoot(document.getElementById("root")).render(<App />);
234}
235if (typeof document !== "undefined") { client(); }
236
237export default async function server(request: Request): Promise<Response> {
238 return new Response(
239 `

git_jiggymain.tsx4 matches

@stevekrouse•Updated 8 months ago
17];
18
19function App() {
20 const [username, setUsername] = useState("stevekrouse");
21 const [contributionData, setContributionData] = useState(null);
323}
324
325function client() {
326 createRoot(document.getElementById("root")).render(<App />);
327}
328if (typeof document !== "undefined") { client(); }
329
330export default async function server(request: Request): Promise<Response> {
331 if (request.method === "POST" && new URL(request.url).pathname === "/contributions") {
332 const { username } = await request.json();
359}
360
361async function fetchGitHubContributions(username: string) {
362 const query = `
363 query($username: String!) {

valleBlogV0main.tsx4 matches

@demon•Updated 8 months ago
8import _ from "npm:lodash@4";
9
10async function main(req: Request): Promise<Response> {
11 const { readable, writable } = new TransformStream();
12 const writer = writable.getWriter();
20 <script>
21 // Scroll to the bottom of the page when the page changes.
22 (new MutationObserver(function (mutationsList, observer) {
23 window.scrollTo({ left: 0, top: document.body.scrollHeight, behavior: "instant" });
24 })).observe(document, { childList: true, characterData: true, subtree: true });
47 Your response should start with \`\`\`ts and end with \`\`\`, so full code fences.
48 There should be no comments like "more content here", it should be complete and directly runnable.
49 The val should have an "export default async function main". The val should return a valid HTML website.
50 Prefer using Tailwind. Put frontend functions in a <script> tag, using dangerouslySetInnerHTML. Don't use Hono. Don't use Response.redirect.
51 `.replace("\n", " "),
52 },

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 1 month 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.