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=967&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 15007 results for "function"(2035ms)

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;

video_calling_appmain.tsx3 matches

@reetkumarbind•Updated 2 months ago
4import Peer from 'https://esm.sh/simple-peer@9.11.1';
5
6function App() {
7 const [myStream, setMyStream] = useState(null);
8 const [remoteStream, setRemoteStream] = useState(null);
179};
180
181function client() {
182 createRoot(document.getElementById("root")).render(<App />);
183}
185if (typeof document !== "undefined") { client(); }
186
187export default async function server(request: Request): Promise<Response> {
188 return new Response(`
189 <html>

OpenAIChatCompletionmain.tsx1 match

@rozek•Updated 2 months ago
9/**** rate-limited access to the OpenAI API ****/
10
11 export default async function (Request:Request):Promise<Response> {
12 if (Request.method === 'OPTIONS') {
13 return new Response(null, {

blueskyBotTutorialblueskyScheduler1 match

@charmaine•Updated 2 months ago
1import { postToBluesky } from "./blueskyPost";
2
3export default async function(interval: Interval) {
4 await postToBluesky();
5}

blueskyBotTutorialblueskyPost1 match

@charmaine•Updated 2 months ago
1import { BskyAgent } from "npm:@atproto/api";
2
3export async function postToBluesky() {
4 const agent = new BskyAgent({
5 service: "https://bsky.social",

NotionJsSDKmain.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;

aqimain.tsx1 match

@viraj•Updated 2 months ago
2import { easyAQI } from "https://esm.town/v/stevekrouse/easyAQI?v=5";
3
4export async function aqi(interval: Interval) {
5 const location = "downtown brooklyn"; // <-- change to place, city, or zip code
6 const data = await easyAQI({ location });

BraintrustSDKtutorial1 match

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

trackESMContentmain.tsx5 matches

@shouser•Updated 2 months ago
10const TABLE_NAME = `${KEY}_versions_v1`;
11
12async function fetchContent(url: string) {
13 const response = await fetch(url);
14 return await response.text();
15}
16
17async function initializeDatabase() {
18 await sqlite.execute(`
19 CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (
26}
27
28export default async function(interval: Interval) {
29 await initializeDatabase();
30
56}
57
58async function sha256(message: string): Promise<string> {
59 const msgUint8 = new TextEncoder().encode(message);
60 const hashBuffer = await crypto.subtle.digest("SHA-256", msgUint8);
64}
65
66export async function getAllVersions() {
67 await initializeDatabase();
68 const versions = await sqlite.execute(`SELECT * FROM ${TABLE_NAME} ORDER BY timestamp DESC`);

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 1 week 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": "*",