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=940&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 18081 results for "function"(1082ms)

redditAlertmain.tsx1 match

@charmaine•Updated 2 months ago
7const serpApiKey = Deno.env.get("SERP_API_KEY");
8
9export async function redditAlert({ lastRunAt }: Interval) {
10 if (!serpApiKey || !mentionsDiscord) {
11 console.error("Missing SERP_API_KEY or Discord webhook URL. Exiting.");

transaction_challengemain.tsx9 matches

@danielblaker•Updated 2 months ago
4import { blob } from "https://esm.town/v/std/blob";
5
6function generateMockTransaction() {
7 const types = ["purchase", "transfer", "withdrawal", "deposit"];
8 const amounts = [10, 50, 100, 500, 1000];
15}
16
17function Leaderboard() {
18 const [leaderboard, setLeaderboard] = useState([
19 { username: "AlgoTrader", score: 92 },
115}
116
117function App() {
118 const [activeTab, setActiveTab] = useState("challenge");
119 const [activeLevel, setActiveLevel] = useState(1);
120 const [username, setUsername] = useState("");
121 const [code, setCode] = useState(`
122// Write a function to approve or deny transactions
123function processTransaction(transaction) {
124 // Return true to approve, false to deny
125 return transaction.amount < 500;
135 try {
136 // eslint-disable-next-line no-eval
137 processRef.current = new Function("transaction", code + "\nreturn processTransaction(transaction);");
138 setIsRunning(true);
139 setTransactions([]); // Clear transactions when code is run
337 </h2>
338
339 As an intern at WallexAir, you're tasked with ensuring we meet this obligation. Write a function
340 that takes a transaction and returns true if it is a compliant transaction, and false if we should
341 reject it.
408}
409
410function client() {
411 createRoot(document.getElementById("root")).render(<App />);
412}
413if (typeof document !== "undefined") { client(); }
414
415export default async function server(request: Request): Promise<Response> {
416 return new Response(
417 `

getProjectsAsZipsApp.tsx1 match

@shouser•Updated 2 months ago
3import { MessageInput } from "./MessageInput.tsx";
4
5export function App({ projects }: { projects: any[] }) {
6 const [url, setURL] = React.useState("");
7

neighborsolutionsmain.tsx4 matches

@rowdypow•Updated 2 months ago
88 * @return {number} the distance in miles
89 */
90function convertMetersToMiles(meters: number): number {
91 return 0.000621371 * meters;
92}
93
94// Round a number to the nearest quarter.
95function roundToQuarter(number: number) {
96 let remainder = number % 1;
97
121 * @return {SearchParams | SearchParamsWithPreset} The constructed search parameters.
122 */
123function constructTypesenseParams({
124 query,
125 lat,
165 * @return {Promise<any>} A Promise that resolves to an array of resources matching the search criteria.
166 */
167export async function getResources({
168 lat,
169 lng,

reactWeatherDashboardmain.tsx4 matches

@vanzel•Updated 2 months ago
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function WeatherDashboard() {
6 const [location, setLocation] = useState({ latitude: 40.7128, longitude: -74.0060 }); // Default to NYC
7 const [weather, setWeather] = useState(null);
28
29 useEffect(() => {
30 async function fetchWeather() {
31 try {
32 const response = await fetch(
152};
153
154function client() {
155 createRoot(document.getElementById("root")).render(<WeatherDashboard />);
156}
157if (typeof document !== "undefined") { client(); }
158
159export default async function server(request: Request): Promise<Response> {
160 return new Response(`
161 <html>

reactHonoStarterApp.tsx1 match

@pomdtr•Updated 2 months ago
2import { useState } from "https://esm.sh/react@18.2.0";
3
4export function App() {
5 const [clicked, setClicked] = useState(0);
6 return (

utilsREADME.md1 match

@std•Updated 2 months ago
6
7If you're running code in Val Town, sometimes you want to know
8information about the val that's running. This module has functions for that.
9
10## Usage

reactHonoStarterApp.tsx1 match

@std•Updated 2 months ago
2import { useState } from "https://esm.sh/react@18.2.0";
3
4export function App() {
5 const [clicked, setClicked] = useState(0);
6 return (

utilsindex.ts2 matches

@std•Updated 2 months ago
2import { readFile } from "../file/index.ts";
3
4export async function serveFile(path: string, metaImportUrl: string): Promise<Response> {
5 const text = await readFile(path, metaImportUrl);
6 const content_type = getContentType(path);
12}
13
14export function getContentType(path: string): string {
15 if (path.endsWith(".ts") || path.endsWith(".jsx") || path.endsWith(".tsx")) {
16 return "text/javascript";

tenaciousPurpleSquirrelmain.tsx1 match

@pomcute•Updated 2 months ago
1import { arenaChannelContents } from "https://esm.town/v/pomcute/arenaChannelContents";
2
3export default async function questionPractice(interval: Interval) {
4 const contents = await arenaChannelContents({ channelId: "asking-the-right-questions-sbkcnb9eank" });
5

getFileEmail4 file matches

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

tuna8 file matches

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