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/$%7Burl%7D?q=function&page=22&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 19140 results for "function"(922ms)

ColosseumrunCheckUnderground.tsx1 match

@lirenxn•Updated 1 day 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 1 day 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 1 day ago
11
12**/
13export function mailMeTheLink({ calLink, date, type, slots }: {
14 calLink: string;
15 date: string;

nell-parker-townindex.ts1 match

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

Work_Time_Calculator_2main.tsx7 matches

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

brokenLinkCrawlercrawlWebsite.tsx.tsx2 matches

@willthereader•Updated 2 days ago
1export default async function handleRequest(request: Request): Promise<Response> {
2 // this is a function called handleRequest that is exported for use elsewhere and accepts one input
3 const { url } = await request.json();
4 // the variable url cannot be changed and to the code to wait until the HTTP data is read and and turned into JSON

ValTownForNotionresets1 match

@siaa•Updated 2 days ago
7});
8
9export default async function(interval: Interval) {
10 const subdomain = "valtownfornotion";
11 const items = await blob.list(subdomain);

ValTownForNotionnotionHelpers.ts20 matches

@siaa•Updated 2 days ago
7});
8
9export async function createDatabasePagesParallel(databaseId: string, pages: []) {
10 const creations = pages.map((page) =>
11 notion.pages.create({
43
44// delete all database rows
45export async function deleteAllDatabasePagesParallel(databaseId: string) {
46 const pageIds = await notion.databases.query({
47 database_id: databaseId,
59}
60
61export async function getDatabaseId(databaseTitle: string) {
62 // getDatabaseId(databaseTitle)
63 const database = await notion.databases
66}
67
68export async function getDatabaseTitle(databaseId: string) {
69 // getDatabaseTitle(databaseId)
70 const database = await notion.databases.retrieve({ database_id: databaseId });
73}
74
75export async function getDatabaseParentPageId(databaseId: string) {
76 let currentBlockId = databaseId;
77
98}
99
100export async function getCalloutProperties(askingFor: string) {
101 const blockProperties = (askingFor != "val.town")
102 ? {
121}
122
123export async function findChildDatabaseBlocks(rootBlockId: string, blockIdentifier: string) {
124 const matchingBlocks = [];
125
126 async function searchBlock(blockId) {
127 const res = await notion.blocks.children.list({ block_id: blockId });
128
165}
166
167export async function findCalloutBlocks(rootBlockId: string, blockIdentifier: string) {
168 const matchingBlocks = [];
169
170 async function searchBlock(blockId) {
171 const res = await notion.blocks.children.list({ block_id: blockId });
172
200}
201
202export async function getBostonTime() {
203 const now = new Date();
204
213}
214
215export async function listChildrenChildPages(blockId: string) {
216 try {
217 const response = await notion.blocks.children.list({
229}
230
231export async function addFavicon(data?: any) {
232 const pageId = data?.id;
233 // use notion if nothing if the URL property is empty
234 const url = await getWebhookPropertyValue(data, "Website") || "notion.com";
235 // send the URL value to the function that will get the site's favicon location
236 const faviconURL = await helpers.scrapeFaviconUrl(url);
237 console.log({ "Verified favicon URL": faviconURL });
242}
243
244export async function setPageStatus(object: any) {
245 const { data, section, step } = object;
246 const pageId = data?.id;
282}
283
284export async function updatePageIcon(pageId: string, faviconURL?: string) {
285 try {
286 const response = await notion.pages.update({
302}
303
304export async function listChildren(pageId: string) {
305 // get page properties
306 try {
318}
319
320// Helper function to get property value from webhook payload
321export async function getWebhookPropertyValue(payload: any, propertyName: any) {
322 let result = null;
323 // check to see if the whole payload was sent, or just the data object
357}
358
359export async function getNotionPage(pageId: string) {
360 // get page properties
361 try {

ValTownForNotionhelpers.ts5 matches

@siaa•Updated 2 days ago
1export async function setBlobKey(object: any) {
2 const { slug, clientPageId, containerId } = object;
3 const blobKey = [ // key_legend: "[subdomain]--[id of guest page]--[id of container to be reset]",
11}
12
13export async function slugify(str: string) {
14 // const containerTitleSlug = (await helpers.setContainerTitle(c.req.headers.get("x-container-title"))).split(" ").join("-");
15 return (str.replace(/[^\w\s]|_/g, "").replace(/\s+/g, " ").trim().toLowerCase()).split(" ").join("-");
16}
17
18// Function to scrape favicon URL from a website
19export async function scrapeFaviconUrl(url: string) {
20 try {
21 // Ensure URL has protocol
75}
76
77export async function extractCamelCaseWords(str: string) {
78 if (!str) return [];
79

ValTownForNotionexample-database-pages.ts1 match

@siaa•Updated 2 days ago
58
59 // if the blob exists that maps to this callout for this user, use the id property inside it
60 // otherwise call the function to find the id of the callout for this user
61 // const blockId = blobject // if therre's a blob, then this isn't the first call
62 // ? blobject.id // use the id in the blob to speed up subsequent calls

getFileEmail4 file matches

@shouser•Updated 2 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
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": "*",