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/image-url.jpg%20%22Image%20title%22?q=function&page=63&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 19319 results for "function"(1122ms)

TowniecalculateCost.tsx1 match

@pomdtrUpdated 5 days ago
5const CACHE_WRITE_RATE = 3.75; // $3.75 per M cache-write tokens
6
7export function calculateCost({
8 input_tokens,
9 output_tokens,

TownieBranchSelect.tsx1 match

@pomdtrUpdated 5 days ago
7const NEW_BRANCH_VAL = "__NEW_BRANCH__";
8
9export function BranchSelect () {
10 const { projectId, branchId } = useParams() as {
11 projectId: string;

Townieauth.ts1 match

@pomdtrUpdated 5 days ago
5 * Returns null if authentication is successful, or a Response if it fails
6 */
7export async function basicAuthMiddleware(req: Request): Promise<Response | null> {
8 const realm = "Usage Dashboard";
9 const unauthorizedResponse = new Response("Unauthorized", {

TownieApp.tsx1 match

@pomdtrUpdated 5 days ago
26});
27
28export function App() {
29 const [audio, setAudio] = useLocalStorage("AUDIO", false);
30 return (

EEPMOnitoringlogin.tsx1 match

@solomonferedeUpdated 5 days ago
8};
9
10export function LoginForm({ onLogin }) {
11 const [username, setUsername] = useState("");
12 const [password, setPassword] = useState("");
6 * The main App component is rendered on the client.
7 */
8function App() {
9 // --- State declarations ---
10 const [query, setQuery] = React.useState("");
25 const sourceUrl = import.meta.url.replace("esm.town", "val.town");
26
27 // --- Helper Functions ---
28 const buildQuery = React.useCallback((keywords, account, since, until) => {
29 let finalQuery = keywords.trim();
580 * Client-only code
581 */
582function client() {
583 const root = document.getElementById("root");
584 if (root) {
595 * Server-only code
596 */
597export default async function server(request: Request): Promise<Response> {
598 const url = new URL(request.url);
599
32};
33
34// Main function
35async function registerToggleRoleCommand() {
36 console.log("🚀 Starting server-pings command registration process...");
37
103const result = await registerToggleRoleCommand();
104
105// Export the result and function for external use
106export default result;
13} from "https://esm.town/v/ktodaz/Discord_Bot_Services/services/toggle-server-helper-pings-service.tsx"; // Fixed import path
14
15// Function to verify Discord request signature
16function verifyDiscordRequest(
17 body: string,
18 signature: string,
39
40// Handle Discord interactions
41export default async function(req: Request): Promise<Response> {
42 try {
43 const publicKey = Deno.env.get("DISCORD_PUBLIC_KEY");
128
129// Handle role autocomplete interaction
130async function handleRoleAutocomplete(interaction: any): Promise<Response> {
131 try {
132 const guildId = interaction.guild_id;
176
177// Handle toggle role command
178async function handleToggleRole(interaction: any): Promise<Response> {
179 const guildId = interaction.guild_id;
180 const userId = interaction.member.user.id;
12import { sqlite } from "https://esm.town/v/std/sqlite";
13
14// Function to convert hex string to Uint8Array (required for verification)
15function hexToUint8Array(hex: string): Uint8Array {
16 return new Uint8Array(
17 (hex.match(/.{1,2}/g) || []).map(byte => parseInt(byte, 16)),
19}
20
21// Function to verify Discord's signature
22function verifyDiscordRequest(
23 body: string,
24 signature: string,
43
44// Setup database for tracking command processing
45async function setupDatabase() {
46 await sqlite.execute(`
47 CREATE TABLE IF NOT EXISTS pending_commands (
61
62// Store command for later processing
63async function storeCommand(
64 interactionId: string,
65 guildId: string,
81
82// Main HTTP handler for Discord interactions
83export default async function(req: Request): Promise<Response> {
84 try {
85 console.log("📥 Received Discord interaction request");
16
17// Send a follow-up message to a Discord interaction
18async function sendFollowUp(applicationId: string, interactionToken: string, content: string): Promise<void> {
19 console.log(`📤 Sending follow-up message: ${content}`);
20 try {
36
37// Remove a pending command
38async function removePendingCommand(interactionId: string): Promise<void> {
39 await sqlite.execute({
40 sql: `DELETE FROM pending_commands WHERE interaction_id = ?`,
45
46// Process pending commands
47async function processPendingCommands(): Promise<void> {
48 console.log("🔄 Processing pending commands...");
49
189}
190
191// Main function that runs when this val is scheduled
192export default async function() {
193 console.log("⏰ Starting scheduled command processor...");
194

getFileEmail4 file matches

@shouserUpdated 2 weeks ago
A helper function to build a file's email
tuna

tuna8 file matches

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