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=30&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 7309 results for "function"(269ms)

custom-jsx-runtime-starterjsx-runtime1 match

@jxnblk•Updated 3 days ago
20}
21
22export function jsxs (type, props, key) {
23 return jsx(type, props, key);
24}

JimeluStevenshandleTelegramMessage.ts5 matches

@luke_f•Updated 3 days ago
30 * Store a chat message in the database
31 */
32export async function storeChatMessage(
33 chatId,
34 senderId,
63 * Retrieve chat history for a specific chat
64 */
65export async function getChatHistory(chatId, limit = 50) {
66 try {
67 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
88 * Format chat history for Anthropic API
89 */
90function formatChatHistoryForAI(history) {
91 const messages = [];
92
112 * Analyze a Telegram message and extract memories from it
113 */
114async function analyzeMessageContent(
115 anthropic,
116 username,
487
488// Handle webhook requests
489export default async function(req: Request): Promise<Response> {
490 console.log("something happened");
491 // Set webhook if it is not set yet

JimeluStevenstestDailyBrief.ts1 match

@luke_f•Updated 3 days ago
4import { sendDailyBriefing } from "./sendDailyBrief.ts";
5
6export async function testDailyBrief() {
7 try {
8 const testChatId = Deno.env.get("TEST_TELEGRAM_CHAT_ID");

JimeluStevensqueries.ts4 matches

@luke_f•Updated 3 days ago
6const tableName = "memories";
7
8export async function getAllMemories(): Promise<Memory[]> {
9 const result = await sqlite.execute(
10 `SELECT id, date, text, createdBy, createdDate, tags FROM ${tableName}
23}
24
25export async function createMemory(
26 memory: Omit<Memory, "id">,
27): Promise<Memory> {
51}
52
53export async function updateMemory(
54 id: string,
55 memory: Partial<Omit<Memory, "id">>,
70}
71
72export async function deleteMemory(id: string): Promise<void> {
73 await sqlite.execute(`DELETE FROM ${tableName} WHERE id = ?`, [id]);
74}

JimeluStevensmemoryUtils.ts3 matches

@luke_f•Updated 3 days ago
7 * @returns Array of memory objects
8 */
9export async function getAllMemories(includeDate = true, startDate = null) {
10 try {
11 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
42 * @returns Array of memory objects
43 */
44export async function getRelevantMemories() {
45 try {
46 // Get today's date in US Eastern Time
60 * @returns Formatted string of memories
61 */
62export function formatMemoriesForPrompt(memories) {
63 if (!memories || memories.length === 0) {
64 return "No stored memories are available.";

JimeluStevenscreateMemoriesTable.ts1 match

@luke_f•Updated 3 days ago
2// Run this script manually to add new columns to the memories table
3
4export default async function createMemoriesTable() {
5 try {
6 // Import SQLite module

stevens-openaihandleTelegramMessage.ts5 matches

@yash_ing•Updated 3 days ago
20// -------------------- SQLITE HELPERS -------------------- //
21
22export async function storeChatMessage(
23 chatId: number | string,
24 senderId: string,
49}
50
51export async function getChatHistory(chatId: number | string, limit = 50) {
52 try {
53 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
63}
64
65function formatChatHistoryForAI(history: any[]) {
66 const messages = [] as { role: "user" | "assistant"; content: string }[];
67 for (const msg of history) {
77// -------------------- LLM ANALYSIS -------------------- //
78
79async function analyzeMessageContent(
80 openai: OpenAI,
81 username: string,
261// -------------------- WEBHOOK HANDLER -------------------- //
262
263export default async function(req: Request): Promise<Response> {
264 if (!isEndpointSet) {
265 await bot.api.setWebhook(req.url, { secret_token: SECRET_TOKEN });

stevens-openaigenerateFunFacts.ts7 matches

@yash_ing•Updated 3 days ago
10// Helper: fetch previous fun facts so we avoid duplicates
11// -----------------------------------------------------------------------------
12async function getPreviousFunFacts() {
13 try {
14 const result = await sqlite.execute(
30// Helper: delete and insert DB rows
31// -----------------------------------------------------------------------------
32async function deleteExistingFunFacts(dates: string[]) {
33 try {
34 for (const date of dates) {
43}
44
45async function insertFunFact(date: string, factText: string) {
46 try {
47 await sqlite.execute(
65// LLM: generate seven new fun‑facts (OpenAI)
66// -----------------------------------------------------------------------------
67async function generateFunFacts(previousFacts: { date: string; text: string }[]) {
68 const apiKey = Deno.env.get("OPENAI_API_KEY");
69 if (!apiKey) {
153// Fallback regex parser (unchanged except for generic references)
154// -----------------------------------------------------------------------------
155function parseFallbackFacts(responseText: string, expectedDates: string[]) {
156 const factPattern = /(\d{4}-\d{2}-\d{2})["']?[,:]?\s*["']?(.*?)["']?[,}]/gs;
157 const facts: { date: string; text: string }[] = [];
179// Pipeline: generate & store fun facts weekly
180// -----------------------------------------------------------------------------
181export async function generateAndStoreFunFacts() {
182 const previousFacts = await getPreviousFunFacts();
183 const newFacts = await generateFunFacts(previousFacts);
205// Default export: cron entry point (weekly)
206// -----------------------------------------------------------------------------
207export default async function () {
208 console.log("Running fun facts generation cron job…");
209 return await generateAndStoreFunFacts();

stevens-openaigetWeather.ts5 matches

@yash_ing•Updated 3 days ago
5const TABLE_NAME = `memories`;
6
7function summarizeWeather(weather: WeatherResponse) {
8 const summarizeDay = (day: WeatherResponse["weather"][number]) => ({
9 date: day.date,
25 * into a <25‑word sentence.
26 */
27async function generateConciseWeatherSummary(weatherDay: ReturnType<typeof summarizeWeather>[number]) {
28 const apiKey = Deno.env.get("OPENAI_API_KEY");
29 if (!apiKey) {
63}
64
65async function deleteExistingForecast(date: string) {
66 await sqlite.execute(
67 `DELETE FROM ${TABLE_NAME} WHERE date = ? AND text LIKE 'weather forecast:%'`,
70}
71
72async function insertForecast(date: string, forecast: string) {
73 const { nanoid } = await import("https://esm.sh/nanoid@5.0.5");
74 await sqlite.execute(
89 * Main entry. Fetches the forecast, generates concise summaries, and stores them.
90 */
91export default async function getWeatherForecast(interval: number) {
92 const weather = await getWeather("Washington, DC");
93 const summary = summarizeWeather(weather);

stevens-openaisendDailyBrief.ts5 matches

@yash_ing•Updated 3 days ago
11 * Generate the daily briefing using OpenAI Chat Completions
12 */
13async function generateBriefingContent(
14 openai: OpenAI,
15 memories: Awaited<ReturnType<typeof getRelevantMemories>>,
92// -------------------------- MAIN EXPORT --------------------------- //
93
94export async function sendDailyBriefing(
95 chatId?: string,
96 today?: DateTime,
131 }
132
133 // Fetch relevant memories using the utility function
134 const memories = await getRelevantMemories();
135 console.log(memories);
178 * Generate helper text listing today + six subsequent days in readable form.
179 */
180function generateWeekDays(today: DateTime) {
181 const output: string[] = [];
182
198
199// Default export for cron compatibility
200export default async function(overrideToday?: DateTime) {
201 return await sendDailyBriefing(undefined, overrideToday);
202}

getFileEmail4 file matches

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

TwilioHelperFunctions

@vawogbemi•Updated 2 months ago