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=2323&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 28709 results for "function"(5717ms)

Ms_Spanglermain.tsx11 matches

@arthrod•Updated 6 months ago
153 const typingIndicator = document.querySelector('.typing-indicator');
154
155 function addMessage(content, type) {
156 const messageElement = document.createElement('div');
157 messageElement.classList.add('message', type);
161 }
162
163 function loadChatHistories() {
164 try {
165 const savedChatsRaw = localStorage.getItem('chatHistories');
167
168 chatHistorySelect.innerHTML = '';
169 savedChats.forEach(function(chat, index) {
170 const option = document.createElement('option');
171 option.value = index;
178 }
179
180 function saveChat() {
181 try {
182 const chatName = prompt('Enter a name for this chat history:') || ('Chat ' + Date.now());
183 const messages = Array.from(chatMessages.children).map(function(msg) {
184 return {
185 content: msg.textContent,
200 }
201
202 function loadSelectedChat() {
203 try {
204 const selectedIndex = chatHistorySelect.value;
211 if (selectedChat) {
212 chatMessages.innerHTML = '';
213 selectedChat.messages.forEach(function(msg) {
214 addMessage(msg.content, msg.type === 'user' ? 'user-message' : 'ai-message');
215 });
221 }
222
223 function deleteSelectedChat() {
224 try {
225 const selectedIndex = chatHistorySelect.value;
239 }
240
241 async function sendMessage() {
242 const message = messageInput.value.trim();
243 if (!message) return;
270 loadButton.addEventListener('click', loadSelectedChat);
271 deleteButton.addEventListener('click', deleteSelectedChat);
272 messageInput.addEventListener('keypress', function(e) {
273 if (e.key === 'Enter') sendMessage();
274 });
308 } catch (error) {
309 console.error("OpenAI error:", error);
310 return c.json({ response: "Neural networks malfunctioning. Try again, human." });
311 }
312});

gameplay_agentmain.tsx5 matches

@arthrod•Updated 6 months 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({

whoIsHiringmain.tsx3 matches

@dxaginfo•Updated 6 months ago
7import About from "https://esm.town/v/vawogbemi/whoIsHiringAbout";
8
9function App() {
10 const tabs = { "/": "Home", "/about": "About" };
11 const [activeTab, setActiveTab] = useState("/");
335}
336
337function ServerApp() {
338 return (
339 <html>
358}
359
360export default async function(req: Request): Promise<Response> {
361 const url = new URL(req.url);
362 if (url.pathname === "/api/stories") {

lazyCookmain.tsx5 matches

@dxaginfo•Updated 6 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 const [numPeople, setNumPeople] = useState(4);
7 const [numRecipes, setNumRecipes] = useState(1);
229}
230
231function client() {
232 createRoot(document.getElementById("root")).render(<App />);
233}
234if (typeof document !== "undefined") { client(); }
235
236function extractJSONFromMarkdown(markdown: string): string {
237 const jsonMatch = markdown.match(/```json\n([\s\S]*?)\n```/);
238 return jsonMatch ? jsonMatch[1] : "";
239}
240
241export default async function server(request: Request): Promise<Response> {
242 if (request.method === "POST" && new URL(request.url).pathname === "/recipes") {
243 const { OpenAI } = await import("https://esm.town/v/std/openai");
338}
339
340async function generateImage(recipeName: string): Promise<string> {
341 const response = await fetch(`https://maxm-imggenurl.web.val.run/${encodeURIComponent(recipeName)}`);
342 if (!response.ok) {

savvyTealCardinalmain.tsx7 matches

@dxaginfo•Updated 6 months ago
4import React, { useEffect, useRef, useState } from "https://esm.sh/react@18.2.0";
5
6function ConfirmationModal({ isOpen, onClose }) {
7 if (!isOpen) return null;
8
18}
19
20function App() {
21 const [sport, setSport] = useState("");
22 const [skillLevel, setSkillLevel] = useState("");
396}
397
398function client() {
399 createRoot(document.getElementById("root")).render(<App />);
400}
735`;
736
737async function server(request: Request): Promise<Response> {
738 if (request.method === "POST" && new URL(request.url).pathname === "/generate-training") {
739 const YOUTUBE_API_KEY = Deno.env.get("YOUTUBE_API_KEY2");
826 const { email } = await import("https://esm.town/v/std/email");
827
828 // Function to insert YouTube links into the training plan
829 const insertYouTubeLinks = (plan, links) => {
830 let modifiedPlan = plan;
891}
892
893async function getYouTubeVideoId(query, sport, apiKey, useApiKey = true) {
894 if (useApiKey) {
895 try {
913}
914
915function getFallbackYouTubeLink(query, sport) {
916 const searchQuery = encodeURIComponent(`${sport} ${query}`);
917 return `https://www.youtube.com/results?search_query=${searchQuery}`;

getWeathermain.tsx3 matches

@tokyotribe•Updated 6 months ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export async function getWeather(location: string): Promise<WeatherResponse> {
4 return fetchJSON(`https://wttr.in/${location}?format=j1`);
5}
124}
125
126export default async function server(request: Request): Promise<Response> {
127 const url = new URL(request.url);
128 const location = url.searchParams.get('location') || 'New York';
295 var coll = document.getElementsByClassName("collapsible");
296 for (var i = 0; i < coll.length; i++) {
297 coll[i].addEventListener("click", function() {
298 this.classList.toggle("active");
299 var content = this.nextElementSibling;

getWeatherREADME.md1 match

@tokyotribe•Updated 6 months ago
1## Get Weather
2
3Simple function to get weather data from the free [wttr.in](https://wttr.in/:help) service.
4
5```ts

twitterAlertmain.tsx2 matches

@daniellevine•Updated 6 months ago
8 .join(" OR ") + " " + excludes;
9
10function relevant(t: Tweet) {
11 if (keywords.some(k => t.full_text?.includes(k))) return true;
12 return t.entities.urls?.some(u => keywords.some(k => u.expanded_url?.includes(k)));
17const isProd = true;
18
19export async function twitterAlert({ lastRunAt }: Interval) {
20 // search
21 const since = isProd

getSiteMetadatamain.tsx1 match

@nbbaier•Updated 6 months ago
4import { z } from "npm:zod";
5
6export async function getUrlMetadata(url: string) {
7 try {
8 const metadata = await urlMetadata(url);

versatileBrownClownfishmain.tsx1 match

@riagersappe•Updated 6 months ago
3// Fetches a random joke.
4// Fetches a random joke.
5async function fetchRandomJoke() {
6 const response = await fetch(
7 "https://official-joke-api.appspot.com/random_joke",

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.