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/$%7Bart_info.art.src%7D?q=function&page=1536&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 20531 results for "function"(3118ms)

lang_codemain.tsx4 matches

@faseeu•Updated 6 months ago
118}
119
120function App() {
121 const [prompt, setPrompt] = useState("");
122 const [generationResult, setGenerationResult] = useState<{
128 const [error, setError] = useState<string | null>(null);
129
130 async function handleSubmit(e: React.FormEvent) {
131 e.preventDefault();
132 setLoading(true);
195}
196
197function client() {
198 createRoot(document.getElementById("root")!).render(<App />);
199}
201if (typeof document !== "undefined") { client(); }
202
203export default async function server(req: Request): Promise<Response> {
204 return new Response(
205 `

sqlitemain.tsx7 matches

@markscrivo•Updated 6 months ago
31
32// ------------
33// Functions
34// ------------
35
36async function execute(statement: InStatement, args?: InArgs): Promise<ResultSet> {
37 const res = await fetch(`${API_URL}/v1/sqlite/execute`, {
38 method: "POST",
49}
50
51async function batch(statements: InStatement[], mode?: TransactionMode): Promise<ResultSet[]> {
52 const res = await fetch(`${API_URL}/v1/sqlite/batch`, {
53 method: "POST",
64}
65
66function createResError(body: string) {
67 try {
68 const e = zLibsqlError.parse(JSON.parse(body));
85}
86
87function normalizeStatement(statement: InStatement, args?: InArgs) {
88 if (Array.isArray(statement)) {
89 // for the case of an array of arrays
107}
108
109function upgradeResultSet(results: ImpoverishedResultSet): ResultSet {
110 return {
111 ...results,
116// adapted from
117// https://github.com/tursodatabase/libsql-client-ts/blob/17dd996b840c950dd22b871adfe4ba0eb4a5ead3/packages/libsql-client/src/sqlite3.ts#L314C1-L337C2
118function rowFromSql(
119 sqlRow: Array<unknown>,
120 columns: Array<string>,

homemain.tsx1 match

@patrick6971•Updated 6 months ago
2import { renderToString } from "npm:react-dom/server";
3
4export default async function(req: Request) {
5 return new Response(
6 renderToString(

tfidf_analyser_90s_versionmain.tsx14 matches

@mikehiggins•Updated 6 months ago
17]);
18
19// Function to calculate TF-IDF
20function calculateTFIDF(text, outputSize = 7) {
21 const words = text.toLowerCase().match(/\b[a-z]{2,}\b/g) || [];
22 const wordCount = words.length;
61}
62
63// Function to calculate word frequency
64function calculateWordFrequency(text, topN = 30) {
65 const words = text.toLowerCase().match(/\b[a-z]{3,}\b/g) || [];
66 const frequency = {};
75}
76
77// Function to generate a fun fact
78function generateFunFact(text) {
79 const wordCount = text.trim().split(/\s+/).length;
80 const charCount = text.length;
96}
97
98// Function to perform simple sentiment analysis
99function analyseSentiment(text) {
100 const positiveWords = new Set([
101 "good", "great", "excellent", "wonderful", "amazing", "fantastic", "awesome", "happy", "joy", "love",
124}
125
126// Function to generate a simple summary
127function generateSummary(text, sentenceCount = 3) {
128 const sentences = text.match(/[^\.!\?]+[\.!\?]+/g) || [];
129 return sentences.slice(0, sentenceCount).join(" ");
336 });
337
338 async function analyseText() {
339 const text = inputText.value.trim();
340
389 }
390
391 function displayResult(data) {
392 let tfidfHtml = '<br><h3>Top TF-IDF Scores:</h3>';
393 tfidfHtml += '<p><em>How it works: TF-IDF calculates the importance of words by multiplying how often they appear in the text (TF) with how unique they are across all documents (IDF). This helps identify key terms that are both frequent and distinctive in the text.</em></p>';
440
441 // Client-side character count limit
442 inputText.addEventListener('input', function() {
443 if (this.value.length > 100000) {
444 this.value = this.value.slice(0, 100000);
503});
504
505export default async function(request: Request): Promise<Response> {
506 return app.fetch(request);
507}

twitterAlertmain.tsx1 match

@nick•Updated 6 months ago
4const query = "\"val.town\" OR \"val.run\" OR \"val town\" -_ValTown_ -is:retweet -from:valenzuelacity -from:val__run";
5
6export async function twitterAlert({ lastRunAt }: Interval) {
7 // search
8 // const since = Math.floor((Date.now() / 1000) - (24 * 60 * 60)); // test since for last day

cerebras_codermain.tsx5 matches

@zpankz•Updated 6 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();

genuineBrownErminemain.tsx5 matches

@natsa•Updated 6 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function NodeJSLearningTodoList() {
6 const initialTasks = [
7 {
18 {
19 text: "Funciones",
20 description: "Aprende sobre funciones regulares, arrow functions, parámetros, scope y cierres (closures).",
21 completed: false
22 },
327}
328
329function App() {
330 return <NodeJSLearningTodoList />;
331}
332
333function client() {
334 createRoot(document.getElementById("root")).render(<App />);
335}
336if (typeof document !== "undefined") { client(); }
337
338export default async function server(request: Request): Promise<Response> {
339 return new Response(`
340 <html>

cekdatatruckmain.tsx5 matches

@nirwan•Updated 6 months ago
16const transportTypes = ["Industri", "SPBU", "Kero"];
17
18function AddVehicleForm({ company, onVehicleAdded, onCancel }) {
19 const [formData, setFormData] = useState({
20 plateNumber: "",
115}
116
117function AllVehiclesTable({ onClose }) {
118 const [vehicles, setVehicles] = useState([]);
119 const [sortConfig, setSortConfig] = useState({ key: null, direction: "ascending" });
202}
203
204function App() {
205 const [selectedCompany, setSelectedCompany] = useState(null);
206 const [showScanner, setShowScanner] = useState(false);
450}
451
452function client() {
453 createRoot(document.getElementById("root")).render(<App />);
454}
456if (typeof document !== "undefined") { client(); }
457
458export default async function server(request: Request): Promise<Response> {
459 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
460 const SCHEMA_VERSION = 2;

qualityBrownTyrannosaurusmain.tsx3 matches

@natsa•Updated 6 months ago
5const STORAGE_KEY = "nodeJSLearningPath";
6
7function NodeJSLearningRoadmap() {
8 const [learningPath, setLearningPath] = useState(() => {
9 const savedPath = localStorage.getItem(STORAGE_KEY);
168}
169
170function client() {
171 createRoot(document.getElementById("root")).render(<NodeJSLearningRoadmap />);
172}
173if (typeof document !== "undefined") { client(); }
174
175export default async function server(request: Request): Promise<Response> {
176 return new Response(
177 `

email_jokemain.tsx1 match

@kswang06•Updated 6 months ago
2
3// Fetches a random joke.
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 3 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.