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/?q=function&page=1644&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 18182 results for "function"(3285ms)

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);

editRedirectmain.tsx1 match

@stevekrouse•Updated 1 year ago
1import { refs } from "https://esm.town/v/stevekrouse/refs";
2
3export function editRedirect() {
4 const ref = refs()[0];
5 const editURL = `https://val.town/v/${ref.userHandle}/${ref.valName}`;

date_me_doc_helpersmain.tsx1 match

@stevekrouse•Updated 1 year ago
1export function parseNotionDateDoc(obj): DateMeDoc {
2 return {
3 Id: obj.id,

diffHtmlmain.tsx1 match

@chet•Updated 1 year ago
2import { diffLines } from "https://esm.town/v/chet/diffLines";
3
4export function diffHtml(before: string, after: string) {
5 return diffLines(cleanHtml(before), cleanHtml(after));
6}

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 2 weeks ago
Simple functional CSS library for Val Town
webup
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.
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": "*",