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/$%7Bart_info.art.src%7D?q=function&page=1567&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 20194 results for "function"(4861ms)

TodoAppmain.tsx6 matches

@mrt•Updated 6 months ago
5import { Form, hydrate } from "https://esm.town/v/stevekrouse/ssr_react_mini?v=75";
6
7export async function loader(req: Request) {
8 const { sqlite } = await import("https://esm.town/v/std/sqlite?v=4");
9 const [, { columns, rows }] = await sqlite.batch([
20}
21
22export async function action(req: Request) {
23 const { sqlite } = await import("https://esm.town/v/std/sqlite?v=4");
24 const formData = await req.formData();
47}
48
49export function Component({ initialTodos, initialLogs }) {
50 const [todos, setTodos] = useState(initialTodos);
51 const [logs, setLogs] = useState(initialLogs);
54 useEffect(() => addLog(`Client rendered`), []);
55
56 function addTodo() {
57 setTodos([...todos, { text: newTodo }]);
58 setNewTodo("");
64 }
65
66 function toggleTodo(e) {
67 const formData = new FormData(e.target);
68 const id = parseInt(formData.get("id") as string);
71 }
72
73 function deleteTodo(e) {
74 const formData = new FormData(e.target);
75 const id = parseInt(formData.get("id") as string);

dailyScheduleTrackermain.tsx4 matches

@mrt•Updated 6 months ago
236};
237
238function AnalogueScheduleClock({
239 schedule = defaultSchedule,
240 todoList = defaultTodoList,
340}
341
342function App() {
343 return <AnalogueScheduleClock />;
344}
345
346function client() {
347 const rootElement = document.getElementById("root");
348 if (rootElement) {
357}
358
359export default async function server(request: Request): Promise<Response> {
360 return new Response(
361 `

apimain.tsx6 matches

@campsite•Updated 6 months ago
199}
200
201function createCampsiteAPI(options?: RequestOptions): CampsiteAPI {
202 return new CampsiteAPI(options?.apiKey);
203}
204
205export async function getPost(postId: string, options?: RequestOptions) {
206 const api = createCampsiteAPI(options);
207 return api.getPost(postId);
208}
209
210export async function createPost(
211 data: CreatePostRequest,
212 options?: RequestOptions
216}
217
218export async function createComment(
219 data: CreateCommentRequest,
220 options?: RequestOptions
224}
225
226export async function createMessage(
227 data: CreateMessageRequest,
228 options?: RequestOptions
232}
233
234export async function listChannels(
235 params?: ListChannelsRequest,
236 options?: RequestOptions

instantdbCursorsDemomain.tsx4 matches

@vawogbemi•Updated 6 months ago
7 "flex h-screen w-screen items-center justify-center overflow-hidden font-mono text-sm text-gray-800 touch-none";
8
9function InstantCursorsProvider(props: { children: JSX.Element }) {
10 const db = init({
11 appId: "25280469-70aa-4c6e-9d47-be46e0bca539", // ADD YOUR APP ID HERE
29}
30
31function App() {
32 return (
33 <div className="flex h-screen w-screen items-center justify-center bg-gray-100">
40}
41
42function client() {
43 createRoot(document.getElementById("root")).render(
44 <InstantCursorsProvider>
52}
53
54export default async function server(request: Request): Promise<Response> {
55 return new Response(
56 `

instantCursorsDemomain.tsx4 matches

@vawogbemi•Updated 6 months ago
4import { createRoot } from "https://esm.sh/react-dom/client";
5
6function InstantCursors() {
7 const db = init<
8 {},
32}
33
34function App() {
35 return (
36 <div className="min-h-screen bg-red-100 flex items-center justify-center">
43}
44
45function client() {
46 createRoot(document.getElementById("root")).render(<App />);
47}
49if (typeof document !== "undefined") { client(); }
50
51export default async function server(request: Request): Promise<Response> {
52 return new Response(
53 `

FetchBasicmain.tsx1 match

@julesb22•Updated 6 months ago
1export default async function(req: Request): Promise<Response> {
2 // Setup CORS Headers
3 const headers = new Headers();

FetchBasic_deleted_1729503955main.tsx1 match

@julesb22•Updated 6 months ago
1export default async function(req: Request): Promise<Response> {
2 // Setup CORS Headers
3 const headers = new Headers();

astuteAquamarineAardvarkmain.tsx1 match

@julesb22•Updated 6 months ago
1export default async function(req: Request): Promise<Response> {
2 return Response.json({ data: true });
3}

aqimain.tsx1 match

@jessicatheodosius•Updated 6 months ago
2import { easyAQI } from "https://esm.town/v/stevekrouse/easyAQI?v=5";
3
4export async function aqi(interval: Interval) {
5 const location = "downtown brooklyn"; // <-- change to place, city, or zip code
6 const data = await easyAQI({ location });

instantdbReactionsExamplemain.tsx6 matches

@vawogbemi•Updated 6 months ago
37 "rounded-lg bg-white p-3 text-3xl shadow-lg transition duration-200 ease-in-out hover:-translate-y-1 hover:shadow-xl";
38
39function animateEmoji(
40 config: { emoji: string; directionAngle: number; rotationAngle: number },
41 target: HTMLDivElement | null,
80}
81
82function style(el: HTMLElement, styles: Partial<CSSStyleDeclaration>) {
83 Object.assign(el.style, styles);
84}
85
86function InstantTopics() {
87 const db = init({
88 appId: "25280469-70aa-4c6e-9d47-be46e0bca539", // Replace with your actual InstantDB app ID
140}
141
142function App() {
143 return <InstantTopics />;
144}
145
146function client() {
147 createRoot(document.getElementById("root")!).render(<App />);
148}
152}
153
154export default async function server(request: Request): Promise<Response> {
155 return new Response(
156 `

getFileEmail4 file matches

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

tuna8 file matches

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