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%22Image%20title%22?q=function&page=2508&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 29319 results for "function"(3227ms)

createGitHubContribGraphmain.tsx4 matches

@tmcw•Updated 8 months ago
172}
173
174function App() {
175 const [username, setUsername] = useState("stevekrouse")
176 const [contributionData, setContributionData] = useState<any>(null)
360}
361
362function client() {
363 createRoot(document.getElementById("root")).render(<App />)
364}
365if (typeof document !== "undefined") { client() }
366
367export default async function server(request: Request): Promise<Response> {
368 if (request.method === "POST" && new URL(request.url).pathname === "/contributions") {
369 const { username } = await request.json()
395}
396
397async function fetchGitHubContributions(username: string) {
398 const query = `
399 query($username: String!) {

versionLogggerREADME.md1 match

@willthereader•Updated 8 months ago
1This helper function logs the version number of the val.
2
3```ts

immenseBlushSpidermain.tsx2 matches

@ngmi•Updated 8 months ago
2const API_URL = "https://build.wield.xyz/farcaster/v2/feed";
3
4export default async function server(request: Request): Promise<Response> {
5 let feedItems = [];
6 let error = null;
9 error = "API key is not set. Please configure the FARCASTER_API_KEY environment variable.";
10 } else {
11 async function fetchFeedItems() {
12 try {
13 const response = await fetch(`${API_URL}?limit=50`, {

jealousMagentaFleamain.tsx1 match

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

disgustedAzureChinchillamain.tsx1 match

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

violentGoldSnakemain.tsx1 match

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

chatmain.tsx1 match

@lt_07•Updated 8 months ago
23 });
24 const message = data.choices[0].message;
25 return message.function_call ? message.function_call : message.content;
26};

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);
tuna

tuna9 file matches

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