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%22Optional%20title%22?q=function&page=16&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 18631 results for "function"(1708ms)

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

Discord_Bot_ServicescronFirstHalfMapVote5 matches

@ktodaz•Updated 1 day ago
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

@stevekrouse•Updated 1 day 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");

crypto-geminiscript.tsx2 matches

@hexmanshu•Updated 1 day ago
57const FNG_API_URL = "https://api.alternative.me/fng/?limit=1";
58
59async function fetchFromApi<T>(url: string, isCoinGecko: boolean = true): Promise<T | null> {
60 const headers: HeadersInit = {};
61 if (isCoinGecko && COINGECKO_API_KEY) {
78}
79
80export default async function(req: Request): Promise<Response> {
81 // Set CORS headers to allow requests from any origin (or restrict to your frontend's domain)
82 // For development, '*' is fine. For production, specify your frontend's origin.
27}
28// Get current configuration from hardcoded values
29export function getCurrentConfig() {
30 try {
31 const config = {
42
43// Get completed vote bookend embed data
44export function getCompletedVoteBookendEmbedData(): CompletedVoteCreationBookendEmbedData {
45 return {
46 topBookend: {
23}
24
25export function getHellLetLooseMapData(): HellLetLooseMapData {
26 return {
27 Maps: [
12
13// Get initial embed data
14export function getInitialEmbedData(): InitialVoteCreationEmbedData {
15 return {
16 InitialEmbedTitle: "Loading . . .",

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 2 weeks 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.