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=1422&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 18324 results for "function"(1507ms)

valWallmain.tsx6 matches

@stevekrouse•Updated 7 months ago
62});
63
64async function generateGraph(username, useVersions = true) {
65 if (!username) {
66 return html`<p class="text-red-500">Please enter a username</p>`;
104}
105
106function renderPage(c, initialUsername = null) {
107 return c.html(html`
108 <!DOCTYPE html>
164 `);
165}
166function generateMonthLabels(contributionData) {
167 const months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
168 const today = dayjs();
202}
203
204function generateContributionRows(contributionData) {
205 const dayLabels = ["", "Mon", "", "Wed", "", "Fri", ""];
206 let rows = [];
217 return rows;
218}
219function generateContributionCells(contributionData, dayOfWeek) {
220 let cells = [];
221 for (let i = dayOfWeek; i < contributionData.length; i += 7) {
240 return cells;
241}
242function processVals(vals, useVersions) {
243 const today = new Date();
244 const oneYearAgo = new Date(today.getFullYear() - 1, today.getMonth(), today.getDate());

vtTokenSessionAuthmain.tsx5 matches

@stevekrouse•Updated 7 months ago
11};
12
13async function createSessionTable(tableName: string) {
14 await sqlite.execute(`CREATE TABLE ${tableName} (
15 id TEXT NOT NULL PRIMARY KEY,
19}
20
21async function createSession(tableName: string, valSlug: string): Promise<Session> {
22 try {
23 const expires_at = new Date();
39}
40
41async function getSession(tableName: string, sessionID: string, valSlug: string): Promise<Session> {
42 try {
43 const { rows, columns } = await sqlite.execute({
82</html>`;
83
84export function redirect(location: string): Response {
85 return new Response(null, {
86 headers: {
100const cookieName = "auth_session";
101
102export function passwordAuth(next, options?: PasswordAuthOptions) {
103 const sessionTable = options?.sessionTable || "password_auth_session";
104 return async (req: Request) => {

vtTokenSessionAuthSafemain.tsx2 matches

@stevekrouse•Updated 7 months ago
1export function vtTokenSessionAuth(handler) {
2 return async function(req: Request) {
3 const { passwordAuth } = await import("https://esm.town/v/stevekrouse/vtTokenSessionAuth");
4 const { verifyToken } = await import("https://esm.town/v/pomdtr/verifyToken?v=1");

sqliteAdminDashboardmain.tsx4 matches

@stevekrouse•Updated 7 months ago
1// This val creates a SQLite dashboard admin panel with a sidebar for table names
2// It uses React for the frontend and the Val Town SQLite API for database operations
3// Now includes functionality to edit rows, using rowid or all columns as identifiers
4// and the ability to add new rows to tables
5// Column types are displayed next to column names in the UI
10import { vtTokenSessionAuth } from "https://esm.town/v/stevekrouse/vtTokenSessionAuthSafe";
11
12function App() {
13 const [tables, setTables] = useState([]);
14 const [selectedTable, setSelectedTable] = useState(null);
195}
196
197function client() {
198 createRoot(document.getElementById("root")).render(<App />);
199}
203}
204
205async function server(request: Request): Promise<Response> {
206 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
207 const url = new URL(request.url);

QR_Generatormain.tsx3 matches

@muhammad_owais_warsi•Updated 7 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 const [text, setText] = useState("");
7 const [qrCode, setQrCode] = useState("");
34}
35
36function client() {
37 createRoot(document.getElementById("root")).render(<App />);
38}
42}
43
44export default async function server(request: Request): Promise<Response> {
45 return new Response(
46 `

thisvalmain.tsx1 match

@begoon•Updated 7 months ago
6};
7
8function info(): ValInfo {
9 try {
10 throw new Error();

thisvalREADME.md2 matches

@begoon•Updated 7 months ago
1This val default exports a function returning ValInfo.
2
3The val information comes from the Deno stack trace induced by `throw new Error()`.
16import thisval from "https://esm.town/v/begoon/thisval";
17const val = thisval();
18export default async function(req: Request): Promise<Response> {
19 return Response.json(val);
20}

oddTanRoundwormmain.tsx1 match

@l2046a•Updated 7 months ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2
3export default async function(req: Request): Promise<Response> {
4 if (req.method === "OPTIONS") {
5 return new Response(null, {

tonpickmain.tsx1 match

@cyrilos•Updated 7 months ago
13
14// handle incoming requests
15export default async function(req) {
16 const PLATFORM = "tonpick.game";
17 // const cookies = await blob.getJSON("platforms");

httpHelloWorldmain.tsx6 matches

@hugenshen•Updated 7 months ago
42];
43
44function MenuItem({ item }) {
45 const [isOpen, setIsOpen] = React.useState(false);
46 const [isHovered, setIsHovered] = React.useState(false);
68}
69
70function Menu() {
71 return (
72 <div style={{ width: "250px", borderRight: "1px solid #ccc", height: "100vh", overflowY: "auto" }}>
76}
77
78function Content() {
79 return (
80 <div style={{ padding: "20px", flexGrow: 1 }}>
97}
98
99function App() {
100 return (
101 <BrowserRouter>
108}
109
110function client() {
111 ReactDOM.createRoot(document.getElementById("root")).render(<App />);
112}
114if (typeof document !== "undefined") { client(); }
115
116async function server(request: Request): Promise<Response> {
117 return new Response(
118 `

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 2 weeks 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": "*",
webup
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.