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=2058&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 31285 results for "function"(16698ms)

logoWorkshopOpenMojiSvgHostClient.tsx3 matches

@dcm31โ€ขUpdated 2 months ago
3
4/**
5 * Client utility functions to interact with svgHost service
6 */
7
8// Function to validate SVG content
9export const validateSvg = (content: string): boolean => {
10 return (
15};
16
17// Function to upload SVG content to svgHost
18export const uploadSvgToHost = async (svgContent: string, name: string): Promise<{success: boolean, id?: string, url?: string, error?: string}> => {
19 try {

hono_html_AppsApp.tsx5 matches

@arfanโ€ขUpdated 2 months ago
35
36\`\`\`javascript
37function greet(name) {
38 console.log(\`Hello, \${name}!\`);
39}
173 const SectionTitle = ({ title }: { title: string }) => <h2 className="text-2xl font-semibold mb-4">{title}</h2>;
174
175 // Helper function to create toast notifications
176 const showToast = (message: string, type: 'info' | 'success' | 'error' = 'success') => {
177 const toastContainer = document.getElementById('toast-container');
831 * Initializes the app in the browser
832 *******************************************/
833function client() {
834 createRoot(document.getElementById("root")).render(<ThemeDemo />);
835}
840 * Handles initial page load and HTML setup
841 *******************************************/
842export default async function server(request: Request): Promise<Response> {
843 return new Response(
844 `
854 <script>
855 // Set theme from localStorage on page load
856 (function() {
857 const savedTheme = localStorage.getItem('theme');
858 if (savedTheme) {

hono_html_AppsApp.tsx3 matches

@arfanโ€ขUpdated 2 months ago
139};
140
141function App() {
142 const [selectedCategories, setSelectedCategories] = useState<string[]>([]);
143 const [, setUpdateTrigger] = useState({});
237}
238
239function client() {
240 createRoot(document.getElementById("root")).render(<App />);
241}
242if (typeof document !== "undefined") { client(); }
243
244export default async function server(request: Request): Promise<Response> {
245 const html = `
246 <!DOCTYPE html>

hono_html_Appsserver3 matches

@arfanโ€ขUpdated 2 months ago
7const app = new Hono();
8
9// Helper function to read files relative to the current module
10const readAsset = (path: string) => readFile(path, import.meta.url);
11
57 // Import the App.tsx module to execute it
58 const module = await import("./hm_links/App.tsx");
59 // Call the default export function (server) with the request
60 return await module.default(c.req.raw);
61 } catch (error) {
70 // Import the theme-demo App.tsx module to execute it
71 const module = await import("./theme-demo/App.tsx");
72 // Call the default export function (server) with the request
73 return await module.default(c.req.raw);
74 } catch (error) {

MiniAppStarterFarcasterMiniApp.tsx1 match

@andrewcarnealโ€ขUpdated 2 months ago
4import { formatAddress, formatJSON, MonoButtonWithStatus, Section } from "./ui.tsx";
5
6export function FarcasterMiniApp() {
7 const [context, setContext] = useState<any>();
8 const [walletAddresses, setWalletAddresses] = useState<any>();

OpenTownieuseProjectFiles.ts1 match

@neverstewโ€ขUpdated 2 months ago
17 * Custom hook to fetch and manage project files
18 */
19export function useProjectFiles({
20 projectId,
21 branchId,

OpenTownieuseChatLogic.ts1 match

@neverstewโ€ขUpdated 2 months ago
13}
14
15export function useChatLogic({
16 project,
17 branchId,

OpenTownietext-editor.ts6 matches

@neverstewโ€ขUpdated 2 months ago
5 * View a file or directory in a Val Town project
6 */
7async function view(
8 vt: ValTown,
9 project: any,
70 * Replace a string in a file in a Val Town project
71 */
72async function str_replace(
73 vt: ValTown,
74 project: any,
132 * Create a new file in a Val Town project
133 */
134async function create(vt: ValTown, project: any, branch_id: string | undefined, path: string, file_text?: string) {
135 let type_: "file" | "http" | "script";
136 if (path.includes("backend/index.ts")) type_ = "http";
166 * Insert a string at a specific line in a file in a Val Town project
167 */
168async function insert(
169 vt: ValTown,
170 project: any,
209 * Undo the last edit to a file in a Val Town project (not implemented)
210 */
211async function undo_edit(vt: ValTown, project: any, branch_id: string | undefined) {
212 return {
213 type: "error",
219 * Creates a text editor tool for editing files in a Val Town project
220 */
221export function getTextEditorTool(bearerToken: string, project: any, branch_id: string | undefined) {
222 const vt = new ValTown({ bearerToken });
223 return anthropic.tools.textEditor_20250124({

OpenTowniesystem_prompt.txt9 matches

@neverstewโ€ขUpdated 2 months ago
7- Respond in a friendly and concise manner
8- Ask clarifying questions when requirements are ambiguous
9- Provide complete, functional solutions rather than skeleton implementations
10- Test your logic against edge cases before presenting the final solution
11- Ensure all code follows Val Town's specific platform requirements
30- **Never bake in secrets into the code** - always use environment variables
31- Include comments explaining complex logic (avoid commenting obvious operations)
32- Follow modern ES6+ conventions and functional programming practices where appropriate
33
34### Val Town Utility Functions
35
36Val Town provides several utility functions to help with common project tasks. These utilities handle file management, project information, and testing.
37
38### Importing Utilities
84 {
85 name: "should add numbers correctly",
86 function: () => {
87 expect(1 + 1).toBe(2);
88 },
168โ”‚ โ”œโ”€โ”€ database/
169โ”‚ โ”‚ โ”œโ”€โ”€ migrations.ts # Schema definitions
170โ”‚ โ”‚ โ”œโ”€โ”€ queries.ts # DB query functions
171โ”‚ โ”‚ โ””โ”€โ”€ README.md
172โ”‚ โ”œโ”€โ”€ index.ts # Main entry point
184โ””โ”€โ”€ shared/
185 โ”œโ”€โ”€ README.md
186 โ””โ”€โ”€ utils.ts # Shared types and functions
187```
188
190- Hono is the recommended API framework (similar to Express, Flask, or Sinatra)
191- Main entry point should be `backend/index.ts`
192- **Static asset serving:** Use the utility functions to read and serve project files:
193 ```ts
194 // Use the serveFile utility to handle content types automatically
231- Run migrations on startup or comment out for performance
232- Change table names when modifying schemas rather than altering
233- Export clear query functions with proper TypeScript typing
234- Follow the queries and migrations pattern from the example
235

OpenTowniesoundEffects.ts3 matches

@neverstewโ€ขUpdated 2 months ago
1/**
2 * Sound effects utility functions for the application
3 */
4
7 * @returns A Promise that resolves when the sound has started playing
8 */
9export function playBellSound(): Promise<void> {
10 return new Promise((resolve) => {
11 try {
69 * @returns A Promise that resolves when the sound has started playing
70 */
71export function playSimpleNotification(): Promise<void> {
72 return new Promise((resolve) => {
73 try {
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.