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/$%7Burl%7D?q=function&page=2609&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 31513 results for "function"(12394ms)

petunia_chatmain.tsx4 matches

@robertmccallnz•Updated 6 months ago
109 const errorDisplay = document.getElementById('error-display');
110
111 function logError(message) {
112 console.error(message);
113 errorDisplay.textContent = message;
114 }
115
116 async function sendMessage() {
117 const message = userInput.value.trim();
118 if (!message) {
244 const refreshButton = document.getElementById('refresh-market');
245
246 function createMarketStatHTML(emoji, name, trend, value) {
247 const div = document.createElement('div');
248 div.className = 'market-stat';
260 }
261
262 async function fetchMarketInsights() {
263 try {
264 const response = await fetch('/market-data', {

forEmulated1main.tsx4 matches

@manyone•Updated 6 months ago
5import imageCompression from "https://esm.sh/browser-image-compression";
6
7function App() {
8 const [generatedCode, setGeneratedCode] = useState('');
9 const [codeHistory, setCodeHistory] = useState([]);
310}
311
312function client() {
313 createRoot(document.getElementById("root")).render(<App />);
314}
315if (typeof document !== "undefined") { client(); }
316
317function getCurrentYear() {
318 return new Date().getFullYear();
319}
320
321export default async function server(request: Request): Promise<Response> {
322 if (request.method === 'POST' && new URL(request.url).pathname === '/generate-landing-page') {
323 try {

twitterAlertmain.tsx2 matches

@dhruv•Updated 6 months ago
14 .join(" OR ") + " " + excludes;
15
16function relevant(t: Tweet) {
17 const lowercaseText = t.full_text?.toLowerCase() || "";
18
28const isProd = true;
29
30export async function twitterAlert({ lastRunAt }: Interval) {
31 // search
32 const since = isProd

functionExerciseREADME.md1 match

@willthereader•Updated 6 months ago
1Migrated from folder: fullstackJavaScriptIntro/archiveFullstackJavaScriptIntro/functionExercise

LotecaV2main.tsx6 matches

@maxm•Updated 6 months ago
15// console.log(MEUS_JOGOS);
16
17function compareGames(drawnNumbers, userGame) {
18 return userGame.filter(num => drawnNumbers.includes(num)).length;
19}
20
21function TabelaDistribuicaoPremios({ premios }) {
22 if (!premios || premios.length === 0) return null;
23
51}
52
53function App() {
54 const [dadosLoteria, setDadosLoteria] = useState(null);
55 const [numeroAtual, setNumeroAtual] = useState(null);
56 const [erro, setErro] = useState(null);
57
58 async function buscarDadosLoteria(numero = null) {
59 const url = numero
60 ? `https://servicebus2.caixa.gov.br/portaldeloterias/api/megasena/${numero}`
195}
196
197function client() {
198 createRoot(document.getElementById("root")).render(<App />);
199}
200if (typeof document !== "undefined") { client(); }
201
202export default async function server(request: Request): Promise<Response> {
203 return new Response(
204 `

laudableTurquoiseOpossummain.tsx5 matches

@zdmta•Updated 6 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 const [user, setUser] = useState(null);
7 const [view, setView] = useState("login");
202}
203
204function LoginForm({ onLogin, onSignupView }) {
205 const [username, setUsername] = useState('');
206 const [password, setPassword] = useState('');
252}
253
254function SignupForm({ onSignup, onLoginView }) {
255 const [username, setUsername] = useState('');
256 const [password, setPassword] = useState('');
322// Rest of the components remain the same as in the previous implementation
323
324function client() {
325 createRoot(document.getElementById("root")).render(<App />);
326}
328if (typeof document !== "undefined") { client(); }
329
330export default async function server(request: Request): Promise<Response> {
331 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
332 const KEY = "laudableTurquoiseOpossum";

glifbuxmain.tsx18 matches

@jamiedubs•Updated 6 months ago
14}
15
16function normalizeAddress(address: string): string {
17 return address.toLowerCase();
18}
19
20async function initializeDatabase() {
21 await sqlite.execute(`
22 CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (
27}
28
29async function getBalance(address: string): Promise<number> {
30 const normalizedAddress = normalizeAddress(address);
31 const result = await sqlite.execute(
40}
41
42async function setBalance(address: string, amount: number) {
43 const normalizedAddress = normalizeAddress(address);
44 await sqlite.execute(
49}
50
51async function incrementBalance(address: string, amount: number) {
52 const normalizedAddress = normalizeAddress(address);
53 await sqlite.execute(
58}
59
60async function decrementBalance(address: string, amount: number) {
61 await incrementBalance(address, -amount);
62}
63
64async function getAllAccounts(): Promise<{ address: string; balance: number }[]> {
65 const result = await sqlite.execute(`SELECT address, balance FROM ${TABLE_NAME}`);
66 return result.rows.map(row => ({ address: String(row.address), balance: Number(row.balance) }));
67}
68
69async function mint(address: string, amount: number) {
70 await incrementBalance(address, amount);
71}
72
73function generateInstructions(baseUrl: string): string {
74 return `
75 <html>
131}
132
133function handleHome(baseUrl: string): ApiResponse {
134 return {
135 status: 200,
139}
140
141async function handleBalance(address: string | null): Promise<ApiResponse> {
142 if (!address) {
143 return {
153}
154
155async function handleSend(data: any): Promise<ApiResponse> {
156 const { from, to, amount } = data;
157 if (!from || !to || amount === undefined) {
193}
194
195async function handleAccounts(): Promise<ApiResponse> {
196 const accounts = await getAllAccounts();
197 return {
201}
202
203async function handleMint(data: any, authHeader: string | null): Promise<ApiResponse> {
204 const { address, amount } = data;
205 if (!address || amount === undefined) {
235}
236
237function handleFavicon(): ApiResponse {
238 return {
239 status: 204,
242}
243
244function handleNotFound(): ApiResponse {
245 return {
246 status: 404,
249}
250
251function logRequestResponse(req: Request, res: ApiResponse) {
252 console.log(`Request: ${req.method} ${req.url}`);
253 console.log(`Response: Status ${res.status}, Body:`, res.body);
254}
255
256export default async function(req: Request): Promise<Response> {
257 await initializeDatabase();
258

md_links_resolvermain.tsx4 matches

@argimko•Updated 6 months ago
1import { createApp, h, nextTick, onMounted, ref } from "https://esm.sh/vue@3.4.21";
2
3function useMarkdownResolver() {
4 const markdown = ref("");
5 const processedMarkdown = ref("");
85}
86
87function client() {
88 const RootComponent = {
89 setup() {
150if (typeof document !== "undefined") { client(); }
151
152export default async function server(request: Request): Promise<Response> {
153 // Handle link resolution endpoint
154 if (request.method === "POST" && new URL(request.url).pathname === "/resolve-links") {
349}
350
351async function resolveRedirect(url: string): Promise<string> {
352 const fetchOptions = {
353 headers: {

versatileBlackKitemain.tsx3 matches

@eligosmlytics•Updated 6 months ago
4import { createRoot } from "https://esm.sh/react-dom/client";
5
6function App() {
7 const [youtubeUrl, setYoutubeUrl] = useState("https://www.youtube.com/embed/QskiaNqaqlc?si=MvD_ydotKgovS9pC");
8 const [postVideoImages, setPostVideoImages] = useState<string[]>([]);
207}
208
209function client() {
210 createRoot(document.getElementById("root")).render(<App />);
211}
212if (typeof document !== "undefined") { client(); }
213
214export default async function server(request: Request): Promise<Response> {
215 // Image proxy endpoint
216 const url = new URL(request.url);

embedVideoWebPagemain.tsx3 matches

@eligosmlytics•Updated 6 months ago
4import { createRoot } from "https://esm.sh/react-dom/client";
5
6function App() {
7 const [youtubeUrl, setYoutubeUrl] = useState("https://www.youtube.com/embed/QskiaNqaqlc?si=MvD_ydotKgovS9pC");
8 const [postVideoImages, setPostVideoImages] = useState<string[]>([]);
218}
219
220function client() {
221 createRoot(document.getElementById("root")).render(<App />);
222}
223if (typeof document !== "undefined") { client(); }
224
225export default async function server(request: Request): Promise<Response> {
226 // Image proxy endpoint
227 const url = new URL(request.url);
tuna

tuna9 file matches

@jxnblk•Updated 2 weeks 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.