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=887&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"(1531ms)

statusstatus3 matches

@safone•Updated 2 months ago
9const thisURL = parseProject(import.meta.url).links.self.project;
10
11function StatusRow({ rows }) {
12 return (
13 <div className="w-full flex flex-col space-y-2">
31}
32
33function StatusSection({ url, rows }) {
34 const sectionRows = rows.filter(row => row[0] === url);
35 const percentUp = Math.round((sectionRows.filter(row => row[1]).length / sectionRows.length) * 100);
47}
48
49export default async function(req: Request): Promise<Response> {
50 const { rows } = await sqlite.execute(
51 "select url, ok, duration, timestamp from uptime order by timestamp desc limit 200",

statussparklineSVG1 match

@safone•Updated 2 months ago
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2export function SparklineSVG({ strokeWidth = 2, data = [], fill = "none", stroke = "black" }) {
3 const padding = 2;
4 const xMargin = 25;

statusnotify1 match

@safone•Updated 2 months ago
4const thisURL = parseProject(import.meta.url).links.self.latest;
5
6export async function notify(message: string) {
7 await email({ subject: message, text: `Email sent from ${thisURL}` });
8}

statusmonitor1 match

@safone•Updated 2 months ago
7);
8
9export async function uptimeCheck(url: string, attempt = 1) {
10 let reason: string = "";
11 let status: number | null = null;

trendsToEmailflourishingBlushRaccoon1 match

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

brightEmeraldQuokkamain.tsx3 matches

@riii•Updated 2 months ago
29];
30
31function App() {
32 const [noClicks, setNoClicks] = useState(0);
33 const [isValentine, setIsValentine] = useState(false);
114}
115
116function client() {
117 createRoot(document.getElementById("root")).render(<App />);
118}
119if (typeof document !== "undefined") { client(); }
120
121export default async function server(request: Request): Promise<Response> {
122 return new Response(
123 `

jovialTurquoiseVicunamain.tsx3 matches

@riii•Updated 2 months ago
28];
29
30function App() {
31 const [noClicks, setNoClicks] = useState(0);
32 const [isValentine, setIsValentine] = useState(false);
113}
114
115function client() {
116 createRoot(document.getElementById("root")).render(<App />);
117}
118if (typeof document !== "undefined") { client(); }
119
120export default async function server(request: Request): Promise<Response> {
121 return new Response(
122 `

mathOfTheDayaccomplishedOrangePenguin15 matches

@charmaine•Updated 2 months ago
5import React, { useEffect, useState } from "https://esm.sh/react@18.2.0";
6
7function renderMath(text) {
8 if (!text) return "";
9 return text.replace(/\$\$(.*?)\$\$|\$(.*?)\$/g, (match, eq1, eq2) => {
21}
22
23function App() {
24 const [problem, setProblem] = useState(null);
25 const [userAnswer, setUserAnswer] = useState("");
100 <ul>
101 <li>
102 Functions: <code>sin(x)</code>, <code>cos(x)</code>, <code>tan(x)</code>
103 </li>
104 <li>
105 Inverse functions: <code>arcsin(x)</code> or <code>sin^{-1}(x)</code>
106 </li>
107 <li>
150}
151
152function normalizeAnswer(answer) {
153 // Remove all spaces and convert to lowercase
154 answer = answer.replace(/\s+/g, "").toLowerCase();
155
156 // Standardize trig function notations
157 answer = answer.replace(/arcsin/g, "sin^{-1}");
158 answer = answer.replace(/arccos/g, "cos^{-1}");
180}
181
182function client() {
183 createRoot(document.getElementById("root")).render(<App />);
184}
188}
189
190export default async function server(request) {
191 const { OpenAI } = await import("https://esm.town/v/std/openai");
192 const { blob } = await import("https://esm.town/v/std/blob");
209 },
210 ],
211 functions: [
212 {
213 name: "generate_math_problem",
233 },
234 ],
235 function_call: { name: "generate_math_problem" },
236 });
237
238 const functionCall = completion.choices[0].message.function_call;
239 if (!functionCall || functionCall.name !== "generate_math_problem") {
240 return new Response("Failed to generate problem", { status: 500 });
241 }
243 let problem;
244 try {
245 problem = JSON.parse(functionCall.arguments);
246 } catch (error) {
247 console.error("Failed to parse function call arguments:", error);
248 console.log("Raw arguments:", functionCall.arguments);
249 return new Response("Failed to generate problem", { status: 500 });
250 }

imageToWebPConvertermain.tsx3 matches

@AIWB•Updated 2 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 const [imageUrl, setImageUrl] = useState(null);
7 const [webpUrl, setWebpUrl] = useState(null);
93}
94
95function client() {
96 createRoot(document.getElementById("root")).render(<App />);
97}
99if (typeof document !== "undefined") { client(); }
100
101export default async function server(request: Request): Promise<Response> {
102 return new Response(`
103 <!DOCTYPE html>

parseImportMetaproject.test3 matches

@std•Updated 2 months ago
94}
95
96function runTest(test: TestCase) {
97 let pass, message;
98 let start = performance.now();
111}
112
113function renderBadge({ label, passedCount, testCount }: { label?: string; passedCount: number; testCount: number }) {
114 return makeBadge({
115 label: label ?? "Tests",
119}
120
121function renderTestResults(tests: TestCase[], outputs: TestOutput[]) {
122 const passedCount = outputs.filter((output: TestOutput) => output.pass).length;
123 const testCount = tests.length;

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