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=2728&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 28929 results for "function"(4286ms)

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}`);

nftMetadatamain.tsx2 matches

@jamiedubs•Updated 1 year ago
2import process from "node:process";
3
4export async function fetchNftMetadata(contractAddress: string, tokenId: string) {
5 const apiKey = process.env.ALCHEMY_API_KEY;
6 const rpcUrl = `https://eth-mainnet.g.alchemy.com/nft/v2/${apiKey}`;
25}
26
27export default async function nftMetadata(req: Request): Promise<Response> {
28 const searchParams = new URL(req.url).searchParams;
29 const contractAddress = searchParams.get("contractAddress");

untitled_bronzeCoralmain.tsx1 match

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

untitled_amethystShrewmain.tsx1 match

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

aoc23_05main.tsx5 matches

@karfau•Updated 1 year ago
60// expect(firstStar(``), "*1 sample 2").to.equal("?");
61
62function firstStar(input: string) {
63 const [, seedsInput, ...mapsInput] = input.split(/\s*[a-z -]+:\s*/m);
64 const seeds = extractNumbers(seedsInput);
71expect(secondStar(sample), "*2 sample 1").to.equal(46);
72// expect(secondStar(``), "*1 sample 2").to.equal("?");
73function secondStar(input: string) {
74 const [, seedsInput, ...mapsInput] = input.split(/\s*[a-z -]+:\s*/m);
75 const maps = mapsInput.map(parseMap);
91console.log("solution *2:", secondStar(input()));
92
93function input() {
94 return `seeds: 3121711159 166491471 3942191905 154855415 3423756552 210503354 2714499581 312077252 1371898531 165242002 752983293 93023991 3321707304 21275084 949929163 233055973 3626585 170407229 395618482 226312891
95
282
283// [0,1,2,3].reduce(sum, 0) => 6
284function sum(sum: number, current: number) {
285 return sum + current;
286}
287// wrap a value to print and return it
288function debug<T>(value: T, msg = "debug"): T {
289 console.log(msg, value);
290 return value;

untitled_coralGerbilmain.tsx1 match

@lokyeyoung_create•Updated 1 year ago
2
3// Fetches a random joke.
4function fetchRandomJoke() {
5 const SAMPLE_JOKE = {
6 "setup": "What do you call a group of disorganized cats?",
tuna

tuna9 file matches

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