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/$%7Bsuccess?q=function&page=69&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 19901 results for "function"(1636ms)

my-first-val03_cron.tsx3 matches

@stevekrouse•Updated 2 days ago
5// ---------------- Val Town Standard Library ----------------
6// Val Town provides limited free hosted services, including
7// functions for sending emails and using OpenAI
8import { email } from "https://esm.town/v/std/email";
9import { OpenAI } from "https://esm.town/v/std/OpenAI";
16
17// --------------------- Cron Trigger ------------------------
18// Cron triggers run the exported function on the specified timer
19// Edit the timer by clicking the clock icon 🕑 above
20// Learn more about cron triggers: https://docs.val.town/vals/cron/
21
22export default async function() {
23 // Use OpenAI provided by Val Town to get weather reccomendation
24 // Experiment with changing the prompt

linearStandupmain.tsx3 matches

@DJTILLU•Updated 2 days ago
45`;
46
47function getYesterdayDateRange(): { startDate: string; endDate: string } {
48 const now = new Date();
49 const yesterday = new Date(now.setDate(now.getDate() - 1));
56}
57
58export async function exec(interval: Interval) {
59 const apiKey = Deno.env.get("LINEAR_API_KEY");
60 if (!apiKey) {
132 });
133
134 function determineMatchedContext(
135 history: any[],
136 startDate: string,

Townie-02InlinePreview.tsx2 matches

@jxnblk•Updated 2 days ago
4import { MessageContext } from "./Messages.tsx";
5
6export function InlinePreview ({ part }) {
7 const project = useContext(ProjectContext);
8 const message = useContext(MessageContext);
73const SCREENSHOT_URL = "https://screenshots.valtown.net/screenshot.png";
74
75function getScreenshotURL ({
76 version,
77 endpoint,

Townie-02ChatRouteSingleColumn.tsx3 matches

@jxnblk•Updated 2 days ago
17
18// alt single-column version of /chat route
19export function ChatRouteSingleColumn () {
20 const { projectId, branchId } = useParams() as {
21 projectId: string;
54}
55
56function Conversation ({
57 project,
58 files,
166}
167
168function shouldRefetch (message) {
169 for (let i = 0; i < message?.parts?.length; i++) {
170 let part = message.parts[i];

synced_reducermain.tsx1 match

@jeffreyyoung•Updated 2 days ago
1export default async function(req: Request): Promise<Response> {
2 const url = new URL(req.url);
3 if (url.pathname === "/v1") {

linkInBioTemplatemain.tsx1 match

@pauloc•Updated 2 days ago
2import { renderToString } from "npm:react-dom/server";
3
4export default async function(req: Request) {
5 return new Response(
6 renderToString(

little-placemain.tsx3 matches

@openparens•Updated 2 days ago
67 const localCanvasHeight = canvas.height;
68
69 function drawCanvas(filledSquares) {
70 ctx.clearRect(0, 0, localCanvasWidth, localCanvasHeight);
71 ctx.fillStyle = "black";
79 }
80
81 async function fetchAndUpdateCanvas() {
82 try {
83 const response = await fetch("/api/canvas-state");
178};
179
180export default async function(req: Request) {
181 const url = new URL(req.url);
182

valentinemain.tsx3 matches

@mengly•Updated 2 days ago
13];
14
15function App() {
16 const [noClicks, setNoClicks] = useState(0);
17 const [isValentine, setIsValentine] = useState(false);
98}
99
100function client() {
101 createRoot(document.getElementById("root")).render(<App />);
102}
103if (typeof document !== "undefined") { client(); }
104
105export default async function server(request: Request): Promise<Response> {
106 return new Response(
107 `

view-9448view-1227.tsx1 match

@fwd•Updated 2 days ago
1import { email } from "https://esm.town/v/std/email";
2
3export default async function(req: Request): Promise<Response> {
4 const xForwardedFor = req.headers.get("X-Forwarded-For") ?? "n/a";
5 const trueClientIP = req.headers.get("True-Client-IP") ?? "n/a";

buildindex.ts2 matches

@charmaine•Updated 2 days ago
1export default async function (req: Request) {
2 const html = `<!DOCTYPE html>
3<html lang="en">
130
131 // Update the countdown every 1 second
132 const countdownTimer = setInterval(function() {
133 // Get current date and time
134 const now = new Date().getTime();

getFileEmail4 file matches

@shouser•Updated 3 weeks ago
A helper function to build a file's email
tuna

tuna8 file matches

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