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=874&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 10292 results for "function"(632ms)

CDS_Countermain.tsx9 matches

@toowired•Updated 5 months ago
33let model;
34
35async function loadModel() {
36 model = await cocoSsd.load();
37}
39loadModel();
40
41self.onmessage = async function(e) {
42 if (!model) {
43 await loadModel();
56const worker = new Worker(workerUrl);
57
58export default async function server(request: Request): Promise<Response> {
59 if (request.method === "POST") {
60 try {
139}
140
141// Helper function to map detected objects to acceptable container types
142function mapToAcceptableContainer(detectedClass) {
143 const lowerClass = detectedClass.toLowerCase();
144 if (lowerClass.includes("bottle")) return "plastic bottle";
149}
150
151// Cleanup function to revoke the worker URL when the val is unloaded
152globalThis.addEventListener("unload", () => {
153 URL.revokeObjectURL(workerUrl);
155
156// Implementation of sendNotification
157async function sendNotification(message) {
158 try {
159 // Using Val Town's email functionality:
160 await email.send({
161 to: 'your_email@example.com', // Replace with your email
172
173// Implementation of logDetection
174async function logDetection(containers) {
175 try {
176 const timestamp = new Date().toISOString();

uptimemain.tsx1 match

@bootspoon•Updated 5 months ago
6);
7
8export async function uptimeCheck(url: string) {
9 let reason: string, status: number, end: number;
10 let ok = true;

codecommentermain.tsx2 matches

@JamesAndrew•Updated 5 months ago
15);
16
17function App() {
18 const [input, setInput] = useState("");
19 const [output, setOutput] = useState("");
85}
86
87export default async function server(request: Request): Promise<Response> {
88 if (request.method === "POST" && new URL(request.url).pathname === "/comment") {
89 const { OpenAI } = await import("https://esm.town/v/std/openai");

shirtGenmain.tsx4 matches

@torlanco•Updated 5 months ago
10}
11
12function ImageGenerator() {
13 const [promptSuffix, setPromptSuffix] = useState("");
14 const [generation, setGeneration] = useState<PendingGeneration | null>(null);
81}
82
83function App() {
84 return <ImageGenerator />;
85}
86
87function client() {
88 createRoot(document.getElementById("root")).render(<App />);
89}
90if (typeof document !== "undefined") { client(); }
91
92export default async function server(request: Request): Promise<Response> {
93 return new Response(
94 `

aqimain.tsx1 match

@davidhariri•Updated 5 months ago
2import { easyAQI } from "https://esm.town/v/stevekrouse/easyAQI?v=5";
3
4export async function aqi(interval: Interval) {
5 const location = "Toronto, Canada"; // <-- change to place, city, or zip code
6 const data = await easyAQI({ location });

emailEchomain.tsx1 match

@sumansaurabh91•Updated 5 months ago
2import { thisEmail } from "https://esm.town/v/stevekrouse/thisEmail";
3
4export const emailEcho = async function(e: Email) {
5 return await email({
6 to: e.from,

passionateScarletPrawnmain.tsx3 matches

@stevekrouse•Updated 5 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 const [prompt, setPrompt] = useState("");
7 const [useProModel, setUseProModel] = useState(false);
77}
78
79function client() {
80 createRoot(document.getElementById("root")).render(<App />);
81}
85}
86
87export default async function server(request: Request): Promise<Response> {
88 if (request.method === "GET") {
89 return new Response(

laudableFuchsiaMastodonmain.tsx3 matches

@stevekrouse•Updated 5 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 const [prompt, setPrompt] = useState("");
7 const [useProModel, setUseProModel] = useState(false);
72}
73
74function client() {
75 createRoot(document.getElementById("root")).render(<App />);
76}
80}
81
82export default async function server(request: Request): Promise<Response> {
83 if (request.method === "POST") {
84 const { prompt, useProModel } = await request.json();

shirtGenScriptmain.tsx1 match

@stevekrouse•Updated 5 months ago
1export default async function server(request: Request): Promise<Response> {
2 if (request.method !== "POST") {
3 return new Response("Method Not Allowed", { status: 405 });

shirtGenScriptmain.tsx1 match

@stevekrouse•Updated 5 months ago
1export default async function server(request: Request): Promise<Response> {
2 if (request.method !== "POST") {
3 return new Response("Method Not Allowed", { status: 405 });

getFileEmail4 file matches

@shouser•Updated 1 week ago
A helper function to build a file's email

TwilioHelperFunctions

@vawogbemi•Updated 2 months ago