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=1380&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 18948 results for "function"(1715ms)

hnFollowAppmain.tsx2 matches

@omerco•Updated 5 months ago
3import { hnLatestPosts } from "https://esm.town/v/stevekrouse/hnLatestPosts?v=18";
4
5export const hnFollowApp = function(authors: string[]) {
6 return async function({ lastRunAt }) {
7 let posts = await hnLatestPosts({
8 authors,

cerebras_codermain.tsx5 matches

@omerco•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("");
18 >(null);
19
20 async function handleSubmit(e: React.FormEvent) {
21 e.preventDefault();
22 setLoading(true);
97}
98
99function client() {
100 createRoot(document.getElementById("root")!).render(<App />);
101}
105}
106
107function extractCodeFromFence(text: string): string {
108 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
109 return htmlMatch ? htmlMatch[1].trim() : text;
110}
111
112export default async function server(req: Request): Promise<Response> {
113 if (req.method === "POST") {
114 const client = new Cerebras();

statusmain.tsx3 matches

@omerco•Updated 5 months ago
5import { renderToString } from "npm:react-dom/server";
6
7function StatusRow({ rows }) {
8 return (
9 <div className="w-full flex flex-col space-y-2">
28}
29
30function StatusSection({ url, rows }) {
31 const sectionRows = rows.filter(row => row[0] === url);
32 const percentUp = Math.round((sectionRows.filter(row => row[1]).length / sectionRows.length) * 100);
44}
45
46export default async function(req: Request): Promise<Response> {
47 const { rows } = await sqlite.execute(
48 "select url, ok, duration, timestamp from uptime order by timestamp desc limit 200",

uptimemain.tsx1 match

@omerco•Updated 5 months ago
6);
7
8export async function uptimeCheck(url: string) {
9 let reason: string, status: number, end: number;
10 let ok = true;

weatherGPTmain.tsx1 match

@omerco•Updated 5 months ago
31console.log(text);
32
33export async function weatherGPT() {
34 await email({ subject: "Weather Today", text });
35}

Techstoremain.tsx7 matches

@aneesimran•Updated 5 months ago
43}
44
45function ProductCard({ product, addToCart }) {
46 return (
47 <div
79}
80
81function ParallaxSlider() {
82 const [offsetY, setOffsetY] = useState(0);
83 const handleScroll = () => setOffsetY(window.pageYOffset);
112}
113
114function Footer() {
115 return (
116 <footer className="modern-footer">
153}
154
155function Sidebar() {
156 return (
157 <div className="sidebar">
174}
175
176function App() {
177 const [cart, setCart] = useState([]);
178 const [isClient, setIsClient] = useState(false);
290}
291
292function client() {
293 const root = document.getElementById("root");
294 if (root) {
309}
310
311export default async function server(req: Request): Promise<Response> {
312 return new Response(`
313 <!DOCTYPE html>

labLoginBanUsermain.tsx1 match

@svenlaa•Updated 5 months ago
2import { sqlite } from "https://esm.town/v/std/sqlite";
3
4export default async function(req: Request): Promise<Response> {
5 const TABLE_NAME = "lab_login_users_with_times";
6 const body = await req.json();

lovelyYellowXerinaemain.tsx18 matches

@mikehiggins•Updated 5 months ago
53};
54
55// Simple sentiment analysis function (unchanged)
56function analyseSentiment(text) {
57 const positiveWords = new Set([
58 'good', 'great', 'excellent', 'wonderful', 'amazing', 'fantastic', 'awesome',
84
85// Improved TF-IDF implementation with additional filtering
86function calculateTFIDF(text, outputSize = 7) {
87 const words = text.toLowerCase().match(/\b[a-z]{2,}\b/g) || [];
88 const wordCount = words.length;
133}
134
135// Updated function to calculate word frequency
136function calculateWordFrequency(text, topN = 30) {
137 const words = text.toLowerCase().match(/\b[a-z]{3,}\b/g) || [];
138 const frequency = {};
147}
148
149// Updated function to generate a fun fact
150function generateFunFact(text) {
151 const wordCount = text.trim().split(/\s+/).length;
152 const charCount = text.length;
168}
169
170// Function to generate a simple summary (unchanged)
171function generateSummary(text, sentenceCount = 3) {
172 const sentences = text.match(/[^\.!\?]+[\.!\?]+/g) || [];
173 return sentences.slice(0, sentenceCount).join(' ');
174}
175
176// Updated function to clean the extracted text
177function cleanText(text) {
178 return text
179 .replace(/<[^>]*>/g, '') // Remove HTML tags
187}
188
189// Updated function to fetch and parse URL content
190async function fetchUrlContent(url) {
191 try {
192 console.log('Fetching URL:', url);
199 const root = parse(html);
200
201 if (!root || typeof root.querySelectorAll !== 'function') {
202 throw new Error('Failed to parse HTML content');
203 }
462 });
463
464 async function analyseText() {
465 const text = inputText.value.trim();
466 const url = urlInput.value.trim();
540 }
541
542 function displayResult(data) {
543 let tfidfHtml = '<br><h3>Top TF-IDF Scores:</h3>';
544 tfidfHtml += '<table><tr><th>Term</th><th>Score</th><th>Synonyms</th></tr>';
634
635 // Client-side character count limit
636 inputText.addEventListener('input', function() {
637 if (this.value.length > 100000) {
638 this.value = this.value.slice(0, 100000);
733});
734
735export default async function(request: Request): Promise<Response> {
736 return app.fetch(request);
737}

sanguineCyanMastodonmain.tsx6 matches

@mikehiggins•Updated 5 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function calculateTFIDF(text, outputSize = 7) {
6 const words = text.toLowerCase().match(/\b\w+\b/g) || [];
7 const wordCount = words.length;
35}
36
37function calculateWordFrequency(text, topN = 30) {
38 const words = text.toLowerCase().match(/\b\w+\b/g) || [];
39 const wordFreq = {};
50}
51
52function isValidWord(word) {
53 return word.length > 1;
54}
60]);
61
62function App() {
63 const [text, setText] = useState("");
64 const [tfidfResults, setTfidfResults] = useState([]);
125}
126
127function client() {
128 createRoot(document.getElementById("root")).render(<App />);
129}
133}
134
135export default async function(request: Request): Promise<Response> {
136 return new Response(`
137 <!DOCTYPE html>

parseXMLmain.tsx1 match

@g000m•Updated 5 months ago
1export async function parseXML(xml) {
2 // const { XMLParser } = await import("https://esm.sh/fast-xml-parser@4.5.0");
3 const { parseStringPromise } = await import("npm:xml2js");

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