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/$%7BsvgDataUrl%7D?q=function&page=57&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 31522 results for "function"(1919ms)

GlancerpageID.controller.ts1 match

@charmaine•Updated 3 days ago
6});
7
8export async function setPageID(data: any) {
9 try {
10 const page = await notion.pages.update({

GlancerpageIcon.controller.ts1 match

@charmaine•Updated 3 days ago
6});
7
8export async function setPageIcon(pageId: string, iconURL: string) {
9 try {
10 const page = await notion.pages.update({

Glancerpage.controller.ts1 match

@charmaine•Updated 3 days ago
7
8// generic controller for a Notion database page
9export async function getPage(pageId: string) {
10 try {
11 const page = await notion.pages.retrieve({

GlancerpageContents.controller.ts2 matches

@charmaine•Updated 3 days ago
6});
7
8async function fetchBlockChildren(blockId: string): Promise<any[]> {
9 try {
10 const response = await notion.blocks.children.list({
28}
29
30export async function getPageContents(pageId: string) {
31 try {
32 const response = await notion.blocks.children.list({

Glancerindex.tsx4 matches

@charmaine•Updated 3 days ago
21
22// Type guards
23export function isApiError(data: DemoData): data is ApiErrorResponse {
24 return 'message' in data && 'status' in data;
25}
26
27export function isNotionPage(data: DemoData): data is NotionPage {
28 return 'object' in data && data.object === 'page';
29}
44
45// Prepare initial data
46async function prepareInitialData(): Promise<{
47 demoData: DemoData | null;
48 loading: boolean;
91
92// Initialize the app
93async function initializeApp() {
94 const root = document.getElementById("root");
95 if (!root) {

GlancerhealthCheck.ts2 matches

@charmaine•Updated 3 days ago
8});
9
10function buildData(response) {
11 return {
12 status: "connected",
23// we present that at root and embed that into Notion
24// to show everyone that the connection is healthy btw Notion and val.town
25export default async function (interval: Interval) {
26 const blobKey = await blobKeyForHealthCheck();
27 try {

GlancergeneratePDF.ts2 matches

@charmaine•Updated 3 days ago
1// Convert image URL to base64
2async function getImageBase64(url: string): Promise<string> {
3 const res = await fetch(url);
4 const buffer = await res.arrayBuffer();
136};
137
138export default async function (req: Request): Promise<Response> {
139 try {
140 // Test data - modify this directly in the code to test different scenarios

GlancergenerateHTML.tsx28 matches

@charmaine•Updated 3 days ago
8 let heightSent = false;
9
10 function notifyParentOfHeight() {
11 // Only send height once and only if we're in an iframe
12 if (!heightSent && window.parent !== window) {
55}
56
57function escapeHtml(text: string): string {
58 return text
59 .replace(/&/g, "&amp;")
64}
65
66function extractYouTubeId(url: string): string | null {
67 const patterns = [
68 /(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([^&\n?#]+)/,
77}
78
79function extractVimeoId(url: string): string | null {
80 const match = url.match(/vimeo\.com\/(?:video\/)?(\d+)/);
81 return match ? match[1] : null;
82}
83
84function extractLoomId(url: string): string | null {
85 const match = url.match(/loom\.com\/share\/([a-zA-Z0-9]+)/);
86 return match ? match[1] : null;
87}
88
89function extractDomain(url: string): string {
90 try {
91 const urlObj = new URL(url);
96}
97
98export function GenerateHTML({ data }: any) {
99 if (!data || !data.results) {
100 return <div>No content available</div>;
156}
157
158function renderChildBlocks(children: NotionBlock[]): string {
159 if (!children || !Array.isArray(children) || children.length === 0) {
160 return "";
164}
165
166function renderBlock(block: NotionBlock): string {
167 const { type } = block;
168
217}
218
219function renderRichText(richTextArray: NotionRichText[]): string {
220 if (!richTextArray || !Array.isArray(richTextArray)) {
221 return "";
250}
251
252function renderParagraph(block: NotionBlock): string {
253 const content = renderRichText(block.paragraph?.rich_text || []);
254 return content ? `<p>${content}</p>` : "<p></p>";
255}
256
257function renderHeading(block: NotionBlock, level: number): string {
258 const headingData = block[`heading_${level}`];
259 const content = renderRichText(headingData?.rich_text || []);
261}
262
263function renderListItem(block: NotionBlock, listType: "ul" | "ol"): string {
264 const itemData =
265 block[listType === "ul" ? "bulleted_list_item" : "numbered_list_item"];
275}
276
277function renderTodo(block: NotionBlock): string {
278 const todoData = block.to_do;
279 const content = renderRichText(todoData?.rich_text || []);
289}
290
291function renderToggle(block: NotionBlock): string {
292 const toggleData = block.toggle;
293 const content = renderRichText(toggleData?.rich_text || []);
304}
305
306function renderCode(block: NotionBlock): string {
307 const codeData = block.code;
308 const content = renderRichText(codeData?.rich_text || []);
312}
313
314function renderQuote(block: NotionBlock): string {
315 const quoteData = block.quote;
316 const content = renderRichText(quoteData?.rich_text || []);
325}
326
327function renderCallout(block: NotionBlock): string {
328 const calloutData = block.callout;
329 const content = renderRichText(calloutData?.rich_text || []);
346}
347
348function renderImage(block: NotionBlock): string {
349 const imageData = block.image;
350 let imageUrl = "";
366}
367
368function renderVideo(block: NotionBlock): string {
369 const videoData = block.video;
370 let videoUrl = "";
427}
428
429function renderFile(block: NotionBlock): string {
430 const fileData = block.file;
431 let fileUrl = "";
447}
448
449function renderBookmark(block: NotionBlock): string {
450 const bookmarkData = block.bookmark;
451 const url = bookmarkData?.url || "";
474}
475
476function renderLinkPreview(block: NotionBlock): string {
477 const linkData = block.link_preview;
478 const url = linkData?.url || "";
494}
495
496function renderEmbed(block: NotionBlock): string {
497 const embedData = block.embed;
498 const url = embedData?.url || "";
588}
589
590function renderTable(block: NotionBlock): string {
591 // Tables in Notion are complex and would need child blocks to be fully rendered
592 return '<table class="notion-table"><tbody><!-- Table rows would be rendered here --></tbody></table>';
593}
594
595function renderTableRow(block: NotionBlock): string {
596 const rowData = block.table_row;
597 const cells = rowData?.cells || [];
607}
608
609function renderColumnList(block: NotionBlock): string {
610 return '<div class="column-list"><!-- Columns would be rendered here --></div>';
611}
612
613function renderColumn(block: NotionBlock): string {
614 return '<div class="column"><!-- Column content would be rendered here --></div>';
615}

GlancerdemoURL.controller.ts1 match

@charmaine•Updated 3 days ago
6});
7
8export async function setDemoURL(pageId: string, url: string) {
9 try {
10 const page = await notion.pages.update({

GlancerdemoTableOfContents.tsx1 match

@charmaine•Updated 3 days ago
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2
3export function TOC({ data }): any {
4 return (
5 <ul className="features list-none pl-0 grid grid-cols-2 gap-4">
tuna

tuna9 file matches

@jxnblk•Updated 2 weeks ago
Simple functional CSS library for Val Town

getFileEmail4 file matches

@shouser•Updated 1 month ago
A helper function to build a file's email
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.