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/?q=function&page=1525&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 17289 results for "function"(2630ms)

commentsmain.tsx2 matches

@parkerdavis•Updated 1 year ago
5const KEY = import.meta.url.split("?")[0];
6
7export async function addComment(str) {
8 const comments = await blob.getJSON(KEY) as Array<string> ?? [];
9 comments.push(str);
11 await email({ text: "New Comment Alert!: " + str });
12}
13export async function getComments() {
14 return await blob.getJSON(KEY) as Array<string> ?? [];
15}

brownCoralmain.tsx1 match

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

appendFragment_examplemain.tsx1 match

@vladimyr•Updated 1 year ago
15`.trim();
16
17export default async function(req: Request): Promise<Response> {
18 return new Response(
19 appendFragment(

codeOnValTown_testmain.tsx1 match

@vladimyr•Updated 1 year ago
4const { author, name } = extractValInfo(import.meta.url);
5
6async function serveHtml(req: Request): Promise<Response> {
7 return new Response(
8 `

codeOnValTownmain.tsx2 matches

@vladimyr•Updated 1 year 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: RequestHandler,
44 { val, style }: { val?: ValRef; style?: string } = {},

dataURLmain.tsx2 matches

@vladimyr•Updated 1 year ago
2import ky from "npm:ky";
3
4export async function convertUrlToDataURL(url: string | URL): Promise<string> {
5 const blob = await ky.get(url).blob();
6 return convertBlobToDataURL(blob);
7}
8
9export function convertBlobToDataURL(blob: Blob): Promise<string> {
10 return new Promise((resolve, reject) => {
11 const reader = new FileReader();

pipeResponsemain.tsx2 matches

@vladimyr•Updated 1 year ago
6export type RequestHandler = (req?: Request) => Response | Promise<Response>;
7
8export function createWrappedHandler(
9 handler: RequestHandler,
10 ...transforms: ReadableWritablePair[]
16}
17
18export function pipeResponse(
19 res: Response,
20 ...transforms: ReadableWritablePair[]

codeOnValTownREADME.md1 match

@vladimyr•Updated 1 year 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" }})`

blob_delete_by_prefixmain.tsx1 match

@stevekrouse•Updated 1 year ago
1import { blob } from "https://esm.town/v/std/blob?v=11";
2
3export async function deleteBlobs(prefix: string) {
4 (await blob.list(prefix)).forEach(({ key }) => blob.delete(key));
5}

BalanceBrightDatamain.tsx1 match

@augustohp•Updated 1 year ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export default async function fetchBrightDataBalance(
4 token: string,
5): Promise<number> {

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 1 week ago
Simple functional CSS library for Val Town
webup
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.
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": "*",