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=1079&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 17232 results for "function"(1907ms)

tactfulCoffeeOctopusREADME.md2 matches

@charmaineUpdated 3 months ago
46- Key: `mentionsDiscord`
47- Value: Your Discord webhook URL.
48Notifications will be sent using this function:
49
50```ts
63
64- **Proxies via Val Town's [SocialDataProxy](https://www.val.town/v/stevekrouse/socialDataProxy)**: Limited to 10 cents per day for [**Val Town Pro users**](https://www.val.town/pricing). This API is *only* for Pro users.
65- **Need more calls?** Sign up for your own [SocialData API token](https://socialdata.tools) and configure the [`socialDataSearch`](https://www.val.town/v/stevekrouse/socialDataSearch) function.

tactfulCoffeeOctopusmain.tsx1 match

@charmaineUpdated 3 months ago
12const isProd = false;
13
14export async function twitterAlert({ lastRunAt }: Interval) {
15 // If isProd, search for tweets since that last time this interval ran
16 // if not, search for tweets since 48 hours ago for testing

inventorymain.tsx4 matches

@toowiredUpdated 3 months ago
32 { name: "Heroku", icon: "🚀", explanation: "A cloud platform that lets companies build, deliver, monitor and scale apps", complexity: 2 },
33 { name: "Netlify", icon: "🎛️", explanation: "An all-in-one platform for automating modern web projects", complexity: 1 },
34 { name: "Vercel", icon: "🏁", explanation: "A cloud platform for static sites and Serverless Functions", complexity: 2 },
35 ],
36};
37
38function client() {
39 const root = document.getElementById("root");
40 if (root && typeof React !== 'undefined' && React.useState) {
41 const { useState, useEffect, useRef } = React;
42
43 function App() {
44 const [step, setStep] = useState(0);
45 const [conversation, setConversation] = useState([]);
273}
274
275async function server(request: Request): Promise<Response> {
276 const html = `
277 <!DOCTYPE html>

ReactStaticmain.tsx3 matches

@jxnblkUpdated 3 months ago
22}
23
24export function render<T>(
25 /** Root-level React component that renders an entire <html> element
26 * including the head and body tags.
37 // }
38
39 return async function handler(request: Request): Promise<Response> {
40 const main = reactRender(Component);
41 const middleware: Middleware[] = [
66 Component: React.ComponentType<ReactStreamProps>,
67): Middleware =>
68 async function(req: DataRequest, res: Response): Promise<Response> {
69 const { renderToStaticMarkup } = await import("https://esm.sh/react-dom@18.3.1/server");
70

ReactStaticREADME.md4 matches

@jxnblkUpdated 3 months ago
7import { render, React } from "https://esm.town/v/jxnblk/ReactStatic";
8
9function App() {
10 return (
11 <html>
55```tsx
56// example middleware
57async function api (req: Request, res: Response, next): Promise<Response> {
58 if (req.pathname !== "/api") return next();
59 if (req.method === "POST") {
71```tsx
72// example middleware
73async function getInitialProps (req: Request, res: Response, next) {
74 // fetch data or do async work to pass as props to the component
75 req.data = {
88import { render } from "https://esm.town/v/jxnblk/ReactStatic";
89
90function App () {
91 return (
92 <html>

ReactStream_migratedmain.tsx3 matches

@jxnblkUpdated 3 months ago
22}
23
24export function render<T>(
25 /** Root-level React component that renders an entire <html> element
26 * including the head and body tags.
41 }
42
43 return async function handler(request: Request): Promise<Response> {
44 const main = reactStream(Component, module);
45 const middleware: Middleware[] = [
76 module: string | false,
77): Middleware =>
78 async function(req: DataRequest, res: Response): Promise<Response> {
79 const { renderToReadableStream } = await import("https://esm.sh/react-dom@18.3.1/server");
80

myBookmarkManagermain.tsx19 matches

@arfanUpdated 3 months ago
4import React, { useEffect, useRef, useState } from "https://esm.sh/react@18.2.0";
5
6function MyBookmarkManager() {
7 const [allSavedBookmarks, setAllSavedBookmarks] = useState([]);
8 const [darkModeEnabled, setDarkModeEnabled] = useState(true);
70
71 // ----------------- Helpers -----------------
72 function getSiteIconURL(bookmark) {
73 const explicitFavicon = bookmark.faviconURL?.trim();
74 if (explicitFavicon) return explicitFavicon;
180
181 // ----------------- Data Loading -----------------
182 async function fetchSavedBookmarks() {
183 const response = await fetch("/api/bookmarks");
184 const data = await response.json();
189
190 // ----------------- Overlays -----------------
191 function showAddNewBookmarkOverlay() {
192 setBookmarkFormData({
193 bookmarkCategory: "",
204 }
205
206 function handleRightClickOnBookmark(e, bookmark) {
207 e.preventDefault();
208 setBookmarkFormData({
220 }
221
222 function closeAddBookmarkOverlay() {
223 setShowAddBookmarkOverlay(false);
224 }
225
226 function closeSettingsOverlay() {
227 setShowSettingsOverlay(false);
228 }
229
230 // ----------------- CRUD -----------------
231 async function handleBookmarkFormSubmit(e) {
232 e.preventDefault();
233 if (editBookmarkId === null) {
273
274 // ----------------- Export / Import -----------------
275 async function saveAllBookmarks() {
276 const response = await fetch("/api/bookmarks/export");
277 const bookmarkData = await response.text(); // Get as text instead of blob
289 }
290
291 function importBookmarksFromFile(event) {
292 const uploadedFile = event.target.files[0];
293 if (uploadedFile) {
316 }
317
318 function triggerFileUpload() {
319 fileInputRef.current.click();
320 }
321
322 // ----------------- Category Filtering -----------------
323 function toggleSelectedCategory(category) {
324 setSelectedBookmarkCategories((prev) =>
325 prev.includes(category)
329 }
330
331 function resetAllCategories() {
332 setSelectedBookmarkCategories([]);
333 }
334
335 // ----------------- Field Visibility Toggles -----------------
336 function toggleBookmarkFieldVisibility(fieldName) {
337 setBookmarkVisibility((prev) => ({
338 ...prev,
342
343 // ----------------- Opening Bookmarks -----------------
344 function openBookmarkInSameTab(url) {
345 const actualURL = url.startsWith("http") ? url : `https://${url}`;
346 window.location.href = actualURL;
347 }
348
349 function openBookmarkInNewTab(url) {
350 const actualURL = url.startsWith("http") ? url : `https://${url}`;
351 window.open(actualURL, "_blank", "noopener,noreferrer");
376 // Clipboard Paste Helpers
377 // ------------------------------------------------------------------------
378 async function handlePasteToField(fieldName) {
379 try {
380 const text = await navigator.clipboard.readText();
1270}
1271
1272function startApp() {
1273 createRoot(document.getElementById("app-root")).render(<MyBookmarkManager />);
1274}
1512});
1513
1514export default async function handleRequest(request) {
1515 return app.fetch(request);
1516}

ampleCopperMagpiemain.tsx3 matches

@akshaybondre123Updated 3 months ago
4import React, { useEffect, useState } from "https://esm.sh/react@18.2.0";
5
6function CreativeDeveloperPortfolio() {
7 const [activeSection, setActiveSection] = useState("home");
8
299}
300
301function client() {
302 createRoot(document.getElementById("root")).render(<CreativeDeveloperPortfolio />);
303}
305if (typeof document !== "undefined") { client(); }
306
307export default async function server(request: Request): Promise<Response> {
308 return new Response(
309 `

falDemoAppmain.tsx3 matches

@ben5mills5Updated 3 months ago
5import { falProxyRequest } from "https://esm.town/v/stevekrouse/falProxyRequest";
6
7function App() {
8 const [prompt, setPrompt] = useState("");
9 const [imageUrl, setImageUrl] = useState("");
103}
104
105function client() {
106 createRoot(document.getElementById("root")).render(<App />);
107}
108if (typeof document !== "undefined") { client(); }
109
110export default async function server(req: Request): Promise<Response> {
111 const url = new URL(req.url);
112 if (url.pathname === "/") {

statusmain.tsx3 matches

@charmaineUpdated 3 months ago
5import { renderToString } from "npm:react-dom/server";
6
7function StatusRow({ rows }) {
8 return (
9 <div className="w-full flex flex-col space-y-2">
28}
29
30function StatusSection({ url, rows }) {
31 const sectionRows = rows.filter(row => row[0] === url);
32 const percentUp = Math.round((sectionRows.filter(row => row[1]).length / sectionRows.length) * 100);
44}
45
46export default async function(req: Request): Promise<Response> {
47 const { rows } = await sqlite.execute(
48 "select url, ok, duration, timestamp from uptime order by timestamp desc limit 200",

getFileEmail4 file matches

@shouserUpdated 1 week ago
A helper function to build a file's email
tuna

tuna8 file matches

@jxnblkUpdated 1 week 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": "*",