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=1093&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 17305 results for "function"(4198ms)

abortablemain.tsx2 matches

@postpostscript•Updated 3 months ago
2import type { MaybePromise } from "https://esm.town/v/postpostscript/types/util.ts";
3
4export function abortable<T>(promise: MaybePromise<T>, signal?: AbortSignal): Promise<T> {
5 if (signal?.aborted) {
6 return Promise.reject(
28 };
29
30 function cleanup() {
31 signal!.removeEventListener("abort", handler);
32 }

labUploadGetUploadsmain.tsx1 match

@todepond•Updated 3 months ago
1import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
2
3export default async function(req: Request): Promise<Response> {
4 // Get all rows from lab_upload_blobs
5 const response = await sqlite.execute(`

gsheet_call_loggedREADME.md1 match

@rochambeau314•Updated 3 months ago
1# gsheet_specific_call
2Wrapper around Google Sheets API v4.
3(forked from mattx/gsheet_call; adds functionality to specify the sheet to make changes to)
4
5## Parameters

fabwbogglelikemain.tsx2 matches

@alexwein•Updated 3 months ago
2import { retryFill } from "https://esm.town/v/alexwein/gridRetryFill";
3
4export async function fabw() {
5 // Import d3 and Plot with a server-side compatible approach
6 const d3 = await import("https://cdn.jsdelivr.net/npm/d3@7/+esm");
59}
60
61export default async function(request: Request) {
62 return await fabw();
63}

cryptoVolumeTraderAdvicemain.tsx5 matches

@Sabji•Updated 3 months ago
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function CryptoTracker() {
6 const [cryptoData, setCryptoData] = useState({
7 bitcoin: null,
17
18 useEffect(() => {
19 async function fetchCryptoData() {
20 try {
21 const priceResponse = await fetch('https://api.coingecko.com/api/v3/simple/price?ids=bitcoin,ethereum,dogecoin&vs_currencies=usd&include_24hr_change=true');
61 }, []);
62
63 function analyzeTradeSignal(volume, priceChange, currentPrice) {
64 // Basic volume-based trading strategy
65 if (volume > 1000000000 && Math.abs(priceChange) > 5) {
142}
143
144function client() {
145 createRoot(document.getElementById("root")).render(<CryptoTracker />);
146}
147if (typeof document !== "undefined") { client(); }
148
149export default async function server(request: Request): Promise<Response> {
150 return new Response(`
151 <html>

ReminderAppmain.tsx3 matches

@Azam123•Updated 3 months ago
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function App() {
6 const [reminders, setReminders] = useState([]);
7 const [newReminder, setNewReminder] = useState({
177}
178
179function client() {
180 createRoot(document.getElementById("root")).render(<App />);
181}
182if (typeof document !== "undefined") { client(); }
183
184export default async function server(request: Request): Promise<Response> {
185 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
186 const KEY = "ReminderApp";

cerebras_codermain.tsx11 matches

@muneeb683•Updated 3 months ago
24);
25
26function Hero({
27 prompt,
28 setPrompt,
45
46 <p className="text-[#bababa] text-center max-w-[25ch] mx-auto my-4 font-dm-sans">
47 Turn your ideas into fully functional apps in{" "}
48 <span className="relative w-fit text-fuchsia-400 z-10 italic font-semibold rounded-full">
49 less than a second
116}
117
118function App() {
119 const previewRef = React.useRef<HTMLDivElement>(null);
120 const [prompt, setPrompt] = useState("");
170 });
171
172 function handleStarterPromptClick(promptItem: typeof prompts[number]) {
173 setLoading(true);
174 setTimeout(() => handleSubmit(promptItem.prompt), 0);
175 }
176
177 async function handleSubmit(e: React.FormEvent | string) {
178 if (typeof e !== "string") {
179 e.preventDefault();
226 }
227
228 function handleVersionChange(direction: "back" | "forward") {
229 const { currentVersionIndex, versions } = versionHistory;
230 if (direction === "back" && currentVersionIndex > 0) {
974);
975
976function client() {
977 const path = window.location.pathname;
978 const root = createRoot(document.getElementById("root")!);
1010}
1011
1012function extractCodeFromFence(text: string): string {
1013 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
1014 return htmlMatch ? htmlMatch[1].trim() : text;
1015}
1016
1017async function generateCode(prompt: string, currentCode: string) {
1018 const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
1019 if (starterPrompt) {
1060}
1061
1062export default async function cerebras_coder(req: Request): Promise<Response> {
1063 // Dynamic import for SQLite to avoid client-side import
1064 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
1163 <meta property="og:site_name" content="Cerebras Coder">
1164 <meta property="og:url" content="https://cerebrascoder.com"/>
1165 <meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
1166 <meta property="og:type" content="website">
1167 <meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">

searchWithSerpApimain.tsx2 matches

@charmaine•Updated 3 months ago
1export async function searchWithSerpApi({
2 query,
3 site,
41}
42
43function parseDate(snippet?: string): string | null {
44 if (!snippet) return null;
45

enchantingBlushOrangutanmain.tsx3 matches

@akshaybondre123•Updated 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 `

cleverIndigoSwallowmain.tsx3 matches

@akshaybondre123•Updated 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 `

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 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": "*",