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/image-url.jpg%20%22Image%20title%22?q=function&page=43&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 18900 results for "function"(745ms)

11const CREATION_LOCK_KEY = "map_vote_creation_first_half";
12
13// Main function that runs as a scheduled val for tallying votes (testing version)
14export default async function() {
15 console.log("🧪 TEST MODE: First Half Map Vote Tally Test Job started");
16 console.log("⚠️ WARNING: This version skips time verification and is for testing only!");
86 const tallyStartTime = Date.now();
87
88 // Call the map vote tallying function
89 const tallyResult = await mapVoteTallying(channelId);
90
12const MINIMUM_VOTING_PERIOD_MS = 3 * 24 * 60 * 60 * 1000; // 3 days in milliseconds
13
14// Main function that runs as a scheduled val for tallying second half votes
15export default async function() {
16 console.log("🕒 Second Half Map Vote Tally Cron Job started");
17
111 const tallyStartTime = Date.now();
112
113 // Call the map vote tallying function
114 const tallyResult = await mapVoteTallying(channelId);
115
12const MINIMUM_VOTING_PERIOD_MS = 3 * 24 * 60 * 60 * 1000; // 3 days in milliseconds
13
14// Main function that runs as a scheduled val for tallying votes
15export default async function() {
16 console.log("🕒 Map Vote Tally Cron Job started");
17
110 const tallyStartTime = Date.now();
111
112 // Call the map vote tallying function
113 const tallyResult = await mapVoteTallying(channelId);
114

TowniePreviewFrame.tsx4 matches

@valdottownUpdated 3 days ago
9}
10
11export function PreviewFrame(props: PreviewProps) {
12 const previewKey = useRef<string>("new-chat");
13 const [count, setCount] = useState<number>(0);
73const TSRE = /\/$/;
74
75function URLInput({ url, pathname, setPathname }) {
76 const prefix = url.replace(TSRE, "");
77 return (
90}
91
92function PreviewSelect({ index, setIndex, files }) {
93 return (
94 <div>
116}
117
118function usePreviewURL({ files }) {
119 const [index, setIndex] = useState<number>(0);
120 const htmlVals = files?.filter(file => file.links?.endpoint !== undefined);
326 this.updateRateLimitFromException(routeKey, retryAfter);
327
328 // Check if retry time would exceed the function timeout
329 const MAX_WAIT_TIME = 8 * 60 * 1000; // 8 minutes (to stay safely under 10 min limit)
330 if (retryAfter * 1000 > MAX_WAIT_TIME) {
331 console.log(`⚠️ Retry time (${retryAfter}s) would exceed function timeout.`);
332 console.log(`Saving state to blob and failing with suggestion to retry later.`);
333
336
337 throw new Error(
338 `Rate limit retry time (${retryAfter}s) exceeds function timeout. `
339 + `Please try again later. State has been saved to resume properly.`,
340 );
367 const MAX_WAIT_TIME = 8 * 60 * 1000; // 8 minutes
368 if ((this.globalRateLimitUntil - Date.now()) > MAX_WAIT_TIME) {
369 console.log(`⚠️ Global rate limit wait time (${waitTime}s) would exceed function timeout.`);
370 console.log(`Saving state and failing with suggestion to retry later.`);
371
374
375 throw new Error(
376 `Global rate limit wait time (${waitTime}s) exceeds function timeout. `
377 + `Please try again later. State has been saved to resume properly.`,
378 );
616 console.log(`Rate limit exhausted for route ${routeKey}. Waiting ${waitTimeWithBuffer}ms until reset.`);
617
618 // Check if wait time would exceed the function timeout
619 const MAX_WAIT_TIME = 8 * 60 * 1000; // 8 minutes
620 if (waitTimeWithBuffer > MAX_WAIT_TIME) {
621 console.log(`⚠️ Wait time (${waitTimeWithBuffer}ms) would exceed function timeout.`);
622 console.log(`Saving state and failing with suggestion to retry later.`);
623
626
627 throw new Error(
628 `Rate limit wait time exceeds function timeout. `
629 + `Please try again later. State has been saved to resume properly.`,
630 );
672 console.log(`Global rate limit window full. Waiting ${waitTime}ms for a slot to open.`);
673
674 // Check if wait time would exceed the function timeout
675 const MAX_WAIT_TIME = 8 * 60 * 1000; // 8 minutes
676 if (waitTime > MAX_WAIT_TIME) {
677 console.log(`⚠️ Global rate limit wait time (${waitTime}ms) would exceed function timeout.`);
678 console.log(`Saving state and failing with suggestion to retry later.`);
679
682
683 throw new Error(
684 `Global rate limit wait time exceeds function timeout. `
685 + `Please try again later. State has been saved to resume properly.`,
686 );
692 }
693
694 // Helper function to create a delay
695 private delay(ms: number): Promise<void> {
696 return new Promise(resolve => setTimeout(resolve, ms));
11
12// Calculate days in a month, accounting for leap years
13function getDaysInMonth(year: number, month: number): number {
14 return new Date(year, month, 0).getDate();
15}
16
17// Format date as MM-DD
18function formatDate(date: Date): string {
19 return `${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
20}
21
22// Calculate the date range for the second half of current month
23function calculateSecondHalfCurrentMonth(): { startDate: string; endDate: string; rangeText: string } {
24 const now = new Date();
25 const year = now.getFullYear();
40}
41
42// Main function that runs as a scheduled val for second half
43export default async function() {
44 console.log("🕒 Second Half Map Vote Cron Job started");
45
11
12// Calculate days in a month, accounting for leap years
13function getDaysInMonth(year: number, month: number): number {
14 return new Date(year, month, 0).getDate();
15}
16
17// Format date as MM-DD
18function formatDate(date: Date): string {
19 return `${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
20}
21
22// Calculate the date range for the first half of next month
23function calculateFirstHalfNextMonth(): { startDate: string; endDate: string; rangeText: string } {
24 const now = new Date();
25
46}
47
48// Main function that runs as a scheduled val for first half
49export default async function() {
50 console.log("🕒 First Half Map Vote Cron Job started");
51
1// Map Vote Channel Creator with enhanced rate limit handling
2// This is the main function that will be scheduled as a cron job
3import { DiscordRateLimitService } from "https://esm.town/v/ktodaz/Discord_Bot_Services/discord-rate-limit-service.tsx";
4import { getAlphabetImageUrls } from "https://esm.town/v/ktodaz/Discord_Bot_Services/map_vote/map-vote-getAlphabetImageUrls.tsx";
44};
45
46// Enhanced Discord API request function with rate limiting
47async function discordRequest(endpoint: string, options: RequestInit = {}) {
48 const token = Deno.env.get("DISCORD_BOT_TOKEN");
49 if (!token) {
102
103// Add emoji reaction to message - RATE LIMITED VERSION
104async function addReaction(channelId: string, messageId: string, emoji: string) {
105 const routeKey = `/channels/${channelId}/messages/${messageId}/reactions`;
106
132}
133
134// Helper function to convert color name to integer value
135function getColorFromString(colorName: string): number {
136 const colorMap: Record<string, number> = {
137 "Red": 0xED4245,
151
152// Create the vote channel in Discord
153async function createVoteChannel(config: CurrentConfig, remainder: string = "") {
154 try {
155 const { DiscordTargets, ApplicationPersonalization } = config;
232
233// Send initial placeholder embed
234async function sendInitialEmbed(channel: any, initialEmbedData: InitialVoteCreationEmbedData) {
235 try {
236 const embed = {
272
273// Process variants for a map and add emoji reactions
274async function processMapVariants(messageId: string, channelId: string, map: MapInfo, variantOptions: any) {
275 const mapMetaVariants: string[] = [];
276 const mapEnabledVariants: string[] = [];
388
389// Populate channel with map options and add reactions
390async function populateChannelWithMaps(
391 channel: any,
392 mapData: HellLetLooseMapData,
459
460// Finalize bookend embeds
461async function finalizeBotBookends(
462 channel: any,
463 initialMessage: any,
569
570// Create discussion thread
571async function createDiscussionThread(
572 channel: any,
573 metaVariants: string[],
622}
623
624// Main function - entry point for cron job
625export default async function(remainder: string = "") {
626 console.log("🚀 Starting Map Vote Channel Creation");
627 const startTime = Date.now();
643 };
644
645 // Load all other required data using getter functions
646 const mapData = getHellLetLooseMapData();
647 const alphabetImages = getAlphabetImageUrls();
luciaMagicLinkStarter

luciaMagicLinkStarterApp.tsx1 match

@stevekrouseUpdated 3 days ago
2import { useState } from "https://esm.sh/react@18.2.0";
3
4export function App() {
5 const [clicked, setClicked] = useState(0);
6 return (
9const LOCK_TIMEOUT = 15 * 60 * 1000;
10
11// Main function that runs as a scheduled val
12export default async function() {
13 console.log("🕒 Map Vote Cron Job started");
14
109}
110
111// Utility function to clear the lock manually if needed
112export async function clearLock() {
113 try {
114 await blob.delete("is_creating_map_vote");

getFileEmail4 file matches

@shouserUpdated 2 weeks ago
A helper function to build a file's email
tuna

tuna8 file matches

@jxnblkUpdated 2 weeks ago
Simple functional CSS library for Val Town
webup
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.
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": "*",