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=1414&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 18324 results for "function"(2130ms)

v2FanFicScrapermain.tsx10 matches

@willthereader•Updated 7 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4// last stable version is 47
5function App() {
6 const [url, setUrl] = useState("");
7 const [result, setResult] = useState(null);
104}
105
106function client() {
107 console.log("Initializing client-side React application");
108 createRoot(document.getElementById("root")).render(<App />);
116const _REGEX_POST_URL = /posts\/(?<id>\d+)/;
117
118function normalizeUrl(url) {
119 const threadMatch = url.match(_REGEX_THREAD_URL);
120 const postMatch = url.match(_REGEX_POST_URL);
128}
129
130async function scrapePage(url) {
131 console.log(`Starting to scrape page: ${url}`);
132 const apiKey = await getApiKey();
165}
166
167function processThreadmarks(threadmarks) {
168 return threadmarks.map(tm => {
169 let category = "1";
201}
202
203async function scrapePageWithRules(url, apiKey, extractRules) {
204 console.log(`Sending request to ScrapingBee API for URL: ${url}`);
205 try {
245}
246
247function processResults(results) {
248 console.log("Processing results:", JSON.stringify(results, null, 2));
249 if (!results || results.length === 0) {
275}
276
277function processPost(post) {
278 return {
279 id: post.id,
286}
287
288async function getApiKey() {
289 const apiKey = Deno.env.get("ScrapingBeeAPIkey");
290 if (!apiKey) {
295}
296
297export default async function server(request) {
298 console.log(`Received ${request.method} request for path: ${new URL(request.url).pathname}`);
299 if (request.method === "POST" && new URL(request.url).pathname === "/scrape") {

count_visitsmain.tsx4 matches

@muhammad_owais_warsi•Updated 7 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 const [websiteUrl, setWebsiteUrl] = useState("");
7 const [embedCode, setEmbedCode] = useState("");
61}
62
63function client() {
64 createRoot(document.getElementById("root")).render(<App />);
65}
69}
70
71async function server(request: Request): Promise<Response> {
72 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
73 const SCHEMA_VERSION = 1;
92import { useState, useEffect } from 'react';
93
94function VisitorCounter() {
95 const [count, setCount] = useState(0);
96

zottifymain.tsx1 match

@rapfl•Updated 7 months ago
8});
9
10export default async function(req: Request) {
11 if (req.method === "POST") {
12 const formData = await req.formData();

whoIsHiringmain.tsx3 matches

@stevekrouse•Updated 7 months ago
7import About from "https://esm.town/v/vawogbemi/whoIsHiringAbout";
8
9function App() {
10 const tabs = { "/": "Home", "/about": "About" };
11 const [activeTab, setActiveTab] = useState("/");
335}
336
337function ServerApp() {
338 return (
339 <html>
358}
359
360export default async function(req: Request): Promise<Response> {
361 const url = new URL(req.url);
362 if (url.pathname === "/api/stories") {

imagesToPDFmain.tsx6 matches

@g•Updated 7 months ago
15import { Hono } from 'npm:hono';
16
17function html() {
18 /*
19<!DOCTYPE html>
38}
39
40function css() {
41 /*
42body {
82}
83
84function js() {
85 /*
86const { jsPDF } = window.jspdf;
91convertBtn.addEventListener('click', convertToPDF);
92
93async function convertToPDF() {
94 const files = imageInput.files;
95 if (files.length === 0) {
121}
122
123function readFileAsDataURL(file) {
124 return new Promise((resolve, reject) => {
125 const reader = new FileReader();
130}
131
132function loadImage(blob) {
133 return new Promise((resolve, reject) => {
134 const src = URL.createObjectURL(blob);

satisfactoryBlushCatsharkmain.tsx2 matches

@maxm•Updated 7 months ago
2import { base58 } from "npm:@scure/base";
3
4export function convertUUIDToToken(uuid: string): string {
5 return "vt_" + base58.encode(Buffer.from(uuid.replace(/-/g, ""), "hex"));
6}
7
8export function generateAndConvertUUIDs() {
9 const uuidBuffer = Buffer.alloc(16);
10 let tokenLength = 0;

bedtimeStoryMakermain.tsx2 matches

@dthyresson•Updated 7 months ago
41const identifier = "bedtime-story-limiter";
42
43async function enforceRateLimit() {
44 const ratelimit = await unkey.limit(identifier);
45
52const app = new Hono();
53
54function parseStory(text) {
55 // Split the text into lines and remove empty lines
56 const lines = text.split("\n").filter(line => line.trim() !== "");

bikeInventorymain.tsx7 matches

@all•Updated 7 months ago
6const APP_ID = "5518c0f9-481c-4aa8-85cd-eee42bd45319";
7
8function BikeWindow({ bike, onSave, onClose, title }) {
9 const [brand, setBrand] = useState(bike?.brand || "");
10 const [model, setModel] = useState(bike?.model || "");
112}
113
114function App() {
115 const [bikes, setBikes] = useState([]);
116 const [error, setError] = useState(null);
315}
316
317function client() {
318 console.log("Client function called");
319 const root = document.getElementById("root");
320 if (root) {
327
328if (typeof document !== "undefined") {
329 console.log("Document is defined, calling client function");
330 client();
331} else {
333}
334
335async function server(request: Request): Promise<Response> {
336 console.log("Server function called");
337 return new Response(
338 `

sqliteExplorerAppREADME.md1 match

@flymaster•Updated 7 months ago
33- [x] fix wonky sidebar separator height problem (thanks to @stevekrouse)
34- [x] make result tables scrollable
35- [x] add export to CSV, and JSON (CSV and JSON helper functions written in [this val](https://www.val.town/v/nbbaier/sqliteExportHelpers). Thanks to @pomdtr for merging the initial version!)
36- [x] add listener for cmd+enter to submit query

opensourcepledgeRedirectmain.tsx1 match

@vladh•Updated 7 months ago
1export default function(req: Request) {
2 const url = new URL(req.url);
3 const newUrl = "https://opensourcepledge.com" + url.pathname + url.search;

getFileEmail4 file matches

@shouser•Updated 1 week 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.