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/$2?q=function&page=21&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 31631 results for "function"(3994ms)

image-sliderscript.js7 matches

@ivobg•Updated 3 days ago
5showSlides(SLIDEINDEX);
6
7function showSlides(index) {
8 // get slides html and dots
9 let slides = document.querySelectorAll(".slide"),
26
27// event on prev arrow
28document.querySelector("#arrow-prev").addEventListener("click", function() {
29 showSlides(--SLIDEINDEX);
30});
31
32// event on next arrow
33document.querySelector("#arrow-next").addEventListener("click", function() {
34 showSlides(++SLIDEINDEX);
35});
36
37// event on dots
38document.querySelectorAll(".dot-navigation").forEach(function(elem) {
39 elem.addEventListener("click", function() {
40 // get index of the dot
41 let nodes = Array.prototype.slice.call(this.parentElement.children),
42 dotIndex = nodes.indexOf(elem);
43
44 // call the function for the index of clicked dot
45 showSlides(SLIDEINDEX = dotIndex);
46 });
48
49// automatic slideshow
50setInterval(function() {
51 showSlides(++SLIDEINDEX);
52}, 10000);

Townietext-editor.ts1 match

@valdottown•Updated 3 days ago
4import fileWithLinesNumbers from "../utils/fileWithLinesNumbers.ts";
5
6function printFileType(file: any) {
7 if (file.type === "interval")
8 return " (cron)";

TowniefileWithLinesNumbers.ts1 match

@valdottown•Updated 3 days ago
1export default function fileWithLineNumbers(text: string, view_range) {
2 const lines = text.split("\n")
3 .map((line, index) => (index + 1) + ": " + line)

TownieMessages.tsx9 matches

@valdottown•Updated 3 days ago
23});
24
25export function Messages ({
26 messages,
27 messageEndTimes,
58}
59
60function Message ({
61 message,
62 messageEndTimes,
86}
87
88function AssistantMessage ({ message, messageEndTimes, running }: {
89 message: Message;
90 messageEndTimes: Record<string, number>;
107}
108
109function Part ({ part }) {
110 switch (part.type) {
111 case "text":
122}
123
124function TextPart ({ part }) {
125 return (
126 <ReactMarkdown>
130}
131
132function Details ({ open, onClick, children, summary }) {
133 return (
134 <details
148}
149
150function ToolPart ({ part }) {
151 const { openSummaries, setOpenSummaries } = useContext(MessageContext);
152 const {
312}
313
314function EditorToolPart ({ part }) {
315 const { openSummaries, setOpenSummaries } = useContext(MessageContext);
316 const {
383}
384
385function UserMessage ({ message }: {
386 message: Message;
387}) {

Architmain.tsx1 match

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

statustest-notify.tsx1 match

@helge•Updated 3 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 3 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 3 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 3 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 3 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 ?`,
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.