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=2663&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 29317 results for "function"(4767ms)

TanStackBlogToRSSmain.tsx2 matches

@vogelino•Updated 1 year ago
2import { DOMParser } from "npm:linkedom@0.16.10";
3
4function response(message: string, contentType = "text/markdown"): Response {
5 const headers = new Headers();
6 headers.set("Access-Control-Allow-Origin", "*");
15}
16
17export default async function(req: Request): Promise<Response> {
18 const url = new URL(`https://tanstack.com/blog`);
19 const html = await fetch(url.toString(), {

story_wordcountmain.tsx11 matches

@willthereader•Updated 1 year ago
9
10// Fetch the HTML content of the given URL
11async function fetchHtml(url: string): Promise<string> {
12 const response = await fetch(url, {
13 method: "GET",
31
32// Extract titles by manually parsing the HTML content
33function titleExtractor(html: string): string[] {
34 const regex = /<a[^>]*href="([^"]*threads\/[^"]*)"[^>]*class="[^"]*contentRow-title[^"]*">/g;
35 const titles = [];
44
45// Generates RSS feed links from a base URL
46function urlGenerator(url: string) {
47 return [
48 `${url}threadmarks.rss?threadmark_category=13`,
51}
52
53// Utility function to delay execution
54function delay(ms: number): Promise<void> {
55 return new Promise(resolve => setTimeout(resolve, ms));
56}
57
58// Verifies the validity of each feed URL by checking its contents
59async function urlVerifier(feeds: string[]): Promise<string[]> {
60 const usefulUrls: string[] = [];
61
94
95
96// Main function to execute the scraping process
97async function main() {
98 const baseUrl = "https://forums.spacebattles.com/search/69363141/?t=post&c[content]=thread&c[users]=3ndless&o=date";
99 try {
143}
144
145// Main function to process the flow
146async function main(): Promise<number[]> {
147 const titles = titleExtractor();
148 // console.log("Titles Extracted:", titles); // Debugging log
157}
158
159// Example of how to call the main function and handle the result
160main().then(wordCounts => {
161 console.log("Final Output:", wordCounts);

mdConvertmain.tsx1 match

@nbbaier•Updated 1 year ago
9});
10
11export default async function handler(request: Request) {
12 if (request.method !== "POST") {
13 return html(`

prism_feature_notificationsmain.tsx3 matches

@kishore•Updated 1 year ago
5const confidenceThreshold = 0.8;
6
7function randomlyPickFeature(featuresAboveConfidenceThreshold) {
8 return featuresAboveConfidenceThreshold[Math.floor(Math.random() * featuresAboveConfidenceThreshold.length)];
9}
10
11function getFeatureLink(feature) {
12 const { index } = feature;
13 return `https://thesephist--prism-start-app.modal.run/f/${modelName}/${index}?layout=2`;
14}
15
16export default async function(interval: Interval) {
17 const response = await fetch(dictionaryUrl);
18 const { features } = await response.json();

dailyDadJokemain.tsx1 match

@zhanziyang•Updated 1 year ago
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3
4export async function dailyDadJoke() {
5 let { setup, punchline } = await fetchJSON("https://official-joke-api.appspot.com/random_joke");
6 return email({

greenTigermain.tsx1 match

@maxm•Updated 1 year ago
2import { renderToString } from "npm:react-dom/server";
3
4export default async function(req: Request): Promise<Response> {
5 return new Response(
6 renderToString(

imgGenUrlmain.tsx1 match

@andrewgao•Updated 1 year ago
6};
7
8export default async function(req: Request): Promise<Response> {
9 let key = new URL(req.url).pathname;
10

honoBasicAuthMiddlewaremain.tsx2 matches

@jdan•Updated 1 year ago
2import { createMiddleware } from "npm:hono/factory";
3
4export function honoBasicAuthMiddleware(secretUsername: string, secretPassword: string) {
5 return createMiddleware(async (c, next) => {
6 const authHeader = c.req.header("authorization");
31 * and save those credentials to storage for subsequent requests
32 */
33function promptForAuth(c) {
34 c.header("WWW-Authenticate", "Basic realm=\"Secure Area\"");
35 return c.text("Unauthorized", 401);

aquamarinePiranhamain.tsx1 match

@maxm•Updated 1 year ago
2const resp = await fetch("https://maxm-wasmblobhost.web.val.run/e5vpzt253pv5jxqfmygo7nytl5uvyn5c.wasm");
3const handler = await wasmHandler(new Uint8Array(await resp.arrayBuffer()));
4export default async function(req: Request): Promise<Response> {
5 return handler(req);
6}

compileAndUploadTinygoWasmmain.tsx1 match

@maxm•Updated 1 year ago
59const resp = await fetch("${url}");
60const handler = await wasmHandler(new Uint8Array(await resp.arrayBuffer()));
61export default async function(req: Request): Promise<Response> {
62 return handler(req);
63}`);
tuna

tuna9 file matches

@jxnblk•Updated 1 day ago
Simple functional CSS library for Val Town

getFileEmail4 file matches

@shouser•Updated 1 month ago
A helper function to build a file's email
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.