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=1651&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 18167 results for "function"(1741ms)

vtIdeasTemplatemain.tsx1 match

@nbbaier•Updated 1 year ago
3import { html } from "https://esm.town/v/stevekrouse/html?v=5";
4
5export async function examplePost(req: Request) {
6 const { author, name } = extractValInfo(import.meta.url);
7

downloadmain.tsx1 match

@kutan•Updated 1 year ago
2import Jimp from "npm:jimp";
3
4export async function download(req: Request): Promise<Response> {
5 // Return the picture as a response
6 const searchParams = new URL(req.url).searchParams;

aoc23_08main.tsx7 matches

@karfau•Updated 1 year ago
22).to.equal(6);
23
24function firstStar(input: string) {
25 const [directions, ...mapRaw] = input.split("\n").filter((line) => Boolean(line.trim()));
26 const map = Object.fromEntries(mapRaw.map(line => {
58).to.equal(6);
59// expect(secondStar(``), "*2 sample 2").to.equal("?");
60function secondStar(input: string) {
61 const [directions, ...mapRaw] = input.split("\n").filter((line) => Boolean(line.trim()));
62 const map = Object.fromEntries(mapRaw.map(line => {
84console.log("solution *2:", secondStar(input()));
85
86function input() {
87 return `LLLRRLRRRLLRRLRRLLRLRRLRRRLRRLRRLRRRLRLRRLRLRRLRRLLRRLRLLRRLLLRRRLRRLRLRLRRRLRLLRRLRRRLRRLRRLRRLRLLRLLRRLRRRLRRLRLRRLRRRLRRLLRLLRRLRRRLLRRRLRLRRRLLRLRRLRRLLRRLRRLLLRRRLRLRRRLRRLLRLRRLRLLRRRLRLRLLRLRRRLRLRRRLRRLRLRLLRLRRRLRRLRRRLRRRLRLRRRLRRRLLLLRLRLRRRLLLRLRRRLRRLRLRRLLRLLRRRR
88
831}
832
833function toInt(s: string) {
834 return parseInt(s);
835}
836function extractNumbers(line: string) {
837 return line.match(/\d+/g).map(toInt);
838}
839// [0,1,2,3].reduce(sum, 0) => 6
840function sum(sum: number, current: number) {
841 return sum + current;
842}
843// wrap a value to print and return it
844function debug<T>(value: T, msg = "debug"): T {
845 console.log(msg, value);
846 return value;

githubEmojimain.tsx1 match

@karfau•Updated 1 year ago
9export const githubEmojiNames = (): string[] => Object.keys(GITHUB_EMOJIS);
10
11export default async function githubEmoji(req: Request): Promise<Response> {
12 const contentType = req.headers.get("Content-Type");
13

aoc23_07main.tsx8 matches

@karfau•Updated 1 year ago
25// expect(firstStar(``), "*1 sample 2").to.equal("?");
26
27function firstStar(input: string) {
28 const bids = Object.fromEntries(
29 input.split("\n").map(l => {
61expect(secondStar(sample), "*2 sample 1").to.equal(5905);
62// expect(secondStar(``), "*2 sample 2").to.equal("?");
63function withJokers(jokers: number, first: number, second: number) {
64 switch (first) {
65 case 5:
83}
84
85function secondStar(input: string) {
86 const bids = Object.fromEntries(
87 input.split("\n").map(l => {
110console.log("solution *2:", secondStar(input()));
111
112function input() {
113 return `Q94A5 121
114AQ56Q 611
1113}
1114
1115function toInt(s: string) {
1116 return parseInt(s);
1117}
1118function extractNumbers(line: string) {
1119 return line.match(/\d+/g).map(toInt);
1120}
1121// [0,1,2,3].reduce(sum, 0) => 6
1122function sum(sum: number, current: number) {
1123 return sum + current;
1124}
1125// wrap a value to print and return it
1126function debug<T>(value: T, msg = "debug"): T {
1127 console.log(msg, value);
1128 return value;

aocXX_00main.tsx7 matches

@karfau•Updated 1 year ago
4// expect(firstStar(``), "*1 sample 2").to.equal("?");
5
6function firstStar(input: string) {
7 return "expected output"; // implement :)
8}
12expect(secondStar(``), "*2 sample 1").to.equal("?");
13// expect(secondStar(``), "*2 sample 2").to.equal("?");
14function secondStar(input: string) {
15 return "?";
16}
17console.log("solution *2:", secondStar(input()));
18
19function input() {
20 return ``;
21}
22
23function toInt(s: string) {
24 return parseInt(s);
25}
26function extractNumbers(line: string) {
27 return line.match(/\d+/g).map(toInt);
28}
29// [0,1,2,3].reduce(sum, 0) => 6
30function sum(sum: number, current: number) {
31 return sum + current;
32}
33// wrap a value to print and return it
34function debug<T>(value: T, msg = "debug"): T {
35 console.log(msg, value);
36 return value;

aoc23_06main.tsx7 matches

@karfau•Updated 1 year ago
8// expect(firstStar(``), "*1 sample 2").to.equal("?");
9
10function firstStar(input: string) {
11 const [times, distances] = input.split("\n").map(extractNumbers);
12 const winnings: number[] = times.map((time, i) => {
31).to.equal(71503);
32// expect(secondStar(``), "*1 sample 2").to.equal("?");
33function secondStar(input: string) {
34 return firstStar(input.replace(/[ ]+/g, ""));
35}
36console.log("solution *2:", secondStar(input()));
37
38function input() {
39 //
40 return `Time: 41 77 70 96
42}
43
44function toInt(s: string) {
45 return parseInt(s);
46}
47function extractNumbers(line: string) {
48 return line.match(/\d+/g).map(toInt);
49}
50// [0,1,2,3].reduce(sum, 0) => 6
51function sum(sum: number, current: number) {
52 return sum + current;
53}
54// wrap a value to print and return it
55function debug<T>(value: T, msg = "debug"): T {
56 console.log(msg, value);
57 return value;

basicAuthREADME.md2 matches

@pomdtr•Updated 1 year ago
10import { basicAuth } from "https://esm.town/v/pomdtr/basicAuth";
11
12function handler(req: Request) {
13 return new Response("You are authenticated!");
14}
23import { verifyToken } from "https://www.val.town/v/pomdtr/verifyToken"
24
25function handler(req: Request) {
26 return new Response("You are authenticated!");
27}

simpleJsonReplymain.tsx1 match

@jamiedubs•Updated 1 year ago
1// View at https://stevekrouse-expressHTMLExample.express.val.run?name=Steve
2export async function expressHTMLExample(
3 req: express.Request,
4 res: express.Response,

sqlite_admin_tablemain.tsx1 match

@stevekrouse•Updated 1 year ago
3import { css } from "https://esm.town/v/stevekrouse/sqlite_admin_css";
4
5export async function sqlite_admin_table(name: string) {
6 if (!name.match(/^[A-Za-z_][A-Za-z0-9_]*$/)) return <>Invalid table name</>;
7 let data = await sqlite.execute(`SELECT * FROM ${name}`);

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
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": "*",