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/$%7Bart_info.art.src%7D?q=function&page=1675&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 18574 results for "function"(3013ms)

draftReadmemain.tsx6 matches

@nbbaier•Updated 1 year ago
9}
10
11function createPrompt(code: string, userPrompt?: string) {
12 return `
13 You are an AI assistant that writes documentation for code. You output readmes
23}
24
25async function getVal(username: string, valName: string) {
26 try {
27 const res = await fetch(`https://api.val.town/v1/alias/${username}/${valName}`, {
40}
41
42async function performOpenAICall(prompt: string, model: string, openaiOptions: ClientOptions) {
43 const openai = new OpenAI(openaiOptions);
44
65}
66
67async function updateReadme(id: string, readme: string) {
68 try {
69 const res = await fetch(`https://api.val.town/v1/vals/${id}`, {
82}
83
84async function draftReadme(options: WriterOptions) {
85 const { username, valName, model = "gpt-3.5-turbo", userPrompt, ...openaiOptions } = options;
86 const { id, code } = await getVal(username, valName);
90}
91
92async function writeReadme(options: WriterOptions) {
93 const { username, valName, model = "gpt-3.5-turbo", userPrompt, ...openaiOptions } = options;
94 const { id, code } = await getVal(username, valName);

draftReadmeREADME.md6 matches

@nbbaier•Updated 1 year ago
11```
12
13### Function: draftReadme
14
15```javascript
16async function draftReadme(options: WriterOptions): Promise<string>
17```
18
19The `draftReadme` function generates a readme file based on the provided options.
20
21#### Parameters
31A promise that resolves to a string representing the generated readme file.
32
33### Function: writeReadme
34
35```javascript
36async function writeReadme(options: WriterOptions): Promise<string>
37```
38
39The `writeReadme` function generates a readme file and updates the readme of the corresponding Val with the generated content.
40
41#### Parameters

ToDoesmain.tsx1 match

@cufaoil•Updated 1 year ago
1import { ToDoesList } from "https://esm.town/v/cufaoil/todoeslist";
2
3export function ToDoes() {
4 return Response.json(ToDoesList);
5}

sendLessonResponsesmain.tsx1 match

@petermillspaugh•Updated 1 year ago
4import { renderToString } from "npm:react-dom/server";
5
6export async function sendLessonResponses({ email, lesson, formData }) {
7 const fillBlankResponse = formData.get("fill-in-the-blank") as string;
8 const reflectionResponse = formData.get("reflection") as string;

githubemailmain.tsx1 match

@stevekrouse•Updated 1 year ago
1export default async function (email: Email) {
2 console.log(email)
3}

emailmain.tsx1 match

@chet•Updated 1 year ago
3import { email } from "https://esm.town/v/std/email?v=11";
4
5export default async function(req: Request): Promise<Response> {
6 const searchParams = new URL(req.url).searchParams;
7 const { key, subject, text } = Object.fromEntries(searchParams.entries());

powderNotifymain.tsx1 match

@chet•Updated 1 year ago
6
7/** This doesnt work well */
8export async function powderNotify(location: string) {
9 const weather = await getWeather(location);
10

lessonTemplatemain.tsx1 match

@petermillspaugh•Updated 1 year ago
17}
18
19export function generateLessonHtml({ email, lesson, title, fillBlank, content, quiz }: GenerateLessonHtmlParams) {
20 const lessonJsx = (
21 <html>

sendDailyLessonsmain.tsx2 matches

@petermillspaugh•Updated 1 year ago
5type SubscriberRow = [emailAddress: string, currentLesson: number];
6
7export default async function sendDailyLessons(interval: Interval) {
8 // No-op if I accidentally click "Run now" to avoid double sending lessons
9 const now = Date.now();
10 const time23hrs57min = (23 * 60 + 57) * 60 * 1000;
11 if (!interval.lastRunAt || now - interval.lastRunAt.getTime() < time23hrs57min) {
12 console.log("Don't manually run this function! It will email all subscribers.");
13 return;
14 }

upsertStudentmain.tsx1 match

@petermillspaugh•Updated 1 year ago
19 * The current behavior is to reset to lesson 1.
20 */
21export async function upsertStudent({ name, email, token }: UpsertEmailSubscriberParams) {
22 return sqlite.execute({
23 sql: `

getFileEmail4 file matches

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

tuna8 file matches

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