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/%22script.js//%22https:/editorjs.io/usage/%22?q=function&page=1&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 40674 results for "function"(2224ms)

tinycanvasmain.ts2 matches

@zarutian•Updated 23 mins ago
13
14*/
15const handler = async function(req) {
16 const req_url = new URL(req.url);
17 if (req_url.pathname == "/canvasser.js") {
52 `, { status: 404, statusText: "Not found.", headers: { "Content-Type": "text/html", }})
53}
54export default async function (req: Request): Promise<Response> {
55 try {
56 return await handler(req);

ReactiveNotesmain.tsx1 match

@json•Updated 29 mins ago
1export default function () {
2 const body = `<!DOCTYPE html>
3<html lang="en">

krazyy-cam-configmain.ts2 matches

@krazyykrunal•Updated 53 mins ago
1function corsHeaders() {
2 return {
3 "Content-Type": "application/json",
8}
9
10export default async function handle(req: Request): Promise<Response> {
11 // ---- Handle CORS preflight ----
12 if (req.method === "OPTIONS") {

Gemini-2-5-Pro-O-02main.tsx17 matches

@aibotcommander•Updated 57 mins ago
83].filter(Boolean);
84
85function authenticateRequest(req: Request): { isValid: boolean; error?: string } {
86 if (!BOT_ACCESS_KEY) {
87 console.warn("Warning: BOT_ACCESS_KEY is not set in environment variables");
110}
111
112function createPoeClient(apiKey: string): OpenAI {
113 return new OpenAI({
114 apiKey: apiKey || "YOUR_POE_API_KEY",
117}
118
119function selectOptimalTokens(contentLength: number, taskType: string): number {
120 if (taskType === "Image Generation") return 1024;
121 if (contentLength < 100) return 1024; // Short queries
124}
125
126async function callSinglePoeModel(
127 model: string,
128 prompt: string,
169}
170
171async function callPoeModelParallel(
172 models: string[],
173 prompt: string,
260}
261
262async function imageToBase64(imageUrl: string): Promise<{ data: string; mimeType: string }> {
263 try {
264 const response = await fetch(imageUrl, { timeout: 8000 });
276}
277
278async function callGeminiApi(
279 config: ModelConfig,
280 prompt: string,
338}
339
340async function generateImage(prompt: string, send: SendEventFn): Promise<void> {
341 let cleanPrompt = prompt;
342 if (cleanPrompt.endsWith('--image')) {
364}
365
366async function generateText(prompt: string, send: SendEventFn, useClaudeModels: boolean = false): Promise<void> {
367 send("text", { text: `💬 Processing...` });
368
391}
392
393async function analyzeFile(fileContent: string, fileName: string, userPrompt: string, send: SendEventFn): Promise<void> {
394 if (!fileContent || fileContent.trim().length === 0) {
395 send("error", {
436}
437
438async function analyzeImage(imageUrl: string, userPrompt: string, send: SendEventFn): Promise<void> {
439 let analysisPrompt: string;
440 if (!userPrompt || userPrompt.trim().length === 0) {
468}
469
470async function performSearch(query: string, send: SendEventFn): Promise<void> {
471 const searchPrompt = `Search for comprehensive, current information about: ${query}\n\nProvide detailed, accurate information with sources and references where available. Focus on the most recent and relevant information.`;
472
494}
495
496function detectIntent(content: string, hasAttachments: boolean): { intent: string; useClaudeModels: boolean } {
497 const lowerContent = content.toLowerCase();
498 let useClaudeModels = false;
541}
542
543async function getResponse(req: Query, send: SendEventFn) {
544 send("meta", { content_type: "text/markdown" });
545
649}
650
651async function getBotSettings(): Promise<BotSettings> {
652 const rateCard = "| Task Type | Price |\n" +
653 "|-----------|-------|\n" +
716) => void;
717
718function encodeEvent(event: string, data: any = {}) {
719 return new TextEncoder().encode(
720 `event: ${event}\ndata: ${JSON.stringify(data)}\n\n`,
722}
723
724export default async function (req: Request): Promise<Response> {
725 if (req.method !== "OPTIONS") {
726 const authResult = authenticateRequest(req);

lastLoginGoogleDemomain.tsx3 matches

@stevekrouse•Updated 1 hour ago
3import { LoginWithGoogleButton } from "https://esm.town/v/stevekrouse/LoginWithGoogleButton";
4
5function App() {
6 const email = (window as any).__HYDRATED_EMAIL__;
7
26}
27
28function client() {
29 createRoot(document.getElementById("root")!).render(<App />);
30}
36import { lastlogin } from "https://esm.town/v/stevekrouse/lastlogin_safe";
37
38function server(request: Request): Response {
39 const email = request.headers.get("X-LastLogin-Email");
40

untitled-8233main.ts1 match

@leothorp•Updated 1 hour ago
1// Learn more: https://docs.val.town/vals/http/
2export default async function (req: Request): Promise<Response> {
3 return Response.json({ ok: true })
4}
Gemini-2-5-Pro-O-01

Gemini-2-5-Pro-O-01main.tsx18 matches

@aibotcommander•Updated 1 hour ago
84].filter(Boolean);
85
86function createPoeClient(apiKey: string): OpenAI {
87 return new OpenAI({
88 apiKey: apiKey || "YOUR_POE_API_KEY",
91}
92
93async function callPoeModel(
94 models: string[],
95 prompt: string,
164}
165
166async function imageToBase64(imageUrl: string): Promise<{ data: string; mimeType: string }> {
167 try {
168 const response = await fetch(imageUrl, { timeout: 10000 });
185}
186
187async function callGeminiPro(
188 prompt: string,
189 send: SendEventFn,
250}
251
252async function callGeminiVision(
253 prompt: string,
254 imageUrl: string,
313}
314
315async function callGeminiFirst(
316 prompt: string,
317 send: SendEventFn,
365}
366
367async function fallbackToGemini(
368 prompt: string,
369 send: SendEventFn,
418}
419
420async function generateImage(prompt: string, send: SendEventFn): Promise<void> {
421 let cleanPrompt = prompt;
422 if (cleanPrompt.endsWith('--image')) {
441}
442
443async function generateText(prompt: string, send: SendEventFn, useClaudeModels: boolean = false): Promise<void> {
444 let models = POE_MODELS.textGeneration;
445 if (useClaudeModels) {
465}
466
467async function analyzeFile(fileContent: string, fileName: string, userPrompt: string, send: SendEventFn): Promise<void> {
468 if (!fileContent || fileContent.trim().length === 0) {
469 send("error", {
508}
509
510async function analyzeImage(imageUrl: string, userPrompt: string, send: SendEventFn): Promise<void> {
511 let analysisPrompt: string;
512 if (!userPrompt || userPrompt.trim().length === 0) {
536}
537
538async function performSearch(query: string, send: SendEventFn): Promise<void> {
539 const searchPrompt = `Search for comprehensive, current information about: ${query}\n\nProvide detailed, accurate information with sources and references where available. Focus on the most recent and relevant information.`;
540
560}
561
562function detectIntent(content: string, hasAttachments: boolean): { intent: string; useClaudeModels: boolean } {
563 const lowerContent = content.toLowerCase();
564 let useClaudeModels = false;
607}
608
609async function getResponse(req: Query, send: SendEventFn) {
610 send("meta", { content_type: "text/markdown" });
611
720}
721
722async function getBotSettings(): Promise<BotSettings> {
723 const rateCard = "| Task Type | Price |\n" +
724 "|-----------|-------|\n" +
787) => void;
788
789function encodeEvent(event: string, data: any = {}) {
790 return new TextEncoder().encode(
791 `event: ${event}\ndata: ${JSON.stringify(data)}\n\n`,
793}
794
795function validateBotAccess(req: Request): { success: boolean; error?: string } {
796 const botAccessKey = process.env.BOT_ACCESS_KEY;
797
819}
820
821export default async function (req: Request): Promise<Response> {
822 const reqBody = await req.json().catch((e) => {
823 console.error("body parse error", e);

last-login-demo-1index.tsx2 matches

@stevekrouse•Updated 1 hour ago
24}
25
26function App({ initialEmail, initialThreads = [] }: AppProps) {
27 const [email, setEmail] = useState<string | null>(initialEmail || null);
28 const [threads, setThreads] = useState<Thread[]>(initialThreads);
315
316// Initialize the app
317function initApp() {
318 const initialData = (window as any).__INITIAL_DATA__;
319 const root = createRoot(document.getElementById('root')!);

ReactiveNotescomputedValuesPlugin.js3 matches

@json•Updated 1 hour ago
5const math = create(all, {});
6
7// parse vars + functions
8function buildContext(doc) {
9 const lines = doc.split("\n");
10 const vars = {};
11 for (const line of lines) {
12 // function def: name(args) = expr
13 const funcMatch = line.match(/^([a-zA-Z_]\w*)\(([^)]*)\)\s*=\s*(.+)$/);
14 if (funcMatch) {

last-login-demo-1index.ts1 match

@stevekrouse•Updated 1 hour ago
12
13// Initialize database tables
14async function initDatabase() {
15 // Create threads table
16 await sqlite.execute(`

ratelimit4 file matches

@unkey•Updated 1 month ago
Rate limit your serverless functions

discordWebhook2 file matches

@stevekrouse•Updated 2 months ago
Helper function to send Discord messages
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.