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/?q=function&page=39&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 7656 results for "function"(431ms)

elevenLabsWidgetmain.tsx1 match

@curtcox•Updated 4 days ago
1export default async function server(request: Request): Promise<Response> {
2 const url = new URL(request.url);
3 const agentParam = url.searchParams.get("agent");

Autoblocks_Webhook_Evaluator12main.tsx1 match

@charmaine•Updated 5 days ago
1import { Evaluation } from "npm:@autoblocks/client/testing";
2
3export default async function httpHandler(request: Request): Promise<Response> {
4 if (request.method !== "POST") {
5 return Response.json({ message: "Invalid method." }, {

Glancerresets1 match

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

GlancernotionHelpers.ts20 matches

@bradnoble•Updated 5 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 {

Glancerhelpers.ts5 matches

@bradnoble•Updated 5 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

Glancerexample-database-pages.ts1 match

@bradnoble•Updated 5 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

filterValsmain.tsx1 match

@nbbaier•Updated 5 days ago
1import { fetchPaginatedData } from "https://esm.town/v/nbbaier/fetchPaginatedData";
2
3export async function filterVals(id: string, filter: (value: any, index: number, array: any[]) => unknown) {
4 const token = Deno.env.get("valtown");
5 const res = await fetchPaginatedData(`https://api.val.town/v1/users/${id}/vals`, {

filterValsmain.tsx1 match

@dcm31•Updated 5 days ago
1import { fetchPaginatedData } from "https://esm.town/v/nbbaier/fetchPaginatedData";
2console.log('hi')
3export async function filterVals(id: string, filter: (value: any, index: number, array: any[]) => unknown) {
4 const token = Deno.env.get("valtown");
5 const res = await fetchPaginatedData(`https://api.val.town/v1/users/${id}/vals`, {

filterValsREADME.md1 match

@dcm31•Updated 5 days ago
1# filterVals
2
3This val exports a utility function that returns a list of all a user's val, filtered by a callback function.
4
5## Example

valreadmegeneratormain.tsx4 matches

@dcm31•Updated 5 days ago
4import React, { useRef, useState, useEffect } from "https://esm.sh/react@18.2.0";
5
6function App() {
7 const [username, setUsername] = useState("");
8 const [valName, setValName] = useState("");
158}
159
160function client() {
161 createRoot(document.getElementById("root")).render(<App />);
162}
163if (typeof document !== "undefined") { client(); }
164
165export default async function server(request: Request): Promise<Response> {
166 const url = new URL(request.url);
167 const parts = url.pathname.split('/').filter(Boolean);
248 });
249 } catch (error) {
250 console.error('Error in server function:', error);
251 return new Response(`Error: ${error.message}`, { status: 500 });
252 }

getFileEmail4 file matches

@shouser•Updated 6 days ago
A helper function to build a file's email

TwilioHelperFunctions

@vawogbemi•Updated 2 months ago