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/$%7Bsuccess?q=function&page=1743&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 19266 results for "function"(1326ms)

sleepermain.tsx2 matches

@jamiedubs•Updated 1 year ago
1// a very slow and sleepy function
2// pass it ?sleep=33 to make it sleep for that amount of sleep
3export default async function (req: Request): Promise<Response> {
4 const url = new URL(req.url);
5 const sleepQueryParam = url.searchParams.get('sleep');

status401main.tsx1 match

@patrickroumanoff•Updated 1 year ago
1export default async function(req: Request): Promise<Response> {
2 console.log(req.url);
3 if (req.headers.get("x-fd-healthprobe") == "1") {

lowdbmain.tsx1 match

@pomdtr•Updated 1 year ago
18}
19
20async function BlobPreset<Data>(key: string, initialData: Data) {
21 const db = new Low(new Blob<Data>(key), initialData);
22 await db.read();

reply_to_slack_messageREADME.md1 match

@curtcox•Updated 1 year ago
1This val provides a way of readily having lots of different Slack bots that do different things and support different Slack workspaces without needing a bunch of Val Town accounts. If you only need a single bot on a single workspace, just go with the approach in the Val Town [docs](https://docs.val.town/integrations/slack/bot/).
2
3This bot is essentially the one described in the Val Town [docs](https://docs.val.town/integrations/slack/bot/), but without any of the details. Those are externalized by the SlackConfig and SlackFunction interfaces. It is just glue. In order to make it work, you will need the following additional glue:
4- a public HTTP val to handle requests like [this one](https://www.val.town/v/curtcox/Chatio)
5- a private val to supply any info missing from the public one like [this one](https://www.val.town/v/curtcox/_not_actually_private_so_that_you_can_see_it)

MattssailingNotifyCronmain.tsx1 match

@brezina•Updated 1 year ago
3import process from "node:process";
4
5export async function sailingNotifyCron({ lastRunAt }) {
6 const result = await sailingNotify("Fair Oaks, CA", 10);
7}

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 = ?`,

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 3 weeks 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.