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=1396&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 18324 results for "function"(1187ms)

HTTP_RequestBodymain.tsx1 match

@rozek•Updated 7 months ago
1export default async function (req: Request): Promise<Response> {
2 // Check if the request method is POST
3 if (req.method !== 'POST') {

HTTP_Headersmain.tsx1 match

@rozek•Updated 7 months ago
1export default async function(Request: Request): Promise<Response> {
2 return Response.json(Object.fromEntries(Request.headers.entries()));
3}

HTTP_URLParsermain.tsx1 match

@rozek•Updated 7 months ago
1export default async function(Request: Request): Promise<Response> {
2 const parsedURL = new URL(Request.url);
3

HTTP_StatusCodemain.tsx1 match

@rozek•Updated 7 months ago
1export default async function (req: Request): Promise<Response> {
2 // Extract the path from the request URL
3 const path = new URL(req.url).pathname;

HTTP_HelloWorldmain.tsx1 match

@rozek•Updated 7 months ago
1export default function (request: Request): Response {
2 return new Response("Hello world", {
3 headers: { "Content-Type": "text/plain" },

buildagencymain.tsx3 matches

@elliotbraem•Updated 7 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 return (
7 <div className="container">
28}
29
30function client() {
31 createRoot(document.getElementById("root")).render(<App />);
32}
33if (typeof document !== "undefined") { client(); }
34
35export default async function server(request: Request): Promise<Response> {
36 return new Response(
37 `

youtubeSearchResultsmain.tsx3 matches

@trob•Updated 7 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 const [query, setQuery] = useState("");
7 const [results, setResults] = useState([]);
71}
72
73function client() {
74 createRoot(document.getElementById("root")).render(<App />);
75}
76if (typeof document !== "undefined") { client(); }
77
78export default async function server(request: Request): Promise<Response> {
79 const url = new URL(request.url);
80 if (url.pathname === "/search") {

weekly_mortgage_ratesmain.tsx10 matches

@bleikamp•Updated 7 months ago
12const FRED_API_KEY = process.env.FRED_API_KEY;
13
14// Function to fetch rate data from FRED API
15async function getRateData(seriesId: string): Promise<RateData> {
16 const url =
17 `https://api.stlouisfed.org/fred/series/observations?series_id=${seriesId}&api_key=${FRED_API_KEY}&file_type=json&sort_order=desc&limit=2`;
38}
39
40// Function to fetch all rate data
41async function getAllRateData(): Promise<RateData[]> {
42 const seriesIds = ["MORTGAGE30US", "SOFR30DAYAVG"];
43 const promises = seriesIds.map(seriesId => getRateData(seriesId));
45}
46
47// Function to format the email content
48function formatEmailContent(rateDataArray: RateData[]): string {
49 const rateRows = rateDataArray
50 .map(
77}
78
79// Main function to send the email
80export async function sendMortgageRateEmail() {
81 try {
82 const rateDataArray = await getAllRateData();
94}
95
96export default async function(interval: Interval) {
97 try {
98 const mortgageEmail = await sendMortgageRateEmail();
101 return { mortgageEmail: mortgageEmail };
102 } catch (error) {
103 console.error("Error in main function:", error);
104 throw error;
105 }

smoothBluePanthermain.tsx3 matches

@stevekrouse•Updated 7 months ago
4import { createRoot } from "https://esm.sh/react-dom/client";
5
6function App() {
7 const [htmlInput, setHtmlInput] = useState("<h1>Hello, World!</h1>"); const [silliness, setSilliness] = useState(0);
8 const [slang, setSlang] = useState(0);
90}
91
92function client() {
93 createRoot(document.getElementById("root")).render(<App />);
94}
98}
99
100async function server(request: Request): Promise<Response> {
101 if (request.method === "POST" && new URL(request.url).pathname === "/api/modify") {
102 const { html, silliness, slang } = await request.json();

ThreadmarkLISTFetcher2main.tsx7 matches

@willthereader•Updated 7 months ago
1import { versionLogger } from "https://esm.town/v/willthereader/versionLoggger";
2// version one is the one with the javascript scenario
3function App() {
4 let url = "";
5 let chapterTitles = "";
139}
140
141async function fetchThreadmarksFromServer(url, chapterTitles) {
142 const response = await fetch("/api/threadmarks", {
143 method: "POST",
154}
155
156async function getThreadmarkUrls(baseUrl, apiKey) {
157 versionLogger(import.meta.url);
158 const startTime = Date.now();
224}
225
226function parseThreadmarks(data) {
227 // console.log(`[INFO] Starting to parse threadmarks from HTML data. Total data length: ${data.length}`);
228 const threadmarks = [];
241}
242
243function compareThreadmarks(expectedTitles, retrievedThreadmarks) {
244 const expectedTitlesArray = expectedTitles.split("\n").map(title => title.trim()).filter(title => title !== "");
245 const retrievedTitles = retrievedThreadmarks.map(threadmark => threadmark.title);
298}
299
300function client() {
301 // console.log("Initializing client-side application");
302 const app = App();
308}
309
310export default async function server(request) {
311 console.log(`Received ${request.method} request for path: ${new URL(request.url).pathname}`);
312

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
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.