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=107&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 21039 results for "function"(1627ms)

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

FullstackStarterhome.tsx1 match

@wolf•Updated 3 days ago
3import { Link } from "https://esm.sh/react-router@7";
4
5export function Component() {
6 return (
7 <div className="flex flex-col items-center justify-center min-h-[50vh]">

FullstackStarterindex.tsx2 matches

@wolf•Updated 3 days ago
4
5// HTML wrapper component
6function HTML({ children }: { children: React.ReactNode }) {
7 return (
8 <html lang="en">
23
24// Root layout component
25export function Component() {
26 return (
27 <HTML>

EEPPortalApp.tsx6 matches

@solomonferede•Updated 3 days ago
26};
27
28// --- Helper Functions ---
29async function hashPassword(password) {
30 const encoder = new TextEncoder();
31 const data = encoder.encode(password);
37
38// --- Main App Component ---
39function App() {
40 const [user, setUser] = useState(null);
41 // Add 'profile' and 'task' to the possible views
460Client-side Entry Point
461==========================*/
462function client() {
463 const rootElement = document.getElementById("root");
464 if (rootElement) {
476Server-side Logic
477==========================*/
478export default async function server(
479 request, /*: Request // Removed type for broader compatibility if not in TS env */
480) /*: Promise<Response>*/ {
1810 if (path === "/" && method === "GET") {
1811 // The module script src will be this file itself.
1812 // The client() function will be called.
1813 // The component imports like "./components/login.tsx" will be resolved by the environment
1814 // (e.g., Val Town's bundler or a local dev server/bundler).

FullstackStarterroutes.tsx2 matches

@wolf•Updated 3 days ago
5import { Home } from "./frontend/routes/Home.tsx";
6
7function HTML({ children }: { children: React.ReactNode }) {
8 return (
9 <html lang="en">
23}
24
25function Layout() {
26 return (
27 <HTML>

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.