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=1645&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 18181 results for "function"(4007ms)

siversRssEmailNotificationCronmain.tsx1 match

@chet•Updated 1 year ago
1import siversRssEmailNotification from "https://esm.town/v/chet/siversRssEmailNotification";
2
3export default async function(interval: Interval) {
4 await siversRssEmailNotification(interval);
5}

siversRssEmailNotificationmain.tsx1 match

@chet•Updated 1 year ago
4import { parseXML } from "https://esm.town/v/stevekrouse/parseXML";
5
6export default async function(interval: Interval) {
7 // const lastRunAt = new Date(Date.now() - 1000 * 60 * 60 * 24 * 30 * 3);
8 const lastRunAt = interval.lastRunAt;

runnermain.tsx1 match

@buttondown•Updated 1 year ago
13 "buttondown.bsky.social",
14 ];
15 const promises = ALERT_STRINGS.map(async function(keyword) {
16 let posts = await fetchJSON(
17 `https://search.bsky.social/search/posts?q=${keyword}`,

sendMsgmain.tsx1 match

@envl•Updated 1 year ago
1import { im } from "https://esm.town/v/envl/im";
2
3export async function sendMsg(req: Request) {
4 const msg = new URL(req.url).searchParams.get("msg") ?? (await req.json()).msg;
5 await im(msg);

runGistmain.tsx1 match

@pomdtr•Updated 1 year ago
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=42";
3
4export default async function (req: Request) {
5 const url = new URL(req.url);
6 const [, id, action] = url.pathname.split("/");

myApimain.tsx1 match

@chrisk_7777•Updated 1 year ago
1let { userCount } = await import("https://esm.town/v/chrisk_7777/userCount");
2
3export function myApi(name) {
4 if (!userCount) {
5 userCount = [];

getSqliteDateMeDocsmain.tsx1 match

@stevekrouse•Updated 1 year ago
2import { zip } from "npm:lodash-es";
3
4export async function getDocs() {
5 let { columns, rows } = await sqlite.execute(`select * from DateMeDocs`);
6 return rows.map(row => Object.fromEntries(zip(columns, row.map(d => JSON.parse(d)))));

check_hfsmain.tsx1 match

@rejetto•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2export default async function(req: Request): Promise<Response> {
3 const p = Object.fromEntries(new URL(req.url).searchParams);
4 if (!p.url) return Response.json("missing url");

connect4_mcts_agentmain.tsx3 matches

@saolsen•Updated 1 year ago
9const SIMULATIONS = 10000;
10
11function rand_action(state: connect4.State): connect4.Action {
12 const player = state.next_player;
13 while (true) {
20}
21
22function score_action(
23 current_state: connect4.State,
24 action: connect4.Action,
51}
52
53function agent(state: connect4.State): connect4.Action {
54 // For each action we could take, simulate multiple random games from the resulting state.
55 // Keep track of the number of wins for each action.

connect4main.tsx7 matches

@saolsen•Updated 1 year ago
49export type Action = z.infer<typeof Action>;
50
51export function get(state: State, col: number, row: number): Slot {
52 return state.board[col][row];
53}
54
55export function set(state: State, col: number, row: number, slot: Slot): void {
56 state.board[col][row] = slot;
57}
63 | "column_out_of_bounds";
64
65export function check_action(state: State, action: Action): ActionCheck {
66 if (action.player !== state.next_player) {
67 return "wrong_player";
76}
77
78function check_slots_eq(a: Slot, b: Slot, c: Slot, d: Slot): Slot {
79 if (a === b && b === c && c === d) {
80 return a;
83}
84
85export function status(state: State): Status {
86 // Check Vertical Win
87 for (let col = 0; col < COLS; col++) {
150}
151
152export function apply_action(state: State, action: Action): Status {
153 // Action should be checked before calling this function.
154 // We assert that the action is ok.
155 let check = check_action(state, action);

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