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/image-url.jpg%20%22Optional%20title%22?q=function&page=98&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 20738 results for "function"(1301ms)

untitled-9947ChassiDeAco.tsx1 match

@kiriosโ€ขUpdated 3 days ago
56];
57
58export default function ChassiDeAco() {
59 // Load checklist from localStorage on initial render
60 const [checklist, setChecklist] = useState<{ [key: number]: boolean }>(() => {

untitled-9947react.tsx1 match

@kiriosโ€ขUpdated 3 days ago
47];
48
49export default function ChassiDeAco() {
50 const [checklist, setChecklist] = useState<{ [key: number]: boolean }>({});
51

untitled-3075new-file-1565.tsx1 match

@talizmanโ€ขUpdated 3 days ago
1export default async function (req: Request): Promise<Response> {
2 return Response.json({ ok: true })
3}

posthog-proxyhenry.posthogProxy.ts6 matches

@henrywilliamsโ€ขUpdated 3 days ago
30const sleep = (ms: number) => new Promise(r => setTimeout(r, ms));
31
32function hourKey(ts: number = Date.now()) {
33 const d = new Date(ts);
34 return `hour_${d.getUTCFullYear()}${String(d.getUTCMonth() + 1).padStart(2, "0")}${
38
39/* ensure row for current hour exists */
40async function initHourRow(key: string) {
41 await sqlite.execute({ sql: `INSERT OR IGNORE INTO proxy_usage(key,value) VALUES (?,0);`, args: [key] });
42}
43
44/* โ”€โ”€โ”€โ”€โ”€ semaphore acquire / release โ”€โ”€โ”€โ”€โ”€ */
45async function acquireSlot() {
46 while (true) {
47 const res = await sqlite.execute({
54}
55
56async function releaseSlot() {
57 await sqlite.execute({
58 sql: `UPDATE proxy_usage SET value = MAX(value - 1,0) WHERE key = ?;`,
62
63/* โ”€โ”€โ”€โ”€โ”€ hourly token bucket โ”€โ”€โ”€โ”€โ”€ */
64async function takeHourlyToken(): Promise<void> {
65 while (true) {
66 const key = hourKey();
82
83/* โ”€โ”€โ”€โ”€โ”€ HTTP entry-point โ”€โ”€โ”€โ”€โ”€ */
84export default async function handler(req: Request): Promise<Response> {
85 if (req.method !== "POST") {
86 return new Response("Only POST allowed", { status: 405 });

dhruvindex.html6 matches

@dhruvโ€ขUpdated 3 days ago
80
81 // Fetch suggestions
82 async function fetchSuggestions() {
83 try {
84 const response = await fetch('/api/suggestions');
103
104 // Show error message
105 function showError(message) {
106 errorMessageEl.textContent = message;
107 errorEl.classList.remove('hidden');
110
111 // Render analysis details
112 function renderAnalysis(analysis) {
113 // Create analysis items
114 const items = [
131
132 // Render suggestions
133 function renderSuggestions(suggestions) {
134 suggestionsContainerEl.innerHTML = suggestions.map((suggestion, index) => `
135 <div class="suggestion bg-white rounded-lg shadow-md overflow-hidden">
156 `).join('');
157
158 // Add copy functionality
159 document.querySelectorAll('.copy-btn').forEach(btn => {
160 btn.addEventListener('click', () => {
179
180 // Initialize
181 async function init() {
182 const data = await fetchSuggestions();
183

dhruvsuggestions.ts1 match

@dhruvโ€ขUpdated 3 days ago
21 * @returns Array of content suggestions
22 */
23export async function generateSuggestions(
24 analysis: TweetAnalysis,
25 tweets: Tweet[]

dhruvanalyzer.ts4 matches

@dhruvโ€ขUpdated 3 days ago
22 * @returns Analysis of tweet patterns and content
23 */
24export async function analyzeTweets(tweets: Tweet[]): Promise<TweetAnalysis> {
25 if (!tweets || tweets.length === 0) {
26 throw new Error("No tweets available for analysis");
52 * Calculates the average length of tweets
53 */
54function calculateAverageTweetLength(tweetTexts: string[]): number {
55 const totalLength = tweetTexts.reduce((sum, text) => sum + text.length, 0);
56 return Math.round(totalLength / tweetTexts.length);
60 * Determines posting frequency based on tweet timestamps
61 */
62function calculatePostingFrequency(tweets: Tweet[]): string {
63 if (tweets.length < 2) return "Insufficient data";
64
91 * Uses OpenAI to perform deeper content analysis
92 */
93async function performAIContentAnalysis(content: string): Promise<{
94 topTopics: string[];
95 contentStyle: string;

dhruvtwitter.ts1 match

@dhruvโ€ขUpdated 3 days ago
20 * @returns Array of tweets
21 */
22export async function fetchUserTweets(userId: string): Promise<Tweet[]> {
23 const bearerToken = Deno.env.get("TWITTER_BEARER_TOKEN");
24

MobileTestingindex.ts1 match

@nbbaierโ€ขUpdated 3 days ago
21// Initialize database
22const TABLE_NAME = 'todos';
23async function initDb() {
24 await sqlite.execute(`CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (
25 id INTEGER PRIMARY KEY AUTOINCREMENT,

MobileTestingindex.html9 matches

@nbbaierโ€ขUpdated 3 days ago
105
106 // Fetch todos from API
107 async function fetchTodos() {
108 try {
109 loadingEl.classList.remove('hidden');
124
125 // Render todos to the DOM
126 function renderTodos() {
127 todoList.innerHTML = '';
128
176
177 // Add a new todo
178 async function addTodo(e) {
179 e.preventDefault();
180 const text = todoInput.value.trim();
206
207 // Toggle todo completion status
208 async function toggleTodo(e) {
209 const id = this.dataset.id;
210 const todo = todos.find(t => t.id == id);
234
235 // Open edit modal
236 function editTodo(e) {
237 e.stopPropagation();
238 const id = this.dataset.id;
248
249 // Save edited todo
250 async function saveEdit() {
251 if (!currentEditId) return;
252
278
279 // Close edit modal
280 function closeEditModal() {
281 editModal.classList.add('hidden');
282 currentEditId = null;
284
285 // Delete a todo
286 async function deleteTodo(e) {
287 e.stopPropagation();
288 const id = this.dataset.id;
306
307 // Escape HTML to prevent XSS
308 function escapeHtml(unsafe) {
309 return unsafe
310 .replace(/&/g, "&amp;")

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.