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=2374&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 27609 results for "function"(1829ms)

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

forwardermain.tsx1 match

@taytay•Updated 9 months ago
5const { author, name } = extractValInfo(import.meta.url);
6
7export async function forwarder(e: Email) {
8 let attachments: AttachmentData[] = [];
9 for (const f of e.attachments) {

textSummarizationComparisonToolmain.tsx3 matches

@sharanbabu•Updated 9 months ago
12import { createRoot } from "https://esm.sh/react-dom/client";
13
14function App() {
15 const [inputText, setInputText] = useState("");
16 const [summary1, setSummary1] = useState("");
252}
253
254function client() {
255 createRoot(document.getElementById("root")).render(<App />);
256}
260}
261
262async function server(request: Request): Promise<Response> {
263 if (request.method === "POST" && new URL(request.url).pathname === "/summarize") {
264 const { text, temperature } = await request.json();

obnoxiousAmaranthCamelREADME.md1 match

@jamisonl•Updated 9 months ago
1Bot for Cama discord server. To initialize new slash commands, you have to run a separate bit of code. This is for modifying their functionality

typingTestSpectrogrammain.tsx4 matches

@ejfox•Updated 9 months ago
7import { createRoot } from "https://esm.sh/react-dom/client";
8
9function App() {
10 const [input, setInput] = useState("");
11 const [currentIndex, setCurrentIndex] = useState(0);
18
19 const text = `
20function quickSort(arr) {
21 if (arr.length <= 1) {
22 return arr;
172}
173
174function client() {
175 console.log("Client-side code running");
176 createRoot(document.getElementById("root")).render(<App />);
178if (typeof document !== "undefined") { client(); }
179
180async function server(request: Request): Promise<Response> {
181 return new Response(`
182 <html>

aqimain.tsx1 match

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

solidExamplemain.tsx2 matches

@mhalle•Updated 9 months ago
2import { renderToString } from "npm:solid-js/web";
3
4function calc() {
5 return 4 + 5;
6}
7function getMarkup() {
8 return <div>Test {calc()}</div>;
9}

twitterAlertmain.tsx2 matches

@marianogenovese•Updated 9 months ago
11// const query = `${baseQuery}`.trim();
12// console.log(Deno.env.get("twitter"));
13// export async function twitterAlert() {
14// const results = await twitterSearch({
15// query,
34// }
35
36export async function main() {
37 console.log("ok");
38}

exponentialBackoffMiddlewaremain.tsx3 matches

@stevekrouse•Updated 9 months ago
8 * @param http handler
9 */
10export function exponentialBackoffMiddleware(
11 handler: (req: Request) => Response | Promise<Response>,
12): (req: Request) => Promise<Response> {
50}
51
52// Helper function to parse cookies
53function parseCookies(cookieString: string): Record<string, string> {
54 return cookieString.split(";").reduce((cookies, cookie) => {
55 const [name, value] = cookie.trim().split("=");

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.