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=1330&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 18498 results for "function"(2970ms)

ModuloCreazioneIntimitamain.tsx4 matches

@cicciocappaUpdated 5 months ago
343
344// Progress Bar Component
345function ProgressBar({
346 currentStep,
347 totalSteps,
375}
376
377function QuestionnaireApp() {
378 const [currentQuestionIndex, setCurrentQuestionIndex] = useState(0);
379 const [answers, setAnswers] = useState<Record<string, string>>({});
518}
519
520function client() {
521 createRoot(document.getElementById("root")).render(<QuestionnaireApp />);
522}
523if (typeof document !== "undefined") { client(); }
524
525export default async function server(request: Request): Promise<Response> {
526 // Import blob storage dynamically
527 const { blob } = await import("https://esm.town/v/std/blob");

Family100main.tsx9 matches

@nirwanUpdated 5 months ago
6const { useState, useRef, useEffect } = React;
7
8function compressImage(file, maxWidth = 800, maxHeight = 800, quality = 0.7) {
9 return new Promise((resolve, reject) => {
10 const reader = new FileReader();
47}
48
49function PhotoUploader({ onPhotoUpload, label = "Upload Photo" }) {
50 const fileInputRef = useRef(null);
51
90}
91
92function ConnectionLine({ type = 'vertical' }) {
93 const lineStyle = {
94 vertical: {
118}
119
120function FamilyTreeNode({
121 node,
122 onAddSpouse,
225}
226
227function FamilyTreeChart() {
228 const [nodes, setNodes] = useState({});
229 const [isLoading, setIsLoading] = useState(true);
231 // Fetch initial family tree data from server
232 useEffect(() => {
233 async function fetchFamilyTree() {
234 try {
235 const response = await fetch('/family-tree');
486}
487
488function App() {
489 return (
490 <div>
498
499// Simplified client-side rendering
500function renderApp() {
501 const rootElement = document.getElementById("root");
502 if (rootElement) {
511}
512
513export default async function server(request: Request): Promise<Response> {
514 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
515 const KEY = "Family100";

scrapeAndPreviewDelta8Productsmain.tsx5 matches

@teretzdevUpdated 5 months ago
5 * @returns Array of product objects with details
6 */
7export default async function scrapeProducts() {
8 try {
9 const response = await fetch("https://delta8pro.com/products/", {
52 * @returns Formatted string of product previews
53 */
54export function previewProducts(products, limit = 5) {
55 return products.slice(0, limit).map(product => {
56 const stockEmoji = product.inStock ? '✅' : '❌';
70 * @returns Array of scraped products
71 */
72export async function runAndPreview() {
73 const products = await scrapeProducts();
74 console.log(previewProducts(products));
82 * @returns Filtered array of products
83 */
84export function filterProductsByCategory(products, category) {
85 return products.filter(product =>
86 product.categories.some(cat =>
96 * @returns Sorted array of products
97 */
98export function sortProductsByPrice(products, ascending = true) {
99 return [...products].sort((a, b) => {
100 const priceA = parseFloat(a.price.replace(/[^0-9.-]+/g, ''));

scrapeProductsmain.tsx5 matches

@teretzdevUpdated 5 months ago
5 * @returns Array of product objects with details
6 */
7export default async function scrapeProducts() {
8 try {
9 const response = await fetch("https://delta8pro.com/products/", {
52 * @returns Formatted string of product previews
53 */
54export function previewProducts(products, limit = 5) {
55 return products.slice(0, limit).map(product => {
56 const stockEmoji = product.inStock ? '✅' : '❌';
70 * @returns Array of scraped products
71 */
72export async function runAndPreview() {
73 const products = await scrapeProducts();
74 console.log(previewProducts(products));
82 * @returns Filtered array of products
83 */
84export function filterProductsByCategory(products, category) {
85 return products.filter(product =>
86 product.categories.some(cat =>
96 * @returns Sorted array of products
97 */
98export function sortProductsByPrice(products, ascending = true) {
99 return [...products].sort((a, b) => {
100 const priceA = parseFloat(a.price.replace(/[^0-9.-]+/g, ''));

portfolioSitemain.tsx14 matches

@shegosthatoUpdated 5 months ago
4
5// Custom Icons
6function MoonIcon(props) {
7 return (
8 <svg
23}
24
25function SunIcon(props) {
26 return (
27 <svg
50}
51
52function GithubIcon(props) {
53 return (
54 <svg
65}
66
67function MailIcon(props) {
68 return (
69 <svg
85}
86
87function LinkedinIcon(props) {
88 return (
89 <svg
101
102// Custom Button Component
103function Button({
104 children,
105 variant = 'primary',
133
134// Custom Card Components
135function Card({ children, className = '' }) {
136 return (
137 <div className={`bg-white dark:bg-gray-800 rounded-lg shadow-md ${className}`}>
141}
142
143function CardHeader({ children, className = '' }) {
144 return (
145 <div className={`p-4 border-b border-gray-200 dark:border-gray-700 ${className}`}>
149}
150
151function CardTitle({ children, className = '' }) {
152 return (
153 <h3 className={`text-xl font-semibold text-gray-900 dark:text-gray-100 ${className}`}>
157}
158
159function CardContent({ children, className = '' }) {
160 return (
161 <div className={`p-4 ${className}`}>
166
167// Custom Switch Component
168function Switch({ checked, onCheckedChange }) {
169 return (
170 <button
190}
191
192function App() {
193 const [theme, setTheme] = useState<'light' | 'dark'>('light');
194
349}
350
351function client() {
352 createRoot(document.getElementById("root")).render(<App />);
353}
354if (typeof document !== "undefined") { client(); }
355
356export default async function server(request: Request): Promise<Response> {
357 return new Response(`
358 <!DOCTYPE html>

Albertmain.tsx11 matches

@jidunUpdated 5 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});

Ms_Spanglermain.tsx11 matches

@jidunUpdated 5 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});

cerebras_codermain.tsx5 matches

@franklycUpdated 5 months ago
6import { tomorrow } from "https://esm.sh/react-syntax-highlighter/dist/esm/styles/prism";
7
8function App() {
9 const [prompt, setPrompt] = useState("hello llamapalooza");
10 const [code, setCode] = useState("");
18 >(null);
19
20 async function handleSubmit(e: React.FormEvent) {
21 e.preventDefault();
22 setLoading(true);
97}
98
99function client() {
100 createRoot(document.getElementById("root")!).render(<App />);
101}
105}
106
107function extractCodeFromFence(text: string): string {
108 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
109 return htmlMatch ? htmlMatch[1].trim() : text;
110}
111
112export default async function server(req: Request): Promise<Response> {
113 if (req.method === "POST") {
114 const client = new Cerebras();

effortlessAquamarineHookwormmain.tsx8 matches

@nsafouaneUpdated 5 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function ThemeToggle({ isDarkMode, toggleTheme }) {
6 return (
7 <div className="theme-toggle-container">
21}
22
23function BlogPost({ title, content, timestamp, author, preview = false }) {
24 const truncatedContent = preview
25 ? content.length > 200
49}
50
51function Navigation({ currentPage, setCurrentPage, isDarkMode, toggleTheme }) {
52 return (
53 <nav className="main-nav">
71}
72
73function HomePage({ posts, currentPage, setCurrentPage, totalPages }) {
74 return (
75 <div className="home-page">
110}
111
112function Dashboard({ postCount, totalViews, posts, fetchDashboardStats }) {
113 const [title, setTitle] = useState("");
114 const [content, setContent] = useState("");
257}
258
259function BlogApp() {
260 const [posts, setPosts] = useState([]);
261 const [dashboard, setDashboard] = useState({ postCount: 0, totalViews: 0 });
341}
342
343function client() {
344 createRoot(document.getElementById("root")).render(<BlogApp />);
345}
346if (typeof document !== "undefined") { client(); }
347
348export default async function server(request: Request): Promise<Response> {
349 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
350 const KEY = "effortlessAquamarineHookworm";

multilingualchatroommain.tsx9 matches

@lloydpearsonivUpdated 5 months ago
93};
94
95function Banner({ message, isVisible, language }) {
96 if (!isVisible) return null;
97 return <div className="banner">{message[language] || message.en}</div>;
98}
99
100function UserList({ users, t }) {
101 return (
102 <div className="user-list">
113}
114
115function Sidebar({ users, language, handleLanguageChange, roomUrl, copyToClipboard, copied, t }) {
116 return (
117 <div className="sidebar">
149}
150
151function TypingIndicator({ typingUsers, t }) {
152 if (typingUsers.length === 0) return null;
153
164}
165
166function App() {
167 const [messages, setMessages] = useState([]);
168 const [inputMessage, setInputMessage] = useState("");
490}
491
492function client() {
493 createRoot(document.getElementById("root")).render(<App />);
494}
495if (typeof document !== "undefined") { client(); }
496
497export default async function server(request: Request): Promise<Response> {
498 const url = new URL(request.url);
499 const { blob } = await import("https://esm.town/v/std/blob");
508 const TIME_WINDOW = 60 * 1000; // 1 minute
509
510 async function checkRateLimit() {
511 const now = Date.now();
512 const rateLimit = await blob.getJSON(RATE_LIMIT_KEY) || { count: 0, timestamp: now };
523 }
524
525 async function translateText(text: string, targetLanguage: string, sourceLanguage: string): Promise<string> {
526 const cacheKey = `${KEY}_translation_${sourceLanguage}_${targetLanguage}_${text}`;
527 const cachedTranslation = await blob.getJSON(cacheKey);

getFileEmail4 file matches

@shouserUpdated 2 weeks ago
A helper function to build a file's email
tuna

tuna8 file matches

@jxnblkUpdated 2 weeks 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.