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/?q=function&page=630&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 17350 results for "function"(1469ms)

JokeGeneratormain.tsx2 matches

@nicholasstathos•Updated 3 weeks ago
1import { email } from "https://esm.town/v/std/email?v=9";
2
3async function fetchRandomJoke() {
4 const response = await fetch(
5 "https://official-joke-api.appspot.com/random_joke",
8}
9
10export async function emailRandomJoke() {
11 const randomJoke = await fetchRandomJoke();
12 const setup = randomJoke.setup;

skilledAquamarineAngelfishmain.tsx1 match

@simar•Updated 3 weeks ago
2
3// Fetches a random joke.
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",

testtest1 match

@wolf•Updated 3 weeks ago
1export default async function (req: Request): Promise<Response> {
2 return Response.json({ ok: true })
3}

testmain.tsx14 matches

@tallesjp•Updated 3 weeks ago
11];
12
13// URL validation function
14function isValidUrl(urlString: string): boolean {
15 try {
16 // Automatically prepend http:// if no protocol is specified
48}
49
50// Simple HTML sanitization function
51function sanitizeHtml(html: string): string {
52 // Basic HTML sanitization to prevent XSS
53 return html
75}
76
77export default async function server(request: Request): Promise<Response> {
78 try {
79 // Parse and validate URL
93}
94
95function validateAndGetUrl(request: Request): string {
96 const url = new URL(request.url);
97 const targetUrl = url.searchParams.get('url');
115}
116
117function renderInputPage(): string {
118 const sourceUrl = import.meta.url.replace('esm.town', 'val.town');
119 return `# URL to Markdown Converter 🔗📄
151}
152
153async function fetchWithTimeout(url: string): Promise<{
154 content: string;
155 contentType: string;
188}
189
190async function processResponse(
191 { content, contentType }: { content: string; contentType: string },
192 url: string
214}
215
216function createResponse({ content, status, headers = {} }: MarkdownResponse): Response {
217 return new Response(content, {
218 status,
225}
226
227function handleError(error: Error): Response {
228 const status = error instanceof FetchError ? error.status || 500 : 500;
229 const message = error.message || 'An unexpected error occurred';
237}
238
239async function convertHtmlToMarkdown(html: string): Promise<string> {
240 // Sanitize HTML first
241 const cleanHtml = sanitizeHtml(html);
256
257 // Process nodes recursively
258 function processNode(node: Element): string {
259 let result = '';
260
307}
308
309function convertJsonToMarkdown(json: any, depth: number = 0): string {
310 const indent = ' '.repeat(depth);
311

sophisticatedGreenOxmdtort3 matches

@charmaine•Updated 3 weeks ago
5import { createRoot } from "https://esm.sh/react-dom/client";
6
7function App() {
8 const [markdown, setMarkdown] = useState("");
9 const [html, setHtml] = useState("");
146}
147
148function client() {
149 createRoot(document.getElementById("root")).render(<App />);
150}
154}
155
156export default async function server(request: Request): Promise<Response> {
157 return new Response(
158 `

blogrender-markdown.ts1 match

@valdottown•Updated 3 weeks ago
10
11// Process markdown content
12export async function processMarkdown(content: string): Promise<string> {
13 const result = await unified()
14 .use(remarkParse)

newestindex.tsx1 match

@loading•Updated 3 weeks ago
4import { ValCard, ValList } from "./components/Card.tsx";
5
6function App() {
7 const [vals, setVals] = React.useState(null);
8 const [loading, setLoading] = React.useState(true);

reverseProxymod.ts1 match

@maxm•Updated 3 weeks ago
1export function newSingleHostReverseProxy(
2 target: string,
3): (req: Request) => Promise<Response> {

accurateIvoryElkmain.tsx2 matches

@vthopcherneni•Updated 3 weeks ago
1// Joke Generator Val
2
3// Async function to fetch joke and simulate sending an email
4async function jokeGeneratorVal() {
5 try {
6 // 1. Fetch a random joke

sampleweb1 match

@charmaine•Updated 3 weeks ago
1export default async function (req: Request): Promise<Response> {
2 return Response.json({ ok: true })
3}

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 1 week ago
Simple functional CSS library for Val Town
webup
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.
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": "*",