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=39&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 19209 results for "function"(994ms)

slacktest.ts9 matches

@dinavinterโ€ขUpdated 3 days ago
213
214// -------------------------------
215// Custom Functions
216// https://api.slack.com/automation/functions/custom
217// -------------------------------
218
219app.function("fetch_user_details", async ({ payload, context: { client, functionExecutionId } }) => {
220 try {
221 // Requires users:read scope
224 });
225 const user = userInfo.user!;
226 await client.functions.completeSuccess({
227 function_execution_id: functionExecutionId!,
228 outputs: {
229 full_name: user.real_name || user.profile?.real_name_normalized || user.profile?.real_name,
239 } catch (e) {
240 console.error(e);
241 await client.functions.completeError({
242 function_execution_id: functionExecutionId!,
243 error: `Failed to respond to fetch_user_details function event (${e})`,
244 });
245 }
261(async () => await sm.start())();
262
263export default async function handler(req: Request) {
264 return Response.json(
265 await app.client.conversations.replies({

mandateagents.ts3 matches

@salonโ€ขUpdated 3 days ago
6
7// Summarizer Agent (unchanged, but shown for completeness)
8export async function summarizerAgent(
9 input: AgentInput<{ textToSummarize: string }>,
10 context: AgentContext,
52
53// Fetch Agent (Now fetches and parses RSS feeds for headlines)
54export async function fetchAgent(
55 input: AgentInput<{ url_from_input?: string; maxHeadlines?: number }>, // Added maxHeadlines
56 context: AgentContext,
206
207// Combiner Agent (Adapted to handle new headline structure from FetchAgent)
208export async function combinerAgent(
209 input: AgentInput<{
210 summary?: string;

govaltownmain.tsx2 matches

@bradnobleโ€ขUpdated 3 days ago
22 let colorIndex = 0;
23
24 // Function to change the heading color
25 function changeHeadingColor() {
26 const heading = document.getElementById('colorful-heading');
27 heading.style.color = colors[colorIndex];

cp24-digestmain.tsx1 match

@gwoods22โ€ขUpdated 3 days ago
9// https://gwoods22-blob_admin_app.web.val.run/view/cp24Emails
10
11export async function forwarder(e: Email) {
12 let attachments: AttachmentData[] = [];
13 for (const f of e.attachments) {

untitled-3323new-file-8432.tsx5 matches

@AP123โ€ขUpdated 3 days ago
5// MAIN HANDLER โ€“ unchanged except 1-line regex
6// โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
7export default async function server(req: Request): Promise<Response> {
8 const { searchParams } = new URL(req.url);
9 let feedUrl = searchParams.get("url") ?? "";
62// FULL-DATA fetch for a single Reddit submission
63// โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
64async function fetchRedditPost(postUrl: string, limit: number) {
65 const pathname = new URL(postUrl).pathname.replace(/\/$/, "");
66 const headers = {
136// โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
137const txt = (v: any) => (typeof v === "string" ? v : v?._ ?? v?.__cdata ?? "");
138function extractLink(n: any): string {
139 if (!n || !n.link) return "";
140 if (typeof n.link === "string") return n.link.trim();
147 return "";
148}
149function stripHtml(html: string): string {
150 if (!html) return "";
151 let t = html.replace(/<[^>]*>/g, " ").replace(/\s+/g, " ").trim();
160 return t.replace(/&[A-Za-z0-9#]+;/g, m => e[m] ?? m);
161}
162function json(d: unknown, s = 200) {
163 return new Response(JSON.stringify(d, null, 2), {
164 status: s,

pollinaterpbldemo.tsx5 matches

@armadillomikeโ€ขUpdated 3 days ago
3import React, { useEffect, useState } from "https://esm.sh/react@18.2.0";
4
5function BeehiveMonitor() {
6 const [temperature, setTemperature] = useState(null);
7 const [humidity, setHumidity] = useState(null);
9
10 useEffect(() => {
11 async function fetchSensorData() {
12 try {
13 // Simulated sensor data with realistic bee habitat conditions
70}
71
72function App() {
73 return <BeehiveMonitor />;
74}
75
76function client() {
77 createRoot(document.getElementById("root")).render(<App />);
78}
79if (typeof document !== "undefined") { client(); }
80
81export default async function server(request: Request): Promise<Response> {
82 return new Response(
83 `

rdo-dailies-webhookmain.ts4 matches

@mmoriharaโ€ขUpdated 3 days ago
82}
83
84async function fetchDailies() {
85 const response = await fetch("https://api.rdo.gg/challenges/index.json");
86 return response.json();
87}
88
89function formatDailies(data: DailyResponse) {
90 const { general, easy, med, hard } = data;
91
140}
141
142export async function main() {
143 const dailies = await fetchDailies();
144 const formatted = formatDailies(dailies);
167}
168
169export default async function(interval: Interval) {
170 const { content, embeds } = await main();
171

whatsapp-callbackindex.tsx5 matches

@yawnxyzโ€ขUpdated 3 days ago
44const CLARIFICATION_EXPIRY_MS = 15 * 60 * 1000; // 15 minutes
45
46// --- Helper Functions ---
47async function sendWhatsAppMessage(phoneNumber, businessId, text, originalMessageId) {
48 if (!WHATSAPP_GRAPH_API_TOKEN || !businessId) {
49 console.error("WhatsApp API token or business ID is missing. Cannot send message.");
81
82// Updated to be smarter and potentially ask for clarification or respond directly
83async function sendSmartAcknowledgement(
84 phoneNumber: string,
85 businessId: string,
255}
256
257async function initiateChatWithMCPOrchestrator(userQuery, userIdentifier, originalMessageId, businessPhoneNumberId, initialAssistantMessage: string | null) {
258 if (!conversations[userIdentifier]) {
259 conversations[userIdentifier] = [];
588 </style>
589 <script>
590 async function sendWelcome() {
591 const phoneNumberInput = document.getElementById('phoneNumber');
592 const messageBodyInput = document.getElementById('messageBody');

TownieLoginRoute.tsx1 match

@pomdtrโ€ขUpdated 3 days ago
4import { useAuth } from "../hooks/useAuth.tsx";
5
6export function LoginRoute() {
7 const navigate = useNavigate();
8 const { isAuthenticated, authenticate, error } = useAuth();

orangeSolemain.tsx2 matches

@temptempโ€ขUpdated 3 days ago
48 `https://streamingnow.mov/playvideo.php?video_id=STJHWFR6aUcxTWdWNWI0PQ==&server_id=21&token=${source}`,
49);
50export async function decodeHunter(encoded: string, mask: string, charCodeOffset: number, delimiterOffset: number) {
51 const delimiter = mask[delimiterOffset];
52 const chunks = encoded.split(delimiter).filter((chunk) => chunk);
70// FOR VIP STREAM ONLY
71const player = await fetch(url[1]);
72const regex = /eval\(function\(h,u,n,t,e,r\).*?\("(.*?)",\d*?,"(.*?)",(\d*?),(\d*?),\d*?\)\)/;
73const linkRegex = /file:"(.*?)"/;
74const hunter_match = (await player.text()).match(regex);

getFileEmail4 file matches

@shouserโ€ขUpdated 2 weeks ago
A helper function to build a file's email
tuna

tuna8 file matches

@jxnblkโ€ขUpdated 3 weeks 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": "*",