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=2563&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 28712 results for "function"(5165ms)

plumOwlmain.tsx1 match

@tempguy•Updated 11 months ago
11 };
12}
13export default async function(req: Request): Promise<Response> {
14 const showbox = await Fetch("https://www.showbox.media/index/share_link?id=55137&type=1", {
15 headers: {

tripsmain.tsx2 matches

@mxdvl•Updated 11 months ago
9};
10
11async function to_line_string(
12 coordinates: readonly Coordinates[],
13 en_route = false,
32}
33
34export async function* trips(
35 coordinates: readonly Coordinates[],
36 distance_threshold = 120,

discordBotREADME.md1 match

@dglazkov•Updated 11 months ago
1A simple Discord Bot scaffolding, a slight rev on the one in the [valtown guide](https://docs.val.town/integrations/discord/how-to-make-a-discord-bot-hosted-24-7-for-free-in-/).
2
3The `discordBot` function takes in an object where each key is a Discord command and the value is a function to handle the command. If the function returns a `Promise`, it will be handled as a deferred interaction with a [followup message](https://discord.com/developers/docs/interactions/receiving-and-responding#followup-messages).
4
5Usage:

serve_readmemain.tsx2 matches

@cooka•Updated 11 months ago
4import { html } from "https://esm.town/v/stevekrouse/html?v=5";
5
6export async function valReadme({ val, title }: {
7 val: { author: string; name: string };
8 title?: string;
15}
16
17export function serveReadme({ val, title }: {
18 val: { author: string; name: string };
19 title?: string;

blackLobstermain.tsx7 matches

@boson•Updated 11 months ago
29
30// Format an ISO datetime like Sun 06:00 AM
31function fmtDate(d: string): string {
32 return new Date(d).toLocaleString("en-US", { weekday: "short", hour: "numeric", minute: "numeric", hour12: true });
33}
34
35// Format ISO datetime like 06:00 AM
36function fmtTime(d: string): string {
37 return new Date(d).toLocaleString("en-US", { hour: "numeric", minute: "numeric", hour12: true });
38}
39
40// Retry a function n times with exponential backoff.
41async function retry<T>(fn: () => Promise<T>, n: number): Promise<T> {
42 for (let i = 0; i < n; i++) {
43 try {
53
54// Sleep a random amount of seconds (to respect NOAA's API).
55async function sleepRand(seconds: number) {
56 const s = Math.random() * seconds * 1000;
57 await new Promise(r => setTimeout(r, s));
59
60// Find some weather intervals!
61async function run(): Promise<string> {
62 try {
63 await sleepRand(15);
103}
104
105export default async function(interval: Interval) {
106 const msg = await retry(run, 3);
107 await email({ subject: "🚲 Good times to bike!", text: msg });

aqimain.tsx1 match

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

linkInBioTemplatemain.tsx1 match

@djs•Updated 11 months ago
2import { renderToString } from "npm:react-dom/server";
3
4export default async function(req: Request) {
5 return new Response(
6 renderToString(

cronLoggermain.tsx2 matches

@nbbaier•Updated 11 months ago
5import { refs } from "https://esm.town/v/stevekrouse/refs?v=11";
6
7type CronFunction = (interval: Interval) => Promise<void>;
8
9export const cronEvalLogger = (cron: CronFunction): CronFunction => {
10 let interval: Interval;
11 const cronProxy = new Proxy(cron, {

weather_forecast_in_the_morningmain.tsx1 match

@benrobo•Updated 11 months ago
106 await fetch(telegramSendUrl);
107};
108export default async function(interval: Interval) {
109 const forecast = await fetchForecast();
110 const formatted = formatWeatherForecast(forecast);

private_fal_modelmain.tsx1 match

@turbo1912•Updated 11 months ago
4import { renderToString } from "npm:react-dom/server";
5
6export default async function(interval: Interval) {
7 const result = await fal.subscribe("turbo1912/multiple-models/esrgan", {
8 input: {

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.