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=1626&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 19270 results for "function"(2093ms)

val_town_by_example_tocmain.tsx3 matches

@iamseeley•Updated 10 months ago
15};
16
17function todo(title: string) {
18 return {
19 title: `${title}`,
96const blobKey = "val_town_by_example_toc.json";
97
98export default async function refreshToc() {
99 const toc: Toc = [];
100 for (const item of dataset) {
128}
129
130export async function readToc(): Promise<Toc> {
131 try {
132 return await blob.getJSON(blobKey);

aqimain.tsx1 match

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

smallestMissingNatmain.tsx1 match

@clumma•Updated 10 months ago
1var smallestMissingNat = function(arr) {
2 var mask = Array(arr.length).fill(false);
3 for (var i=0; i < arr.length; i++) {

validateHTMLandCSSmain.tsx3 matches

@iamseeley•Updated 10 months ago
8};
9
10function validateHTML(html: string): ValidationResult {
11 const errors: ValidationResult['errors'] = [];
12 const lines = html.split('\n');
57}
58
59function validateCSS(css: string): ValidationResult {
60 const errors: ValidationResult['errors'] = [];
61 const lines = css.split('\n');
102}
103
104export function validateHTMLAndCSS(code: string): ValidationResult {
105 const htmlErrors = validateHTML(code);
106 const cssErrors = validateCSS(code);

counterTownmain.tsx6 matches

@stevekrouse•Updated 10 months ago
4import { Hono } from "npm:hono";
5
6function setupTable() {
7 return sqlite.execute(`create table if not exists counter_town (
8 time timestamp default current_timestamp,
21// TODO - we should probably not expose this to our users
22// this rewrite removes that and stores the url underneath
23function removeCustomDomainRewriter(req) {
24 const servedFor = req.headers.get("x-served-for");
25 return req.url.replace("saascustomdomains.val.run", servedFor);
26}
27
28function countRequest(req: Request) {
29 console.log(req);
30 return sqlite.execute({
41}
42
43export function counterTownMiddleware(handler) {
44 return async function(req: Request) {
45 // don't await this so it doesn't add to the timing
46 countRequest(req).catch(e => console.error(e));
125
126// zipped execute
127async function execute(sql) {
128 const results = await sqlite.execute(sql);
129 return results.rows.map(row =>

slack_cleanermain.tsx12 matches

@stevekrouse•Updated 10 months ago
1export function slackHTMLToMarkdown(html) {
2 removeAbsolutePositioning();
3
9 let markdown = "";
10
11 function convertMessage(messageElement) {
12 function safeGetAttribute(selector, attribute) {
13 const element = messageElement.querySelector(selector);
14 return element ? element.getAttribute(attribute) : "";
28 let messageMarkdown = "";
29
30 function processNode(node) {
31 if (node.nodeType === Node.TEXT_NODE) {
32 return node.textContent;
122 // -----
123
124 function postProcessMarkdown(markdown) {
125 // Split the markdown into lines
126 let lines = markdown.split("\n");
155 }
156
157 function parseTimestamp(ariaLabel) {
158 const now = new Date();
159 const months = [
203 }
204
205 function removeAbsolutePositioning() {
206 // Get all elements on the page
207 var allElements = document.getElementsByTagName("*");
333 import { marked } from "https://cdn.jsdelivr.net/npm/marked/lib/marked.esm.js";
334
335 window.convertToMarkdown = function() {
336 const htmlInput = document.getElementById("htmlInput").innerHTML;
337 const markdown = slackHTMLToMarkdown(htmlInput);
341 }
342
343 function copyToClipboard(selector, { html }) {
344 const target = document.querySelector(selector);
345
352 }
353
354 function copyMarkdownAndHTMLToClipboard() {
355 const mdTarget = document.querySelector('#markdownOutput');
356 const htmlTarget = document.querySelector('#renderedMarkdown');
364 }
365
366 async function pasteFromClipboard() {
367 const clipboardItems = await navigator.clipboard.read();
368 for (const clipboardItem of clipboardItems) {
407`;
408
409export default async function(req: Request) {
410 return new Response(html, {
411 headers: {

placemarkGlobeMonitormain.tsx2 matches

@seanehalpin•Updated 10 months ago
1import { sqlite } from "https://esm.town/v/std/sqlite?v=4";
2
3async function fetchPluginData(pluginId) {
4 const response = await fetch(`https://www.figma.com/api/plugins/${pluginId}/versions`);
5 if (!response.ok) {
10}
11
12export default async function(interval: Interval) {
13 try {
14 const microPlugin = await fetchPluginData("1349001943025285729");

twitterAlertmain.tsx1 match

@mwsz•Updated 10 months ago
1import { email } from "https://esm.town/v/std/email";
2
3// Hypothetical API functions (these would need to be implemented or replaced with actual APIs)
4import { searchGoogle, searchLinkedIn, searchX } from "https://esm.town/v/mwsz/searchApis";
5

HttpResponsemain.tsx4 matches

@emarref•Updated 10 months ago
1export function internalServerError(err: unknown, body: string = "An unknown error has occurred.") {
2 console.error("Internal Server Error", String(err));
3
8}
9
10export function badRequest(body: string = null) {
11 return new Response(body, {
12 status: 400,
15}
16
17export function forbidden(body: string = null) {
18 return new Response(body, {
19 status: 401,
22}
23
24export function success(body: string = null) {
25 return new Response(body, {
26 status: 200,

basicAuthmain.tsx2 matches

@pomdtr•Updated 10 months ago
1function extractCredentials(authorization) {
2 const parts = authorization.split(" ");
3 if (parts[0] != "Basic") {
11export type ServeHandler = (req: Request) => Response | Promise<Response>
12
13export function basicAuth(next: ServeHandler, params: {
14 verifyUser: (username: string, password: string) => boolean | Promise<boolean>;
15}): ServeHandler {

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.