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/$%7Bsuccess?q=function&page=15&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 31576 results for "function"(1399ms)

statustest-notify.tsx1 match

@helge•Updated 2 days ago
2import { pushover } from "./pushover";
3
4export async function testNotify() {
5 notify("hello world2");
6 pushover({ message: "message", title: "title" });

statusmonitor1 match

@helge•Updated 2 days ago
10const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
11
12export async function uptimeCheck(url: string, attempt = 1) {
13 let reason: string = "";
14 let status: number | null = null;

statusstatus3 matches

@helge•Updated 2 days ago
9const thisURL = parseProject(import.meta.url).links.self.project;
10
11function StatusRow({ rows }) {
12 return (
13 <div className="w-full flex flex-col space-y-2">
31}
32
33function StatusSection({ url, rows }) {
34 const sectionRows = rows.filter(row => row[0] === url);
35 const percentUp = Math.round((sectionRows.filter(row => row[1]).length / sectionRows.length) * 100);
47}
48
49export default async function(req: Request): Promise<Response> {
50 const { rows } = await sqlite.execute(
51 "select url, ok, duration, timestamp from uptime order by timestamp asc limit 200",

kebede-and-ben-testgame.ts3 matches

@bmitchinson•Updated 2 days ago
5const app = new Hono();
6
7// Game logic functions
8function checkWinner(board: (Player | null)[]): Player | null {
9 const winPatterns = [
10 [0, 1, 2], [3, 4, 5], [6, 7, 8], // rows
22}
23
24function isBoardFull(board: (Player | null)[]): boolean {
25 return board.every(cell => cell !== null);
26}

kebede-and-ben-testqueries.ts4 matches

@bmitchinson•Updated 2 days ago
3import type { GameState, Player, Board, GameStatus } from "../../shared/types.ts";
4
5export async function createGame(): Promise<GameState> {
6 const id = crypto.randomUUID();
7 const now = new Date().toISOString();
27}
28
29export async function getGame(id: string): Promise<GameState | null> {
30 const result = await sqlite.execute(
31 `SELECT * FROM ${TABLE_NAME} WHERE id = ?`,
49}
50
51export async function updateGame(game: GameState): Promise<void> {
52 const now = new Date().toISOString();
53
67}
68
69export async function getRecentGames(limit: number = 10): Promise<GameState[]> {
70 const result = await sqlite.execute(
71 `SELECT * FROM ${TABLE_NAME} ORDER BY updated_at DESC LIMIT ?`,

kebede-and-ben-testGameStatus.tsx1 match

@bmitchinson•Updated 2 days ago
9}
10
11export default function GameStatus({ game, onNewGame, loading }: GameStatusProps) {
12 const getStatusMessage = () => {
13 if (game.status === 'won') {

kebede-and-ben-testGameBoard.tsx1 match

@bmitchinson•Updated 2 days ago
9}
10
11export default function GameBoard({ game, onCellClick, disabled }: GameBoardProps) {
12 const renderCell = (position: number) => {
13 const value = game.board[position];

kebede-and-ben-testApp.tsx1 match

@bmitchinson•Updated 2 days ago
5import type { GameState, GameResponse, MoveRequest } from "../../shared/types.ts";
6
7export default function App() {
8 const [game, setGame] = useState<GameState | null>(null);
9 const [loading, setLoading] = useState(false);

kebede-and-ben-testmigrations.ts1 match

@bmitchinson•Updated 2 days ago
3const TABLE_NAME = 'tic_tac_toe_games_1';
4
5export async function runMigrations() {
6 await sqlite.execute(`CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (
7 id TEXT PRIMARY KEY,

age-calculatorscript.js1 match

@ivobg•Updated 2 days ago
7});
8
9function calculateAge() {
10 const currDate = Date.now();
11 const pastDate = Date.parse(dateInpElem.value);
tuna

tuna9 file matches

@jxnblk•Updated 2 weeks ago
Simple functional CSS library for Val Town

getFileEmail4 file matches

@shouser•Updated 2 months 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.