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=36&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 29117 results for "function"(942ms)

boggleSolverTowniemain.tsx5 matches

@alexwein•Updated 1 day ago
16}
17
18function buildTrie(words: string[]): TrieNode {
19 const root = new TrieNode();
20 for (const word of words) {
31}
32
33function findBoggleWords(board: { x: number; y: number; letter: string }[], wordList: string[]): string[] {
34 const trie = buildTrie(wordList);
35 const foundWords = new Set<string>();
49 ];
50
51 function isValidCell(x: number, y: number): boolean {
52 return x >= 0 && x < cols && y >= 0 && y < rows;
53 }
54
55 function dfs(x: number, y: number, node: TrieNode, visited: Set<string>, currentWord: string) {
56 // Out of bounds or already visited cell
57 const cellKey = `${x},${y}`;
93}
94
95export default function boggleSolver(
96 board: { x: number; y: number; letter: string }[],
97 wordList: string[] = wordListCache || [],

parquetApp.tsx1 match

@maxm•Updated 1 day ago
3import { Chat } from "./Chat.tsx";
4
5export function App() {
6 return (
7 <div className="app-container">

parquetpages.html1 match

@maxm•Updated 1 day ago
110 const pages = __PAGES_DATA__;
111
112 function renderPages() {
113 const pagesListElement = document.getElementById('pagesList');
114

ApiifyApp.tsx1 match

@wolf•Updated 1 day ago
31}
32
33export function App() {
34 const [url, setUrl] = useState("");
35 const [maxPages, setMaxPages] = useState(5);

Apiifysdk.ts1 match

@wolf•Updated 1 day ago
10 * @returns The newly created val or throws an error
11 */
12export async function forkVal(valId: string, newValName: string) {
13 const projectDetails = await sdk.vals.retrieve(valId);
14

Apiifyinputer.ts14 matches

@wolf•Updated 1 day ago
17 }
18
19 public async generateQueryFunction() {
20 const page = await this.browser.newPage();
21 await page.goto(this.page);
47 console.log("Element info:", elementInfo);
48
49 const { object: generatedFunction } = await generateObject({
50 model: google("gemini-1.5-pro"),
51 schema: z.object({
52 functionCode: z.string().describe(
53 "JavaScript function code that will interact with the element",
54 ),
55 inputArgSchema: z.string().describe(
56 "JSON schema for the input data that the function expects",
57 ),
58 }),
59 prompt: `
60 You are a specialized automation engineer. Your task is to create a JavaScript function that will
61 interact with a specific element on a webpage.
62
66
67 # REQUIREMENTS
68 Create an async JavaScript function that:
69 1. Takes two parameters: 'page' (a Puppeteer Page object) and 'inputData' (an object containing input values)
70 2. Uses the element's data-element-id attribute to find and interact with the element
74
75 # IMPORTANT NOTES
76 - The function should work with Puppeteer's Page API
77 - Find the element using: page.$('[data-element-id="${this.elementId}"]')
78 - Use page.waitForSelector() for waiting
85 # EXAMPLE FORMAT (adapt based on the actual element type):
86 \`\`\`javascript
87 async function(page, inputData) {
88 try {
89 // Find the element by its data attribute
112 \`\`\`
113
114 Generate ONLY the function body code that would be used between the function() { } brackets.
115 Make it as specific as possible to this particular element and its behavior.
116 IMPORTANT: Use the data-element-id attribute approach shown in the example with Puppeteer syntax.
119
120 return {
121 code: generatedFunction.functionCode,
122 inputSchema: generatedFunction.inputArgSchema,
123 };
124 }
125}
126
127export async function generateQueryFunction(
128 browser: Browser,
129 elementId: string,
132 return await Inputer
133 .of(browser, elementId, page)
134 .generateQueryFunction();
135}
136

Apiifywebsite-analyzer.ts3 matches

@wolf•Updated 1 day ago
130 schema: z.object({
131 mainClass: z.string().describe("Main automation class code"),
132 helperFunctions: z.string().describe("Helper functions for element interactions"),
133 usageExamples: z.string().describe("Example usage code"),
134 documentation: z.string().describe("Documentation explaining how to use the generated code"),
180${codeGeneration.mainClass}
181
182${codeGeneration.helperFunctions}
183
184// Usage Examples:
217}
218
219export async function analyzeWebsite(
220 startUrl: string,
221 browser: Browser,

Apiifyelements.ts1 match

@wolf•Updated 1 day ago
101}
102
103export async function getAllGoodElements(url: string, browser: Browser) {
104 const scraper = Scraper.of(url, browser);
105 return await scraper.findUsefulElements();

live-reloadclient.ts3 matches

@stevekrouse•Updated 1 day ago
5 * @returns {Promise<void>} A promise that resolves when the long poll is registered
6 */
7async function registerLongPoll({ pageLoadedAt }: { pageLoadedAt: number }) {
8 const { lastUpdatedAt, status } = await (await fetch("/__lastUpdatedAt"))
9 .json();
21}
22
23async function wait(ms: number) {
24 return new Promise((resolve) => setTimeout(resolve, ms));
25}
26
27async function pollForChange(message?: string) {
28 let targetURL = new URLSearchParams(window.location.search).get("url");
29 if (!targetURL) {

parquetChat.tsx1 match

@maxm•Updated 1 day ago
3import { useChat } from "npm:@ai-sdk/react";
4
5export function Chat() {
6 const messagesEndRef = useRef<HTMLDivElement>(null);
7
tuna

tuna9 file matches

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