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/image-url.jpg%20%22Optional%20title%22?q=function&page=2486&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 28622 results for "function"(5669ms)

valleBlogV0main.tsx4 matches

@wlxiaozhzh•Updated 9 months ago
8import _ from "npm:lodash@4";
9
10async function main(req: Request): Promise<Response> {
11 const { readable, writable } = new TransformStream();
12 const writer = writable.getWriter();
20 <script>
21 // Scroll to the bottom of the page when the page changes.
22 (new MutationObserver(function (mutationsList, observer) {
23 window.scrollTo({ left: 0, top: document.body.scrollHeight, behavior: "instant" });
24 })).observe(document, { childList: true, characterData: true, subtree: true });
47 Your response should start with \`\`\`ts and end with \`\`\`, so full code fences.
48 There should be no comments like "more content here", it should be complete and directly runnable.
49 The val should have an "export default async function main". The val should return a valid HTML website.
50 Prefer using Tailwind. Put frontend functions in a <script> tag, using dangerouslySetInnerHTML. Don't use Hono. Don't use Response.redirect.
51 `.replace("\n", " "),
52 },

bbaasmain.tsx1 match

@dglazkov•Updated 9 months ago
136
137export const service = (boardUrl: string, options?: ServiceOptions) => {
138 return async function(req: Request): Promise<Response> {
139 const url = new URL(req.url);
140 const path = url.pathname;

sweetAzureFinchmain.tsx1 match

@cingozilyas•Updated 9 months ago
1const Airtable = require("airtable");
2
3export default async function saveToAirtable(videoName, videoDescription, videoCover, videoFile, clientLogo) {
4 // Set up your Airtable API key and base ID
5 const API_KEY = "patrq3goiFF1u09Dz.b435affff5fb534b9d5c76e2544ddf88612d6a19aebaec5c14f9434b0d10d2e6";

requestCollectormain.tsx2 matches

@maxm•Updated 9 months ago
26}
27
28function App({ requests, stats, fullRequest }: { requests: RequestData[], stats: Stats, fullRequest?: RequestData }) {
29 return (
30 <div>
84}
85
86export default async function server(request: Request): Promise<Response> {
87 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
88 const SCHEMA_VERSION = 1;

reloadOnSaveREADME.md1 match

@lisardo•Updated 9 months ago
9import { reloadOnSaveFetchMiddleware } from "https://esm.town/v/stevekrouse/reloadOnSave";
10
11export default reloadOnSaveFetchMiddleware(async function(req: Request): Promise<Response> {
12 return html(`<h1>Hello!!</h1>`);
13})

reloadOnSavemain.tsx4 matches

@lisardo•Updated 9 months ago
8
9// this script runs client-side
10export const reloadOnVals = async function(vals: ValRef[]) {
11 const valVersions = await Promise.all(vals.map(getCurrentValVersionNumber));
12 // console.log("initialValVersions: ", valVersions);
22
23// experimental - don't use this
24export function reloadOnSaveHonoMiddleware(vals: ValRef[] = [rootValRef()]): MiddlewareHandler {
25 return async function(c, next) {
26 await next();
27 // don't reload on custom domains, only reload on val.run URLs
40 * @param vals to watch
41 */
42export function reloadOnSaveFetchMiddleware(
43 handler: (req: Request) => Response | Promise<Response>,
44 vals = [rootValRef()],

linkInBioTemplatemain.tsx3 matches

@Olive•Updated 9 months ago
18];
19
20function App() {
21 const [votes, setVotes] = useState({});
22 const [selectedLocation, setSelectedLocation] = useState(null);
98}
99
100function client() {
101 createRoot(document.getElementById("root")).render(<App />);
102}
106}
107
108async function server(request: Request): Promise<Response> {
109 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
110 const SCHEMA_VERSION = 1;

codeshowcasemain.tsx3 matches

@ejfox•Updated 9 months ago
9import { OpenAI } from "https://esm.town/v/std/openai";
10
11export default async function server(request: Request): Promise<Response> {
12 const url = new URL(request.url);
13 const code = url.searchParams.get("code") || "console.log(\"Hello, World!\");";
75 hljs.highlightAll();
76
77 function shuffleGradient() {
78 const t1 = Math.random();
79 const t2 = (t1 + 0.3) % 1; // Ensure colors are distinct
91 const duration = 10000; // 10 seconds
92
93 function animate(timestamp) {
94 if (!start) start = timestamp;
95 const progress = (timestamp - start) / duration;

weeksummarymain.tsx3 matches

@ejfox•Updated 9 months ago
12}
13
14function App() {
15 const [summary, setSummary] = useState<string>("");
16 const [loading, setLoading] = useState<boolean>(true);
135}
136
137function client() {
138 createRoot(document.getElementById("root")).render(<App />);
139}
143}
144
145async function server(request: Request): Promise<Response> {
146 const url = new URL(request.url);
147

AdmiralCloudbergCheckermain.tsx1 match

@csl_•Updated 9 months ago
7import { default as Parse } from "npm:rss-to-json";
8
9export default async function notify() {
10 try {
11 // Fetch and parse the RSS feed

getFileEmail4 file matches

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

tuna8 file matches

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