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=2104&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 31264 results for "function"(16573ms)

smeared_quantizationmain.js2 matches

@fractalkitty•Updated 2 months ago
3let w, d, n1, s1, p1, w2;
4let t = 0;
5export function setup() {
6 document.body.style.margin = "0";
7 document.body.style.backgroundColor = "slategrey";
20}
21
22export function draw() {
23 translate(width / 2, height / 2);
24 t += 0.005;

password_authmain.tsx5 matches

@ogtosin•Updated 2 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({
80</html>`;
81
82export function redirect(location: string): Response {
83 return new Response(null, {
84 headers: {
98const cookieName = "auth_session";
99
100export function passwordAuth(next, options?: PasswordAuthOptions) {
101 const sessionTable = options?.sessionTable || "password_auth_session";
102 return async (req: Request) => {
ditherPng

ditherPngmain.tsx2 matches

@maxm•Updated 2 months ago
10];
11
12async function getImage(url: string) {
13 const data = await fetch(url).then((e) => e.arrayBuffer()).then((e) => new Uint8Array(e));
14 const image = await loadImage(data);
23}
24
25export default async function(req: Request): Promise<Response> {
26 const url = new URL(req.url);
27 const imgUrl = url.searchParams.get("url")

thoughtfulAquaSilverfishmain.tsx6 matches

@dcm31•Updated 2 months ago
101
102// Main app component
103function App() {
104 const canvasRef = useRef(null);
105 const [dimensions, setDimensions] = useState({ width: window.innerWidth, height: window.innerHeight });
116 }, []);
117
118 // Drawing context functions
119 const addDrawing = (id, drawingData) => {
120 setDrawings(prev => ({ ...prev, [id]: drawingData }));
181 }, [dimensions, drawings]);
182
183 // Helper function to create SVG-like rounded rectangle path
184 function drawRoundedRectPath(x, y, width, height, radius) {
185 return [
186 `M${x + radius},${y}`,
264}
265
266function client() {
267 createRoot(document.getElementById("root")).render(<App />);
268}
272}
273
274export default async function server(request: Request): Promise<Response> {
275 return new Response(`
276 <!DOCTYPE html>

roughUIElementsmain.tsx4 matches

@dcm31•Updated 2 months ago
100};
101
102// Helper function to create SVG-like rounded rectangle path
103function drawRoundedRectPath(x, y, width, height, radius) {
104 return [
105 `M${x + radius},${y}`,
117
118// Main app component
119function App() {
120 const canvasRef = useRef(null);
121 const [dimensions, setDimensions] = useState({ width: window.innerWidth, height: window.innerHeight });
133 }, []);
134
135 // Drawing context functions
136 const addDrawing = (id, drawingData) => {
137 setDrawings(prev => ({ ...prev, [id]: drawingData }));

adventurousIvoryGrasshoppermain.tsx1 match

@omark98•Updated 2 months ago
2import { renderToString } from "npm:react-dom/server";
3
4export default async function(req: Request) {
5 return new Response(
6 renderToString(

monkehistogram.ts1 match

@maxm•Updated 2 months ago
43
44/** Get a histogram of frequency of colors. */
45export function getHistogram(colors: Color[]): ColorHistogram {
46 const histo = new ColorHistogram();
47 let i = 0;

monkemedianCut.ts5 matches

@maxm•Updated 2 months ago
4import type { ColorRange } from "./common.ts";
5
6export function quantizeByMedianCut(
7 pixels: Color[],
8 extractCount: number,
13}
14
15function quantize(
16 vbox: ColorRange,
17 histo: ColorHistogram,
73
74/** Get number of colors in vbox */
75function vboxSize(vbox: ColorRange, histo: ColorHistogram): number {
76 let count = 0;
77 let ri = vbox.r.min;
92
93/** Get volume by dimensions of vbox */
94function vboxVolume(vbox: ColorRange): number {
95 return ~~(vbox.r.max - vbox.r.min) * ~~(vbox.g.max - vbox.g.min) *
96 ~~(vbox.b.max - vbox.b.min);
98
99/** Cut vbox into two */
100function medianCutApply(
101 vbox: ColorRange,
102 histo: ColorHistogram,

monkebox.ts1 match

@maxm•Updated 2 months ago
2
3/** Box blur with r = 3 */
4export function boxBlur(image: { pixels: Color[]; width: number }) {
5 let i = 0;
6 // pixels is an array of pixels with r, g, b values

monkesierra.ts2 matches

@maxm•Updated 2 months ago
6 * Uses two-row Sierra matrix
7 */
8export function sierra2(
9 pixels: Color[],
10 width: number,
68 * Use twoRowSierraDither for more accuracy
69 */
70export function sierraLite(
71 pixels: Color[],
72 width: number,
tuna

tuna9 file matches

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