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/$%7Bsuccess?q=function&page=1667&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 20505 results for "function"(3250ms)

dailyDadJokemain.tsx1 match

@davidpadbury•Updated 8 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 8 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 8 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 8 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 8 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 8 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 8 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 8 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 }: {

ministerialLavenderSlothmain.tsx1 match

@maxm•Updated 8 months ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2export default async function(req: Request): Promise<Response> {
3 const openai = new OpenAI();
4 const stream = await openai.chat.completions.create({

pgliteNpmmain.tsx1 match

@maxm•Updated 8 months ago
15 `);
16
17export default async function(req: Request): Promise<Response> {
18 await db.query(`
19 UPDATE test

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.