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%22Image%20title%22?q=function&page=97&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 20320 results for "function"(1963ms)

Jobschat.js9 matches

@Fatimaโ€ขUpdated 2 days ago
1// Chat functionality
2
3// Fetch chat messages
4export async function fetchChatMessages(limit = 50) {
5 try {
6 const response = await fetch(`/api/chat?limit=${limit}`);
16
17// Send a new chat message
18export async function sendChatMessage(userName, message) {
19 try {
20 const response = await fetch('/api/chat', {
42
43// Format date for display
44function formatDate(dateString) {
45 const date = new Date(dateString);
46 return date.toLocaleString();
48
49// Render chat messages
50export function renderChatMessages(messages, container) {
51 if (!messages || messages.length === 0) {
52 container.innerHTML = '<div class="text-center text-gray-500">No messages yet. Start the conversation!</div>';
87
88// Initialize chat form submission
89export function initChatForm(formElement, userNameInput, onSuccess) {
90 const chatSubmitButton = document.getElementById('chat-submit-button');
91 const usernameWarning = document.getElementById('username-warning');
92 const usernameRequired = document.getElementById('username-required');
93
94 // Function to check if username is provided
95 function checkUsername() {
96 const userName = userNameInput.value.trim();
97 const hasUsername = !!userName;
153
154// Poll for new messages
155export function startChatPolling(interval, callback) {
156 // Initial fetch
157 callback();

Jobsjobs.js6 matches

@Fatimaโ€ขUpdated 2 days ago
1// Job posting related functionality
2
3// Fetch all job postings
4export async function fetchJobs() {
5 try {
6 const response = await fetch('/api/jobs');
16
17// Create a new job posting
18export async function createJob(jobData) {
19 try {
20 const response = await fetch('/api/jobs', {
39
40// Format date for display
41function formatDate(dateString) {
42 const date = new Date(dateString);
43 return date.toLocaleString();
45
46// Render job listings
47export function renderJobs(jobs, container) {
48 if (!jobs || jobs.length === 0) {
49 container.innerHTML = '<li class="px-4 py-4 sm:px-6 text-gray-500">No job postings available.</li>';
69
70// Initialize job form submission
71export function initJobForm(formElement, onSuccess) {
72 formElement.addEventListener('submit', async (event) => {
73 event.preventDefault();

Jobstypes.ts2 matches

@Fatimaโ€ขUpdated 2 days ago
17}
18
19// Helper function to format dates
20export function formatDate(dateString: string): string {
21 const date = new Date(dateString);
22 return date.toLocaleString();

Jobsqueries.ts4 matches

@Fatimaโ€ขUpdated 2 days ago
20
21// Job posting queries
22export async function getAllJobs(): Promise<JobPosting[]> {
23 const result = await sqlite.execute(
24 `SELECT * FROM ${JOB_POSTINGS_TABLE} ORDER BY created_at DESC`
27}
28
29export async function createJob(job: Omit<JobPosting, "id" | "created_at">): Promise<JobPosting> {
30 const created_at = new Date().toISOString();
31
41
42// Chat message queries
43export async function getChatMessages(limit = 50): Promise<ChatMessage[]> {
44 const result = await sqlite.execute(
45 `SELECT * FROM ${CHAT_MESSAGES_TABLE}
51}
52
53export async function createChatMessage(message: Omit<ChatMessage, "id" | "created_at">): Promise<ChatMessage> {
54 const created_at = new Date().toISOString();
55

Jobsmigrations.ts1 match

@Fatimaโ€ขUpdated 2 days ago
5export const CHAT_MESSAGES_TABLE = "chat_messages_v1";
6
7export async function runMigrations() {
8 // Create job postings table
9 await sqlite.execute(`

JobsREADME.md1 match

@Fatimaโ€ขUpdated 2 days ago
25โ”‚ โ”œโ”€โ”€ database/
26โ”‚ โ”‚ โ”œโ”€โ”€ migrations.ts # Schema definitions
27โ”‚ โ”‚ โ””โ”€โ”€ queries.ts # DB query functions
28โ”‚ โ”œโ”€โ”€ routes/ # Route modules
29โ”‚ โ”‚ โ”œโ”€โ”€ jobs.ts # Job posting endpoints

WaitTimeProxymain.tsx1 match

@raymondcamdenโ€ขUpdated 2 days ago
1export async function main() {
2 let res = await fetch("https://queue-times.com/parks.json");
3 let data = await res.json();

Landing-Pageindex.ts4 matches

@charmaineโ€ขUpdated 2 days ago
1export default async function (req: Request) {
2 const html = `<!DOCTYPE html>
3<html lang="en">
463 <script>
464 // Mobile menu toggle
465 document.getElementById('mobile-menu-button').addEventListener('click', function() {
466 const mobileMenu = document.getElementById('mobile-menu');
467 mobileMenu.classList.toggle('hidden');
470 // Smooth scrolling for anchor links
471 document.querySelectorAll('a[href^="#"]').forEach(anchor => {
472 anchor.addEventListener('click', function (e) {
473 e.preventDefault();
474
494 // Add to cart animation
495 document.querySelectorAll('.product-card button').forEach(button => {
496 button.addEventListener('click', function() {
497 this.innerHTML = '<i class="fas fa-check"></i>';
498 setTimeout(() => {

Demostripe-to-discord.ts8 matches

@charmaineโ€ขUpdated 2 days ago
35 * Main handler for Stripe webhook events
36 */
37export default async function(req: Request): Promise<Response> {
38 // Only allow POST requests
39 if (req.method !== 'POST') {
96 * Format a Stripe event into a Discord message
97 */
98function formatStripeEventForDiscord(event: Stripe.Event): any {
99 // Base embed structure
100 const embed: any = {
162 * Send a formatted message to Discord
163 */
164async function sendToDiscord(webhookUrl: string, message: any): Promise<void> {
165 const response = await fetch(webhookUrl, {
166 method: 'POST',
180 * Format a human-readable title from an event type
181 */
182function formatEventTitle(eventType: string): string {
183 const parts = eventType.split('.');
184 const entity = parts[0];
211 * Get the appropriate color for an event type
212 */
213function getColorForEvent(eventType: string): number {
214 if (eventType.includes('succeeded') || eventType.includes('created') || eventType.includes('paid')) {
215 return COLORS.success;
228 * Format a currency amount
229 */
230function formatAmount(amount: number, currency: string): string {
231 const formatter = new Intl.NumberFormat('en-US', {
232 style: 'currency',
242 * Format a date range
243 */
244function formatDateRange(startTimestamp: number, endTimestamp: number): string {
245 const start = new Date(startTimestamp * 1000);
246 const end = new Date(endTimestamp * 1000);
260 * Get subscription plan name
261 */
262function getSubscriptionPlanName(subscription: Stripe.Subscription): string {
263 if (!subscription.items?.data?.length) {
264 return 'N/A';

automate-workflowsREADME.md1 match

@charmaineโ€ขUpdated 2 days ago
6
7- `types.ts` - TypeScript interfaces and types
8- `utils.ts` - Utility functions for parsing commits and generating markdown
9
10## Key Components

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.