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=1547&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 18011 results for "function"(2170ms)

sunbeamTrendingRepositoriesmain.tsx1 match

@pomdtr•Updated 12 months ago
1import { trendingRepositories } from "https://esm.town/v/pomdtr/trendingRepositories";
2
3export async function sunbeamTrendingRepositories() {
4 const repositories = await trendingRepositories();
5 const items = repositories.map((repo) => ({

serve_blobsmain.tsx1 match

@pomdtr•Updated 12 months ago
4import mime from "npm:mime";
5
6export function serveBlobs({
7 root,
8 mimes = {},

auth_middlewaremain.tsx5 matches

@pomdtr•Updated 12 months ago
21</html>`;
22
23export function redirect(location: string): Response {
24 return new Response(null, {
25 headers: {
35};
36
37async function fetchUser(token: string): Promise<User> {
38 const resp = await fetch("https://api.val.town/v1/me", {
39 headers: {
49}
50
51async function isCurrentUser(userID: string) {
52 const currentUser = await fetchUser(Deno.env.get("valtown"));
53 return userID == currentUser.id;
54}
55
56function signout() {
57 const res = redirect("/");
58 cookie.setCookie(res.headers, {
67}
68
69export function auth(handler) {
70 const secretKey = Deno.env.get("AUTH_SECRET_KEY");
71 if (!secretKey) {

beigeEarthwormmain.tsx1 match

@canglangdahai•Updated 12 months ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2
3export default async function(req: Request): Promise<Response> {
4 if (req.method === "OPTIONS") {
5 return new Response(null, {

isthegtrainfuckedmain.tsx1 match

@stevekrouse•Updated 12 months ago
4import Uwuifier from "npm:uwuifier";
5
6export default async function(req: Request) {
7 const uwuifier = new Uwuifier();
8 const query = new URL(req.url).searchParams;

react_httpmain.tsx2 matches

@tfayyaz•Updated 12 months ago
1export default (component: Function, url: string) =>
2 function(req: Request) {
3 return new Response(
4 `<html>

Which_Jacketmain.tsx1 match

@emilycoe•Updated 1 year ago
2import { getWeather } from "https://esm.town/v/stevekrouse/getWeather?v=2";
3
4export default async function(interval: Interval) {
5 let weather = await getWeather("Brooklyn, NY");
6 let temperature = weather.current_condition[0].FeelsLikeF;

cors_examplemain.tsx2 matches

@neverstew•Updated 1 year ago
5const BASE_URL = "https://stevekrouse-cors_example_backend.web.val.run";
6
7export function App() {
8 const [logs, setLogs] = useState([]);
9 async function request(url, options) {
10 try {
11 const response = await fetch(url, options);

ask_aimain.tsx18 matches

@pomdtr•Updated 1 year ago
3import { OpenAI } from "https://esm.town/v/std/OpenAI";
4
5async function getValByAlias({ author, name }: { author: string; name: string }) {
6 const { id, code, readme } = await api(`/v1/alias/${author}/${name}`, {
7 authenticated: true,
11}
12
13async function updateValCode({ id, code }: { id: string; code: string }) {
14 console.log({ id, code });
15 await api(`/v1/vals/${id}/versions`, {
25}
26
27async function sendEmail({ subject, text }: { subject: string; text: string }) {
28 await email({
29 subject,
66
67Do not communicate with the user directly.
68Instead, use the provided functions to accomplish your task on the behalf of the user.
69
70For example, if you need to modify the code of a val, use the updateValCode function.
71`;
72
73type Tool = {
74 type: "function";
75 function: {
76 function: (...args: any[]) => any;
77 description: string;
78 parse: (...args: any[]) => any;
87};
88
89export function askAI(content: string) {
90 const client = new OpenAI();
91 const runner = client.beta.chat.completions.runTools({
96 }],
97 tools: [{
98 type: "function",
99 function: {
100 function: getValByAlias,
101 description: "Get val info (id, code) from it's alias",
102 parse: JSON.parse,
115 },
116 }, {
117 type: "function",
118 function: {
119 function: updateValCode,
120 description: "update the javascript code of a val",
121 parse: JSON.parse,
134 },
135 }, {
136 type: "function",
137 function: {
138 function: sendEmail,
139 description: "send an email",
140 parse: JSON.parse,

github_cmdk_extensionmain.tsx1 match

@pomdtr•Updated 1 year ago
1import { Hono } from "npm:hono";
2
3export function githubExtension({
4 token: string,
5}) {

getFileEmail4 file matches

@shouser•Updated 1 week 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": "*",