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/$%7Bsuccess?q=function&page=3&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 31553 results for "function"(3219ms)

wahoearnmain.tsx6 matches

@wahobdUpdated 6 hours ago
5
6// রেফার ও ব্যালেন্স ডাটাবেজ ফাংশন
7async function getReferCount(user_id: number) {
8 return (await get(`refer_${user_id}`)) || 0;
9}
10
11async function addRefer(user_id: number) {
12 const current = await getReferCount(user_id);
13 await set(`refer_${user_id}`, current + 1);
14}
15
16async function getBalance(user_id: number) {
17 return (await get(`balance_${user_id}`)) || 0;
18}
19
20async function addBalance(user_id: number, amount: number) {
21 const current = await getBalance(user_id);
22 await set(`balance_${user_id}`, current + amount);
23}
24
25export default async function(req: Request): Promise<Response> {
26 const { message } = await req.json();
27 if (!message) return new Response("No message found");
131
132// ✅ মেসেজ পাঠানো ফাংশন
133async function sendMessage(chat_id: number, text: string, reply_markup: any = null) {
134 await fetch(`https://api.telegram.org/bot${BOT_TOKEN}/sendMessage`, {
135 method: "POST",

table-mountain-status-cronmain.tsx2 matches

@spookyuserUpdated 7 hours ago
1import { createClient } from "https://esm.sh/@libsql/client@0.6.0";
2
3async function main() {
4 const response = await fetch(
5 "https://cms.tablemountain.net/admin/actions/submissions/default/weather-api",
27}
28
29export default async function(interval: Interval) {
30 await main();
31}

markdownBlogStarterLayout.tsx1 match

@barbra_ke4627Updated 7 hours ago
2import type { ReactNode } from "npm:react@18.2.0";
3
4export function Layout({ children }: { children: ReactNode }) {
5 return (
6 <html lang="en">

markdownBlogStarterindex.tsx3 matches

@barbra_ke4627Updated 7 hours ago
5import { Layout } from "./Layout.tsx";
6
7function PostComponent({ markdown, link }: { markdown: string; link?: string }) {
8 return (
9 <div style={{ border: "1px solid gray", padding: "10px", marginBottom: "20px", borderRadius: "5px" }}>
14}
15
16export default async function(req: Request): Promise<Response> {
17 const url = new URL(req.url);
18 if (url.pathname === "/") {
44}
45
46function html(children: React.ReactNode) {
47 return new Response(
48 renderToString(

reactHonoStarterindex.ts3 matches

@RaazbhaiiUpdated 7 hours ago
218 </div>
219 <script>
220 function getIcon(iconName) {
221 const icons = { 'gear': '⚙️', 'crosshairs': '🎯', 'map': '🗺️', 'calculator': '🧮' };
222 return icons[iconName] || '🔧';
223 }
224
225 function calculateDamage() {
226 const health = parseInt(document.getElementById('health-input').value) || 0;
227 const damage = health > 0 ? Math.min(health, 50) : 0;
244export default app.fetch;
245
246function getIcon(iconName: string): string {
247 const icons = { "gear": "⚙️", "crosshairs": "🎯", "map": "🗺️", "calculator": "🧮" };
248 return icons[iconName] || "🔧";

proxydatasaver.ts21 matches

@jrcUpdated 7 hours ago
45// =============================================================================
46
47function formatBytes(bytes: number): string {
48 if (bytes === 0) return "0 B";
49 const k = 1024;
53}
54
55async function getGzippedSize(text: string): Promise<number> {
56 if (!text) return 0;
57 try {
83// =============================================================================
84
85function generateHtmlTemplate(
86 article: Article,
87 targetUrl: string,
145</main>
146<script>
147 (function() {
148 const url = new URL(window.location);
149 const actualMode = '${sizeInfo.processingMode}';
158}
159
160function generateMetaInfo(
161 targetUrl: string,
162 sizeInfo: SizeInfo,
199}
200
201function generateHomePage(): string {
202 return `<!DOCTYPE html>
203<html lang="en">
245 * Makes a URL absolute if it's relative
246 */
247function makeAbsoluteUrl(href: string, baseUrl: string): string {
248 if (!href || !baseUrl.startsWith("http")) {
249 return href;
267 * Converts a URL to go through the datasaver proxy
268 */
269function createProxyUrl(url: string, originalRequestUrl: string): string {
270 const params = new URLSearchParams();
271 params.set("_url", url);
289 * Removes all JavaScript from HTML content
290 */
291function removeJavaScript(content: string): string {
292 // Remove <script> tags and their content
293 content = content.replace(/<script[^>]*>[\s\S]*?<\/script>/gi, "");
315 * Processes HTML content to fix URLs and optionally remove JavaScript
316 */
317function processContent(
318 content: string,
319 baseUrl: string,
370 * Extracts basic metadata (title, description) from HTML
371 */
372function extractBasicMetadata(html: string): {
373 title: string;
374 excerpt: string;
388 * Extracts body content from HTML, with fallback to full content
389 */
390function extractBodyContent(html: string): string {
391 const bodyMatch = html.match(/<body[^>]*>([\s\S]*?)<\/body>/i);
392 if (bodyMatch) {
401 * High-optimization article extraction using Readability
402 */
403function extractArticle(
404 html: string,
405 url: string,
446 * Medium-optimization extraction: preserves layout, removes JS
447 */
448function extractStatic(
449 html: string,
450 url: string,
498 * Low-optimization extraction: preserves JS for interactivity
499 */
500function extractDynamic(
501 html: string,
502 url: string,
550 * Determines optimal processing mode based on content analysis
551 */
552function determineProcessingMode(
553 html: string,
554 url: string,
689 * Extracts and processes content based on determined mode
690 */
691function extractContent(
692 html: string,
693 url: string,
748 * Calculates size information for the processed content
749 */
750async function calculateSizeInfo(
751 originalHtml: string,
752 contentLength: number,
782 * Fetches content from the target URL
783 */
784async function fetchContent(
785 targetUrl: string,
786 requestHeaders: Headers,
842
843/**
844 * Main datasaver function
845 *
846 * @param _url - Required. The URL to fetch and optimize
852 * @param _debug - Optional. Enables debug logging
853 */
854export default async function(req: Request): Promise<Response> {
855 if (req.method !== "GET") {
856 return new Response("Method not allowed", { status: 405 });

personal_trmnlmalifold_cron.tsx1 match

@ramtinalamiUpdated 7 hours ago
8
9/** @param {Interval} interval */
10export async function cronValHandler(interval: any) {
11 console.log("⏰ Cron fired at", new Date(interval.lastRunAt).toISOString());
12

qkwen02_http.tsx1 match

@bishojoismUpdated 8 hours ago
1export default async function httpHandler(req: Request) {
2 try {
3 const targetUrl = new URL(req.url).searchParams.get("url");

personal_trmnlmain.tsx1 match

@ramtinalamiUpdated 8 hours ago
1import { sqlite } from "https://esm.town/v/std/sqlite";
2
3export default async function handler(_: Request): Promise<Response> {
4 const res = await sqlite.execute({
5 sql: `SELECT summary, updated FROM manifold_cache WHERE key = ?`,

weather-aimain.tsx16 matches

@helgeUpdated 8 hours ago
11}
12
13async function getWeather(latitude: number, longitude: number): Promise<WeatherData> {
14 console.log(`[getWeather] Fetching weather for lat: ${latitude}, lon: ${longitude}`);
15 const url =
26}
27
28async function getCoordinates(locationName: string): Promise<Coordinates> {
29 console.log(`[getCoordinates] Looking up: ${locationName}`);
30
77}
78
79async function callOpenAI(messages: any[], tools: any[]) {
80 const OPENAI_API_KEY = Deno.env.get("OPENAI_API_KEY");
81
96}
97
98async function processWeatherRequest(location: string) {
99 console.log(`[processWeatherRequest] Starting weather lookup for: ${location}`);
100 const tools = [
101 {
102 type: "function",
103 function: {
104 name: "get_coordinates",
105 description: "Get latitude and longitude coordinates for a given location name.",
116 },
117 {
118 type: "function",
119 function: {
120 name: "get_weather",
121 description: "Get current temperature for provided coordinates in celsius.",
152
153 for (const toolCall of completion.choices[0].message.tool_calls) {
154 const name = toolCall.function.name;
155 const args = JSON.parse(toolCall.function.arguments);
156
157 console.log(`[processWeatherRequest] Calling function: ${name} with args:`, args);
158
159 let result;
166 }
167
168 console.log(`[processWeatherRequest] Function ${name} result:`, result);
169
170 messages.push({
196 <meta charset="UTF-8">
197 <meta name="viewport" content="width=device-width, initial-scale=1.0">
198 <title>Weather Function Calling Demo</title>
199 <style>
200 body {
279<body>
280 <div class="container">
281 <h1>🌤️ Weather Lookup with Function Calling</h1>
282 <div class="input-group">
283 <input
293
294 <script>
295 async function getWeather() {
296 const location = document.getElementById('location').value;
297 const resultDiv = document.getElementById('result');
346`;
347
348export default async function handler(req: Request): Promise<Response> {
349 // Handle GET request - serve the HTML page
350 if (req.method === "GET") {
tuna

tuna9 file matches

@jxnblkUpdated 2 weeks ago
Simple functional CSS library for Val Town

getFileEmail4 file matches

@shouserUpdated 2 months ago
A helper function to build a file's email
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.