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=772&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 7804 results for "function"(716ms)

untitled_roseGuanacomain.tsx1 match

@stevekrouse•Updated 1 year ago
1import { html } from "https://esm.town/v/stevekrouse/html";
2
3export default async function(req: Request): Promise<Response> {
4 // return new Response("<h1>Hello FRC!</h1>", { headers: {
5 // "Content-Type": "text/html"

updateValByIDmain.tsx1 match

@nbbaier•Updated 1 year ago
11}
12
13export function updateValByID({ token, valId, code, name, readme, privacy }: UpdateValArgs): Promise<any> {
14 const body: Record<string, unknown> = {
15 token,

updateValByNamemain.tsx1 match

@nbbaier•Updated 1 year ago
7}
8
9export function updateValByName({ token, code, name }: UpdateValArgs): Promise<any> {
10 const body: Record<string, unknown> = {
11 token,

fetchPaginatedDataREADME.md1 match

@nbbaier•Updated 1 year ago
1# Fetch Paginated Data
2
3This val exports a function that loops through paginated API responses and returns the combined data as an array. It expects pagination with `next` and there to be a `data` property in the API response. This conforms to the Val Town API, so this function is useful when fetching paginated Val Town API responses for creating custom folders in [pomdtr's vscode extension](https://github.com/pomdtr/valtown-vscode).
4
5Usage:

paginatedResponseREADME.md2 matches

@nbbaier•Updated 1 year ago
1# Return a paginated response
2
3A helper function to take an array and return a paginated response. This is useful when defining one's own folders for [pomdtr's vscode extension](https://github.com/pomdtr/valtown-vscode).
4
5Usage:
8const data = [...]
9
10export default async function(req: Request): Promise<Response> {
11 return paginatedResponse(req, data);
12}

placemarkGlobeMonitormain.tsx1 match

@tmcw•Updated 1 year ago
1import { sqlite } from "https://esm.town/v/std/sqlite?v=4";
2
3export default async function(interval: Interval) {
4 const versions = await fetch("https://www.figma.com/api/plugins/1323092380415927575/versions").then(r => r.json());
5 const { install_count, like_count, view_count } = versions.meta.plugin;

testEmail2main.tsx1 match

@tmcw•Updated 1 year ago
3import { testEmails } from "https://esm.town/v/stevekrouse/testEmails";
4
5export async function testEmail2(e: Email) {
6 await set("testEmails", [...testEmails, {
7 ...e,

sqlite_admin_tablesmain.tsx1 match

@stevekrouse•Updated 1 year ago
2import { blob } from "https://esm.town/v/std/blob?v=10";
3
4export async function sqlite_admin_tables() {
5 let blobs = await blob.list();
6 return (

dbToAPIREADME.md1 match

@nbbaier•Updated 1 year ago
1## Create an API from a [lowdb blob](https://www.val.town/v/pomdtr/lowdb)
2
3This val exports a function that takes a lowdb instance and returns a [Hono](https://hono.dev) router that can be used to interact with the data. This is the beginning of an implementation of something like [json-server](https://github.com/typicode/json-server) for Val Town.
4
5The resulting server also comes with a frontend at `/`. The code for the frontend can be found [here](https://www.val.town/v/nbbaier/dbToAPIFrontend).

untitled_moccasinHeronmain.tsx1 match

@stevekrouse•Updated 1 year ago
1export const str = "hello world";
2
3export default function handler(request: Request) {
4 return Response.json({ ok: true });
5}

getFileEmail4 file matches

@shouser•Updated 6 days ago
A helper function to build a file's email

TwilioHelperFunctions

@vawogbemi•Updated 2 months ago