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=2531&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 29356 results for "function"(6263ms)

AlgoliaInstantSearchWebsitemain.tsx5 matches

@willthereader•Updated 9 months ago
2import { configure, hits, pagination, searchBox } from "https://esm.sh/instantsearch.js@4.49.1/es/widgets";
3
4function validateConfig(): { appId: string; apiKey: string } {
5 const appId = Deno.env.get("ALGOLIA_APP_ID");
6 const apiKey = Deno.env.get("ALGOLIA_SEARCH_API_KEY");
13}
14
15function generateHtml(appId: string, apiKey: string): string {
16 console.log("Generating HTML with App ID:", appId, "and API Key:", apiKey ? "exists" : "missing");
17 return `
92 container: '#hits',
93 templates: {
94 item: function(hit) {
95 console.log('Hit:', hit); // Add this line
96 return '<div class="hit">' +
116}
117
118function handleError(error: Error): Response {
119 console.error("Server error:", error);
120 return new Response(`Error: ${error.message}`, { status: 500 });
121}
122
123async function handleRequest(request: Request): Promise<Response> {
124 console.log("Received request:", request.url);
125 try {

InstantSearchAlgoliaStoryTestmain.tsx5 matches

@willthereader•Updated 9 months ago
2import { configure, hits, pagination, searchBox } from "https://esm.sh/instantsearch.js@4.49.1/es/widgets";
3
4function validateConfig(): { appId: string; apiKey: string } {
5 const appId = Deno.env.get("ALGOLIA_APP_ID");
6 const apiKey = Deno.env.get("ALGOLIA_SEARCH_API_KEY");
13}
14
15function generateHtml(appId: string, apiKey: string): string {
16 console.log("Generating HTML with App ID:", appId, "and API Key:", apiKey ? "exists" : "missing");
17 return `
92 container: '#hits',
93 templates: {
94 item: function(hit) {
95 console.log('Hit:', hit); // Add this line
96 return '<div class="hit">' +
116}
117
118function handleError(error: Error): Response {
119 console.error("Server error:", error);
120 return new Response(`Error: ${error.message}`, { status: 500 });
121}
122
123async function handleRequest(request: Request): Promise<Response> {
124 console.log("Received request:", request.url);
125 try {

splendidSapphireMockingbirdmain.tsx1 match

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

multirouteHTMLmain.tsx10 matches

@iamseeley•Updated 9 months ago
8import { generateTrackingHtml } from 'https://esm.town/v/iamseeley/counterTown';
9
10export default async function (req: Request): Promise<Response> {
11 const url = new URL(req.url);
12 const path = url.pathname;
13
14 // Function to create navigation links with active state
15 function createNavLinks(currentPath: string): string {
16 const links = [
17 { path: '/', text: 'Home' },
29
30 // Common HTML structure
31 function createHTML(title: string, content: string, req: Request): string {
32 return `
33 <!DOCTYPE html>
69 }
70
71 // Router function to handle different routes
72 function router(path: string, req: Request): Response {
73 switch (path) {
74 case '/':
84
85 // Home page
86 function homePage(req: Request): Response {
87 const content = `
88 <h2>Welcome to My Portfolio</h2>
98
99 // About page
100 function aboutPage(req: Request): Response {
101 const content = `
102 <h2>About Me</h2>
109
110 // Projects page
111 function projectsPage(req: Request): Response {
112 const content = `
113 <h2>My Projects</h2>
127
128 // 404 Not Found page
129 function notFoundPage(req: Request): Response {
130 const content = `
131 <h2>404 Not Found</h2>

faviconGeneratormain.tsx4 matches

@iamseeley•Updated 9 months ago
6import { createRoot } from "https://esm.sh/react-dom/client";
7
8function App() {
9 const [prompt, setPrompt] = useState("");
10 const [faviconUrl, setFaviconUrl] = useState("");
66}
67
68function client() {
69 createRoot(document.getElementById("root")).render(<App />);
70}
74}
75
76async function generateImage(prompt: string) {
77 const FAL_KEY = Deno.env.get("FAL_KEY");
78 if (!FAL_KEY) {
112}
113
114export default async function server(request: Request): Promise<Response> {
115 const url = new URL(request.url);
116 const pathname = url.pathname;

valWallmain.tsx6 matches

@yawnxyz•Updated 9 months ago
69
70
71async function generateGraph(username, useVersions = true) {
72 if (!username) {
73 return html`<p class="text-red-500">Please enter a username</p>`;
111}
112
113function renderPage(c, initialUsername = null) {
114 return c.html(html`
115 <!DOCTYPE html>
163 `);
164}
165function generateMonthLabels(contributionData) {
166 const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
167 const today = dayjs();
197}
198
199function generateContributionRows(contributionData) {
200 const dayLabels = ['', 'Mon', '', 'Wed', '', 'Fri', ''];
201 let rows = [];
212 return rows;
213}
214function generateContributionCells(contributionData, dayOfWeek) {
215 let cells = [];
216 for (let i = dayOfWeek; i < contributionData.length; i += 7) {
235 return cells;
236}
237function processVals(vals, useVersions) {
238 const today = new Date();
239 const oneYearAgo = new Date(today.getFullYear() - 1, today.getMonth(), today.getDate());

dbpediaenhancedmain.tsx6 matches

@ejfox•Updated 9 months ago
2import React, { useEffect, useState } from "https://esm.sh/react@18.2.0";
3
4function sanitizeHtml(html) {
5 return html ? html.replace(/<\/?[^>]+(>|$)/g, "") : "";
6}
7
8function calculateScore(result, query) {
9 let score = 0;
10 let explanation = [];
44}
45
46function App() {
47 const [query, setQuery] = useState("");
48 const [results, setResults] = useState([]);
215}
216
217function client() {
218 createRoot(document.getElementById("root")).render(React.createElement(App));
219}
221if (typeof document !== "undefined") { client(); }
222
223async function fetchDBpediaResults(query: string) {
224 const lookupResponse = await fetch(
225 `https://lookup.dbpedia.org/api/search?query=${encodeURIComponent(query)}&format=json&maxResults=10`
240}
241
242async function server(request: Request): Promise<Response> {
243 const url = new URL(request.url);
244 const path = url.pathname;

valVersionsmain.tsx4 matches

@yawnxyz•Updated 9 months ago
10 * @returns {Promise<Object>} The user object.
11 */
12export async function getUser(username) {
13 const user = await client.alias.username.retrieve(username);
14 return user;
20 * @returns {Promise<Array>} An array of values associated with the user.
21 */
22export async function getVals(username) {
23 const user = await getUser(username);
24 const valsArray = []; // Initialize an array to store values
44 * @returns {Promise<Array>} An array of versions associated with the value.
45 */
46export async function getValVersions(valOrId) {
47 const versionsArray = []; // Initialize an array to store versions
48 const valId = typeof valOrId === 'string' ? valOrId : valOrId.id; // Determine if input is a val or valId
63 * @returns {Promise<Array>} An array of values with their associated versions.
64 */
65export async function getValsWithVersions(username, concurrency = 40) {
66 const user = await getUser(username);
67 const valsArray = []; // Initialize an array to store values with versions

dbpediamain.tsx6 matches

@ejfox•Updated 9 months ago
2// It provides a web interface and a JSON API endpoint for entity search, including hero images.
3
4// Helper function to strip HTML tags and decode HTML entities
5function sanitizeHtml(html: string): string {
6 const decoded = html.replace(/&quot;/g, '"')
7 .replace(/&amp;/g, "&")
15import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
16
17function App() {
18 const [query, setQuery] = useState("");
19 const [results, setResults] = useState([]);
119}
120
121function client() {
122 createRoot(document.getElementById("root")).render(React.createElement(App));
123}
125if (typeof document !== "undefined") { client(); }
126
127async function fetchDBpediaResults(query: string) {
128 const lookupResponse = await fetch(
129 `https://lookup.dbpedia.org/api/search?query=${encodeURIComponent(query)}&format=json&maxResults=5`,
161}
162
163async function server(request: Request): Promise<Response> {
164 const url = new URL(request.url);
165 const path = url.pathname;

oraclemain.tsx1 match

@blur•Updated 9 months ago
6const { author, name } = extractValInfo(import.meta.url);
7
8export async function main(e: Email) {
9 const openai = new OpenAI();
10
tuna

tuna9 file matches

@jxnblk•Updated 2 days ago
Simple functional CSS library for Val Town

getFileEmail4 file matches

@shouser•Updated 1 month ago
A helper function to build a file's email
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.