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=3020&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 33686 results for "function"(13019ms)

sassymain.tsx1 match

@pinjasaur•Updated 11 months ago
1import sass from "npm:sass";
2
3export default async function(req: Request): Promise<Response> {
4 if (req.method !== "POST") {
5 return Response.json({ error: "This val responds to POST requests." }, {

extractValInfomain.tsx1 match

@syhner•Updated 11 months ago
1export function extractValInfo(url: string | URL) {
2 const { pathname, search } = new URL(url);
3 const [author, filename] = pathname.split("/").slice(-2);

valleGetValsContextWindowmain.tsx7 matches

@stevekrouse•Updated 11 months ago
1export default async function getValsContextWindow(model: any) {
2 const readmeVals: any = await (await fetch("https://janpaul123-readmevals.web.val.run/")).json();
3
183 import { render } from "npm:preact-render-to-string";
184
185 export default async function(req: Request) {
186 return new Response(
187 render(
212 const FLAT_TEMPLATES = sections.flatMap((section) => section.templates);
213
214 function tsResponse(code) {
215 return "```ts\n" + code + "\n```";
216 }
383 ### Utilities
384
385 Our Blob SDK also includes some utility functions to make working with blobs easier.
386
387 ##### Copy
507 role: "assistant",
508 content:
509 "\n```ts\nexport default async function (req: Request): Promise<Response> {\n return Response.json(\"Hello world\")\n}\n```",
510 },
511 {
516 role: "assistant",
517 content:
518 "\n```ts\nexport default async function(req: Request): Promise<Response> {\n const query = new URL(req.url).searchParams;\n\n // Read name from the querystring or body. Defaults to \"you\" if not present.\n const name = query.get(\"name\") || (await req.json().catch(() => ({}))).name || \"you\";\n\n // Returns the HTML response\n return new Response(`<h1>Hi ${name}!</h1>`, {\n headers: { \"Content-Type\": \"text/html\" },\n });\n}\n```",
519 },
520 {
533 role: "assistant",
534 content:
535 "```ts\nexport default async function(req: Request): Promise<Response> {\n const apiKey = Deno.env.get(\"METEO_KEY\");\n const apiUrl = `https://api.open-meteo.com/v1/forecast?latitude=40.6782&longitude=-73.9442&hourly=temperature_2m&current_weather=true&apikey=${apiKey}`;\n\n const response = await fetch(apiUrl);\n const weatherData = await response.json();\n\n return new Response(JSON.stringify(weatherData), { headers: { \"Content-Type\": \"application/json\" } });\n}\n```",
536 },
537 {

ipqsScoreChangeAlertmain.tsx2 matches

@nickgolden•Updated 11 months ago
6const ipDataName = "googleIpqsData";
7
8async function sendEmail(oldData, newData) {
9 const emailBody = `The IPQS score for the IP address "${ipAddress}" has changed.
10Old evaluation:
17}
18
19export async function checkIp() {
20 const result = await fetch(`https://ipqualityscore.com/api/json/ip/${ipqsApiKey}/${ipAddress}`);
21 const newData = await result.json();

surfboardDemoSchedule2main.tsx4 matches

@szymonator•Updated 11 months ago
17// DO NOT EDIT
18
19async function getSchedule() {
20 try {
21 let start = new Date();
53}
54
55function Demo({ data }) {
56 if (!data) return <p>Failed to fetch</p>;
57
58 function processData(data) {
59 /*console.log(JSON.stringify(data,null,2))*/
60 let processedData = [];
187// }
188
189export default async function(req: Request): Promise<Response> {
190 const scheduleData = await getSchedule();
191 const { renderToReadableStream } = await import("https://esm.sh/react-dom/server");

blobCommentsReactmain.tsx2 matches

@keenanzucker•Updated 11 months ago
6import { blob } from "https://esm.town/v/std/blob?v=10";
7
8function App() {
9 const [data, setData] = useState();
10
11 useEffect(() => {
12 async function fetchSchedule() {
13 await fetch("/schedule")
14 .then(response => {

codeOnValTownmain.tsx2 matches

@andreterron•Updated 11 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 } = {},

reactClientDemomain.tsx1 match

@keenanzucker•Updated 11 months ago
26// }
27
28export default async function(req: Request): Promise<Response> {
29 const { renderToReadableStream } = await import("https://esm.sh/react-dom/server");
30 const stream = await renderToReadableStream(<App />, { bootstrapModules: [import.meta.url] });

surfboardDemoSchedule2main.tsx3 matches

@keenanzucker•Updated 11 months ago
3import { renderToString } from "npm:react-dom/server";
4
5async function getSchedule() {
6 try {
7 const today = new Date();
35 });
36};
37function Schedule({ data }) {
38 if (!data) return <p>Failed to fetch</p>;
39
69);
70
71export default async function(req: Request): Promise<Response> {
72 const scheduleData = await getSchedule();
73 const { renderToReadableStream } = await import("https://esm.sh/react-dom/server");

coffeeMongoosemain.tsx1 match

@mmrech•Updated 11 months ago
1export default async function (req: Request): Promise<Response> {
2 return Response.json({ ok: true })
3}<script src="//code.jquery.com/jquery-1.10.2.min.js"></script>

discordWebhook2 file matches

@stevekrouse•Updated 1 week ago
Helper function to send Discord messages
tuna

tuna9 file matches

@jxnblk•Updated 1 month 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.