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=1576&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 19899 results for "function"(5711ms)

ethereumTokenBalancesmain.tsx2 matches

@jamiedubs•Updated 8 months ago
1import { alchemyFetch } from "https://esm.town/v/jamiedubs/alchemyClient";
2
3export async function getBalances(address: string) {
4 const [tokens, eth] = await Promise.all([
5 alchemyFetch(`getTokenBalances?address=${address}`),
9}
10
11export default async function ethereumTokenBalances(req: Request): Promise<Response> {
12 const searchParams = new URL(req.url).searchParams;
13 const address = searchParams.get("address");

bioFeelermain.tsx3 matches

@o_sv•Updated 8 months ago
8const PASSWORD_HASH = "75699634e8d0a66d4c9e0c8f4a5a4e02c3a1d0a13b3a5e9c7b3a1d0a13b3a5e9c";
9
10function App() {
11 const [view, setView] = useState("home");
12 const [bio, setBio] = useState("");
202}
203
204function client() {
205 createRoot(document.getElementById("root")).render(<App />);
206}
208if (typeof document !== "undefined") { client(); }
209
210async function server(request: Request): Promise<Response> {
211 const { blob } = await import("https://esm.town/v/std/blob");
212 const url = new URL(request.url);

variableIvoryEgretmain.tsx1 match

@monu_shaw•Updated 8 months ago
1export default async function(req: Request): Promise<Response> {
2 let params = new URLSearchParams(req.url);
3 let name = params.get("https://monu_shaw-variableivoryegret.web.val.run/?passcode");

ThumbMakermain.tsx7 matches

@g•Updated 8 months ago
2 * This application creates a thumbnail maker using Hono for server-side routing and client-side JavaScript for image processing.
3 * It allows users to upload images, specify output options, and generate a composite thumbnail image.
4 * The app uses the HTML5 Canvas API for image manipulation and supports drag-and-drop functionality.
5 *
6 * The process is divided into two steps:
18import { Hono } from 'npm:hono';
19
20function html() {
21 /*
22<!DOCTYPE html>
81}
82
83function css() {
84 /*
85body {
216}
217
218function js() {
219 /*
220const fileInput = document.getElementById('fileInput');
240let thumbnailMetadata;
241
242function updateUI() {
243 generateBtn.disabled = files.length === 0;
244 thumbWidth.disabled = keepAspectRatio.checked;
245}
246
247function resetToStep1() {
248 thumbnailOptions.style.display = 'block';
249 renderOptions.style.display = 'none';
375});
376
377function getImage(file) {
378 return new Promise((resolve) => {
379 const url = URL.createObjectURL(file);

slackbotmain.tsx2 matches

@begoon•Updated 8 months ago
7const SLACK_VERIFICATION_TOKEN = env.get("SLACK_VERIFICATION_TOKEN");
8
9async function message(channel: string, text: string, thread_ts?: string) {
10 return await fetchJSON(
11 "https://slack.com/api/chat.postMessage",
18}
19
20async function reaction(channel: string, timestamp: string, name: string = "thumbsup") {
21 return await fetchJSON(
22 "https://slack.com/api/reactions.add",

slackScoutmain.tsx10 matches

@fahadakhan2•Updated 8 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
60// async 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))) {

catchmain.tsx6 matches

@stevekrouse•Updated 8 months ago
1// Custom error logger
2function logError(error, errorType) {
3 var errorMessage = error.message || error.toString();
4 var errorSource = error.fileName || error.sourceURL || error.src || "unknown";
19
20// Catch general JavaScript errors
21window.addEventListener("error", function(event) {
22 // Check if the error is a script loading error
23 if (event.target && event.target.tagName === "SCRIPT") {
33
34// Handle unhandled promise rejections
35window.addEventListener("unhandledrejection", function(event) {
36 logError(event.reason, "unhandledRejection");
37});
38
39// Catch and log any errors that occur during script execution
40document.addEventListener("error", function(event) {
41 if (event.target && event.target.tagName === "SCRIPT") {
42 logError({
49// Override createElement to catch dynamic script loading errors
50var originalCreateElement = document.createElement;
51document.createElement = function() {
52 var element = originalCreateElement.apply(this, arguments);
53 if (arguments[0].toLowerCase() === "script") {
54 element.addEventListener("error", function(event) {
55 logError({
56 message: "Failed to load dynamically added script",

linkInBioTemplatemain.tsx1 match

@opeala•Updated 8 months ago
12import { renderToString } from "npm:react-dom/server";
13
14export default async function(req: Request) {
15 return new Response(
16 renderToString(

snakeclonemain.tsx5 matches

@parsadotsh•Updated 8 months ago
7const CELL_SIZE = CANVAS_SIZE / GRID_SIZE;
8
9function ChatRoom() {
10 const [messages, setMessages] = useState([]);
11 const [inputMessage, setInputMessage] = useState('');
46}
47
48function SnakeGame() {
49 const [snake, setSnake] = useState([{ x: 10, y: 10 }]);
50 const [food, setFood] = useState({ x: 15, y: 15 });
127}
128
129function App() {
130 const [currentView, setCurrentView] = useState('menu');
131
157}
158
159function mountApp() {
160 const root = document.getElementById("root");
161 if (root) {
166}
167
168async function server(request: Request): Promise<Response> {
169 return new Response(`
170 <html>

missingRosePonymain.tsx1 match

@jakub_tel•Updated 8 months ago
4import { currency } from "https://esm.town/v/stevekrouse/currency";
5
6export default async function btcPriceAlert() {
7 const lastBtcPrice: number = await blob.getJSON("lastBtcPrice");
8 let btcPrice = await currency("usd", "btc");

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.