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/$%7BsvgDataUrl%7D?q=function&page=45&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 31478 results for "function"(3711ms)

thelounge-oklchmain.tsx1 match

@deankerrโ€ขUpdated 2 days ago
10const c = 0.177;
11
12function printCss(n: number, hue: number) {
13 return `
14#chat.colored-nicks .user.color-${n} {

cryptoisfakemain.tsx1 match

@cashlessmanโ€ขUpdated 2 days ago
1export default async function(interval: Interval) {
2 try {
3 const response = await fetch("https://degensub.vercel.app/users/21", {

zeromain.tsx1 match

@cashlessmanโ€ขUpdated 2 days ago
1export default async function(interval: Interval) {
2 try {
3 const response = await fetch("https://degensub.vercel.app/users/20", {

thirdTimervaltown.mdc12 matches

@charmaineโ€ขUpdated 2 days ago
9
10- Ask clarifying questions when requirements are ambiguous
11- Provide complete, functional solutions rather than skeleton implementations
12- Test your logic against edge cases before presenting the final solution
13- Ensure all code follows Val Town's specific platform requirements
22- **Never bake in secrets into the code** - always use environment variables
23- Include comments explaining complex logic (avoid commenting obvious operations)
24- Follow modern ES6+ conventions and functional programming practices if possible
25
26## Types of triggers
33
34```ts
35export default async function (req: Request) {
36 return new Response("Hello World");
37}
45
46```ts
47export default async function () {
48 // Scheduled task code
49}
57
58```ts
59export default async function (email: Email) {
60 // Process email
61}
65## Val Town Standard Libraries
66
67Val Town provides several hosted services and utility functions.
68
69### Blob Storage
119```
120
121## Val Town Utility Functions
122
123Val Town provides several utility functions to help with common project tasks.
124
125### Importing Utilities
181โ”‚ โ”œโ”€โ”€ database/
182โ”‚ โ”‚ โ”œโ”€โ”€ migrations.ts # Schema definitions
183โ”‚ โ”‚ โ”œโ”€โ”€ queries.ts # DB query functions
184โ”‚ โ”‚ โ””โ”€โ”€ README.md
185โ”‚ โ””โ”€โ”€ routes/ # Route modules
200โ””โ”€โ”€ shared/
201 โ”œโ”€โ”€ README.md
202 โ””โ”€โ”€ utils.ts # Shared types and functions
203```
204
208- Main entry point should be `backend/index.ts`
209- Do NOT use Hono serveStatic middleware
210- **Static asset serving:** Use the utility functions to read and serve project files:
211 ```ts
212 import { readFile, serveFile } from "https://esm.town/v/std/utils/index.ts";
242- Run migrations on startup or comment out for performance
243- Change table names when modifying schemas rather than altering
244- Export clear query functions with proper TypeScript typing
245
246## Common Gotchas and Solutions

thirdTimerutils.ts2 matches

@charmaineโ€ขUpdated 2 days ago
4 * @returns {string} Formatted time string
5 */
6export function formatTime(seconds: number): string {
7 const hours = Math.floor(seconds / 3600);
8 const minutes = Math.floor((seconds % 3600) / 60);
22 * @returns {string} Formatted duration string (e.g., "30s", "5m", "2h 30m")
23 */
24export function formatMinutes(minutes: number): string {
25 if (minutes < 1) return `${Math.round(minutes * 60)}s`;
26 if (minutes < 60) return `${Math.round(minutes)}m`;

thirdTimerTimerDisplay.tsx1 match

@charmaineโ€ขUpdated 2 days ago
16}
17
18export function TimerDisplay({
19 state,
20 currentSessionTime,

thirdTimerTimerContainer.tsx1 match

@charmaineโ€ขUpdated 2 days ago
23}
24
25export const TimerContainer = React.memo(function TimerContainer({
26 state,
27 setState,

thirdTimertimer-actions.ts6 matches

@charmaineโ€ขUpdated 2 days ago
18 * a success notification, and the current timestamp
19 */
20export function startWork(currentState: TimerState): TimerActionResult {
21 const now = Date.now();
22
44 * or unchanged state if not currently working
45 */
46export function takeBreak(currentState: TimerState): TimerActionResult {
47 if (!currentState.workStartTime) {
48 return { newState: currentState };
79 * and notification about remaining break time
80 */
81export function resumeWork(currentState: TimerState): TimerActionResult {
82 if (!currentState.breakStartTime) {
83 return { newState: currentState, currentTime: Date.now() };
121 * or unchanged state if not currently working
122 */
123export function handleInterruption(currentState: TimerState): TimerActionResult {
124 if (!(currentState.mode === "working" && currentState.workStartTime)) {
125 return { newState: currentState };
154 * @returns A TimerActionResult with break mode activated and all saved break time consumed
155 */
156export function takeBigBreak(currentState: TimerState): TimerActionResult {
157 const now = Date.now();
158 const newState = { ...currentState };
186 * @returns A TimerActionResult with the timer reset to idle state and all timing data cleared
187 */
188export function resetSession(currentState: TimerState): TimerActionResult {
189 return {
190 newState: {

thirdTimerStatsGrid.tsx1 match

@charmaineโ€ขUpdated 2 days ago
12}
13
14export function StatsGrid({ stats, columns = 3 }: StatsGridProps) {
15 const colorClasses = {
16 green: "text-green-500",

thirdTimerSessionStats.tsx1 match

@charmaineโ€ขUpdated 2 days ago
10}
11
12export function SessionStatsDisplay({ stats, formatMinutes }: SessionStatsProps) {
13 const statsData = [
14 {
tuna

tuna9 file matches

@jxnblkโ€ขUpdated 2 weeks 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.