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=105&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 21024 results for "function"(1999ms)

untitled-5961Toast.tsx1 match

@toowired•Updated 3 days ago
104
105// Toast Hook
106export function useToast() {
107 const [toasts, setToasts] = useState<ToastMessage[]>([]);
108

untitled-5961useFileProcessor.ts1 match

@toowired•Updated 3 days ago
17}
18
19export function useFileProcessor() {
20 const [state, setState] = useState<FileProcessorState>({
21 isProcessing: false,

untitled-5961useTTS.ts4 matches

@toowired•Updated 3 days ago
1// hooks/useTTS.ts - TTS functionality with background processing and queue management
2import { useCallback, useEffect, useRef, useState } from "react";
3import { ttsCache } from "../lib/ttsCache";
20}
21
22export function useTTS() {
23 const [state, setState] = useState<TTSState>({
24 voices: [],
383}
384
385// Helper function to estimate audio duration
386function estimateDuration(text: string, rate: number = 1): number {
387 const wordsPerMinute = 150 * rate; // Base rate adjusted by speed
388 const wordCount = text.split(/\s+/).length;

untitled-5961useLibrary.ts2 matches

@toowired•Updated 3 days ago
4import { AudioChunk, Collection, LibraryItem, ProcessedDocument } from "../lib/types";
5
6export function useLibrary() {
7 const [items, setItems] = useState<LibraryItem[]>([]);
8 const [collections, setCollections] = useState<Collection[]>([]);
277 }, []);
278
279 // Export/Import functionality
280 const exportLibrary = useCallback(async (): Promise<string> => {
281 try {

untitled-5961useAudioPlayer.ts1 match

@toowired•Updated 3 days ago
15}
16
17export function useAudioPlayer() {
18 const [state, setState] = useState<AudioPlayerState>({
19 isPlaying: false,

untitled-5961tts.ts9 matches

@toowired•Updated 3 days ago
25}
26
27export default async function handler(req: Request, context: HandlerContext) {
28 const { method } = req;
29 const url = new URL(req.url);
77 * Handle voice list requests
78 */
79async function handleGetVoices(req: Request, headers: Headers): Promise<Response> {
80 const url = new URL(req.url);
81 const apiKey = url.searchParams.get("apiKey");
139 * Handle single text synthesis
140 */
141async function handleSynthesize(req: Request, headers: Headers): Promise<Response> {
142 const requestData: TTSRequest = await req.json();
143 const { text, voice, settings, apiKey, chunkId } = requestData;
205 * Handle batch synthesis for multiple chunks
206 */
207async function handleBatchSynthesize(req: Request, headers: Headers): Promise<Response> {
208 const { chunks, voice, settings, apiKey } = await req.json() as {
209 chunks: Array<{ id: string; text: string }>;
282 * Synthesize text with Google TTS API
283 */
284async function synthesizeWithGoogle(
285 text: string,
286 voice: TTSVoice,
344 * Get voice quality tier
345 */
346function getVoiceQuality(voiceName: string): string {
347 if (voiceName.includes("Studio")) return "studio";
348 if (voiceName.includes("Wavenet")) return "wavenet";
354 * Get voice pricing information
355 */
356function getVoicePricing(voiceName: string): {
357 tier: string;
358 pricePerMillionChars: number;
375 * Estimate audio duration based on text and speaking rate
376 */
377function estimateAudioDuration(text: string, rate: number = 1): number {
378 const wordsPerMinute = 150 * rate; // Base rate of 150 WPM
379 const wordCount = text.split(/\s+/).length;
384 * Generate unique chunk ID
385 */
386function generateChunkId(): string {
387 return `chunk_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
388}

untitled-5961audioUtils.ts1 match

@toowired•Updated 3 days ago
3
4/**
5 * Audio utility functions for processing, combining, and analyzing audio data
6 */
7export class AudioUtils {

untitled-5961ttsCache.ts3 matches

@toowired•Updated 3 days ago
27
28 /**
29 * Simple hash function for text
30 */
31 private hashCode(str: string): number {
180 voice: TTSVoice,
181 settings: TTSSettings,
182 synthesizeFunction: (text: string, voice: TTSVoice, settings: TTSSettings) => Promise<string>,
183 ): Promise<void> {
184 const prefetchPromises = texts
187 .map(async text => {
188 try {
189 const audioData = await synthesizeFunction(text, voice, settings);
190 await this.set(text, voice, settings, audioData);
191 } catch (error) {
hanabi

hanabiREADME.md2 matches

@jxnblk•Updated 3 days ago
10import hanabi from "https://esm.town/v/jxnblk/hanabi/main.tsx";
11
12function Home () {
13 return (
14 <div>
20}
21
22function About () {
23 return (
24 <div>

doorREADME.md1 match

@valdottown•Updated 3 days ago
20
21- `main.tsx`: The main application file with Hono routes and UI components
22- `utils.tsx`: Utility functions for Switchbot API authentication and requests
23- `styles.tsx`: CSS styles for the web interface

getFileEmail4 file matches

@shouser•Updated 3 weeks ago
A helper function to build a file's email
tuna

tuna8 file matches

@jxnblk•Updated 4 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.