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/$%7Bart_info.art.src%7D?q=function&page=2757&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 29291 results for "function"(7422ms)

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

twitterWrappermain.tsx1 match

@stevekrouse•Updated 1 year ago
2import { twitterJSON } from "https://esm.town/v/stevekrouse/twitterJSON";
3
4export default async function(req: Request): Promise<Response> {
5 if (req.headers.get("authorization") !== "Bearer " + Deno.env.get("boozedog"))
6 return Response.json("Unauthorized", { status: 401 });

myApimain.tsx1 match

@boozedog•Updated 1 year ago
1export function myApi(name) {
2 return "hi " + name;
3}

untitled_harlequinDragonmain.tsx1 match

@bantic•Updated 1 year ago
1export default function() {
2 console.log("hi");
3 return "foo";

use_example_rust_http_valmain.tsx1 match

@saolsen•Updated 1 year ago
1import { handler } from "https://esm.town/v/saolsen/example_rust_http_val";
2
3export default async function(req: Request): Promise<Response> {
4 let response = handler(req.method, req.url, await req.text());
5 console.log(response);

example_rust_http_valmain.tsx12 matches

@saolsen•Updated 1 year ago
17let cachedUint8Memory0 = null;
18
19function getUint8Memory0() {
20 if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
21 cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
24}
25
26function getStringFromWasm0(ptr, len) {
27 ptr = ptr >>> 0;
28 return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
33let cachedTextEncoder = new TextEncoder("utf-8");
34
35const encodeString = typeof cachedTextEncoder.encodeInto === "function"
36 ? function(arg, view) {
37 return cachedTextEncoder.encodeInto(arg, view);
38 }
39 : function(arg, view) {
40 const buf = cachedTextEncoder.encode(arg);
41 view.set(buf);
46 };
47
48function passStringToWasm0(arg, malloc, realloc) {
49 if (realloc === undefined) {
50 const buf = cachedTextEncoder.encode(arg);
85let cachedInt32Memory0 = null;
86
87function getInt32Memory0() {
88 if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
89 cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
96heap.push(undefined, null, true, false);
97
98function getObject(idx) {
99 return heap[idx];
100}
102let heap_next = heap.length;
103
104function dropObject(idx) {
105 if (idx < 132) return;
106 heap[idx] = heap_next;
108}
109
110function takeObject(idx) {
111 const ret = getObject(idx);
112 dropObject(idx);
119 * @returns {string}
120 */
121export const handler = imports.handler = function(method, url, _body) {
122 let deferred5_0;
123 let deferred5_1;
151};
152
153export const __wbg_log_18b11754c5793c04 = imports.__wbg_log_18b11754c5793c04 = function(arg0, arg1) {
154 console.log(getStringFromWasm0(arg0, arg1));
155};

valtownGeocitiesmain.tsx3 matches

@jamiedubs•Updated 1 year ago
1import { blob } from "https://esm.town/v/std/blob?v=10";
2
3function isJSON(input: string | null | undefined) {
4 if (!input || input === null) return false;
5 try {
11}
12
13function processInputHtml(html: string) {
14 let output = html;
15
21}
22
23function formatPage(key: string, data: string) {
24 return `
25 ${data}

example_rust_valmain.tsx5 matches

@saolsen•Updated 1 year ago
20let cachedUint8Memory0 = null;
21
22function getUint8Memory0() {
23 if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
24 cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
27}
28
29function getStringFromWasm0(ptr, len) {
30 ptr = ptr >>> 0;
31 return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
32}
33/** */
34export const say_hello = (imports.say_hello = function() {
35 wasm.say_hello();
36});
41 * @returns {number}
42 */
43export const add = (imports.add = function(x, y) {
44 const ret = wasm.add(x, y);
45 return ret;
46});
47
48export const __wbg_log_08850d6d4d91f4c9 = (imports.__wbg_log_08850d6d4d91f4c9 = function(arg0, arg1) {
49 console.log(getStringFromWasm0(arg0, arg1));
50});
tuna

tuna9 file matches

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