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/$2?q=function&page=2482&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 28949 results for "function"(2030ms)

recordWebsitePreparermain.tsx8 matches

@willthereader•Updated 8 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 const [input, setInput] = useState({
7 storyTitle: "",
63}
64
65function client() {
66 createRoot(document.getElementById("root")).render(<App />);
67}
68if (typeof document !== "undefined") { client(); }
69
70function preparestoryForAlgolia(storyTitle, storyText) {
71 const generateUniqueID = (() => {
72 let counter = 1000000000; // Start from 1 billion
77 })();
78
79 function isWordBoundary(text, index) {
80 if (index === 0 || index === text.length) return true;
81 const prevChar = text[index - 1];
89 }
90
91 function createAlgoliaRecord(storyContent, startIndex, endIndex, storyTitle, chapterTitle, chunkIndex) {
92 return {
93 storyTitle: storyTitle,
102 }
103
104 function processstory(storyTitle, storyText) {
105 let algoliaRecords = [];
106 let currentChunk = "";
224}
225
226async function server(request: Request): Promise<Response> {
227 if (request.method === "POST") {
228 const { storyTitle, storyText } = await request.json();
314`;
315
316function extractContent(inputText) {
317 // Split the input text by newlines
318 const lines = inputText.split("\n");

InventionDetailstoJSONConvertermain.tsx7 matches

@willthereader•Updated 8 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 const [inputText, setInputText] = useState("");
7 const [jsonResults, setJsonResults] = useState([]);
63 handleRateLimitError(errorData.error.match(/\d+/)[0]);
64 setIsLoading(false);
65 return; // Exit the function, but useEffect will resume after countdown
66 }
67 throw new Error(await response.text());
125}
126
127function client() {
128 createRoot(document.getElementById("root")).render(<App />);
129}
130if (typeof document !== "undefined") { client(); }
131
132async function server(request: Request): Promise<Response> {
133 if (request.method === "POST" && new URL(request.url).pathname === "/convert") {
134 try {
176 });
177
178 async function processLine(line) {
179 const dateMatch = line.match(/^(\d{4}):/);
180 if (!dateMatch) {
225 } catch (error) {
226 console.error("Error processing request:", error);
227 console.error("Error in server function:", error);
228 return new Response(
229 JSON.stringify({ error: error.message }),
316`;
317
318async function checkRateLimit(blob, key) {
319 const now = Date.now();
320 const lastRequest = await blob.getJSON(key) || { timestamp: 0, count: 0 };

MyHawFeedmain.tsx1 match

@matthiasraimann•Updated 8 months ago
4import { parseStringPromise } from "npm:xml2js";
5
6export default async function queryNewFeed() {
7 const user = Deno.env.get("HAW_USER");
8 const hash = Deno.env.get("HAW_HASH");

alchemyClientmain.tsx1 match

@jamiedubs•Updated 8 months ago
4type TokenParam = "erc20" | "nft" | string;
5
6export async function alchemyFetch(path: string, tokens: TokenParam = "erc20") {
7 const apiKey = process.env.ALCHEMY_API_KEY;
8 if (!apiKey) throw new Error("missing ALCHEMY_API_KEY");

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))) {
tuna

tuna9 file matches

@jxnblk•Updated 17 hours 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.