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=641&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 17289 results for "function"(1531ms)

blog1get-posts.ts1 match

@charmaine•Updated 3 weeks ago
4
5// Get all blog posts (local + RSS)
6export async function getAllBlogPosts(): Promise<BlogPost[]> {
7 return (await Promise.all([
8 getNewPosts(),

blog1get-old-posts.ts2 matches

@charmaine•Updated 3 weeks ago
4const OLD_BLOG_RSS = "https://val-town-blog.pages.dev/rss.xml";
5// Get blog posts from RSS feed
6async function getOldPosts(): Promise<BlogPost[]> {
7 const parser = new RssParser();
8 const feed = await parser.parseURL(OLD_BLOG_RSS);
289 "slug": "deprecating-the-run-api",
290 "link": "/blog/deprecating-the-run-api",
291 "description": "Not every function should be an API",
292 "pubDate": "Wed, 07 Feb 2024 00:00:00 GMT",
293 "author": "André Terron",

blog1get-new-posts.ts2 matches

@charmaine•Updated 3 weeks ago
5
6// Get all blog posts from the file system
7export async function getNewPosts(): Promise<BlogPost[]> {
8 const files = await listFiles(import.meta.url);
9 const blogPostFiles = files.filter(
42
43// Get a single blog post by slug
44export async function getBlogPostBySlug(slug: string): Promise<BlogPost | null> {
45 const post = posts.find(post => post.slug.includes(slug));
46 return post;

blog1Footer.tsx1 match

@charmaine•Updated 3 weeks ago
5const year = new Date().getFullYear();
6
7export default function Footer () {
8 return (
9 <footer className="container">

blog1Byline.tsx1 match

@charmaine•Updated 3 weeks ago
2import { formatDate, dayOfWeek } from "./util.tsx";
3
4export default function Byline ({ post }: {
5 post: {
6 author: string;

blog1BlogPost.tsx1 match

@charmaine•Updated 3 weeks ago
11
12
13export function BlogPostComponent({ post, content }: BlogPostProps) {
14 return (
15 <Layout title={`${post.title} - Val Town Blog`}>

react-starterhttp.tsx1 match

@charmaine•Updated 3 weeks ago
7const CLIENT_MODULE = import.meta.url.replace("http.tsx", "client.tsx");
8
9export default async function(req: Request): Promise<Response> {
10 const app = renderToString(<App />);
11 const html = `<!DOCTYPE html>

blob_adminmain.tsx8 matches

@kucukkanat•Updated 3 weeks ago
13}
14
15function Tooltip({ children, content }: TooltipProps) {
16 const [isVisible, setIsVisible] = useState(false);
17 const tooltipRef = useRef<HTMLDivElement>(null);
52}
53
54function formatBytes(bytes: number, decimals = 2) {
55 if (bytes === 0) return "0 Bytes";
56 const k = 1024;
61}
62
63function copyToClipboard(text: string) {
64 navigator.clipboard.writeText(text).then(() => {
65 console.log("Text copied to clipboard");
69}
70
71function ActionMenu({ blob, onDownload, onRename, onDelete, onMoveToPublic, onMoveOutOfPublic }) {
72 const [isOpen, setIsOpen] = useState(false);
73 const menuRef = useRef(null);
76
77 useEffect(() => {
78 function handleClickOutside(event) {
79 if (menuRef.current && !menuRef.current.contains(event.target)) {
80 event.stopPropagation();
158}
159
160function BlobItem({ blob, onSelect, isSelected, onDownload, onRename, onDelete, onMoveToPublic, onMoveOutOfPublic }) {
161 const [isLoading, setIsLoading] = useState(false);
162 const decodedKey = decodeURIComponent(blob.key);
219}
220
221function App({ initialEmail, initialProfile }) {
222 const encodeKey = (key: string) => encodeURIComponent(key);
223 const decodeKey = (key: string) => decodeURIComponent(key);
645}
646
647function client() {
648 const initialEmail = document.getElementById("root").getAttribute("data-email");
649 const initialProfile = JSON.parse(document.getElementById("root").getAttribute("data-profile"));

pin-the-mapclient.ts1 match

@wilhelm•Updated 3 weeks ago
13const valTownMapUrl = `pmtiles://${window.location}map.pmtiles`;
14
15function initMap() {
16 const valTownMapOptionChecked = document.querySelector("#val-town-map-option").checked;
17 let protocol = new pmtiles.Protocol();

alexBlogsindex.tsx5 matches

@alexwein•Updated 3 weeks ago
7import { Layout } from "./Layout.tsx";
8
9function Header() {
10 return (
11 <header style={{ marginBottom: "20px", padding: "10px", borderBottom: "1px solid gray" }}>
16}
17
18function PostComponent({ markdown, link }: { markdown: string; link?: string }) {
19 return (
20 <div style={{ border: "1px solid gray", padding: "10px", marginBottom: "20px", borderRadius: "5px" }}>
25}
26
27export default async function(req: Request): Promise<Response> {
28 const url = new URL(req.url);
29 const referer = req.headers.get("referer");
86 animation-duration: 7000ms;
87 animation-iteration-count: infinite;
88 animation-timing-function: linear;
89 transform-origin: 400px 315px;
90 }
170}
171
172function html(children: React.ReactNode) {
173 return new Response(
174 renderToString(

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 1 week 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": "*",