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=54&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 7825 results for "function"(405ms)

twitterCardstwitterCards.tsx1 match

@nbbaier•Updated 6 days ago
17}
18
19export default async function(req: Request): Promise<Response> {
20 return html(`<html lang="en">
21 <head>

twitterCardstweetCard.tsx4 matches

@nbbaier•Updated 6 days ago
66};
67
68function TweetCard({ tweet }: { tweet: TweetData }) {
69 return (
70 <div className="tweet-card">
122};
123
124function App() {
125 return (
126 <div className="container">
133}
134
135function client() {
136 const rootElement = document.getElementById("root");
137 if (rootElement) {
146}
147
148export default function server(request: Request): Response {
149 return new Response(
150 `

twitterCardstweetCardUtils.ts8 matches

@nbbaier•Updated 6 days ago
8} from "https://esm.town/v/nbbaier/twitterCards/tweetCardTypes.ts";
9
10function intlFormat(num: number) {
11 return new Intl.NumberFormat().format(Math.round(num * 10) / 10);
12}
13
14export function makeFriendly(num: number) {
15 if (num >= 1000000) return `${intlFormat(num / 1000000)}M`;
16 if (num >= 1000) return `${intlFormat(num / 1000)}k`;
18}
19
20function transformAuthor(author: APITweet["author"]): TweetAuthor {
21 return {
22 name: author.name,
27}
28
29function getTweetMedia(
30 media: NonNullable<APITweet["media"]>,
31): TweetData["media"] {
43}
44
45export function transformTweet(tweet: APITweet): TweetData {
46 return {
47 url: tweet.url,
57}
58
59export async function fetchTweet(url: URL | string): Promise<APITweet> {
60 const response = await fetch(url);
61 const { tweet } = (await response.json()) as {
68}
69
70export function transformPhoto(inputPhoto: APIPhoto): TweetPhoto {
71 return {
72 url: inputPhoto.url,
75}
76
77export function transformVideo(inputVideo: APIVideo): TweetVideo {
78 return {
79 url: inputVideo.thumbnail_url,

twitterCardsmain.tsx1 match

@nbbaier•Updated 6 days ago
15}
16
17export default async function (req: Request): Promise<Response> {
18 const url =
19 "https://publish.twitter.com/oembed?url=https%3A%2F%2Ftwitter.com%2FInterior%2Fstatus%2F507185938620219395";

dbToAPI_backupserver.tsx1 match

@nbbaier•Updated 6 days ago
11
12// TODO: implement options
13export async function createServer(db, options: Options & { auth?: { username: string; password: string } } = {}) {
14 const app = new Hono();
15

FarcasterMiniAppStoreHome.tsx3 matches

@moe•Updated 6 days ago
9import { useQuery } from "../util/useQuery.ts";
10
11export function Home() {
12 const [context, setContext] = useState<any>();
13 useEffect(() => {
36}
37
38function MiniApps() {
39 const { data: miniapps } = useQuery(["miniapps"], async () => {
40 // return await fetch(`/api/miniapps`).then(r => r.json()).then(r => r);
124}
125
126function MiniApp({ miniapp }) {
127 const navigate = useNavigate();
128 // console.log(miniapp.manifest?.frame?.name);
pie

piemain.tsx1 match

@jxnblk•Updated 6 days ago
12const dashArray = n => `${(R * Math.PI * n)} ${Math.PI * R}`;
13
14export default async function(req: Request): Promise<Response> {
15 const params = new URL(req.url).searchParams;
16 const { values, ...args } = Object.fromEntries(params);
the-juice

the-juicetragic-indigo-gopher3 matches

@jxnblk•Updated 6 days ago
11 * The main App component is rendered on the client.
12 */
13function App() {
14 const [splats, setSplats] = useState([]);
15 const [shake, setShake] = useState(false);
82
83// Client-side only code
84function client() {
85 createRoot(document.getElementById("root")).render(<App />);
86}
88
89// Server-side only code
90export default async function server(request: Request): Promise<Response> {
91 return new Response(`
92 <!DOCTYPE html>
the-juice

the-juicestill-olive-barnacle7 matches

@jxnblk•Updated 6 days ago
1/**
2 * This program implements a simple Wave Function Collapse algorithm to generate
3 * a random game world rendered in ASCII characters with different colors.
4 * It uses React for the client-side rendering and handles the generation
18};
19
20function App() {
21 const [world, setWorld] = useState([]);
22
47}
48
49function client() {
50 createRoot(document.getElementById("root")).render(<App />);
51}
53if (typeof document !== "undefined") { client(); }
54
55async function server(request: Request): Promise<Response> {
56 const url = new URL(request.url);
57
79}
80
81function generateWorld(height: number, width: number): string[][] {
82 const world = Array(height).fill(0).map(() => Array(width).fill(null));
83 const stack: [number, number][] = [];
118}
119
120function getRandomTile(): string {
121 const tiles = Object.keys(tileTypes);
122 return tiles[Math.floor(Math.random() * tiles.length)];
123}
124
125function getPossibleTiles(world: string[][], y: number, x: number): string[] {
126 const neighbors = [
127 world[y - 1]?.[x],
the-juice

the-juiceresponsible-aqua-orca1 match

@jxnblk•Updated 6 days ago
2// We'll use a basic HTML structure with inline CSS for styling.
3
4export default async function server(request: Request): Promise<Response> {
5 const html = `
6 <!DOCTYPE html>

getFileEmail4 file matches

@shouser•Updated 6 days ago
A helper function to build a file's email

TwilioHelperFunctions

@vawogbemi•Updated 2 months ago