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=2457&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 31449 results for "function"(18179ms)

loanCalculatormain.tsx3 matches

@arifio•Updated 4 months ago
3import React, { useState } from "https://esm.sh/react@18.2.0";
4
5function LoanCalculator() {
6 const [loanAmount, setLoanAmount] = useState(100000);
7 const [interestRate, setInterestRate] = useState(5);
121};
122
123function client() {
124 createRoot(document.getElementById("root")).render(<LoanCalculator />);
125}
127if (typeof document !== "undefined") { client(); }
128
129export default async function server(request: Request): Promise<Response> {
130 return new Response(
131 `

feedbackmain.ts1 match

@pomdtr•Updated 4 months ago
1import { gfm } from "https://esm.town/v/pomdtr/gfm";
2
3export default async function(req: Request): Promise<Response> {
4 const markdown = await fetch(import.meta.resolve("./README.md")).then(res => res.text());
5 const url = new URL(req.url);

APIBuilderTemplateenthusiasticPeachTapir1 match

@dcm31•Updated 4 months ago
1export default async function (interval: Interval) {
2
3}

spotifyOauthServergetSpotifyToken1 match

@charmaine•Updated 4 months ago
1import { getRow, getLatestRefreshRow, updateRow } from"./db";
2
3export async function getSpotifyToken(state: string) {
4 const authData = await getRow(state);
5 if (!authData) throw "NO_DATA";

spotifyOauthServergetSpotifyToken1 match

@neverstew•Updated 4 months ago
1import { getRow, getLatestRefreshRow, updateRow } from"./db";
2
3export async function getSpotifyToken(state: string) {
4 const authData = await getRow(state);
5 if (!authData) throw "NO_DATA";

sacredScarletSkinkmain.tsx6 matches

@charmaine•Updated 4 months ago
12];
13
14function PersonaSelector({ onSelectPersona }) {
15 return (
16 <div className="persona-selector">
33}
34
35function ChatApp({ persona, goBack }) {
36 const [messages, setMessages] = useState([
37 {
50 useEffect(scrollToBottom, [messages]);
51
52 function handleSendMessage() {
53 if (!inputMessage.trim()) return;
54
160}
161
162function App() {
163 const [selectedPersona, setSelectedPersona] = useState(null);
164
182}
183
184function client() {
185 createRoot(document.getElementById("root")).render(<App />);
186}
187if (typeof document !== "undefined") { client(); }
188
189export default async function server(request: Request): Promise<Response> {
190 return new Response(`
191 <html>

loggingTesthelperFunction2 matches

@willthereader•Updated 4 months ago
1export function squareNumber(num: number) {
2 console.log("helper function log");
3 console.log(`Squaring number: ${num}`);
4 return num * num;

loggingTestmainFunction3 matches

@willthereader•Updated 4 months ago
1import { squareNumber } from "./helperFunction";
2
3function processMathList() {
4 console.log("Starting math processing");
5 const numbers = [1, 2, 3];
7}
8
9console.log("\nTesting Math Functions:");
10console.log(processMathList());

vblogimport-file1 match

@jxnblk•Updated 4 months ago
1/** Import a file relative to the root of the project */
2export async function importFile(path: string) {
3 const url = new URL(path, import.meta.url);
4 const res = await fetch(url, { redirect: "follow" });

cerebrasTemplatemain.tsx3 matches

@charmaine•Updated 4 months ago
3import React, { useState } from "https://esm.sh/react@18.2.0";
4
5function App() {
6 const [messages, setMessages] = useState([]);
7 const [input, setInput] = useState("");
71}
72
73function client() {
74 createRoot(document.getElementById("root")).render(<App />);
75}
79}
80
81export default async function server(request: Request): Promise<Response> {
82 if (request.method === "POST" && new URL(request.url).pathname === "/chat") {
83 const { messages } = await request.json();
tuna

tuna9 file matches

@jxnblk•Updated 1 week ago
Simple functional CSS library for Val Town

getFileEmail4 file matches

@shouser•Updated 1 month ago
A helper function to build a file's email
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.