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=807&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 10261 results for "function"(558ms)

cerebrasTemplatemain.tsx3 matches

@charmaine•Updated 2 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();

listNotionUsersmain.tsx2 matches

@charmaine•Updated 2 months ago
7});
8
9// Example function to list Notion users
10export async function listNotionUsers() {
11 const listUsersResponse = await notion.users.list({});
12 return listUsersResponse;

windsurf_projectContextmain.tsx12 matches

@toowired•Updated 2 months ago
45 * @returns {React.ReactElement}
46 */
47function App() {
48 const [state, setState] = useState({
49 currentPhase: "",
117/**
118 * CurrentPhase component
119 * @param {{phase: string, onUpdate: Function}} props
120 * @returns {React.ReactElement}
121 */
122function CurrentPhase({ phase, onUpdate }) {
123 const [newPhase, setNewPhase] = useState(phase || "");
124 const [error, setError] = useState("");
157/**
158 * ActiveBlocks component
159 * @param {{blocks: string[], onUpdate: Function}} props
160 * @returns {React.ReactElement}
161 */
162function ActiveBlocks({ blocks = [], onUpdate }) {
163 const [newBlock, setNewBlock] = useState("");
164 const [error, setError] = useState("");
215/**
216 * TaskList component
217 * @param {{tasks: Task[], onUpdate: Function}} props
218 * @returns {React.ReactElement}
219 */
220function TaskList({ tasks = [], onUpdate }) {
221 const [newTask, setNewTask] = useState({ description: "", priority: "medium", assignedTo: "" });
222 const [error, setError] = useState("");
341/**
342 * StepList component
343 * @param {{steps: Step[], onUpdate: Function}} props
344 * @returns {React.ReactElement}
345 */
346function StepList({ steps = [], onUpdate }) {
347 const [newStep, setNewStep] = useState({ description: "", priority: "medium" });
348 const [error, setError] = useState("");
458 * @returns {React.ReactElement}
459 */
460function ChangeList({ changes = [] }) {
461 return (
462 <div className="section">
476 * Client-side initialization
477 */
478function client() {
479 createRoot(document.getElementById("root")).render(<App />);
480}
490 * @returns {Promise<Response>} The server response
491 */
492export default async function server(req: Request): Promise<Response> {
493 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
494 const { blob } = await import("https://esm.town/v/std/blob");

BraintrustSDKtutorial1 match

@stevekrouse•Updated 2 months ago
3import { Eval } from "npm:braintrust";
4
5export default async function handler() {
6 const result = {
7 apiKeyStatus: null,

selfassuredAquaTyrannosaurusmain.tsx1 match

@charmaine•Updated 2 months ago
2import { Eval } from "npm:braintrust";
3
4export default async function handler() {
5 const result = {
6 apiKeyStatus: null,

queueparseImportMeta1 match

@maxm•Updated 2 months ago
7}
8
9export function parseImportMeta(url: string): ImportMetaUrl {
10 const pattern = /^https:\/\/esm\.town\/v\/([^/]+)\/([^@]+)@(\d+)-(.+?)(\/.*)?$/;
11 const match = url.match(pattern);

fortuitousVioletLeopardadmirableGreenMink1 match

@charmaine•Updated 2 months ago
1export default async function (req: Request): Promise<Response> {
2 return Response.json({ ok: true })
3}

TestprojectfineRoseSquirrel1 match

@Gj64•Updated 2 months ago
1export default async function (req: Request): Promise<Response> {
2 return Response.json({ ok: true })
3}

easygoingEmeraldGamefowlmain.tsx1 match

@toowired•Updated 2 months ago
69
70// Export for Val Town
71export async function test(args) {
72 return await runTests();
73}

exceptionalBlushCarpmain.tsx7 matches

@toowired•Updated 2 months ago
1import { blob } from '@val.town/utils';
2
3export async function windsurfIDE(args) {
4 const { type, ...params } = args;
5
22}
23
24async function handleStartGoal(goal) {
25 const state = await blob.get('windsurf_state') || {
26 goals: [],
58}
59
60async function handleCompleteTask(taskId) {
61 const state = await blob.get('windsurf_state');
62 if (!state) return { error: 'No active state' };
82}
83
84async function handleAutoNext() {
85 const state = await blob.get('windsurf_state');
86 if (!state || !state.currentGoal) return { status: "NO_ACTIVE_GOAL" };
116}
117
118async function loadMemory(memoryId) {
119 const state = await blob.get('windsurf_state');
120 if (!state) return { error: 'No active state' };
136}
137
138async function applyRule(rule, target, state) {
139 // Rule application logic
140 switch(rule.action) {
155}
156
157function prioritizeTask(task, state, criteria) {
158 // Task prioritization logic based on rules
159 return task;

getFileEmail4 file matches

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

TwilioHelperFunctions

@vawogbemi•Updated 2 months ago