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=2&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 31553 results for "function"(2338ms)

vdsindex.tsx3 matches

@mubasahiranshahshahâ€ĸUpdated 2 hours ago
5import { Layout } from "./Layout.tsx";
6
7function PostComponent({ markdown, link }: { markdown: string; link?: string }) {
8 return (
9 <div style={{ border: "1px solid gray", padding: "10px", marginBottom: "20px", borderRadius: "5px" }}>
14}
15
16export default async function(req: Request): Promise<Response> {
17 const url = new URL(req.url);
18 if (url.pathname === "/") {
44}
45
46function html(children: React.ReactNode) {
47 return new Response(
48 renderToString(
2import type { ReactNode } from "npm:react@18.2.0";
3
4export function Layout({ children }: { children: ReactNode }) {
5 return (
6 <html lang="en">

markdownBlogStarterindex.tsx3 matches

@mubasahiranshahshahâ€ĸUpdated 2 hours ago
5import { Layout } from "./Layout.tsx";
6
7function PostComponent({ markdown, link }: { markdown: string; link?: string }) {
8 return (
9 <div style={{ border: "1px solid gray", padding: "10px", marginBottom: "20px", borderRadius: "5px" }}>
14}
15
16export default async function(req: Request): Promise<Response> {
17 const url = new URL(req.url);
18 if (url.pathname === "/") {
44}
45
46function html(children: React.ReactNode) {
47 return new Response(
48 renderToString(

duxtoogleMenu.js2 matches

@n4k0m3â€ĸUpdated 4 hours ago
1/**
2 * Initializes a mobile menu toggle functionality.
3 * Toggles the visibility of the mobile menu and updates the toggle button icon.
4 */
27 * @param {Event} event - The click event
28 */
29 function handleToggle(event) {
30 event.preventDefault();
31

duxtoogleTheme.js3 matches

@n4k0m3â€ĸUpdated 4 hours ago
1/**
2 * Initializes a theme toggle functionality.
3 * Switches between light and dark modes, updates the toggle button icon, and persists the theme in localStorage.
4 */
46 * Initializes the theme based on localStorage when the DOM is fully loaded.
47 */
48 function initializeTheme() {
49 const savedTheme = localStorage.getItem("theme");
50 if (savedTheme === "dark") {
62 * @param {Event} event - The click event
63 */
64 function handleThemeToggle(event) {
65 event.preventDefault();
66

FarcasterSpacesanalytics.tsx13 matches

@moeâ€ĸUpdated 4 hours ago
4import { dbQuery } from './supabase.ts'
5
6export function handleAnalyticsEndpoints(app: Hono) {
7 app.get('/analytics', async (c) => {
8 // todo: load all data in parallel (postgress connection issue)
53}
54
55function Table({ data, title, props, w = 84 }) {
56 const renderRow = (item) =>
57 props
87}
88
89function B({ children }) {
90 return <span className="text-neutral-300 dark:text-neutral-600">{children}</span>
91}
92
93function Spacer({ w }) {
94 return (
95 <div>
99}
100
101function queryHistoricalCountUsersOverPeriod({ periodFormat = 'YYYY-MM-DD' }) {
102 return analyticsQuery(`
103 select TO_CHAR(created_at, '${periodFormat}') as period, COUNT(distinct fid)
108 limit 10`)
109}
110function topOpenLocations() {
111 return analyticsQuery(`
112 select param, COUNT(*)
117 limit 10`).then(miniappLocationDataTransformer)
118}
119function topScreens() {
120 return analyticsQuery(`
121 select param, COUNT(*)
126 limit 10`)
127}
128function topUsers() {
129 return analyticsQuery(`
130 select fid, COUNT(*)
136}
137
138function miniappLocationDataTransformer(data: any) {
139 return data.map((item: any) => {
140 return {
145}
146
147function getLocationText(param: string) {
148 let locationText = ''
149 if (param) {
162 return locationText
163}
164function getClientFidText(clientFid: any) {
165 if (!clientFid) return `[W] `
166 if (clientFid == 9152) return `[W] `
169}
170
171async function analyticsQuery(query: string, args: any[] = []) {
172 const result = await dbQuery(query, args)
173 return safeRows(result.rows)
174}
175
176function safeRows(rows: any[]) {
177 return rows.map((row) => {
178 const newRow: Record<string, any> = {}

newvalmain.tsx8 matches

@wahobdâ€ĸUpdated 5 hours ago
4
5// Key-Value DB āĻĨ⧇āϕ⧇ āĻ­ā§āϝāĻžāϞ⧁ āĻĒāĻžāĻ“ā§ŸāĻžāϰ āĻĢāĻžāĻ‚āĻļāύ
6async function kvGet(key: string): Promise<number> {
7 const res = await fetch(`https://api.val.town/v1/kv/get?key=${key}`, {
8 headers: { "X-API-Key": API_KEY },
14
15// Key-Value DB āϤ⧇ āĻ­ā§āϝāĻžāϞ⧁ āϏ⧇āϟ āĻ•āϰāĻžāϰ āĻĢāĻžāĻ‚āĻļāύ
16async function kvSet(key: string, value: number) {
17 await fetch(`https://api.val.town/v1/kv/set`, {
18 method: "POST",
26
27// āϰ⧇āĻĢāĻžāϰ āĻ•āĻžāωāĻ¨ā§āϟ āĻĒāĻžāĻ“ā§ŸāĻžāϰ āĻĢāĻžāĻ‚āĻļāύ
28async function getReferCount(user_id: number) {
29 return await kvGet(`refer_${user_id}`);
30}
31
32// āϰ⧇āĻĢāĻžāϰ āĻŦāĻžā§œāĻžāύ⧋āϰ āĻĢāĻžāĻ‚āĻļāύ
33async function addRefer(user_id: number) {
34 const current = await getReferCount(user_id);
35 await kvSet(`refer_${user_id}`, current + 1);
37
38// āĻŦā§āϝāĻžāϞ⧇āĻ¨ā§āϏ āĻĒāĻžāĻ“ā§ŸāĻžāϰ āĻĢāĻžāĻ‚āĻļāύ
39async function getBalance(user_id: number) {
40 return await kvGet(`balance_${user_id}`);
41}
42
43// āĻŦā§āϝāĻžāϞ⧇āĻ¨ā§āϏ āĻŦāĻžā§œāĻžāύ⧋āϰ āĻĢāĻžāĻ‚āĻļāύ
44async function addBalance(user_id: number, amount: number) {
45 const current = await getBalance(user_id);
46 await kvSet(`balance_${user_id}`, current + amount);
48
49// āĻŽā§‡āϏ⧇āϜ āĻĒāĻžāĻ āĻžāύ⧋āϰ āĻĢāĻžāĻ‚āĻļāύ
50async function sendMessage(chat_id: number, text: string, reply_markup: any = null) {
51 await fetch(`https://api.telegram.org/bot${BOT_TOKEN}/sendMessage`, {
52 method: "POST",
56}
57
58export default async function(req: Request): Promise<Response> {
59 if (req.method !== "POST") {
60 return new Response("đŸŸĸ Telegram Bot Webhook Active (POST only)");

reactHonoStarterApp.tsx1 match

@n4k0m3â€ĸUpdated 5 hours ago
2import { useState } from "https://esm.sh/react@18.2.0";
3
4export function App() {
5 const [clicked, setClicked] = useState(0);
6 return (

basic-html-starterindex.html24 matches

@Raazbhaiiâ€ĸUpdated 5 hours ago
585
586 // Apply dark mode on load
587 function applyDarkMode() {
588 if (darkMode) {
589 document.documentElement.classList.add('dark-mode');
596
597 // Toggle dark mode
598 function toggleDarkMode() {
599 darkMode = !darkMode;
600 localStorage.setItem('darkMode', darkMode);
603
604 // Show login/register forms
605 function showLogin() {
606 document.getElementById('login-form').style.display = 'block';
607 document.getElementById('register-form').style.display = 'none';
608 }
609
610 function showRegister() {
611 document.getElementById('login-form').style.display = 'none';
612 document.getElementById('register-form').style.display = 'block';
614
615 // Toggle mobile menu
616 function showMobileMenu() {
617 mobileMenu.style.display = 'flex';
618 }
619
620 function hideMobileMenu() {
621 mobileMenu.style.display = 'none';
622 }
623
624 // Show/hide sections
625 function showSection(sectionId) {
626 document.querySelectorAll('.section').forEach(section => {
627 section.classList.add('hidden');
631
632 // Show/hide withdraw modal
633 function showWithdrawModal() {
634 document.getElementById('withdraw-modal').style.display = 'flex';
635 }
636
637 function hideWithdrawModal() {
638 document.getElementById('withdraw-modal').style.display = 'none';
639 }
665
666 // Check if user is admin
667 function checkAdmin(userId) {
668 database.ref('admins/' + userId).once('value', snapshot => {
669 if (snapshot.exists()) {
675
676 // Load user data
677 function loadUserData(userId) {
678 // Load balance and tasks
679 database.ref('users/' + userId).on('value', snapshot => {
817 }
818
819 // Auth functions
820 function login() {
821 const email = document.getElementById('login-email').value;
822 const password = document.getElementById('login-password').value;
828 }
829
830 function register() {
831 const username = document.getElementById('register-username').value;
832 const email = document.getElementById('register-email').value;
859 }
860
861 function logout() {
862 auth.signOut();
863 }
864
865 // Task functions
866 function completeTask(taskId) {
867 const userId = auth.currentUser.uid;
868
891 }
892
893 function completeOffer(offerId) {
894 const userId = auth.currentUser.uid;
895
920 }
921
922 // Withdrawal functions
923 function submitWithdrawal() {
924 const userId = auth.currentUser.uid;
925 const amount = parseFloat(document.getElementById('withdraw-amount').value);
973 }
974
975 // Admin functions
976 function addTask() {
977 const title = document.getElementById('task-title').value;
978 const reward = parseFloat(document.getElementById('task-reward').value);
999 }
1000
1001 function deleteTask(taskId) {
1002 if (confirm('Are you sure you want to delete this task?')) {
1003 database.ref('tasks/' + taskId).remove();
1006
1007 // Initialize sample data if empty
1008 function initializeSampleData() {
1009 database.ref('tasks').once('value', snapshot => {
1010 if (!snapshot.exists()) {

saveImdbToDebridindex.ts2 matches

@larryhudsonâ€ĸUpdated 5 hours ago
1export default async function(req: Request): Promise<Response> {
2 try {
3 const url = new URL(req.url);
61 }
62
63 // Helper function to parse size from title and convert to MB
64 const parseSizeInMB = (title: string): number => {
65 // Look for GB format: "💾 X.XX GB"
tuna

tuna9 file matches

@jxnblkâ€ĸUpdated 2 weeks ago
Simple functional CSS library for Val Town

getFileEmail4 file matches

@shouserâ€ĸUpdated 2 months 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.