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/$%7Burl%7D?q=function&page=2052&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 22744 results for "function"(2650ms)

infiniteNewIdeasmain.tsx1 match

@leon•Updated 1 year ago
1export default async function(req: Request): Promise<Response> {
2 return Response.json({
3 idea: `imagine that https://www.${crypto.randomUUID()}.com was a cool web site about ${crypto.randomUUID()}`,

valshotmain.tsx1 match

@burningion•Updated 1 year ago
21export default router.fetch;
22
23export async function createScreenshot(code: string, theme: string = "dark-plus"): Promise<URL> {
24 const apiUrl = "https://sourcecodeshots.com/api/image/permalink";
25 const { url } = await ky.post(apiUrl, {

aqimain.tsx1 match

@burningion•Updated 1 year ago
2import { easyAQI } from "https://esm.town/v/stevekrouse/easyAQI";
3
4export async function aqi(interval: Interval) {
5 const location = "Brooklyn Navy Yard, Brooklyn"; // <-- change to place, city, or zip code
6 const data = await easyAQI({ location });

apricotTurkeymain.tsx4 matches

@yawnxyz•Updated 1 year ago
2
3const openai = new OpenAI();
4const functionExpression = await openai.chat.completions.create({
5 "messages": [
6 { "role": "user", "content": "whats the weather in sf" },
8 tools: [
9 {
10 function: {
11 name: "weather",
12 parameters: {
19 },
20 },
21 type: "function",
22 },
23 ],
26});
27
28console.log(functionExpression.choices);

goldVulturemain.tsx1 match

@yawnxyz•Updated 1 year ago
1export function currentDate() {
2 return new Date();
3}

love_letterREADME.md4 matches

@pomdtr•Updated 1 year ago
7The idea is simple: you write down a javascript snippet (named vals) in your browser, and it's instantly executed on a server. You can use it to:
8
9- execute a function on a cron schedule
10- host a small websites (this article [hosted on Val Town](https://www.val.town/v/pomdtr/love_letter))
11- send yourself emails
32
33// run every hour
34export default function(interval: Interval) {
35 // create the val table
36 await options.sqlite.execute(createQuery);
78
79// triggered each time an email is sent to pomdtr.sqlite_email@valtown.email
80export default async function(email: Email) {
81 // forward the email to my own email address
82 await sendEmail({
96## Publishing the Table
97
98The val.town stdlib provides a neat `rpc` function that provides a simple way to expose a function as an API. So I decided to write a simple val that would run a query on the table, and return the result.
99
100```ts

pushovermain.tsx1 match

@pranjaldotdev•Updated 1 year ago
3// Send a pushover message.
4// token, user, and other opts are as specified at https://pushover.net/api
5export default async function pushover({
6 token,
7 user,

scrapermain.tsx2 matches

@pranjaldotdev•Updated 1 year ago
3const NEWSLETTER_URL = "https://bytes.dev/archives";
4
5function normalizeURL(url: string) {
6 return url.startsWith("http://") || url.startsWith("https://")
7 ? url
9}
10
11async function fetchText(url: string, options?: any) {
12 const response = await fetch(normalizeURL(url), {
13 redirect: "follow",

indigoWombatmain.tsx1 match

@josh_len•Updated 1 year ago
2
3// Fetches a random joke.
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",

basic_authmain.tsx2 matches

@rdimartino•Updated 1 year ago
9};
10
11export function authMiddleware(
12 handler: (Request) => Promise<Response>,
13 options: Options,
56}
57
58export default async function(req: Request): Promise<Response> {
59 return new Response("This is middleware only");
60}

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.