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=59&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 19499 results for "function"(1078ms)

informacao_lisboa_pt-agendamain.tsx1 match

@gmcabrita•Updated 4 days ago
55/* ------------------------------------------------------------------ */
56/* Utility: minimal XML escaping (only for text nodes) */
57function escapeXml(str: string = ""): string {
58 return str
59 .replace(/&/g, "&")

Timenew-file-5970.html7 matches

@zuno•Updated 4 days ago
42 stopButton.addEventListener('click', stopSpeaking);
43
44 function startSpeaking() {
45 speaking = true;
46 startButton.disabled = true;
50 }
51
52 function stopSpeaking() {
53 speaking = false;
54 startButton.disabled = false;
57 }
58
59 function updateTimer() {
60 const currentTime = new Date();
61 const hours = currentTime.getHours();
69 }
70
71 function speakTime() {
72 const currentTime = new Date();
73 const hours = currentTime.getHours();
106 }
107
108 function getNumberWord(num) {
109 const numbers = {
110 1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five',
121 }
122
123 function getTensNumberWord(num) {
124 const tens = Math.floor(num / 10) * 10;
125 const ones = num % 10;
131 }
132
133 function getSpecialNumberWord(num) {
134 const specialNumbers = {
135 10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen',
6});
7
8export default async function(interval: Interval) {
9 // Initializing a client
10 const notion = new Client({

getDatagetData.tsx1 match

@eduardoamaral•Updated 4 days ago
1// @val-town/api
2export default async function(req: Request): Promise<Response> {
3 return Response.json({
4 status: "ok",

ColosseumcheckAvail.tsx12 matches

@lirenxn•Updated 4 days ago
11
12**/
13export async function checkAvail({ type, date, debug, notify }: {
14 type: string;
15 date: string;
26 ];
27 const USER_AGENT = UA_LIST[Math.floor(Math.random() * UA_LIST.length)];
28 function getHeaders(opts) {
29 const { cookies, referer } = opts;
30 const cookieObj = cookies
74 },
75 };
76 function findThatScript(htmlText: string) {
77 const $ = cheerio.load(htmlText);
78 const firstBodyScript = $("body script")[0];
92 return res;
93 }
94 async function safeEvalOctofenceTokenValTown(script: string) {
95 const res = await fetch("https://api.val.town/v1/eval", {
96 method: "POST",
106 return await res.json();
107 }
108 async function getOctofenceToken(htmlText: string) {
109 const script = findThatScript(htmlText);
110 // octofence_token
112 return octofence_token;
113 }
114 function fetchCalendar(
115 id: string,
116 month: number,
137 });
138 }
139 async function getToken(id: string, thisMonth: number, eventPageUrl: string) {
140 const resWithAuthToken = await fetchCalendar(id, thisMonth, eventPageUrl);
141 const htmlWithAuth = await resWithAuthToken.text();
159 return token;
160 }
161 function fetchDateSlots(
162 date: string,
163 id: string,
176 });
177 }
178 function extractAvailSlots(html: string): Array<{
179 time: string;
180 tickets: number;
212 debug && console.log("Cal html: ", calThisMonth);
213 // Parse cal
214 function extractAvailDates(calHtml: string) {
215 const $ = cheerio.load(calHtml);
216 const availableDatesEL = $(".available.active").toArray();
222 ];
223 debug && console.log("Avail dates: ", availableDates);
224 function isDateAvail(availableDates, date) {
225 const compare = (d) => {
226 const dArr = d.split("/");
241 coupleSlots = slots.filter((s) => s.tickets >= 2);
242 if (coupleSlots.length > 0) {
243 function getCartCartLink(
244 productId: string,
245 performanceId: string,

ColosseumrunCheckUnderground.tsx1 match

@lirenxn•Updated 4 days ago
1import { checkAvail } from "https://esm.town/v/lirenxn/checkAvail";
2
3export async function runCheckUnderground() {
4 const result = await checkAvail({
5 type: "underground",

ColosseumrunCheckUnderground2.tsx1 match

@lirenxn•Updated 4 days ago
3import { set } from "https://esm.town/v/std/set?v=11";
4
5export async function runCheckUnderground2() {
6 const result = await checkAvail({
7 type: "underground",

ColosseummailMeTheLink.tsx1 match

@lirenxn•Updated 4 days ago
11
12**/
13export function mailMeTheLink({ calLink, date, type, slots }: {
14 calLink: string;
15 date: string;

nell-parker-townindex.ts1 match

@parkerdavis•Updated 4 days ago
1export default async function (req: Request): Promise<Response> {
2 return Response.json({ ok: true })
3}

Work_Time_Calculator_2main.tsx7 matches

@willthereader•Updated 4 days ago
1function parseTimeRanges(daySchedule) {
2 // console.log(`Parsing schedule: ${daySchedule}`);
3 const timeRanges = daySchedule.match(/(\d{1,2}(?::\d{2})?(?:am|pm)?)/g);
53}
54
55function convertTo24HourFormat(time) {
56 if (!time) {
57 throw new Error("Invalid time input: time is undefined or empty");
91}
92
93function calculateDuration(day, startTime, endTime) {
94 console.log(`calculateDuration: Calculating duration on ${day} from ${startTime} to ${endTime}`);
95 const start24 = convertTo24HourFormat(startTime);
112}
113
114function calculateDailyTotal(day, parsedSchedule) {
115 console.log(`calculateDailyTotal: Calculating daily total for ${day}`, parsedSchedule);
116 let totalMinutes = 0;
130}
131
132function calculateWeeklyTotal(day, dailyTotals) {
133 console.log(`calculateWeeklyTotal: Calculating weekly total for daily totals for ${day} is`, dailyTotals);
134 let totalHours = 0;
148}
149
150function isValidDay(day) {
151 const validDays = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];
152 return validDays.includes(day.charAt(0).toUpperCase() + day.slice(1).toLowerCase());
153}
154
155function calculateWorkTime(schedule) {
156 const dailyTotals = [];
157 const scheduleArray = schedule.split("\n").filter(Boolean);

getFileEmail4 file matches

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

tuna8 file matches

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