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/image-url.jpg%20%22Image%20title%22?q=function&page=2145&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 23281 results for "function"(1893ms)

MattsSFsailingNotifymain.tsx1 match

@brezina•Updated 1 year ago
1import { getWeather } from "https://esm.town/v/chet/getWeather";
2import { email } from "https://esm.town/v/std/email";
3export async function sailingNotify(
4 where: string,
5 minWindMph = 1,

DeleteThingmain.tsx1 match

@cufaoil•Updated 1 year ago
1import { blob } from "https://esm.town/v/std/blob";
2import { set } from "https://esm.town/v/std/set?v=11";
3export default async function(req: Request): Promise<Response> {
4 const searchParams = new URL(req.url).searchParams;
5 let value = searchParams.get("todo");

getAppleWeathermain.tsx1 match

@chet•Updated 1 year ago
2import { createJTW, getForecast } from "npm:apple-weatherkit";
3
4export async function getAppleWeather(args: { lat: number; lng: number }) {
5 const token = createJTW({
6 teamId: process.env.APPLE_WEATHERKIT_TEAM_ID,

todo_appmain.tsx4 matches

@stevekrouse•Updated 1 year ago
11)`);
12
13async function addTask(description: string) {
14 await sqlite.execute({
15 sql: `INSERT INTO tasks (description) VALUES (?)`,
18}
19
20async function getTasks() {
21 const { columns, rows } = await sqlite.execute(`SELECT id, description, completed FROM tasks`);
22 return rows.map((row) => {
33}
34
35async function toggleTaskCompletion(id: number, completed: boolean) {
36 await sqlite.execute({
37 sql: `UPDATE tasks SET completed = ? WHERE id = ?`,
40}
41
42async function removeTask(id: number) {
43 await sqlite.execute({
44 sql: `DELETE FROM tasks WHERE id = ?`,

todo_demomain.tsx4 matches

@billtrenchard•Updated 1 year ago
11)`);
12
13async function addTask(description: string) {
14 await sqlite.execute({
15 sql: `INSERT INTO tasks (description) VALUES (?)`,
18}
19
20async function getTasks() {
21 const { columns, rows } = await sqlite.execute(`SELECT id, description, completed FROM tasks`);
22 return rows.map((row) => {
33}
34
35async function toggleTaskCompletion(id: number, completed: boolean) {
36 await sqlite.execute({
37 sql: `UPDATE tasks SET completed = ? WHERE id = ?`,
40}
41
42async function removeTask(id: number) {
43 await sqlite.execute({
44 sql: `DELETE FROM tasks WHERE id = ?`,

API_URLmain.tsx1 match

@std•Updated 1 year ago
1function envOrUndefined(key: string): string | undefined {
2 // try/catch prevents crashes if the script doesn't have env access
3 try {

chat_openaimain.tsx1 match

@cosmo•Updated 1 year ago
1const { default: OpenAI } = await import("npm:openai");
2
3export async function chat(apiKey, messages) {
4 const openai = new OpenAI({ apiKey });
5

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}

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 1 month ago
Simple functional CSS library for Val Town
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.