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/$%7Burl%7D?q=function&page=2358&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 27247 results for "function"(2456ms)

lucia_sqlitemain.tsx5 matches

@stevekrouse•Updated 9 months ago
4import { generateId, Scrypt } from "npm:lucia";
5
6export async function createTables(userTable: string, sessionTable: string) {
7 return sqlite.batch([
8 `CREATE TABLE ${userTable} (
20}
21
22async function safeExecute({ userTable, sessionTable, query, error }: {
23 userTable: string;
24 sessionTable: string;
38}
39
40export async function createUser({ userTable, sessionTable, username, password }: {
41 userTable: string;
42 sessionTable: string;
58}
59
60export async function getUser(
61 { userTable, sessionTable, username },
62): Promise<{ id: string; username: string; hashed_password: string } | null> {
74}
75
76export async function verifyPassword(hashed_password: string, password: string): Promise<boolean> {
77 return new Scrypt().verify(hashed_password, password);
78}

pglite2main.tsx2 matches

@samwillis•Updated 9 months ago
4let pg;
5
6async function init() {
7 if (pg) return;
8 console.log(1);
25}
26
27export default async function(req: Request): Promise<Response> {
28 console.log(0);
29 await init();

aloneAquaGophermain.tsx4 matches

@parthstown•Updated 9 months ago
3console.log("potato", main);
4
5export default async function printWeather(req: Request) {
6 if (typeof main === "function") {
7 const newWeather = await main(req);
8
12 return new Response(JSON.stringify(data));
13 } else {
14 console.error("main is not a function");
15 return new Response("Error: main is not a function", { status: 500 });
16 }
17}

twitchmain.tsx1 match

@pinjasaur•Updated 9 months ago
1const getText = async url => (await fetch(url)).text();
2
3export default async function(req: Request): Promise<Response> {
4 if (req.headers.get("referer")?.includes("val.")) {
5 return Response.json({ error: "Cannot access from val.town" }, {

dieselREADME.md2 matches

@yawnxyz•Updated 9 months ago
9- **Multi-format Support**: Works with JSON, YAML, CSV, and TOML.
10- **Dynamic Selectors**: Use conditions to filter data dynamically.
11- **Function Support**: Built-in functions for data manipulation (e.g., length, sum, avg).
12- **Easy Integration**: Can be used in both Deno and Val Town environments.
13
17import Diesel from "https://esm.town/v/yawnxyz/diesel";
18
19async function main() {
20 const jsonData = `
21 {

YouTubeSubmissionsmain.tsx1 match

@mvmattgray•Updated 9 months ago
8const KEY = new URL(import.meta.url).pathname;
9
10export default async function main(req: Request): Promise<Response> {
11 const url = new URL(req.url);
12

whoIsHiringLayoutmain.tsx1 match

@vawogbemi•Updated 9 months ago
4const tabs = { "/": "Home", "/about": "About" }; // { "/": "Home", "/browse": "Browse", "/faq": "FAQ" };
5
6export default function({ activeTab, children }: PropsWithChildren<{ activeTab: string }>) {
7 return (
8 <html>

getEndpointUrlmain.tsx2 matches

@g•Updated 9 months ago
1/**
2 * Function to extract the val HTTP endpoint URL.
3 * @example getEndpointUrl(import.meta.url)
4 * @returns endpoint url without a trailing slash
5 */
6export function getEndpointUrl(url: string | URL) {
7 const { pathname } = new URL(url);
8 const [author, filename] = pathname.split('/').slice(-2);

modifyImagemain.tsx1 match

@ilikescience•Updated 9 months ago
1import { ImageMagick, initializeImageMagick, MagickGeometry } from "https://deno.land/x/imagemagick_deno@0.0.14/mod.ts";
2
3export async function modifyImage(
4 file: File,
5 params: { width: number; height: number },

Countdown2main.tsx2 matches

@all•Updated 9 months ago
2// It uses CSS for styling and animations and JavaScript for the countdown logic.
3
4export default async function main(req: Request): Promise<Response> {
5 const html = `
6 <!DOCTYPE html>
52 </div>
53 <script>
54 function updateCountdown() {
55 const eventDate = new Date('2025-04-14T00:00:00');
56 const now = new Date();

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 1 month 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.