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/$%7Bart_info.art.src%7D?q=function&page=2500&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 28709 results for "function"(6037ms)

likelyPinkPuffinmain.tsx7 matches

@stevedylandev•Updated 9 months ago
16];
17
18// Function to fetch recent questions from Stack Overflow for multiple topics
19async function fetchRecentQuestions(): Promise<StackExchange.Question[]> {
20 const allQuestions: StackExchange.Question[] = [];
21
34}
35
36// Function to format questions into HTML
37function formatQuestionsHtml(questions: StackExchange.Question[]): string {
38 return questions.map(q => `
39 <h2><a href="${q.link}">${q.title}</a></h2>
44}
45
46// Main cron job function
47async function cronJob() {
48 const { email } = await import("https://esm.town/v/std/email");
49
69}
70
71export default async function(interval: Interval) {
72 await cronJob();
73}

codeOnValTownREADME.md1 match

@Serizon•Updated 9 months ago
49### Linking to the val
50
51These functions infer the val using the call stack or the request URL. If the inference isn't working, or if you want to ensure it links to a specific val, pass the `val` argument:
52
53- `modifyFetchHandler(handler, {val: { handle: "andre", name: "foo" }})`

codeOnValTownmain.tsx2 matches

@Serizon•Updated 9 months ago
9 * @param val Define which val should open. Defaults to the root reference
10 */
11export function modifyHtmlString(
12 bodyText: string,
13 { val, style }: { val?: ValRef; style?: string } = {},
40 * @param val Define which val should open
41 */
42export function modifyFetchHandler(
43 handler: (req: Request) => Response | Promise<Response>,
44 { val, style }: { val?: ValRef; style?: string } = {},

umapmain.tsx3 matches

@ejfox•Updated 9 months ago
34const resultCache = new Map();
35
36export default async function server(request: Request): Promise<Response> {
37 if (request.method === "GET") {
38 return new Response(html, {
171const openai = new OpenAI();
172
173async function getEmbeddings(texts) {
174 const response = await openai.embeddings.create({
175 model: "text-embedding-ada-002",
203
204 <script>
205 function runDemo() {
206 const testData = {
207 embeddings: Array.from({length: 100}, () => Array.from({length: 10}, () => Math.random())),

zod_demo_frontendmain.tsx1 match

@stevekrouse•Updated 9 months ago
4import type { User } from "https://esm.town/v/stevekrouse/zod_demo_shared";
5
6export function App() {
7 const [user, setUser] = useState<User>({ username: "", email: "", age: 0 });
8 const [errors, setErrors] = useState<Partial<User>>({});

zod_demo_httpmain.tsx1 match

@stevekrouse•Updated 9 months ago
2import { UserSchema } from "https://esm.town/v/stevekrouse/zod_demo_shared";
3
4async function server(request: Request): Promise<Response> {
5 if (request.method === "POST" && new URL(request.url).pathname === "/register") {
6 try {

weatherGPTmain.tsx1 match

@sarfrazkhan18•Updated 9 months ago
31console.log(text);
32
33export async function weatherGPT() {
34 await email({ subject: "Weather Today", text });
35}

aqimain.tsx1 match

@sarfrazkhan18•Updated 9 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 });

turnitdownmain.tsx1 match

@yawnxyz•Updated 9 months ago
82});
83
84export default async function server(req: Request): Promise<Response> {
85 return app.fetch(req);
86}

turnitdownREADME.md1 match

@yawnxyz•Updated 9 months ago
141. The application uses the Hono framework to create a simple web server.
152. HTMX is used for handling AJAX requests without writing JavaScript.
163. Alpine.js provides reactivity for the clipboard functionality.
174. The Turndown library is used to convert HTML to Markdown.
18

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.