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=766&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 7802 results for "function"(734ms)

freshChartsExamplemain.tsx4 matches

@maxmโ€ขUpdated 11 months ago
34});
35
36export default async function(req: Request): Promise<Response> {
37 if (req.url.endsWith("/img-chart")) {
38 return renderChart(chart());
67];
68
69export function months({ count = 12, section }: Config = {}) {
70 const values = [];
71
78}
79
80export function rand(min = 0, max = 0): number {
81 _seed = (_seed * 9301 + 49297) % 233280;
82 return min + (_seed / 233280) * (max - min);
96}
97
98export function numbers({
99 min = 0,
100 max = 100,

valTownAnalyticsmain.tsx1 match

@maxmโ€ขUpdated 11 months ago
94};
95
96async function handler(req: Request): Promise<Response> {
97 const url = new URL(req.url);
98 if (req.method === "GET" && url.pathname === "/event") {

bloomingButtonmain.tsx7 matches

@maxmโ€ขUpdated 11 months ago
1let active = false;
2
3function getRandomEmoji() {
4 const emojis = ["๐ŸŒณ", "๐ŸŒณ", "๐ŸŒฒ", "๐ŸŒฟ", "๐ŸŒฑ", "๐ŸŒพ", "๐Ÿ", "๐Ÿ‚", "๐Ÿƒ", "๐ŸŒท", "๐Ÿชป", "๐Ÿ„"];
5 const randomIndex = Math.floor(Math.random() * emojis.length);
7}
8
9function injectCSS(css: string) {
10 const style = document.createElement("style");
11 style.type = "text/css";
33const buttonBackgroundMap = new Map();
34
35// Function to create or get the background div
36function getBackgroundDiv(button) {
37 if (!buttonBackgroundMap.has(button)) {
38 const newDiv = document.createElement("div");
49}
50
51// Function to position the background div behind the button
52function positionDivBehindButton(button) {
53 const rect = button.getBoundingClientRect();
54 const newDiv = getBackgroundDiv(button);
63 window.addEventListener("scroll", () => positionDivBehindButton(button));
64
65 button.addEventListener("click", function() {
66 if (active) return;
67 active = true;

bloomingButtonREADME.md1 match

@maxmโ€ขUpdated 11 months ago
11import { renderToString } from "npm:react-dom/server";
12
13export default async function(req: Request): Promise<Response> {
14 return new Response(
15 renderToString(

httpStatusBehaviormain.tsx1 match

@maxmโ€ขUpdated 11 months ago
11];
12
13export default async function(req: Request): Promise<Response> {
14 const url = new URL(req.url);
15 if (url.pathname === "/") {

mdConvertmain.tsx1 match

@nbbaierโ€ขUpdated 11 months ago
9});
10
11export default async function handler(request: Request) {
12 if (request.method !== "POST") {
13 return html(`

greenTigermain.tsx1 match

@maxmโ€ขUpdated 11 months ago
2import { renderToString } from "npm:react-dom/server";
3
4export default async function(req: Request): Promise<Response> {
5 return new Response(
6 renderToString(

aquamarinePiranhamain.tsx1 match

@maxmโ€ขUpdated 11 months ago
2const resp = await fetch("https://maxm-wasmblobhost.web.val.run/e5vpzt253pv5jxqfmygo7nytl5uvyn5c.wasm");
3const handler = await wasmHandler(new Uint8Array(await resp.arrayBuffer()));
4export default async function(req: Request): Promise<Response> {
5 return handler(req);
6}

compileAndUploadTinygoWasmmain.tsx1 match

@maxmโ€ขUpdated 11 months ago
59const resp = await fetch("${url}");
60const handler = await wasmHandler(new Uint8Array(await resp.arrayBuffer()));
61export default async function(req: Request): Promise<Response> {
62 return handler(req);
63}`);

tinygoWasmHelloWorldmain.tsx1 match

@maxmโ€ขUpdated 11 months ago
2const resp = await fetch("https://maxm-wasmBlobHost.web.val.run/jpxqvyy5tphiwehzklmioklpkpz4gpzs.wasm");
3const handler = await wasmHandler(new Uint8Array(await resp.arrayBuffer()));
4export default async function(req: Request): Promise<Response> {
5 return handler(req);
6}

getFileEmail4 file matches

@shouserโ€ขUpdated 6 days ago
A helper function to build a file's email

TwilioHelperFunctions

@vawogbemiโ€ขUpdated 2 months ago