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=717&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 7304 results for "function"(490ms)

loggingTesthelperFunction2 matches

@willthereader•Updated 2 months ago
1export function squareNumber(num: number) {
2 console.log("helper function log");
3 console.log(`Squaring number: ${num}`);
4 return num * num;

loggingTestmainFunction3 matches

@willthereader•Updated 2 months ago
1import { squareNumber } from "./helperFunction";
2
3function processMathList() {
4 console.log("Starting math processing");
5 const numbers = [1, 2, 3];
7}
8
9console.log("\nTesting Math Functions:");
10console.log(processMathList());

vblogimport-file1 match

@jxnblk•Updated 2 months ago
1/** Import a file relative to the root of the project */
2export async function importFile(path: string) {
3 const url = new URL(path, import.meta.url);
4 const res = await fetch(url, { redirect: "follow" });

BraintrustSDKtutorial1 match

@stevekrouse•Updated 2 months ago
3import { Eval } from "npm:braintrust";
4
5export default async function handler() {
6 const result = {
7 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}

Windsurfcontextmanager4 matches

@toowired•Updated 2 months ago
16
17// Context Manager Val
18export async function updateContext(context) {
19 const { phase, activeBlocks, pendingTasks, recentChanges } = context;
20
35}
36
37export async function getLatestContext() {
38 const result = db.prepare(`
39 SELECT * FROM context
53}
54
55export async function getContextHistory(limit = 10) {
56 return db.prepare(`
57 SELECT * FROM context
62
63// HTTP request handler
64export async function onRequest(req) {
65 const { action, params } = await req.json();
66

Windsurfprojectcontext12 matches

@toowired•Updated 2 months ago
45 * @returns {React.ReactElement}
46 */
47function App() {
48 const [state, setState] = useState(null);
49 const [error, setError] = useState(null);
112/**
113 * CurrentPhase component
114 * @param {{phase: string, onUpdate: Function}} props
115 * @returns {React.ReactElement}
116 */
117function CurrentPhase({ phase, onUpdate }) {
118 const [newPhase, setNewPhase] = useState(phase);
119 const [error, setError] = useState("");
152/**
153 * ActiveBlocks component
154 * @param {{blocks: string[], onUpdate: Function}} props
155 * @returns {React.ReactElement}
156 */
157function ActiveBlocks({ blocks, onUpdate }) {
158 const [newBlock, setNewBlock] = useState("");
159 const [error, setError] = useState("");
210/**
211 * TaskList component
212 * @param {{tasks: Task[], onUpdate: Function}} props
213 * @returns {React.ReactElement}
214 */
215function TaskList({ tasks, onUpdate }) {
216 const [newTask, setNewTask] = useState({ description: "", priority: "medium", assignedTo: "" });
217 const [error, setError] = useState("");
338/**
339 * StepList component
340 * @param {{steps: Step[], onUpdate: Function}} props
341 * @returns {React.ReactElement}
342 */
343function StepList({ steps, onUpdate }) {
344 const [newStep, setNewStep] = useState({ description: "", priority: "medium" });
345 const [error, setError] = useState("");
455 * @returns {React.ReactElement}
456 */
457function ChangeList({ changes }) {
458 return (
459 <div className="section">
473 * Client-side initialization
474 */
475function client() {
476 createRoot(document.getElementById("root")).render(<App />);
477}
487 * @returns {Promise<Response>} The server response
488 */
489export default async function server(req: Request): Promise<Response> {
490 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
491 const { blob } = await import("https://esm.town/v/std/blob");

WindsurfunbeatableAquaCow4 matches

@toowired•Updated 2 months ago
1export default async function (req: Request): Promise<Response> {
2 return Response.json({ ok: true })
3 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
58 `);
59
60 // Utility functions
61 async function hashPassword(password: string, salt?: string): Promise<{ hash: string, salt: string }> {
62 salt = salt || crypto.randomUUID();
63 const encoder = new TextEncoder();
69 }
70
71 async function authenticateUser(request: Request): Promise<number | null> {
72 const authHeader = request.headers.get('Authorization');
73 if (!authHeader) return null;

getFileEmail4 file matches

@shouser•Updated 5 days ago
A helper function to build a file's email

TwilioHelperFunctions

@vawogbemi•Updated 2 months ago