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=763&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 7802 results for "function"(424ms)

pinkEgretmain.tsx1 match

@maxm•Updated 9 months ago
1// import { Request, Response } from "./node_modules/express/index.js";
2export default async function(req: Request): Promise<Response> {
3 console.log("Request received:", req);
4

brownPelicanmain.tsx1 match

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

cronLoggermain.tsx2 matches

@nbbaier•Updated 9 months ago
5import { refs } from "https://esm.town/v/stevekrouse/refs?v=11";
6
7type CronFunction = (interval: Interval) => Promise<void>;
8
9export const cronEvalLogger = (cron: CronFunction): CronFunction => {
10 let interval: Interval;
11 const cronProxy = new Proxy(cron, {

uptimemain.tsx1 match

@stevekrouse•Updated 10 months ago
6);
7
8export async function uptimeCheck(url: string) {
9 let reason: string, status: number, end: number;
10 let ok = true;

staticChessREADME.md1 match

@tmcw•Updated 10 months ago
9Plain, brutalist, no bloat chess. Every page is only html and css. Every chess move is made by clicking a link. Send a link to your friend and they'll send you one back to make your move. No silly animations or slick interactivity to trip up your gameplay. When Google indexes this site will we successfully compute all possible chess moves?
10
11Functionality is quite limited, and things might be broken. Please let me know if you find bugs!
12
13Inspired by [this HN discussion](https://news.ycombinator.com/item?id=39456467) about sites that have all possible game states of tic-tac-toe.

mootexmain.tsx1 match

@maxm•Updated 10 months ago
23};
24
25export default async function(req: Request): Promise<Response> {
26 const pageContent = renderToString(
27 <html>

test_explorer_routermain.tsx2 matches

@maxm•Updated 10 months ago
63});
64
65async function loadTests(): Promise<TestType[]> {
66 const query = `https://esm.town/v/${author}/test_explorer`;
67 const { data: vals } = await api(`/v1/search/vals?query=${query}`, { authenticated: true });
90}
91
92async function loadHistory(): Promise<HistoryEntry[]> {
93 try {
94 const entries = await readHistory();

routermain.tsx2 matches

@maxm•Updated 10 months ago
62});
63
64async function loadTests(): Promise<TestType[]> {
65 const query = `https://esm.town/v/${author}/test_explorer`;
66 const { data: vals } = await api(`/v1/search/vals?query=${query}`, { authenticated: true });
89}
90
91async function loadHistory(): Promise<HistoryEntry[]> {
92 try {
93 const entries = await readHistory();

blobbyFacemain.tsx4 matches

@stevekrouse•Updated 10 months ago
17
18
19async function streamToBuffer(stream) {
20 const chunks = [];
21 const reader = stream.getReader();
32}
33
34async function detectFileType(buffer) {
35 const type = await fileTypeFromBuffer(buffer);
36 // return type ? type.mime : 'unknown';
42
43
44export async function get(key, c) {
45 let result = await blobby.get(key);
46 // console.log('raw result for key:', result, typeof result);
185 newKeyName: '',
186
187 init: async function() {
188 console.log('blobby:', this.blobby);
189 },

counterTownmain.tsx6 matches

@stevekrouse•Updated 10 months ago
4import { Hono } from "npm:hono";
5
6function setupTable() {
7 return sqlite.execute(`create table if not exists counter_town (
8 time timestamp default current_timestamp,
21// TODO - we should probably not expose this to our users
22// this rewrite removes that and stores the url underneath
23function removeCustomDomainRewriter(req) {
24 const servedFor = req.headers.get("x-served-for");
25 return req.url.replace("saascustomdomains.val.run", servedFor);
26}
27
28function countRequest(req: Request) {
29 console.log(req);
30 return sqlite.execute({
41}
42
43export function counterTownMiddleware(handler) {
44 return async function(req: Request) {
45 // don't await this so it doesn't add to the timing
46 countRequest(req).catch(e => console.error(e));
125
126// zipped execute
127async function execute(sql) {
128 const results = await sqlite.execute(sql);
129 return results.rows.map(row =>

getFileEmail4 file matches

@shouser•Updated 6 days ago
A helper function to build a file's email

TwilioHelperFunctions

@vawogbemi•Updated 2 months ago