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/image-url.jpg%20%22Optional%20title%22?q=function&page=99&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 20738 results for "function"(1454ms)

zayREADME.md3 matches

@zaaynaah•Updated 3 days ago
5## Structure
6
7- `utils.ts` - Shared types and utility functions
8
9## Contents
10
11- TypeScript interfaces for Jobs and Messages
12- Utility functions for date formatting
13- HTML sanitization functions to prevent XSS attacks

zayREADME.md1 match

@zaaynaah•Updated 3 days ago
14- Job posting form
15- Job listings display
16- Real-time chat functionality
17
18## Technologies

zayREADME.md1 match

@zaaynaah•Updated 3 days ago
8- `database/` - Database setup and queries
9 - `migrations.ts` - Database schema definitions
10 - `queries.ts` - Database query functions
11
12## API Endpoints

zayindex.js8 matches

@zaaynaah•Updated 3 days ago
38
39// Check if user is logged in
40function checkAuth() {
41 if (username) {
42 loginScreen.classList.add("hidden");
49}
50
51// Login functionality
52loginButton.addEventListener("click", () => {
53 const inputUsername = usernameInput.value.trim();
68});
69
70// Logout functionality
71logoutButton.addEventListener("click", () => {
72 username = "";
76
77// Load jobs from API
78async function loadJobs() {
79 try {
80 const response = await fetch("/api/jobs");
90
91// Render jobs to the DOM
92function renderJobs() {
93 if (jobs.length === 0) {
94 jobsContainer.innerHTML = '<div class="text-gray-500 text-center">No jobs posted yet. Be the first!</div>';
142
143// Load chat messages
144async function loadMessages() {
145 try {
146 const response = await fetch("/api/messages");
157
158// Render messages to the DOM
159function renderMessages() {
160 if (messages.length === 0) {
161 chatContainer.innerHTML = '<div class="text-gray-500 text-center">No messages yet. Start the conversation!</div>';
211
212// Poll for new messages every 5 seconds
213function startMessagePolling() {
214 setInterval(loadMessages, 5000);
215}

zayutils.ts2 matches

@zaaynaah•Updated 3 days ago
17
18// Format date for display
19export function formatDate(timestamp: number): string {
20 return new Date(timestamp).toLocaleString();
21}
22
23// Sanitize HTML to prevent XSS
24export function sanitizeHTML(str: string): string {
25 return str
26 .replace(/&/g, "&amp;")

zayqueries.ts4 matches

@zaaynaah•Updated 3 days ago
20
21// Job queries
22export async function getAllJobs(): Promise<Job[]> {
23 const result = await sqlite.execute<Job>(
24 `SELECT * FROM ${JOBS_TABLE} ORDER BY created_at DESC`
27}
28
29export async function createJob(job: Omit<Job, "id" | "created_at">): Promise<Job> {
30 const created_at = Date.now();
31 const result = await sqlite.execute<{ id: number }>(
44
45// Message queries
46export async function getRecentMessages(limit = 50): Promise<Message[]> {
47 const result = await sqlite.execute<Message>(
48 `SELECT * FROM ${MESSAGES_TABLE}
54}
55
56export async function createMessage(message: Omit<Message, "id" | "created_at">): Promise<Message> {
57 const created_at = Date.now();
58 const result = await sqlite.execute<{ id: number }>(

zaymigrations.ts1 match

@zaaynaah•Updated 3 days ago
8 * Initialize database tables
9 */
10export async function initDatabase() {
11 // Create jobs table
12 await sqlite.execute(`

zayREADME.md1 match

@zaaynaah•Updated 3 days ago
27## Getting Started
28
29Visit the app and start by entering a username to access the job board and chat functionality.

numero-gamesfrench-numbers-practice.ts5 matches

@mgm•Updated 3 days ago
2// This Val serves a mobile-friendly web application to practice French numbers
3
4export default async function(req: Request): Promise<Response> {
5 // HTML content with embedded JavaScript and CSS
6 const html = `<!DOCTYPE html>
155
156 // Generate a random number between min and max (inclusive)
157 function getRandomNumber(min, max) {
158 return Math.floor(Math.random() * (max - min + 1)) + min;
159 }
160
161 // Generate a new announcement
162 function generateAnnouncement() {
163 // Reset feedback
164 document.getElementById('feedback').classList.add('hidden');
217
218 // Play the announcement using text-to-speech
219 function playAnnouncement() {
220 if (!window.speechSynthesis) {
221 alert("Sorry, your browser doesn't support text-to-speech!");
235
236 // Check the user's answer
237 function checkAnswer() {
238 const userAnswer = document.getElementById('userAnswer').value.trim();
239 const userNumbers = userAnswer.split(',').map(num => parseInt(num.trim())).filter(num => !isNaN(num));

untitled-6367request-headers-dump.ts1 match

@vnataraja•Updated 3 days ago
8 */
9
10export default async function(req: Request): Promise<Response> {
11 // Clone the request to safely read the body
12 const reqClone = req.clone();

getFileEmail4 file matches

@shouser•Updated 3 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
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.