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/$%7Bsuccess?q=function&page=137&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 21181 results for "function"(3015ms)

untitled-3025index.js1 match

@showloser•Updated 4 days ago
1export default async function (req) {
2 // Get the logo SVG content
3 const logoSvg = `<?xml version="1.0" encoding="UTF-8"?>

untitled-4689tts-fallback.ts1 match

@peteabu•Updated 4 days ago
9 * @returns Audio buffer containing the speech
10 */
11export async function simpleTTS(text: string): Promise<Uint8Array> {
12 try {
13 // Use a simple TTS service that doesn't require authentication

untitled-4689tts.ts5 matches

@peteabu•Updated 4 days ago
17 * @returns Array of script segments with speaker and text
18 */
19function parseScript(script: string): ScriptSegment[] {
20 console.log("Parsing script into segments...");
21 const segments: ScriptSegment[] = [];
65
66/**
67 * Fallback function to generate audio using a simpler approach
68 * This is used if the Google TTS integration fails
69 */
70async function fallbackTextToSpeech(script: string): Promise<Uint8Array> {
71 console.log("Using fallback TTS method...");
72
83 * @returns True if credentials are valid, false otherwise
84 */
85function validateCredentials(credentials: any): boolean {
86 if (!credentials) return false;
87
104 * @returns Audio buffer containing the podcast
105 */
106export async function textToSpeech(script: string, voices: string[] = ["en-US-Neural2-F", "en-US-Neural2-D"]): Promise<Uint8Array> {
107 try {
108 console.log("Starting text-to-speech conversion...");

untitled-4689index.ts1 match

@peteabu•Updated 4 days ago
200});
201
202function parseProject(url: string) {
203 const match = url.match(/v\/([^\/]+)\/([^\/]+)/);
204 return {

untitled-4689openai.ts1 match

@peteabu•Updated 4 days ago
14 * @returns A conversational podcast script
15 */
16export async function generatePodcastScript(title: string, content: string): Promise<string> {
17 // Truncate content to avoid exceeding token limits
18 const truncatedContent = truncateContent(content, 6000);

untitled-4689wikipedia.ts3 matches

@peteabu•Updated 4 days ago
1/**
2 * Utility functions for fetching and processing Wikipedia articles
3 */
4
13 * @returns The article title and content
14 */
15export async function fetchWikipediaArticle(articleInput: string): Promise<WikipediaArticle> {
16 // Extract title from URL if a URL is provided
17 let title = articleInput;
72 * @returns Truncated content
73 */
74export function truncateContent(content: string, maxLength: number = 8000): string {
75 if (content.length <= maxLength) {
76 return content;

untitled-5701index.js10 matches

@ihrodrigues•Updated 4 days ago
37
38// Função principal de inicialização
39async function inicializarApp() {
40 app = document.getElementById('app');
41
69
70// Carrega casas da API
71async function carregarCasas() {
72 try {
73 casasContainer.innerHTML = '<div class="col-span-full text-center py-10"><i class="fas fa-spinner fa-spin text-blue-600 text-3xl"></i></div>';
122
123// Renderiza as casas na interface
124function renderizarCasas() {
125 // Limpa o container
126 casasContainer.innerHTML = '';
169
170// Abre o modal de detalhes da casa
171function abrirDetalhesCasa(casa) {
172 const detalhesTemplate = document.getElementById('detalhes-casa-template');
173 const detalhesElement = document.importNode(detalhesTemplate.content, true);
207
208// Abre o formulário para adicionar nova casa
209function abrirFormularioCasa() {
210 const formTemplate = document.getElementById('form-casa-template');
211 const formElement = document.importNode(formTemplate.content, true);
229
230// Salva uma nova casa
231async function salvarNovaCasa(form) {
232 try {
233 // Obtém os dados do formulário
289
290// Aplica os filtros
291async function aplicarFiltros() {
292 // Atualiza o estado com os valores dos filtros
293 state.filtros.cidade = filtroCidade.value.trim();
301
302// Limpa os filtros
303async function limparFiltros() {
304 // Limpa os campos
305 filtroCidade.value = '';
321
322// Verifica se há filtros ativos
323function temFiltrosAtivos() {
324 return (
325 state.filtros.cidade ||
331
332// Formata o preço para exibição
333function formatarPreco(preco) {
334 return preco.toLocaleString('pt-BR');
335}

TownieuseUser.tsx1 match

@th3nolo•Updated 4 days ago
3const USER_ENDPOINT = "/api/user";
4
5export function useUser() {
6 const [data, setData] = useState<any>(null);
7 const [loading, setLoading] = useState(true);

TownieuseUsageStats.ts1 match

@th3nolo•Updated 4 days ago
1import { useEffect } from "react";
2
3export function useUsageStats(messages: any[], usages: any[]) {
4 useEffect(() => {
5 if (!messages?.length) return;

TownieuseScrollToBottom.tsx3 matches

@th3nolo•Updated 4 days ago
7 *
8 * @param {Array} dependencies - Array of dependencies that trigger scrolling when changed
9 * @returns {Object} An object containing containerRef and scrollToBottom function
10 */
11export function useScrollToBottomContainer(dependencies = []) {
12 const containerRef = useRef(null);
13
28
29// body scroll version
30export function useScrollToBottom(dependencies = []) {
31 const bottomRef = useRef(null);
32

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.