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=2733&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 33917 results for "function"(14135ms)

exampleTestFunctionsmain.tsx4 matches

@willthereader•Updated 5 months ago
1// functions.ts
2export function fibonacci(n: number): number {
3 if (n <= 1) return n;
4 return fibonacci(n - 1) + fibonacci(n - 2);
5}
6
7export function getTomorrowDayName(today: Date): string {
8 const tomorrow = new Date(today);
9 tomorrow.setDate(tomorrow.getDate() + 1);
11}
12
13export function formatTodayDate(): string {
14 return new Date().toLocaleDateString("en-US", {
15 weekday: "long",

insightfulBrownAntmain.tsx1 match

@charmaine•Updated 5 months ago
11});
12
13function getStripeCustomer(customerId: string) {
14 return stripe.customers.retrieve(customerId);
15}

uptimemain.tsx1 match

@jjacobs22•Updated 5 months ago
6);
7
8export async function uptimeCheck(url: string) {
9 let reason: string, status: number, end: number;
10 let ok = true;

earthquakesmain.tsx1 match

@fil•Updated 5 months ago
3let { earthquakes_storage } = await import("https://esm.town/v/fil/earthquakes_storage");
4
5export async function earthquakes(req?) {
6 const yesterday = new Date(-24 * 3600 * 1000 + +new Date()).toISOString();
7 if (!(earthquakes_storage?.date > yesterday)) {

crmtemplatemain.tsx6 matches

@juecd•Updated 5 months ago
3import React, { useEffect, useRef, useState } from "https://esm.sh/react@18.2.0";
4
5function LoginScreen({ onLogin }) {
6 const [password, setPassword] = useState("");
7 const [error, setError] = useState("");
46}
47
48function CustomerInteractionForm({ onSubmit }) {
49 const [email, setEmail] = useState("");
50 const [firstName, setFirstName] = useState("");
240}
241
242function InteractionList() {
243 const [customerInteractions, setCustomerInteractions] = useState({});
244 const [copiedEmail, setCopiedEmail] = useState(null);
470}
471
472function App() {
473 const [isAuthenticated, setIsAuthenticated] = useState(false);
474 const [refreshList, setRefreshList] = useState(0);
517}
518
519function client() {
520 createRoot(document.getElementById("root")).render(<App />);
521}
522if (typeof document !== "undefined") { client(); }
523
524export default async function server(request: Request): Promise<Response> {
525 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
526 const KEY = "crmtemplate";

crmtemplatemain.tsx6 matches

@stevekrouse•Updated 5 months ago
3import React, { useEffect, useRef, useState } from "https://esm.sh/react@18.2.0";
4
5function LoginScreen({ onLogin }) {
6 const [password, setPassword] = useState("");
7 const [error, setError] = useState("");
46}
47
48function CustomerInteractionForm({ onSubmit }) {
49 const [email, setEmail] = useState("");
50 const [firstName, setFirstName] = useState("");
240}
241
242function InteractionList() {
243 const [customerInteractions, setCustomerInteractions] = useState({});
244 const [copiedEmail, setCopiedEmail] = useState(null);
470}
471
472function App() {
473 const [isAuthenticated, setIsAuthenticated] = useState(false);
474 const [refreshList, setRefreshList] = useState(0);
517}
518
519function client() {
520 createRoot(document.getElementById("root")).render(<App />);
521}
522if (typeof document !== "undefined") { client(); }
523
524export default async function server(request: Request): Promise<Response> {
525 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
526 const KEY = "crmtemplate";

CRMmain.tsx6 matches

@stevekrouse•Updated 5 months ago
3import React, { useEffect, useRef, useState } from "https://esm.sh/react@18.2.0";
4
5function LoginScreen({ onLogin }) {
6 const [password, setPassword] = useState("");
7 const [error, setError] = useState("");
46}
47
48function CustomerInteractionForm({ onSubmit }) {
49 const [email, setEmail] = useState("");
50 const [firstName, setFirstName] = useState("");
240}
241
242function InteractionList() {
243 const [customerInteractions, setCustomerInteractions] = useState({});
244 const [copiedEmail, setCopiedEmail] = useState(null);
470}
471
472function App() {
473 const [isAuthenticated, setIsAuthenticated] = useState(false);
474 const [refreshList, setRefreshList] = useState(0);
517}
518
519function client() {
520 createRoot(document.getElementById("root")).render(<App />);
521}
522if (typeof document !== "undefined") { client(); }
523
524export default async function server(request: Request): Promise<Response> {
525 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
526 const KEY = "CRM";

CRMmain.tsx6 matches

@stevekrouse•Updated 5 months ago
3import React, { useEffect, useRef, useState } from "https://esm.sh/react@18.2.0";
4
5function LoginScreen({ onLogin }) {
6 const [password, setPassword] = useState("");
7 const [error, setError] = useState("");
46}
47
48function CustomerInteractionForm({ onSubmit }) {
49 const [email, setEmail] = useState("");
50 const [firstName, setFirstName] = useState("");
240}
241
242function InteractionList() {
243 const [customerInteractions, setCustomerInteractions] = useState({});
244 const [copiedEmail, setCopiedEmail] = useState(null);
470}
471
472function App() {
473 const [isAuthenticated, setIsAuthenticated] = useState(false);
474 const [refreshList, setRefreshList] = useState(0);
517}
518
519function client() {
520 createRoot(document.getElementById("root")).render(<App />);
521}
522if (typeof document !== "undefined") { client(); }
523
524export default async function server(request: Request): Promise<Response> {
525 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
526 const KEY = "CRM";

TodoListmain.tsx16 matches

@vyatka•Updated 5 months ago
8import React, { useEffect, useState } from "https://esm.sh/react@18.2.0";
9
10function TaskBoard() {
11 const [taskLists, setTaskLists] = useState({
12 todo: [],
44 }, []);
45
46 function loadUserPreferences() {
47 const savedDarkMode = localStorage.getItem("app-theme") === "true";
48 setIsDarkMode(savedDarkMode);
59 }
60
61 function updateAppStyle(font, size) {
62 document.body.style.setProperty("--app-font", font);
63 document.body.style.setProperty("--app-font-size", `${size}px`);
64 }
65
66 function saveUserPreferences() {
67 localStorage.setItem("app-font", chosenFont);
68 localStorage.setItem("app-font-size", fontSize.toString());
72 }
73
74 async function fetchTasks() {
75 try {
76 const response = await fetch("/get-tasks");
82 }
83
84 async function addNewTask() {
85 if (!newTaskText.trim()) return;
86
102 }
103
104 async function handleTaskMove(result) {
105 const { destination, source, draggableId } = result;
106 if (!destination) return;
123 }
124
125 async function removeTask(taskId, column) {
126 try {
127 const response = await fetch("/delete-task", {
137 }
138
139 async function moveTaskForward(task, currentColumn) {
140 const currentIndex = listProgression.indexOf(currentColumn);
141 const nextColumn = listProgression[currentIndex + 1];
158 }
159
160 function toggleDarkMode() {
161 const newDarkMode = !isDarkMode;
162 setIsDarkMode(newDarkMode);
165 }
166
167 function openEditModal(task) {
168 setTaskBeingEdited(task);
169 setEditedTaskText(task.title);
171 }
172
173 async function saveEditedTask() {
174 if (!editedTaskText.trim() || !taskBeingEdited) return;
175 try {
191 }
192
193 function handleTaskInteraction(e, task, column) {
194 if (e.button === 1) {
195 e.preventDefault();
432}
433
434function client() {
435 createRoot(document.getElementById("root")).render(<TaskBoard />);
436}
439}
440
441export default async function server(request: Request): Promise<Response> {
442 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
443 const KEY = "TodoList";
517}
518
519async function getAllTasks(sqlite, KEY, SCHEMA_VERSION) {
520 const todo = await sqlite.execute(
521 `SELECT * FROM ${KEY}_tasks_${SCHEMA_VERSION} WHERE column = 'todo'`,

reactExamplemain.tsx1 match

@richardwu9•Updated 5 months ago
1export default async function(req: Request): Promise<Response> {
2 return new Response(JSON.stringify({ message: "Test successful!" }), {
3 status: 200,

discordWebhook2 file matches

@stevekrouse•Updated 1 week ago
Helper function to send Discord messages
tuna

tuna9 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.