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/$1?q=function&page=1&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 23725 results for "function"(866ms)

toolslist-project-files.tsx1 match

@chadparker•Updated 17 mins ago
1import { listFiles } from "https://esm.town/v/std/utils@85-main/index.ts";
2
3export default async function(req: Request) {
4 try {
5 const files = await listFiles(import.meta.url);

blob_adminapp.tsx7 matches

@codeanand•Updated 19 mins ago
10}
11
12function Tooltip({ children, content }: TooltipProps) {
13 const [isVisible, setIsVisible] = useState(false);
14 const tooltipRef = useRef<HTMLDivElement>(null);
49}
50
51function formatBytes(bytes: number, decimals = 2) {
52 if (bytes === 0) return "0 Bytes";
53 const k = 1024;
58}
59
60function copyToClipboard(text: string) {
61 navigator.clipboard.writeText(text).then(() => {
62 console.log("Text copied to clipboard");
66}
67
68function ActionMenu({ blob, onDownload, onRename, onDelete, onMoveToPublic, onMoveOutOfPublic }) {
69 const [isOpen, setIsOpen] = useState(false);
70 const menuRef = useRef(null);
73
74 useEffect(() => {
75 function handleClickOutside(event) {
76 if (menuRef.current && !menuRef.current.contains(event.target)) {
77 event.stopPropagation();
155}
156
157function BlobItem({ blob, onSelect, isSelected, onDownload, onRename, onDelete, onMoveToPublic, onMoveOutOfPublic }) {
158 const [isLoading, setIsLoading] = useState(false);
159 const decodedKey = decodeURIComponent(blob.key);
216}
217
218function App({ initialEmail, initialProfile, sourceURL }) {
219 const encodeKey = (key: string) => encodeURIComponent(key);
220 const decodeKey = (key: string) => decodeURIComponent(key);

youta_servermain.tsx4 matches

@youta•Updated 44 mins ago
5console.log("WebSocket server started on port 8080");
6
7wss.on("connection", function connection(ws) {
8 console.log("Client connected!");
9
10 ws.on("message", function incoming(message) {
11 console.log("Received message from client: %s", message);
12
15 });
16
17 ws.on("close", function close() {
18 console.log("Client disconnected.");
19 });
20
21 ws.on("error", function error(err) {
22 console.error("WebSocket error:", err);
23 });

email-memain.tsx1 match

@superhighfives•Updated 1 hour ago
2import { email } from "https://esm.town/v/std/email";
3
4export default async function(req: Request) {
5 const markdownContent = `
6# Don't forget

MCPChatInterface.tsx1 match

@c15r•Updated 1 hour ago
10}
11
12export function ChatInterface({ messages, onSendMessage, isLoading, availableTools }: ChatInterfaceProps) {
13 const [input, setInput] = useState('');
14 const messagesEndRef = useRef<HTMLDivElement>(null);

MCPApiKeyInput.tsx1 match

@c15r•Updated 1 hour ago
7}
8
9export function ApiKeyInput({ apiKey, onApiKeyChange }: ApiKeyInputProps) {
10 const [isVisible, setIsVisible] = useState(false);
11 const [tempKey, setTempKey] = useState(apiKey);

MCPApp.tsx1 match

@c15r•Updated 1 hour ago
22}
23
24export function App() {
25 const [apiKey, setApiKey] = useState<string>('');
26 const [messages, setMessages] = useState<Message[]>([]);

MCPresources.ts7 matches

@c15r•Updated 1 hour ago
9import { MCPException, MCP_ERRORS } from "../../shared/utils.ts";
10
11export async function listResources(): Promise<MCPResource[]> {
12 const resources: MCPResource[] = [];
13
64}
65
66export async function readResource(uri: string): Promise<{ contents: Array<{ uri: string; mimeType?: string; text?: string }> }> {
67 const [scheme, path] = uri.split("://", 2);
68
81}
82
83async function readBlobResource(key: string): Promise<{ contents: Array<{ uri: string; mimeType?: string; text?: string }> }> {
84 try {
85 const value = await blob.getJSON(key);
108}
109
110async function readFileResource(path: string): Promise<{ contents: Array<{ uri: string; mimeType?: string; text?: string }> }> {
111 try {
112 const content = await readFile(path, import.meta.url);
123}
124
125async function readSqliteResource(resource: string): Promise<{ contents: Array<{ uri: string; mimeType?: string; text?: string }> }> {
126 if (resource === "schema") {
127 try {
153}
154
155async function readEnvResource(resource: string): Promise<{ contents: Array<{ uri: string; mimeType?: string; text?: string }> }> {
156 if (resource === "info") {
157 // Only return environment variable names for security
174}
175
176function getMimeType(filename: string): string {
177 const ext = filename.split('.').pop()?.toLowerCase();
178

MCPserver.ts7 matches

@c15r•Updated 1 hour ago
19};
20
21export async function handleMCPRequest(request: MCPRequest): Promise<MCPResponse> {
22 try {
23 // Validate JSON-RPC format
78}
79
80async function handleInitialize(params: any): Promise<any> {
81 return {
82 protocolVersion: SERVER_INFO.protocolVersion,
89}
90
91async function handleToolsList(): Promise<any> {
92 return {
93 tools: TOOLS
95}
96
97async function handleToolsCall(params: any): Promise<any> {
98 if (!params.name) {
99 throw new MCPException(MCP_ERRORS.INVALID_PARAMS, "Missing tool name");
104}
105
106async function handleResourcesList(): Promise<any> {
107 const resources = await listResources();
108 return { resources };
109}
110
111async function handleResourcesRead(params: any): Promise<any> {
112 if (!params.uri) {
113 throw new MCPException(MCP_ERRORS.INVALID_PARAMS, "Missing resource URI");
117}
118
119export function getServerInfo(): MCPServerInfo {
120 return SERVER_INFO;
121}

MCPtools.ts11 matches

@c15r•Updated 1 hour ago
141];
142
143export async function executeTool(name: string, args: Record<string, any>): Promise<MCPToolResult> {
144 try {
145 switch (name) {
181}
182
183async function handleBlobGet(args: any): Promise<MCPToolResult> {
184 validateRequired(args, ["key"]);
185 const key = sanitizeKey(args.key);
205}
206
207async function handleBlobSet(args: any): Promise<MCPToolResult> {
208 validateRequired(args, ["key", "value"]);
209 const key = sanitizeKey(args.key);
224}
225
226async function handleBlobList(args: any): Promise<MCPToolResult> {
227 const prefix = args.prefix || "";
228 const keys = await blob.list(prefix);
236}
237
238async function handleBlobDelete(args: any): Promise<MCPToolResult> {
239 validateRequired(args, ["key"]);
240 const key = sanitizeKey(args.key);
250}
251
252async function handleSqliteExecute(args: any): Promise<MCPToolResult> {
253 validateRequired(args, ["query"]);
254 const { query, params = [] } = args;
264}
265
266async function handleEmailSend(args: any): Promise<MCPToolResult> {
267 validateRequired(args, ["subject"]);
268
285}
286
287async function handleOpenAIChat(args: any): Promise<MCPToolResult> {
288 validateRequired(args, ["messages"]);
289
311}
312
313async function handleFileRead(args: any): Promise<MCPToolResult> {
314 validateRequired(args, ["path"]);
315
333}
334
335async function handleFileList(args: any): Promise<MCPToolResult> {
336 try {
337 const files = await listFiles(import.meta.url);
353}
354
355async function handleEnvGet(args: any): Promise<MCPToolResult> {
356 validateRequired(args, ["key"]);
357

getFileEmail4 file matches

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

tuna8 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.