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/$%7Bsuccess?q=function&page=1664&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 20538 results for "function"(2963ms)

bulletinBoardmain.tsx4 matches

@roramigator•Updated 8 months ago
7import { createRoot } from "https://esm.sh/react-dom/client";
8
9function App() {
10 const [posts, setPosts] = useState([]);
11 const [newTitle, setNewTitle] = useState("");
79}
80
81function client() {
82 createRoot(document.getElementById("root")).render(<App />);
83}
84if (typeof document !== "undefined") { client(); }
85
86async function server(request: Request): Promise<Response> {
87 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
88 const SCHEMA_VERSION = 1;
99 `);
100
101 // Function to delete old posts
102 const deleteOldPosts = async () => {
103 await sqlite.execute(`

religionClickerGamemain.tsx4 matches

@roramigator•Updated 8 months ago
5import { createRoot } from "https://esm.sh/react-dom/client";
6
7function App() {
8 const [believers, setBelievers] = useState(0);
9 const [believersPerSecond, setBelieversPerSecond] = useState(0);
100}
101
102function getAchievementDescription(key) {
103 const descriptions = {
104 firstBeliever: "Congrats! You've fooled your first believer. It's all downhill from here.",
110}
111
112function client() {
113 createRoot(document.getElementById("root")).render(<App />);
114}
118}
119
120async function server(request: Request): Promise<Response> {
121 return new Response(
122 `

canvasvalcontributionchartmain.tsx6 matches

@ejfox•Updated 8 months ago
1async function fetchContributionData() {
2 try {
3 const response = await fetch('https://ejfox-allvals.web.val.run');
13}
14
15function processContributionData(vals) {
16 try {
17 const today = new Date();
39}
40
41function getColorIntensity(count) {
42 if (count === 0) return '#ebedf0';
43 if (count < 5) return '#9be9a8';
47}
48
49function drawContributionChart(ctx, contributionData, width, height) {
50 try {
51 const cellSize = 10;
78}
79
80async function server(request: Request): Promise<Response> {
81 try {
82 console.log('Fetching contribution data...');
116 });
117 } catch (error) {
118 console.error('Error in server function:', error);
119 return new Response(`Error generating contribution chart: ${error.message}`, { status: 500 });
120 }

valcontributionchartmain.tsx3 matches

@ejfox•Updated 8 months ago
7import { createRoot } from "https://esm.sh/react-dom/client";
8
9function App() {
10 const [contributionData, setContributionData] = useState({});
11 const [loading, setLoading] = useState(true);
96}
97
98function client() {
99 createRoot(document.getElementById("root")).render(<App />);
100}
102if (typeof document !== "undefined") { client(); }
103
104async function server(request: Request): Promise<Response> {
105 return new Response(`
106 <html>

pushmain.tsx1 match

@yawnxyz•Updated 8 months ago
85<script src="https://cdn.jsdelivr.net/gh/philfung/add-to-homescreen@1.9/dist/add-to-homescreen.min.js"></script>
86<script>
87document.addEventListener('DOMContentLoaded', function () {
88 window.AddToHomeScreenInstance = new window.AddToHomeScreen({
89 appName: 'ValPush',

knowledgeExplorermain.tsx3 matches

@sharanbabu•Updated 8 months ago
10const SUGGESTIONS = ["Quantum Computing", "Renaissance Art", "Climate Change", "Artificial Intelligence", "Space Exploration"];
11
12function App() {
13 const [topic, setTopic] = useState("");
14 const [content, setContent] = useState("");
134}
135
136function client() {
137 createRoot(document.getElementById("root")).render(<App />);
138}
142}
143
144async function server(request: Request): Promise<Response> {
145 if (request.method === "POST" && new URL(request.url).pathname === "/generate") {
146 const { topic, prompt, direction } = await request.json();

taxratesmain.tsx4 matches

@stevekrouse•Updated 8 months ago
44}
45
46function parseCsv(csv: string): TaxBracket[] {
47 const lines = csv.trim().split("\n");
48 const headers = lines.shift()?.split(",");
59}
60
61function calculateTax(
62 income: number,
63 filingStatus: string,
91};
92
93function generateHtml(taxBrackets: TaxBracket[], selectedFilingStatus: string): string {
94 let tableRows = "";
95 for (let income = 0; income <= 1000000; income += 1000) {
147}
148
149export default async function main(req: Request): Promise<Response> {
150 const taxBrackets = parseCsv(csvData);
151 const url = new URL(req.url);

pushmain.tsx1 match

@stevekrouse•Updated 8 months ago
85<script src="https://cdn.jsdelivr.net/gh/philfung/add-to-homescreen@1.9/dist/add-to-homescreen.min.js"></script>
86<script>
87document.addEventListener('DOMContentLoaded', function () {
88 window.AddToHomeScreenInstance = new window.AddToHomeScreen({
89 appName: 'ValPush',

outsideBlushShrimpmain.tsx2 matches

@MichaelNollox•Updated 8 months ago
9 * @param val Define which val should open. Defaults to the root reference
10 */
11export function modifyHtmlString(
12 bodyText: string,
13 { val, style, variant }: { val?: ValRef; style?: string; variant?: 'default' | 'green' } = {},
40 * @param val Define which val should open
41 */
42export function modifyFetchHandler(
43 handler: (req: Request) => Response | Promise<Response>,
44 { val, style, variant }: { val?: ValRef; style?: string; variant?: 'default' | 'green' } = {},

outsideBlushShrimpREADME.md1 match

@MichaelNollox•Updated 8 months ago
49### Linking to the val
50
51These functions infer the val using the call stack or the request URL. If the inference isn't working, or if you want to ensure it links to a specific val, pass the `val` argument:
52
53- `modifyFetchHandler(handler, {val: { handle: "andre", name: "foo" }})`

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 3 weeks 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.