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/?q=function&page=1350&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 18949 results for "function"(2494ms)

sqliteExplorerAppREADME.md1 match

@mparker•Updated 5 months ago
33- [x] fix wonky sidebar separator height problem (thanks to @stevekrouse)
34- [x] make result tables scrollable
35- [x] add export to CSV, and JSON (CSV and JSON helper functions written in [this val](https://www.val.town/v/nbbaier/sqliteExportHelpers). Thanks to @pomdtr for merging the initial version!)
36- [x] add listener for cmd+enter to submit query

functionExercisemain.tsx4 matches

@willthereader•Updated 5 months ago
1// make a function, a variable containing a function, block body arrow function,
2// and concise body syntax arrow function
3
4function adder(num1, num2) {
5 return num1 + num2;
6}
8adder(1, 2);
9
10let subtracter = function minus(num1, num2) {
11 return num1 - num2;
12};

sharpCoralCoyotemain.tsx1 match

@tompatiger•Updated 5 months ago
23 return quotes
24
25# Test the function
26quotes = get_quotes()
27print(random.choice(quotes))

petunia_chatmain.tsx4 matches

@robertmccallnz•Updated 5 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 5 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 5 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 5 months ago
1Migrated from folder: fullstackJavaScriptIntro/archiveFullstackJavaScriptIntro/functionExercise

LotecaV2main.tsx6 matches

@maxm•Updated 5 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 5 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 5 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

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 2 weeks ago
Simple functional CSS library for Val Town
webup
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.
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": "*",