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=1338&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 17278 results for "function"(1823ms)

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" }})`

crazyPeachCrayfishREADME.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" }})`

crazyPeachCrayfishmain.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 }: { val?: ValRef; style?: string } = {},
40 * @param val Define which val should open
41 */
42export function modifyFetchHandler(
43 handler: (req: Request) => Response | Promise<Response>,
44 { val, style }: { val?: ValRef; style?: string } = {},

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": "*",