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/$%7Bsuccess?q=function&page=2468&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 28557 results for "function"(7897ms)

outsideBlushShrimpmain.tsx2 matches

@MichaelNollox•Updated 9 months ago
9 * @param val Define which val should open. Defaults to the root reference
10 */
11export function modifyHtmlString(
12 bodyText: string,
13 { val, style, variant }: { val?: ValRef; style?: string; variant?: 'default' | 'green' } = {},
40 * @param val Define which val should open
41 */
42export function modifyFetchHandler(
43 handler: (req: Request) => Response | Promise<Response>,
44 { val, style, variant }: { val?: ValRef; style?: string; variant?: 'default' | 'green' } = {},

outsideBlushShrimpREADME.md1 match

@MichaelNollox•Updated 9 months ago
49### Linking to the val
50
51These functions infer the val using the call stack or the request URL. If the inference isn't working, or if you want to ensure it links to a specific val, pass the `val` argument:
52
53- `modifyFetchHandler(handler, {val: { handle: "andre", name: "foo" }})`

crazyPeachCrayfishREADME.md1 match

@MichaelNollox•Updated 9 months ago
49### Linking to the val
50
51These functions infer the val using the call stack or the request URL. If the inference isn't working, or if you want to ensure it links to a specific val, pass the `val` argument:
52
53- `modifyFetchHandler(handler, {val: { handle: "andre", name: "foo" }})`

crazyPeachCrayfishmain.tsx2 matches

@MichaelNollox•Updated 9 months ago
9 * @param val Define which val should open. Defaults to the root reference
10 */
11export function modifyHtmlString(
12 bodyText: string,
13 { val, style }: { val?: ValRef; style?: string } = {},
40 * @param val Define which val should open
41 */
42export function modifyFetchHandler(
43 handler: (req: Request) => Response | Promise<Response>,
44 { val, style }: { val?: ValRef; style?: string } = {},

codeOnValTownREADME.md1 match

@MichaelNollox•Updated 9 months ago
49### Linking to the val
50
51These functions infer the val using the call stack or the request URL. If the inference isn't working, or if you want to ensure it links to a specific val, pass the `val` argument:
52
53- `modifyFetchHandler(handler, {val: { handle: "andre", name: "foo" }})`

codeOnValTownmain.tsx2 matches

@MichaelNollox•Updated 9 months ago
9 * @param val Define which val should open. Defaults to the root reference
10 */
11export function modifyHtmlString(
12 bodyText: string,
13 { val, style }: { val?: ValRef; style?: string } = {},
40 * @param val Define which val should open
41 */
42export function modifyFetchHandler(
43 handler: (req: Request) => Response | Promise<Response>,
44 { val, style }: { val?: ValRef; style?: string } = {},

emperorOfJapanCrawlermain.tsx2 matches

@jdan•Updated 9 months ago
6const TITLE_SELECTOR = "#firstHeading > span";
7
8async function crawlWikipedia(url: string, visited: Set<string> = new Set()): Promise<string[]> {
9 if (visited.has(url)) {
10 return [];
39}
40
41export default async function server(req: Request): Promise<Response> {
42 const url = new URL(req.url);
43 const startUrl = url.searchParams.get('url');

cliServermain.tsx5 matches

@pomdtr•Updated 9 months ago
22 }) => {
23 const { default: runFn } = await import(url);
24 if (typeof runFn !== "function") {
25 throw new Error("Val should have a default export that is a function");
26 }
27
30 get(target, key) {
31 const real = target[key];
32 if (typeof real === "function" && typeof key === "string") {
33 const fn = function(...args: any[]) {
34 logs.push(args.join(" "));
35 return real.call(this, ...args);
49}
50
51export function createCli(author: string) {
52 return new Cli(author);
53}

lootGenAPImain.tsx4 matches

@roramigator•Updated 9 months ago
100
101// Calculates the rarity threshold for each array
102function calculateRarityThreshold(length: number): number {
103 return Math.max(1, Math.floor(Math.log(length) * 0.6)); // Adjust the divisor to control the rarity spread
104}
105
106// Determine if a component is rare based on its index and the total length of the array
107function isComponentRare(index: number, totalLength: number): boolean {
108 const rarityThreshold = calculateRarityThreshold(totalLength);
109 return index < rarityThreshold;
111
112// Generates a loot item with rarity based on the rarity of its components
113function generateLootItem(index: number, totalLength: number): string {
114 const adjective = adjectives[Math.floor(Math.random() * adjectives.length)];
115 const material = materials[Math.floor(Math.random() * materials.length)];
128
129// Handles HTTP requests and returns a JSON response with an array of loot items
130export default async function server(req: Request): Promise<Response> {
131 const count = 5;
132

animemain.tsx3 matches

@tempdev•Updated 9 months ago
125 let streams = []
126
127 function initPlayer() {
128 const video = document.querySelector("media-player");
129 const serverContainer = document.querySelector("#server-select");
142 }
143
144 function loadServer(val) {
145 const player = document.querySelector("media-player");
146 player.src = val
210 `<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Video Player</title><style>html,body{color:#DDD;background:#090909;font-family:sans-serif;}#video-player{width:100%;max-width:800px;margin:0 auto;}#video-controls{text-align:center;margin-top:10px;}</style></head><body onload=loadVideo(0)><div id="video-player"><p>Playing ${metaData.title}</p><video id="video" controls width="100%"></video><div id="video-controls">${controls}</div><center><p style="color:#555">A Very Fast Anime Embed, No Ads, No Tracking, Completely Free.</p></center></div><script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script><script>const videoElement=document.getElementById('video');const videoData=${
211 JSON.stringify(results)
212 };function loadVideo(index){const videoStream=videoData[index].stream[0];const quality=videoStream.qualities.unknown;const url=quality.url;if(quality.type==='m3u8'){if(Hls.isSupported()){const hls=new Hls();hls.loadSource(url);hls.attachMedia(videoElement);}else if(videoElement.canPlayType('application/vnd.apple.mpegurl')){videoElement.src=url;}}else if(quality.type==='mp4'){videoElement.src=url;}videoElement.load();videoElement.play();}</script></body></html>`,
213 );
214});

getFileEmail4 file matches

@shouser•Updated 1 month ago
A helper function to build a file's email
tuna

tuna8 file matches

@jxnblk•Updated 1 month ago
Simple functional CSS library for Val Town
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.