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=810&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 8781 results for "function"(595ms)

astuteAquamarineAardvarkmain.tsx1 match

@julesb22•Updated 6 months ago
1export default async function(req: Request): Promise<Response> {
2 return Response.json({ data: true });
3}

flutteringVioletBirdmain.tsx4 matches

@stevekrouse•Updated 6 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 const [description, setDescription] = useState("Thu, Sep 26, 2024 2:25 PM EDT");
7 const [dateString, setDateString] = useState("2024-09-26T14:25:00-04:00");
77}
78
79function DateComponent({ dateString }) {
80 if (!dateString) {
81 return <div>Invalid date string provided</div>;
107);
108
109function client() {
110 createRoot(document.getElementById("root")).render(<App />);
111}
115}
116
117export default async function server(request: Request): Promise<Response> {
118 return new Response(`
119 <!DOCTYPE html>

newUserWelcomeEmailmain.tsx2 matches

@charmaine•Updated 6 months ago
4import { html } from "https://esm.town/v/stevekrouse/html";
5
6async function sendTownieEmail() {
7 try {
8 await email({
19}
20
21export async function newUserWelcomeEmail(req: Request): Promise<Response> {
22 if (req.method === "GET") return html(welcomeEmail);
23 if (req.headers.get("clerkNonSensitive") !== Deno.env.get("clerkNonSensitive"))

runescapeWoodCuttingmain.tsx4 matches

@charmaine•Updated 6 months ago
9};
10
11function LoginScreen({ onLogin }) {
12 const [name, setName] = useState("");
13
36}
37
38function App() {
39 const [playerName, setPlayerName] = useState("");
40 const [skill, setSkill] = useState("woodcutting");
107}
108
109function client() {
110 createRoot(document.getElementById("root")).render(<App />);
111}
115}
116
117export default async function server(request: Request): Promise<Response> {
118 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
119 const SCHEMA_VERSION = 2;

anthropicCachingmain.tsx8 matches

@stevekrouse•Updated 6 months ago
1/**
2 * This val creates an interactive webpage that demonstrates the functionality of the Anthropic API.
3 * It uses a React frontend with an input for the API key and buttons to trigger different operations.
4 * The Anthropic API key is stored in the frontend state and sent with each API request.
9import { createRoot } from "https://esm.sh/react-dom/client";
10
11function App() {
12 const [apiKey, setApiKey] = useState("");
13 const [outputs, setOutputs] = useState({
82}
83
84function client() {
85 createRoot(document.getElementById("root")).render(<App />);
86}
90}
91
92async function server(request: Request): Promise<Response> {
93 const url = new URL(request.url);
94
138}
139
140async function fetchContent(): Promise<string> {
141 const response = await fetch("https://www.gutenberg.org/cache/epub/1342/pg1342.txt");
142 const text = await response.text();
146}
147
148async function runNonCachedCall(apiKey: string): Promise<string> {
149 const { default: anthropic } = await import("npm:@anthropic-ai/sdk@0.26.1");
150 const client = new anthropic.Anthropic({ apiKey });
182}
183
184async function runCachedCall(apiKey: string): Promise<string> {
185 const { default: anthropic } = await import("npm:@anthropic-ai/sdk@0.26.1");
186 const client = new anthropic.Anthropic({ apiKey });
221}
222
223async function runMultiTurnConversation(apiKey: string): Promise<string> {
224 const { default: anthropic } = await import("npm:@anthropic-ai/sdk@0.26.1");
225 const client = new anthropic.Anthropic({ apiKey });

wallpapermain.tsx1 match

@Phaeris•Updated 6 months ago
1export default async function(req: Request): Promise<Response> {
2 const url =
3 "https://global.bing.com/HPImageArchive.aspx?format=js&idx=0&n=9&pid=hp&FORM=BEHPTB&uhd=1&uhdwidth=3840&uhdheight=2160&setmkt=zh-CN&setlang=en";

switchbot_partymain.tsx8 matches

@stevekrouse•Updated 6 months ago
37];
38
39function getPartyStatus() {
40 const now = Temporal.Now.zonedDateTimeISO(NYC_TIMEZONE);
41 for (const party of parties) {
53}
54
55function formatTimeDifference(target, now) {
56 const diff = target.since(now);
57 const hours = diff.hours;
65}
66
67async function switchbotRequest(path, args) {
68 const token = Deno.env.get("SWITCHBOT_TOKEN");
69 const secret = Deno.env.get("SWITCHBOT_KEY");
89}
90
91function botPress(device) {
92 return switchbotRequest(`v1.1/devices/${device}/commands`, {
93 method: "POST",
102const { htmlUrl } = extractValInfo(import.meta.url);
103
104function Layout({ children, title }) {
105 return (
106 <html>
122}
123
124function Button({ children }) {
125 return (
126 <button class="bg-green-500 hover:bg-green-600 text-white font-bold py-3 px-6 rounded-full shadow-lg transform transition duration-200 hover:scale-105 focus:outline-none focus:ring-2 focus:ring-green-400 focus:ring-opacity-50">
130}
131
132function MainPage({ partyName }) {
133 return (
134 <Layout title={partyName}>
147}
148
149function ErrorPage({ title, message, backLink = true }) {
150 return (
151 <Layout title={title}>

protectiveCrimsonGalliformREADME.md1 match

@stevekrouse•Updated 6 months ago
1# getMyValId
2
3Helper function for a val to get its own ID.
4
5## Usage

protectiveCrimsonGalliformmain.tsx1 match

@stevekrouse•Updated 6 months ago
2import ValTown from "npm:@valtown/sdk";
3
4async function getMyValId(importMetaURL: string) {
5 const vt = new ValTown();
6 const { author, name } = extractValInfo(importMetaURL);

getMyValIdmain.tsx1 match

@stevekrouse•Updated 6 months ago
2import ValTown from "npm:@valtown/sdk";
3
4async function getMyValId(importMetaURL: string) {
5 const vt = new ValTown();
6 const { author, name } = extractValInfo(importMetaURL);

getFileEmail4 file matches

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

TwilioHelperFunctions

@vawogbemi•Updated 2 months ago