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=1571&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 18400 results for "function"(3791ms)

dailyDadJokemain.tsx1 match

@zhanziyang•Updated 11 months 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 11 months 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 11 months 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 11 months 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 11 months 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 11 months 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}`);

translatormain.tsx2 matches

@stevekrouse•Updated 11 months ago
348
349
350 // Helper function to get the supported MIME type
351 function getSupportedMimeType() {
352 const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
353 const mimeTypes = [

homelessmain.tsx4 matches

@cameronpak•Updated 11 months ago
81 * @return {number} the distance in miles
82 */
83function convertMetersToMiles(meters: number): number {
84 return 0.000621371 * meters;
85}
86
87// Round a number to the nearest quarter.
88function roundToQuarter(number: number) {
89 let remainder = number % 1;
90
114 * @return {SearchParams | SearchParamsWithPreset} The constructed search parameters.
115 */
116function constructTypesenseParams({
117 query,
118 lat,
158 * @return {Promise<any>} A Promise that resolves to an array of resources matching the search criteria.
159 */
160export async function getResources({
161 lat,
162 lng,

tinygoWasmHelloWorldmain.tsx1 match

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

wasmBlobHostmain.tsx7 matches

@maxm•Updated 11 months ago
10const WASM_BLOB_PREFIX = `${author}-${name}-wasm-wasm-blob-v1-`;
11
12async function readAllBytes(stream: ReadableStream<Uint8Array>): Promise<Buffer> {
13 const reader = stream.getReader();
14 const chunks: Uint8Array[] = [];
25}
26
27function getSha256Hash(buffer: Buffer): string {
28 return base32Encode(
29 createHash("sha256").update(buffer).digest().slice(0, 20),
32 ).toLowerCase();
33}
34function trimPrefix(str, prefix) {
35 if (str.startsWith(prefix)) {
36 return str.slice(prefix.length);
38 return str;
39}
40function trimSuffix(str, suffix) {
41 if (str.endsWith(suffix)) {
42 return str.slice(0, -suffix.length);
52};
53
54function formatBytes(bytes: number): string {
55 if (bytes === 0) return "0B";
56
64}
65
66function relativeTimeFromNow(dateString: string): string {
67 const now = new Date();
68 const date = new Date(dateString);
83}
84
85export default async function(req: Request): Promise<Response> {
86 if (req.method === "POST") {
87 const body = await readAllBytes(req.body);

getFileEmail4 file matches

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

tuna8 file matches

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