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=2653&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 29011 results for "function"(2201ms)

purpleBeemain.tsx1 match

@rayman•Updated 1 year ago
1export default async function(req: Request) {
2 if (req.method === "POST") {
3 const name = (await req.formData()).get("name");

aqimain.tsx1 match

@ayush73•Updated 1 year ago
2import { easyAQI } from "https://esm.town/v/stevekrouse/easyAQI";
3
4export async function aqi(interval: Interval) {
5 const location = "Dallas"; // <-- change to place, city, or zip code
6 const data = await easyAQI({ location });

NintendoSydmain.tsx1 match

@lirenxn•Updated 1 year ago
1import { email } from "https://esm.town/v/std/email";
2
3export default async function(interval: Interval) {
4 const resp = await fetch("https://www.nintendo.com/au/nintendo-live-2024-sydney");
5 const html = await resp.text();

passkey_scriptmain.tsx7 matches

@stevekrouse•Updated 1 year ago
20
21const _logEl = document.getElementById("logs");
22function log(message) {
23 console.log(message);
24 _logEl.innerHTML += `<pre>${JSON.stringify(message, null, 2)}</pre>`;
28
29const _statusEl = document.getElementById("status");
30function status(message) {
31 _statusEl.hidden = false;
32 _statusEl.innerText = message;
34}
35
36async function postJson(url, body?) {
37 return await fetch(url, {
38 method: "POST",
42}
43
44async function handleRegister() {
45 const username = document.getElementById("name").value;
46
57}
58
59async function startAuth(options, conditional) {
60 await SimpleWebAuthnBrowser.startAuthentication(options, conditional)
61 .then(log)
74});
75
76async function handleLogin() {
77 const username = document.getElementById("name").value;
78
80}
81
82async function handleLogout() {
83 await postJson("/logout");
84 status("✅ Logged out!");

passkeys_demomain.tsx3 matches

@stevekrouse•Updated 1 year ago
23
24// UTILS
25function generateJWT(userId: string) {
26 return new SignJWT({ userId }).setProtectedHeader({ alg: "HS256" }).sign(SECRET);
27}
28function verifyJWT(token: string) {
29 return jwtVerify(token, SECRET);
30}
31function generateRandomString() {
32 return Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
33}

connect4_agent_randmain.tsx1 match

@saolsen•Updated 1 year ago
9import { agentHandler } from "https://esm.town/v/saolsen/gameplay_agent";
10
11function rand_action(
12 state: Connect4State,
13 agent_data?: { counter: number },

poker_agent_foldsmain.tsx1 match

@saolsen•Updated 1 year ago
7} from "https://esm.town/v/saolsen/gameplay_poker";
8
9function fold_action(
10 view: PokerView,
11 _agent_data?: JsonObject,

poker_agent_all_inmain.tsx1 match

@saolsen•Updated 1 year ago
8} from "https://esm.town/v/saolsen/gameplay_poker";
9
10function agent(view: PokerView, _agent_data?: JsonObject): PokerAgentResponse {
11 const round = view.rounds[view.round];
12 const player = round.active_player;

connect4_agent_mctsmain.tsx3 matches

@saolsen•Updated 1 year ago
11const SIMULATIONS = 10000;
12
13function rand_action(state: Connect4State): Connect4Action {
14 const player = state.active_player;
15 while (true) {
22}
23
24function score_action(
25 current_state: Connect4State,
26 action: Connect4Action,
63}
64
65function agent(state: Connect4State): Connect4AgentResponse {
66 // For each action we could take, simulate multiple random games from the resulting state.
67 // Keep track of the number of wins for each action.

gameplay_agentmain.tsx5 matches

@saolsen•Updated 1 year ago
83 /** The name of the agent. */
84 agentname: string;
85 /** The agent function. */
86 agent: Connect4Agent<T> | Connect4AsyncAgent<T>;
87}
99 /** The name of the agent. */
100 agentname: string;
101 /** The agent function. */
102 agent: PokerAgent<T> | PokerAsyncAgent<T>;
103}
121 * a variety of different http server libraries.
122 *
123 * To see how to write the agent functions,
124 * see the {@link Connect4Agent} and {@link PokerAgent}
125 *
134 * used with an http server that supports the fetch interface.
135 */
136export function agentHandler<
137 T extends Json = Json,
138>(
139 agents: AgentSpec<T>[],
140): (req: Request) => Promise<Response> {
141 return async function(request: Request): Promise<Response> {
142 if (request.method === "GET") {
143 return Response.json({
tuna

tuna9 file matches

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