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=846&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 17278 results for "function"(1773ms)

orbiterHealthnotify1 match

@stevedylandev•Updated 2 months ago
4const thisURL = parseProject(import.meta.url).links.self.latest;
5
6export async function notify(message: string) {
7 await email({
8 to: ["steve@orbiter.host", "justin@orbiter.host"],

cerebras_codermain.tsx10 matches

@mak420•Updated 2 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) {
1059}
1060
1061export default async function server(req: Request): Promise<Response> {
1062 // Dynamic import for SQLite to avoid client-side import
1063 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");

getProjectsAsZipsApp.tsx1 match

@charmaine•Updated 2 months ago
4import { MessageInput } from "./MessageInput.tsx";
5
6export function App(
7 { initialMessages = [], thisProjectURL }: { initialMessages?: Message[]; thisProjectURL?: string },
8) {

Prompt_Improverorchestrator1 match

@toowired•Updated 2 months ago
4const TIMEOUT_MS = 30000; // 30 second timeout
5
6export default async function(request: Request) {
7 try {
8 const { prompt } = await request.json();

practicalIvoryTurtlemain.tsx1 match

@Mustakim12•Updated 2 months ago
12 * @returns {Promise<void>} Sends an email if new stock trades are found
13 */
14export async function fetchCongressTradeReports({ lastRunAt }) {
15 // Fetch the latest trade reports from Capitol Trades API
16 const res = await fetchJSON(

fetchCongressTradeReportsmain.tsx1 match

@Mustakim12•Updated 2 months ago
12 * @returns {Promise<void>} Sends an email if new stock trades are found
13 */
14export async function fetchCongressTradeReports({ lastRunAt }) {
15 // Fetch the latest trade reports from Capitol Trades API
16 const res = await fetchJSON(

ACControllerAppmain.tsx3 matches

@Bikash•Updated 2 months ago
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function ACController() {
6 const [temperature, setTemperature] = useState(72);
7 const [mode, setMode] = useState('cool');
90}
91
92function client() {
93 createRoot(document.getElementById("root")).render(<ACController />);
94}
95if (typeof document !== "undefined") { client(); }
96
97export default async function server(request: Request): Promise<Response> {
98 return new Response(`
99 <html>

aqimain.tsx1 match

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

Prompt_Improverindex.html5 matches

@toowired•Updated 2 months ago
1export default async function(request) {
2 return new Response(
3 `<!DOCTYPE html>
8 <script>
9 if ('serviceWorker' in navigator) {
10 window.addEventListener('load', function() {
11 navigator.serviceWorker.register('/service-worker.js').then(function(registration) {
12 console.log('ServiceWorker registration successful with scope: ', registration.scope);
13 }, function(err) {
14 console.log('ServiceWorker registration failed: ', err);
15 });
16 });
17 }
18 function improvePrompt() {
19 const promptInput = document.getElementById('promptInput').value;
20 // Simulate the improvement process

Prompt_ImproverPrompt_Improver1 match

@toowired•Updated 2 months ago
6const MAX_STEPS = 10;
7
8export default async function(request: Request) {
9 const {
10 prompt,

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": "*",