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=2473&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 28554 results for "function"(3878ms)

aqi_lefkadamain.tsx1 match

@pj0•Updated 9 months ago
2import { easyAQI } from "https://esm.town/v/stevekrouse/easyAQI?v=5";
3
4export async function aqi(interval: Interval) {
5 const location = "lefkada greece"; // <-- change to place, city, or zip code
6 const data = await easyAQI({ location });

concentricCirclesAppmain.tsx4 matches

@kaz•Updated 9 months ago
3 * Below each section, there's a text input field. Each color section can have up to 8 values.
4 * It uses React for the UI and CSS for styling the gradient line and inputs.
5 * It includes a reorder functionality for the items in each section and an expandable "Learn more" section.
6 */
7/** @jsxImportSource https://esm.sh/react */
9import { createRoot } from "https://esm.sh/react-dom/client";
10
11function App() {
12 const [redItems, setRedItems] = useState<string[]>([]);
13 const [yellowItems, setYellowItems] = useState<string[]>([]);
186}
187
188function client() {
189 createRoot(document.getElementById("root")).render(<App />);
190}
191if (typeof document !== "undefined") { client(); }
192
193async function server(request: Request): Promise<Response> {
194
195 return new Response(`

dailyDadJokemain.tsx1 match

@davidpadbury•Updated 9 months ago
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3
4export async function dailyDadJoke() {
5 let { setup, punchline } = await fetchJSON("https://official-joke-api.appspot.com/random_joke");
6 return email({

readableHtmlmain.tsx3 matches

@neverstew•Updated 9 months ago
6const JSDOM = jsdom.JSDOM;
7
8export function readableHtml(urlOrContent: URL | string, options?: RequestInit): Promise<string> {
9 if (typeof urlOrContent === "string") {
10 return readableHtmlFromText(urlOrContent);
15export default readableHtml;
16
17async function readableHtmlFromUrl(url: URL, options?: RequestInit): Promise<string> {
18 const body = await fetchText(url.toString(), options);
19 return readableHtmlFromText(body);
20}
21
22async function readableHtmlFromText(content: string): Promise<string> {
23 let doc = new JSDOM(content);
24 let reader = new Readability(doc.window.document);

githubRepoViewermain.tsx2 matches

@ejfox•Updated 9 months ago
1export default async function server(request: Request): Promise<Response> {
2 const url = new URL(request.url);
3
50
51 <script>
52 async function fetchFiles() {
53 const user = document.getElementById('user').value;
54 const repo = document.getElementById('repo').value;

amusedAquaHeronmain.tsx1 match

@codefromanywhere•Updated 9 months ago
1export default async function handler(request: Request) {
2 if (request.method !== "POST") {
3 return Response.json({ message: "This val responds to POST requests." }, {

relaxedSalmonHawkmain.tsx1 match

@codefromanywhere•Updated 9 months ago
1export default async function handler(request: Request) {
2 if (request.method !== "POST") {
3 return Response.json({ message: "This val responds to POST requests." }, {

linkInBioTemplatemain.tsx1 match

@daisuke•Updated 9 months ago
2import { renderToString } from "npm:react-dom/server";
3
4export default async function(req: Request) {
5 return new Response(
6 renderToString(

BlogChatbotServermain.tsx5 matches

@weaverwhale•Updated 9 months ago
25];
26
27// Function to search blog content
28function searchBlogContent(query: string) {
29 return blogPosts.filter(post =>
30 post.title.toLowerCase().includes(query.toLowerCase()) ||
58 const sendButton = document.getElementById('sendButton');
59
60 function addMessage(message, isUser = false) {
61 const messageElem = document.createElement('p');
62 messageElem.textContent = isUser ? \`You: \${message}\` : \`Bot: \${message}\`;
66 }
67
68 async function sendMessage() {
69 const message = userInput.value.trim();
70 if (!message) return;
136});
137
138export default async function server(req: Request): Promise<Response> {
139 return app.fetch(req);
140}

pushSendNotification_negrelmain.tsx3 matches

@jrmann100•Updated 9 months ago
2
3// https://github.com/web-push-libs/web-push/blob/v3.4.4/README.md#using-vapid-key-for-applicationserverkey
4function urlBase64ToUint8Array(b64) {
5 const padding = "=".repeat((4 - (b64.length % 4)) % 4);
6 const base64 = (b64 + padding)
19
20// https://stackoverflow.com/a/56848917/9068081
21function getPrivKeyJWK({ pubKey, privKey }: { pubKey: string; privKey: string }) {
22 const pubKeyArray = urlBase64ToUint8Array(pubKey);
23 const privKeyArray = urlBase64ToUint8Array(privKey);
49};
50
51async function importVapidKeys(
52 exportedKeys: { pubKey: string; privKey: string },
53 { crypto = globalThis.crypto.subtle, extractable = false }: {

getFileEmail4 file matches

@shouser•Updated 1 month ago
A helper function to build a file's email
tuna

tuna8 file matches

@jxnblk•Updated 1 month 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.