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=79&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 24624 results for "function"(693ms)

ProtoShareAuth.tsx2 matches

@c15rUpdated 2 days ago
7}
8
9function base64urlToBase64(base64url: string): string {
10 // Convert base64url to base64
11 let base64 = base64url.replace(/-/g, '+').replace(/_/g, '/');
17}
18
19export function Auth({ mode, onSuccess }: AuthProps) {
20 const [email, setEmail] = useState('');
21 const [name, setName] = useState('');

Websocketsmain.tsx1 match

@wolfUpdated 2 days ago
1export default function handler(req: Request) {
2 if (req.headers.get("upgrade") != "websocket") {
3 return new Response(null, { status: 501 });
8});
9
10function buildData(response) {
11 return {
12 status: "connected",
23// we present that at root and embed that into Notion
24// to show everyone that the connection is healthy btw Notion and val.town
25export default async function (interval: Interval) {
26 const blobKey = await blobKeyForDemoCache(import.meta.url, "healthCheck");
27 try {

Hompageindex.ts5 matches

@dukkyUpdated 2 days ago
1export default async function(req: Request) {
2 const html = `<!DOCTYPE html>
3<html lang="en">
243
244 <script>
245 // Theme toggle functionality
246 const themeToggle = document.getElementById('theme-toggle');
247 const themeIcon = document.getElementById('theme-icon');
262 });
263
264 function updateThemeIcon(theme) {
265 themeIcon.textContent = theme === 'dark' ? '☀️' : '🌙';
266 }
267
268 // Add some interactive animations
269 document.addEventListener('DOMContentLoaded', function() {
270 // Smooth scroll for any internal links
271 document.querySelectorAll('a[href^="#"]').forEach(anchor => {
272 anchor.addEventListener('click', function (e) {
273 e.preventDefault();
274 const target = document.querySelector(this.getAttribute('href'));

Weather_Cardmain.tsx13 matches

@sky_porie_fire443Updated 2 days ago
1// 在Val.town上创建一个新的HTTP Val
2
3export default async function(req: Request): Promise<Response> {
4 const url = new URL(req.url);
5
480
481 // 更新时间显示
482 function updateDateTime() {
483 const now = new Date();
484 const options = {
491
492 // 显示/隐藏加载状态
493 function setLoading(show, text = '正在获取数据...') {
494 const loadingOverlay = document.getElementById('loadingOverlay');
495 const loadingText = document.getElementById('loadingText');
501
502 // 显示错误信息
503 function showError(message) {
504 const errorMessage = document.getElementById('errorMessage');
505 errorMessage.textContent = message;
512
513 // 获取用户位置
514 async function getUserLocation() {
515 try {
516 setLoading(true, '正在获取位置信息...');
554
555 // 获取天气数据
556 async function fetchWeatherData(location = currentLocation) {
557 if (!location || isLoading) return;
558
593
594 // 更新天气显示
595 function updateWeatherDisplay(data) {
596 // 更新数据
597 document.getElementById('temperature').textContent = \`\${data.degree}°\`;
621
622 // 根据天气更新背景
623 function updateBackground(weatherCode) {
624 const body = document.body;
625 const gradients = {
635
636 // 初始化应用
637 async function initApp() {
638 updateDateTime();
639 const location = await getUserLocation();
642
643 // 事件监听器
644 document.addEventListener('DOMContentLoaded', function() {
645 initApp();
646
660
661 // 键盘快捷键
662 document.addEventListener('keydown', function(e) {
663 if (e.key.toLowerCase() === 'r') fetchWeatherData();
664 if (e.key.toLowerCase() === 'l') document.getElementById('locationBtn').click();
674
675// 获取客户端IP地址
676function getClientIP(req) {
677 const forwarded = req.headers.get("x-forwarded-for");
678 const realIP = req.headers.get("x-real-ip");
687
688// 获取城市的默认区县
689function getDefaultCounty(city) {
690 const defaultCounties = {
691 "广州市": "天河区",

HN-fetch-callmain.tsx1 match

@ImGqbUpdated 2 days ago
2import { spider } from "./fetch.tsx";
3
4export async function main(req: Request) {
5 const url = new URL(req.url);
6
86```typescript
87// Client-side event recording
88window.recordClick = function (action) {
89 fetch(`/api/setAction`, {
90 method: "POST",
116│ └── index.tsx # Frontend JavaScript entry point
117└── shared/ # Utilities used by both frontend and backend
118 └── utils/ # Shared helper functions
119```
120
129### Shared (`/shared`)
130
131Contains utilities and functions that work in both browser and server environments, ensuring code reusability across the application.
132
133## Framework and Technology Stack
189### Shared Utilities (`/shared`)
190
191Contains helper functions that work in both frontend and backend environments:
192
193```typescript
220
221```typescript
222export default async function (interval: Interval) {
223 const pages = await notion.databases.query({
224 database_id: Deno.env.get("GLANCE_DEMOS_DB_ID"),
280| Aspect | Controller | Utility |
281| ------------ | --------------------------------------------- | ------------------------------------------------- |
282| Purpose | Orchestrates business logic and workflows | Provides small, stateless helper functions |
283| Scope | High-level, involves services or side effects | Low-level, narrow focus (string, date operations) |
284| State | Works with application or user-specific data | Stateless - input in, output out |

HN-fetch-callfetch.tsx3 matches

@ImGqbUpdated 2 days ago
8}
9
10// Function to extract posts from HTML content
11function extractPosts(html: string): Post[] {
12 const dom = new JSDOM(html);
13 const document = dom.window.document;
38
39// cat: /newest or blank
40export function spider(cat: string) {
41 return fetch(`${BaseUrl}/${cat}`).then(res => res.text()).then(str => extractPosts(str));
42}

my-first-val04_email.tsx1 match

@anaensadUpdated 3 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

@anaensadUpdated 3 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}`);

getFileEmail4 file matches

@shouserUpdated 1 month ago
A helper function to build a file's email
tuna

tuna8 file matches

@jxnblkUpdated 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.