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=2727&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 29012 results for "function"(9266ms)

watchNimbusDammain.tsx1 match

@chet•Updated 1 year ago
1import { watchWebsite } from "https://esm.town/v/chet/watchWebsite";
2
3export default async function(interval: Interval) {
4 await watchWebsite("https://cdec.water.ca.gov/dynamicapp/QueryRES?s=NAT");
5}

datetimemain.tsx3 matches

@tudorizer•Updated 1 year ago
1export default async function(req: Request): Promise<Response> {
2 interface DateTimeFormatsOutput {
3 iso: string;
5 }
6
7 function getSpecificDateTime(): Date {
8 return new Date();
9 }
10
11 function generateDateTimeFormatsOutput(): DateTimeFormatsOutput {
12 const specificDateTime = getSpecificDateTime();
13

minifyHTMLmain.tsx1 match

@yieldray•Updated 1 year ago
5const decoder = new TextDecoder();
6
7export async function minifyHTML(html: string, options?: Partial<MinifyHTMLOptions>) {
8 return decoder.decode(minify(encoder.encode(html), options));
9}

chocolateMeerkat_publicmain.tsx5 matches

@wannli•Updated 1 year ago
1export async function chocolateMeerkat(req) {
2 const body = await req.json();
3
14 }
15
16 // Function to escape special characters in a string for regex
17 function escapeRegExp(string) {
18 return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
19 }
20
21 // Function to dynamically generate the replacement string based on original casing
22 function replaceNameWithLink(match) {
23 const link = namesToLinks[match.toLowerCase()];
24 if (link) {

plausiblemain.tsx1 match

@saolsen•Updated 1 year ago
1export async function track(domain: string, req: Request) {
2 await fetch("https://plausible.io/api/event", {
3 method: "POST",

watchWebsitemain.tsx1 match

@chet•Updated 1 year ago
4import { fetch } from "https://esm.town/v/std/fetch";
5
6export async function watchWebsite(url: string) {
7 const newHtml = await fetch(url).then(r => r.text());
8

getBlockFeesmain.tsx1 match

@aryanj•Updated 1 year ago
1import { Options, Parser as CsvParser } from "npm:json2csv";
2
3export default async function(req: Request): Promise<Response> {
4 const blockFeesResp = await fetch("https://mempool.space/api/v1/mining/blocks/fees/3y");
5 const blockFees = await blockFeesResp.json();

traced_http_valmain.tsx4 matches

@saolsen•Updated 1 year ago
12 new Promise((resolve) => setTimeout(resolve, delay));
13
14function _foo(x: number) {
15 console.log(x);
16}
17const foo = traced("foo", _foo);
18
19function _throw() {
20 throw new Error("errr");
21}
26});
27
28async function afn(x: number): Promise<number> {
29 return x;
30}
31const tafn = traced("afn", afn);
32
33async function handler(request: Request): Promise<Response> {
34 await tracer.startActiveSpan("sub-span", async (span) => {
35 await doSomething();

cliOldREADME.md3 matches

@pomdtr•Updated 1 year ago
1# Cli Vals
2
3Cli vals are a new type of val (same as http, email, cron and script vals). A cli val must use a function without args as it's default export.
4
5The function body will run on the user device using [deno](https://deno.com). An error message will be shown if deno is not installed.
6
7
8```typescript
9export default function() {
10 if (Deno.args.length == 0) {
11 console.error("<name> arg is required!");

changesmain.tsx4 matches

@saolsen•Updated 1 year ago
30};
31
32async function get_val(
33 user: string,
34 val: string,
50}
51
52function show_val(
53 latest_version: number,
54 val: Val,
90 {html`
91 <script type="module">
92 function unescape(str) {
93 return str.replace(
94 /&amp;|&lt;|&gt;|&#39;|&quot;/g,
164});
165
166async function handler(req: Request): Promise<Response> {
167 await track("saolsen.changes", req);
168 return await app.fetch(req);
tuna

tuna9 file matches

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