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=2088&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 22346 results for "function"(3060ms)

rateLimitedAsyncPoolmain.tsx2 matches

@harryhood•Updated 1 year ago
1import { asyncPool } from "https://esm.town/v/harryhood/asyncPool";
2
3// A generic utility function that handles concurrency and rate-limiting
4export async function rateLimitedAsyncPool<T, V>(
5 items: T[],
6 poolLimit: number,

rateLimitedAsyncPoolREADME.md2 matches

@harryhood•Updated 1 year ago
1## Summary
2
3This function allows you to run a rate limited async pool to make sure no more than `poolLimit` items at a time are run for a given `waitTime`.
4
5## Example Usage
6
7```
8async function fetchURL(url: string): Promise<string[]> {
9 const response = await fetch(url);
10 const html = await response.text();

asyncPoolmain.tsx1 match

@harryhood•Updated 1 year ago
1export async function asyncPool<T, V>(
2 array: T[],
3 poolLimit: number,

asyncPoolREADME.md1 match

@harryhood•Updated 1 year ago
3Async Pool: Promise.all for Bulk Operations. Taken from [this article](https://maxgreenwald.me/blog/async-pool-promise.all-for-bulk-operations).
4
5`asyncPool` is a utility with the same functionality as `Promise.all` + `Array.map` that keeps the number of concurrent executions at or below a set number.
6
7Migrated from folder: lib/async/asyncPool

getValTownButtonClicksmain.tsx1 match

@petermillspaugh•Updated 1 year ago
1import { valTownButtonClicks } from "https://esm.town/v/petermillspaugh/valTownButtonClicks";
2
3export async function getValTownButtonClicks(request: Request): Promise<Response> {
4 return Response.json({ valTownButtonClicks });
5}

setValTownButtonClicksmain.tsx1 match

@petermillspaugh•Updated 1 year ago
2import { set } from "https://esm.town/v/std/set?v=14";
3
4export async function setValTownButtonClicks(request: Request): Promise<Response> {
5 if (request.method !== "POST") return Response.json({ valTownButtonClicks });
6

emailSubscriptionREADME.md2 matches

@petermillspaugh•Updated 1 year ago
21 const [email, setEmail] = useState("");
22
23 async function handleSubmit(e) {
24 e.preventDefault();
25 setName("");
75
76 useEffect(() => {
77 async function confirmEmail() {
78 if (!email || !token) return;
79

pagemain.tsx1 match

@pomdtr•Updated 1 year ago
2import { html } from "https://esm.town/v/stevekrouse/html?v=5";
3
4export async function readme(request: Request): Promise<Response> {
5 const url = new URL(request.url);
6 const [, , author, name] = url.pathname.split("/");

oldfashionedmain.tsx9 matches

@tmcw•Updated 1 year ago
23const { styleRoute, StyleTag } = styleSystem();
24
25function MaterialsList() {
26 const c = useContext(RequestContext);
27 const mats = getMaterialIds(c);
76}
77
78function RecipesList() {
79 const c = useContext(RequestContext);
80 const s = c?.req.param("slug");
131} as const;
132
133function Units() {
134 const requestContext = useContext(RequestContext);
135 let unit = getCookie(requestContext!, "units") || "";
162});
163
164function getTitle(recipe: Recipe | undefined): string {
165 if (!recipe) {
166 return "Old Fashioned";
169}
170
171function parseUnit(unit: string | undefined): Fmt {
172 if (unit === "CL" || unit === "Ml" || unit === "Oz") {
173 return unit;
176}
177
178function WelcomeMessage() {
179 return (
180 <plank id="recipe-detail" hx-swap-oob="true">
203}
204
205function RecipeDetail() {
206 const c = useContext(RequestContext);
207 const s = c?.req.param("slug") || "";
257}
258
259function IngredientDisplay({ ingredient, unit }: {
260 ingredient: Ingredient;
261 unit: keyof typeof units;
292}
293
294function Index() {
295 const requestContext = useContext(RequestContext);
296 const s = requestContext?.req.param("slug") || "";

styleSystemmain.tsx2 matches

@tmcw•Updated 1 year ago
3import { Context } from "npm:hono@3.8.1";
4
5export function styleSystem() {
6 function StyleTag() {
7 return (
8 <style

getFileEmail4 file matches

@shouser•Updated 4 weeks 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.