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=1355&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 18949 results for "function"(1868ms)

CGPAcalculatormain.tsx3 matches

@Aditya230•Updated 5 months ago
18};
19
20function GPACalculator() {
21 const [courses, setCourses] = useState([
22 { credits: "credits", grade: "O" },
88}
89
90function client() {
91 createRoot(document.getElementById("root")).render(<GPACalculator />);
92}
94if (typeof document !== "undefined") { client(); }
95
96export default async function server(request: Request): Promise<Response> {
97 return new Response(
98 `

image2pdfmain.tsx3 matches

@kvrt•Updated 5 months ago
4import { PDFDocument } from "https://esm.sh/pdf-lib";
5
6function App() {
7 const [file, setFile] = useState<File | null>(null);
8 const [pdfUrl, setPdfUrl] = useState<string | null>(null);
96}
97
98function client() {
99 createRoot(document.getElementById("root")).render(<App />);
100}
101if (typeof document !== "undefined") { client(); }
102
103export default async function server(request: Request): Promise<Response> {
104 if (request.method === 'POST') {
105 const formData = await request.formData();

translateTextAPImain.tsx1 match

@sky_porie_fire443•Updated 5 months ago
1export default async function server(request: Request): Promise<Response> {
2 // Handle CORS preflight and OPTIONS requests
3 if (request.method === "OPTIONS") {

popularAquamarineDormousemain.tsx3 matches

@adnan•Updated 5 months ago
14}
15
16// async function overlayTextOnImage(imageDef: Image): Promise<Uint8Array> {
17// console.log(imageDef);
18// const image = await loadImage(imageDef);
56// }
57
58async function overlayTextOnImage(imageDef: Image): Promise<Uint8Array> {
59 const image = await loadImage(imageDef);
60
82}
83
84export default async function generateOneMastodonPost(request: Request): Promise<Response> {
85 const inputs = await blob.list(BLOB_PREFIX);
86

findPlatesmain.tsx6 matches

@adnan•Updated 5 months ago
15}
16
17// Function to format the plate number
18function formatPlateNumber(text: string): string {
19 const match = text.match(/([A-Za-z\s]+)plate number for sale: (.+)/);
20 if (match) {
26}
27
28// Function to extract the price with currency
29function extractPrice(text: string): string | null {
30 const match = text.match(/(\d{1,3}(?: \d{3})*)<span> AED<\/span>/);
31 if (match) {
35}
36
37async function fetchRSSFeed(): Promise<any> {
38 try {
39 const response = await fetch("http://numbers.ae/plate/rss");
62// const feedData = await fetchRSSFeed();
63
64export default async function run() {
65 console.log("running");
66 let results = await fetchRSSFeed();

freeBlackTernmain.tsx1 match

@adnan•Updated 5 months ago
2import { blob } from "https://esm.town/v/std/blob";
3
4export default async function run() {
5 let posts = (await blob.list()).map(n => n.key);
6 console.log(posts.length);

blob_adminmain.tsx8 matches

@andiebuk•Updated 5 months ago
13}
14
15function Tooltip({ children, content }: TooltipProps) {
16 const [isVisible, setIsVisible] = useState(false);
17 const tooltipRef = useRef<HTMLDivElement>(null);
52}
53
54function formatBytes(bytes: number, decimals = 2) {
55 if (bytes === 0) return "0 Bytes";
56 const k = 1024;
61}
62
63function copyToClipboard(text: string) {
64 navigator.clipboard.writeText(text).then(() => {
65 console.log("Text copied to clipboard");
69}
70
71function ActionMenu({ blob, onDownload, onRename, onDelete, onMoveToPublic, onMoveOutOfPublic }) {
72 const [isOpen, setIsOpen] = useState(false);
73 const menuRef = useRef(null);
76
77 useEffect(() => {
78 function handleClickOutside(event) {
79 if (menuRef.current && !menuRef.current.contains(event.target)) {
80 event.stopPropagation();
158}
159
160function BlobItem({ blob, onSelect, isSelected, onDownload, onRename, onDelete, onMoveToPublic, onMoveOutOfPublic }) {
161 const [isLoading, setIsLoading] = useState(false);
162 const decodedKey = decodeURIComponent(blob.key);
219}
220
221function App({ initialEmail, initialProfile }) {
222 const encodeKey = (key: string) => encodeURIComponent(key);
223 const decodeKey = (key: string) => decodeURIComponent(key);
645}
646
647function client() {
648 const initialEmail = document.getElementById("root").getAttribute("data-email");
649 const initialProfile = JSON.parse(document.getElementById("root").getAttribute("data-profile"));

cerebras_codermain.tsx9 matches

@caseyg•Updated 5 months ago
6import { tomorrow } from "https://esm.sh/react-syntax-highlighter/dist/esm/styles/prism";
7
8function App() {
9 const [prompt, setPrompt] = useState("hello llamapalooza");
10 const [code, setCode] = useState("");
31 }[]>([]);
32
33 async function handleSubmit(e: React.FormEvent) {
34 e.preventDefault();
35 setLoading(true);
64 }
65
66 // Function to download prompt history and HTML versions
67 function downloadHistory() {
68 const historyBlob = new Blob(
69 [JSON.stringify(promptHistory, null, 2)],
80 }
81
82 // Function to download HTML versions
83 function downloadHTMLVersions() {
84 promptHistory.forEach((entry) => {
85 const htmlBlob = new Blob([entry.code], { type: 'text/html' });
164}
165
166function client() {
167 createRoot(document.getElementById("root")!).render(<App />);
168}
172}
173
174function extractCodeFromFence(text: string): string {
175 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
176 return htmlMatch ? htmlMatch[1].trim() : text;
177}
178
179export default async function server(req: Request): Promise<Response> {
180 if (req.method === "POST") {
181 const client = new Cerebras();

kickstart_feedbackmain.tsx6 matches

@bansal•Updated 5 months ago
8}
9
10function statusColor(status: string) {
11 switch (status) {
12 case "Planned":
23}
24
25function DetailsModal({ record, onClose }: { record: AirtableRecord; onClose: () => void }) {
26 return (
27 <div className="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
40}
41
42function SubmitFeedbackModal({ onClose }: { onClose: () => void }) {
43 return (
44 <div className="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
68}
69
70function AirtableList() {
71 const [records, setRecords] = useState<AirtableRecord[]>([]);
72 const [filteredRecords, setFilteredRecords] = useState<AirtableRecord[]>([]);
349}
350
351function client() {
352 createRoot(document.getElementById("root")).render(<AirtableList />);
353}
354if (typeof document !== "undefined") { client(); }
355
356export default async function server(request: Request): Promise<Response> {
357 const BASE_ID = Deno.env.get("airtable_kickstart_feedback_base");
358 const TABLE_NAME = "Responses";

map_examplesmain.tsx3 matches

@gloodata•Updated 5 months ago
3const FN_MAP = "FnMap";
4
5async function getInfo() {
6 return {
7 title: "Map Examples (JavaScript)",
21}
22
23function fnMap(_info: any) {
24 return {
25 info: {
199}
200
201async function handleRequest(body: any) {
202 const { opName, info } = body;
203 switch (opName) {

getFileEmail4 file matches

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

tuna8 file matches

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