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=2390&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 28542 results for "function"(4801ms)

openaimain.tsx1 match

@std•Updated 7 months ago
12 * @param {number} [opts.timeout=10 minutes] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
13 * @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
14 * @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
15 * @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
16 * @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.

reqEvaltownmain.tsx4 matches

@vawogbemi•Updated 7 months ago
1import net, { AddressInfo } from "node:net";
2
3export default async function(req: Request): Promise<Response> {
4 return serveRequest(
5 req,
6 `data:text/tsx,${
7 encodeURIComponent(`
8export default async function(req: Request): Promise<Response> {
9 return Response.json("I am within a worker!")
10}
14}
15
16export async function serveRequest(req: Request, importUrl: string): Promise<Response> {
17 let port = await getFreePort();
18 const worker = new Worker(`https://esm.town/v/maxm/evaltownWorker?cachebust=${crypto.randomUUID()}`, {
56 });
57
58export async function isPortListening(port: number): Promise<boolean> {
59 let isListening = false;
60 const maxWaitTime = 2000; // ms

valtowntownmain.tsx5 matches

@vawogbemi•Updated 7 months ago
48await contentStore.init();
49
50function Town() {
51 return (
52 <div
69}
70
71function HomePage() {
72 return (
73 <html>
82 <form method="POST" action="/submit">
83 <textarea name="handler" rows={10} cols={50} autoFocus>
84 {`export default async function(req: Request) {
85 return Response.json("Hello, world!");
86}`}
95}
96
97function ContentPage({ handler, id }: { handler: string; id: string }) {
98 return (
99 <html>
122 let originalContent = textarea.value;
123
124 textarea.addEventListener('input', function() {
125 if (textarea.value !== originalContent) {
126 submitButton.style.display = 'inline-block';

graphqlAPIEndpointmain.tsx5 matches

@flesch•Updated 7 months ago
15});
16
17// Function to handle GraphQL requests
18async function handleGraphQLRequest(request: Request): Promise<Response> {
19 const { query, variables } = await request.json();
20
30}
31
32// HTTP handler function
33export default altairClient(async function(req: Request): Promise<Response> {
34 return handleGraphQLRequest(req);
35});
36
37// Without the Altair GraphQL client:
38// export default async function(req: Request): Promise<Response> {
39// if (req.method === "POST") {
40// return handleGraphQLRequest(req);

altairClientmain.tsx2 matches

@flesch•Updated 7 months ago
3import { getDistDirectory, renderAltair, RenderOptions } from "npm:altair-static";
4
5export function altairClient(next: (request: Request) => Response | Promise<Response>, options?: RenderOptions) {
6 return async (request: Request) => {
7 const { pathname } = new URL(request.url);
26}
27
28export default altairClient(async function(request: Request): Promise<Response> {
29 return new Response("Not found", { status: 404 });
30});

altairClientREADME.md4 matches

@flesch•Updated 7 months ago
22});
23
24// Function to handle GraphQL requests
25async function handleGraphQLRequest(request: Request): Promise<Response> {
26 const { query, variables } = await request.json();
27
39}
40
41// HTTP handler function
42export default altairClient(async function(req: Request): Promise<Response> {
43 if (req.method === "POST") {
44 return handleGraphQLRequest(req);

getProfileProfilePagemain.tsx9 matches

@elliotbraem•Updated 7 months ago
40});
41
42async function getProfile(username: string): Promise<Profile | null> {
43 const response = await social.get({
44 keys: [`${username}/profile/**`],
54}
55
56function SkeletonLoader() {
57 return (
58 <div className="w-full flex flex-col items-center justify-center space-y-4">
70}
71
72function BirthdayBanner({ name }: { name: string }) {
73 return (
74 <div className="birthday-banner">
78}
79
80function launchConfetti() {
81 const defaults = { startVelocity: 45, spread: 90, ticks: 100, zIndex: 1000 };
82
96}
97
98function App({ initialAccountId }: { initialAccountId: string }) {
99 const [profile, setProfile] = useState<Profile | null>(null);
100 const [loading, setLoading] = useState(true);
168}
169
170function getSocialLink(platform: string, username: string) {
171 const links: Record<string, string> = {
172 github: `https://github.com/${username}`,
179}
180
181function getSocialIcon(platform: string) {
182 const icons: Record<string, string> = {
183 github: "📂",
190}
191
192export function client(accountId: string) {
193 createRoot(document.getElementById("root")).render(<App initialAccountId={accountId} />);
194}
195
196export default async function server(request: Request): Promise<Response> {
197 const url = new URL(request.url);
198 const accountId = url.pathname.split("/").pop() || "efiz.near"; // Default to 'efiz.near' if no accountId is provided

falDemoAppmain.tsx3 matches

@spigooli•Updated 7 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 === "/") {

elegantJadeParrotfishmain.tsx1 match

@temptemp•Updated 7 months ago
11import { load } from "npm:cheerio";
12
13async function archive(url: string) {
14 const response = await fetch(url);
15 const body = await response.text();

verbalScarletAntelopemain.tsx3 matches

@vawogbemi•Updated 7 months ago
7import About from "https://esm.town/v/vawogbemi/whoIsHiringAbout";
8
9function App() {
10 const tabs = { "/": "Home", "/about": "About" };
11 const [activeTab, setActiveTab] = useState("/");
352}
353
354function ServerApp() {
355 return (
356 <html>
375}
376
377export default async function(req: Request): Promise<Response> {
378 const url = new URL(req.url);
379 if (url.pathname === "/api/stories") {

getFileEmail4 file matches

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

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