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=743&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 7802 results for "function"(469ms)

Prompt_ImproverPrompt_Improver_Includer1 match

@toowired•Updated 3 months ago
1export default async function(request: Request) {
2 const { prompt } = await request.json();
3

Prompt_ImproverPrompt_Improver_Clarifier1 match

@toowired•Updated 3 months ago
1export default async function (request: Request) {
2 const { prompt } = await request.json();
3

URLReceiverURLReceiverTest10 matches

@willthereader•Updated 3 months ago
22 inputs: Record<string, unknown>;
23 expectedResult: unknown;
24 function: Function;
25}
26
28
29// Create test cases by combining URLs with modifications
30function createURLTests(): TestCase[] {
31 const tests: TestCase[] = [];
32
36 inputs: { url: baseURL },
37 expectedResult: { isValid: true },
38 function: urlReceiver.receiveURL.bind(urlReceiver),
39 });
40
43 inputs: { url: TEST_MODIFICATIONS.withHTTP(baseURL) },
44 expectedResult: { isValid: true },
45 function: urlReceiver.receiveURL.bind(urlReceiver),
46 });
47
53 error: "URL must use HTTP or HTTPS protocol",
54 },
55 function: urlReceiver.receiveURL.bind(urlReceiver),
56 });
57
63 error: "Invalid URL format",
64 },
65 function: urlReceiver.receiveURL.bind(urlReceiver),
66 });
67 });
72 inputs: {},
73 expectedResult: undefined,
74 function: urlReceiver.clearHistory.bind(urlReceiver),
75 });
76
79 inputs: {},
80 expectedResult: [],
81 function: urlReceiver.getURLHistory.bind(urlReceiver),
82 });
83
86 inputs: {},
87 expectedResult: undefined,
88 function: urlReceiver.clearHistory.bind(urlReceiver),
89 });
90
97 console.log(`Running test: ${testCase.description}`);
98
99 const result = testCase.function(testCase.inputs.url);
100 console.log(`Input: ${JSON.stringify(testCase.inputs)}`);
101 console.log(`Expected result: ${JSON.stringify(testCase.expectedResult)}`);

cancelledStripeSubscribermain.tsx1 match

@charmaine•Updated 3 months ago
11});
12
13function getStripeCustomer(customerId: string) {
14 console.log(customerId);
15 return stripe.customers.retrieve(customerId);

quickIndigoBobolinkmain.tsx1 match

@charmaine•Updated 3 months ago
11});
12
13function getStripeCustomer(customerId: string) {
14 return stripe.customers.retrieve(customerId);
15}

insightfulBrownAntmain.tsx1 match

@charmaine•Updated 3 months ago
11});
12
13function getStripeCustomer(customerId: string) {
14 return stripe.customers.retrieve(customerId);
15}

CRMmain.tsx6 matches

@stevekrouse•Updated 3 months ago
3import React, { useEffect, useRef, useState } from "https://esm.sh/react@18.2.0";
4
5function LoginScreen({ onLogin }) {
6 const [password, setPassword] = useState("");
7 const [error, setError] = useState("");
46}
47
48function CustomerInteractionForm({ onSubmit }) {
49 const [email, setEmail] = useState("");
50 const [firstName, setFirstName] = useState("");
240}
241
242function InteractionList() {
243 const [customerInteractions, setCustomerInteractions] = useState({});
244 const [copiedEmail, setCopiedEmail] = useState(null);
470}
471
472function App() {
473 const [isAuthenticated, setIsAuthenticated] = useState(false);
474 const [refreshList, setRefreshList] = useState(0);
517}
518
519function client() {
520 createRoot(document.getElementById("root")).render(<App />);
521}
522if (typeof document !== "undefined") { client(); }
523
524export default async function server(request: Request): Promise<Response> {
525 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
526 const KEY = "CRM";

isESMshChangingmain.tsx1 match

@maxm•Updated 3 months ago
1import { getAllVersions } from "https://esm.town/v/maxm/trackESMContent";
2
3export default async function(req: Request): Promise<Response> {
4 return new Response(
5 JSON.stringify(

money_countermain.tsx7 matches

@arfan•Updated 3 months ago
3 SINGLE-FILE VAL CODE
4 1) Imports React, once.
5 2) Declares CSS + server() function
6 3) Declares the <App/> React component
7 4) Declares client() to mount <App/>
298
299/* ------------------------------------------------
300 2) server() function: returns the HTML skeleton
301------------------------------------------------ */
302export default async function server(request: Request): Promise<Response> {
303 return new Response(
304 `
328 3) The React App
329------------------------------------------------ */
330function App() {
331 // States for inputs
332 const [entryName, setEntryName] = useState("#");
365
366 // Helpers
367 function formatNumber(num) {
368 return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
369 }
370 function formatCurrency(num) {
371 return `$${num.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, "$&,")}`;
372 }
897 4) Mount the React <App/> client-side
898------------------------------------------------ */
899function client() {
900 createRoot(document.getElementById("root")).render(<App />);
901}

tastefulIvoryWormmain.tsx1 match

@maxm•Updated 3 months ago
4 console.log("after 1s");
5});
6export default async function() {
7 console.log("from within export");
8}

getFileEmail4 file matches

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

TwilioHelperFunctions

@vawogbemi•Updated 2 months ago