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=1458&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 19200 results for "function"(2111ms)

fullWebsiteVersionmain.tsx7 matches

@willthereader•Updated 6 months ago
1async function findBrokenLinks(websiteUrl) {
2 console.log("Version: " + import.meta.url.match(/[?&]v=([^&]*)/)?.at(1));
3 console.log(`Starting findBrokenLinks for website: ${websiteUrl}`);
7 const allCheckedLinks = new Set();
8 const allBrokenLinks = [];
9 // Function to check if a URL is valid and accessible
10 async function checkUrl(url) {
11 console.log(`Checking URL: ${url}`);
12 try {
26 }
27
28 // Function to ensure URL is absolute and classify link type
29 function processUrl(baseUrl, href) {
30 try {
31 if (
191}
192
193export default async function(interval) {
194 console.log(`Starting broken link check at ${new Date().toISOString()}`);
195 const url = "https://dateme.directory/browse";
202 console.log("External broken links:", JSON.stringify(results.brokenLinks.external, null, 2));
203 } catch (error) {
204 console.error(`Error in main function: ${error.message}`);
205 }
206}

BBslackScoutmain.tsx10 matches

@alexdphan•Updated 6 months ago
15}
16
17export default async function(interval: Interval): Promise<void> {
18 try {
19 await createTable();
38
39// Create an SQLite table
40async function createTable(): Promise<void> {
41 await sqlite.execute(`
42 CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (
50
51// Fetch Hacker news, Twitter, and Reddit results
52async function fetchHackerNewsResults(topic: string): Promise<Website[]> {
53 return hackerNewsSearch({
54 query: topic,
58}
59
60async function fetchTwitterResults(topic: string): Promise<Website[]> {
61 return twitterSearch({
62 query: topic,
67}
68
69async function fetchRedditResults(topic: string): Promise<Website[]> {
70 return redditSearch({ query: topic });
71}
72
73function formatSlackMessage(website: Website): string {
74 const displayTitle = website.title || website.url;
75 return `*<${website.url}|${displayTitle}>*
78}
79
80async function sendSlackMessage(message: string): Promise<Response> {
81 const slackWebhookUrl = Deno.env.get("SLACK_WEBHOOK_URL");
82 if (!slackWebhookUrl) {
104}
105
106async function isURLInTable(url: string): Promise<boolean> {
107 const result = await sqlite.execute({
108 sql: `SELECT 1 FROM ${TABLE_NAME} WHERE url = :url LIMIT 1`,
112}
113
114async function addWebsiteToTable(website: Website): Promise<void> {
115 await sqlite.execute({
116 sql: `INSERT INTO ${TABLE_NAME} (source, url, title, date_published)
120}
121
122async function processResults(results: Website[]): Promise<void> {
123 for (const website of results) {
124 if (!(await isURLInTable(website.url))) {

falProxyRequestmain.tsx1 match

@stevekrouse•Updated 6 months ago
1export async function falProxyRequest(req: Request) {
2 const method = req.method;
3 const body = method === "GET" || method === "HEAD" ? undefined : await req.text();

cerebras_codermain.tsx5 matches

@kate•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);
92}
93
94function client() {
95 createRoot(document.getElementById("root")!).render(<App />);
96}
100}
101
102function extractCodeFromFence(text: string): string {
103 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
104 return htmlMatch ? htmlMatch[1].trim() : text;
105}
106
107export default async function server(req: Request): Promise<Response> {
108 if (req.method === "POST") {
109 const client = new Cerebras();

reqEvaltownmain.tsx4 matches

@maxm•Updated 6 months ago
1import net, { AddressInfo } from "node:net";
2
3export default async function(req: Request): Promise<Response> {
4 return serveRequest(
5 req,
6 `data:text/tsx,${
7 encodeURIComponent(`
8export default async function(req: Request): Promise<Response> {
9 return Response.json("I am within a worker!")
10}
14}
15
16export async function serveRequest(req: Request, importUrl: string): Promise<Response> {
17 let port = await getFreePort();
18 const worker = new Worker(`https://esm.town/v/maxm/evaltownWorker?cachebust=${crypto.randomUUID()}`, {
55 });
56
57export async function isPortListening(port: number): Promise<boolean> {
58 let isListening = false;
59 const maxWaitTime = 2000; // ms

valtowntownmain.tsx5 matches

@maxm•Updated 6 months ago
48await contentStore.init();
49
50function Town() {
51 return (
52 <div
69}
70
71function HomePage() {
72 return (
73 <html>
82 <form method="POST" action="/submit">
83 <textarea name="handler" rows={10} cols={50} autoFocus>
84 {`export default async function(req: Request) {
85 return Response.json("Hello, world!");
86}`}
95}
96
97function ContentPage({ handler, id }: { handler: string; id: string }) {
98 return (
99 <html>
122 let originalContent = textarea.value;
123
124 textarea.addEventListener('input', function() {
125 if (textarea.value !== originalContent) {
126 submitButton.style.display = 'inline-block';

ethereumAddressGeneratormain.tsx4 matches

@alfongj•Updated 6 months ago
4import { ethers } from "https://esm.sh/ethers@5.7.2";
5
6function CopyableField({ label, value }) {
7 const copyToClipboard = () => {
8 navigator.clipboard.writeText(value).then(() => {
22}
23
24function App() {
25 const [wallet, setWallet] = useState(null);
26
51}
52
53function client() {
54 createRoot(document.getElementById("root")).render(<App />);
55}
57if (typeof document !== "undefined") { client(); }
58
59export default async function server(request: Request): Promise<Response> {
60 return new Response(`
61 <html>

impressiveAzureJellyfishmain.tsx1 match

@felixnordgren•Updated 6 months ago
1export default async function(req: Request): Promise<Response> {
2 // Setup CORS Headers
3 const headers = new Headers();

discordActivityClientmain.tsx5 matches

@neverstew•Updated 6 months ago
11});
12
13async function setupDiscordSdk() {
14 await discordSdk.ready();
15
73
74/**
75 * This function fetches the current voice channel over RPC. It then creates a
76 * text element that displays the voice channel's name
77 */
78async function appendVoiceChannelName() {
79 const app = document.querySelector("#app");
80 if (!app) {
104
105/**
106 * This function utilizes RPC and HTTP apis, in order show the current guild's avatar
107 * Here are the steps:
108 * 1. From RPC fetch the currently selected voice channel, which contains the voice channel's guild id
111 * 4. Append to the UI an img tag with the related information
112 */
113async function appendGuildAvatar() {
114 const app = document.querySelector("#app");
115 if (!app) {

blobbyFacemain.tsx4 matches

@yawnxyz•Updated 6 months ago
26
27
28async function streamToBuffer(stream) {
29 const chunks = [];
30 const reader = stream.getReader();
41}
42
43async function detectFileType(buffer) {
44 const type = await fileTypeFromBuffer(buffer);
45 // return type ? type.mime : 'unknown';
51
52
53export async function get(key, c) {
54 let result = await blobby.get(key);
55 // console.log('raw result for key:', result, typeof result);
211 newKeyName: '',
212
213 init: async function() {
214 console.log('blobby:', this.blobby);
215 },

getFileEmail4 file matches

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