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=74&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 17277 results for "function"(1065ms)

pondiversemain1 match

@iliazeus•Updated 5 days ago
4import updateTable from "./updateTable";
5
6export default async function(req: Request): Promise<Response> {
7 let url = new URL(req.url);
8 if (url.pathname.endsWith("/")) url.pathname = url.pathname.slice(0, -1);

SamCronmain.tsx1 match

@sam254•Updated 5 days ago
1import { email } from "https://esm.town/v/std/email";
2
3export default async function(interval: Interval) {
4 // Use open-meteo for free weather API
5 const response = await fetch(

pondiverseaddCreation1 match

@todepond•Updated 5 days ago
4import { TABLE_NAME } from "./updateTable";
5
6export default async function(req: Request): Promise<Response> {
7 // body contains:
8 // - title (string)

pondiverseupdateTable1 match

@todepond•Updated 5 days ago
2
3export const TABLE_NAME = "pondiverse_creations_v4";
4export default async function(req: Request): Promise<Response> {
5 await sqlite.execute(
6 `CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (

esmtimeouttestmain.tsx1 match

@hacksore•Updated 5 days ago
1export default async function(req: Request): Promise<Response> {
2 setTimeout(() => {
3 }, 150_000);

my-first-val04_email.tsx1 match

@userchandan•Updated 5 days ago
2// Click "Run", copy and paste the email address and send an email to it.
3// This example will log the email details received.
4export default async function emailHandler(email: Email){
5 console.log("Email received!", email.from, email.subject, email.text);
6 for (const file of email.attachments) {

my-first-val03_cron.tsx1 match

@userchandan•Updated 5 days ago
2// Configure the timer with the 🕒 icon in the top right.
3// This example just logs the current time.
4export function scheduledHandler() {
5 const timestamp = new Date().toISOString();
6 console.log(`Cron val executed at: ${timestamp}`);

my-first-val02_http.tsx1 match

@userchandan•Updated 5 days ago
2// Access it via its public URL (you can also pick a nicer subdomain).
3// Try adding ?name=YourName to the URL!
4export default function httpHandler(req: Request): Response {
5 const url = new URL(req.url);
6 const name = url.searchParams.get("name") || "Friend";

my-first-val01_script.tsx1 match

@userchandan•Updated 5 days ago
1// This script returns a random fun fact
2// You can run scripts manually in this view or call it from other vals.
3export default function getRandomFact() {
4 const funFacts = [
5 "Honey never spoils.",

bukola27main.tsx1 match

@Bukola27•Updated 5 days ago
1export default async function(req: Request): Promise<Response> {
2 return Response.json({ ok: true });
3}

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": "*",