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=2796&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 31566 results for "function"(18881ms)

competitiveGraySkunkmain.tsx5 matches

@jeffreyyoung•Updated 10 months ago
2 * Returns a response to the user's query
3 */
4async function getResponse(req: Query, send: SendEventFn) {
5 send("meta", { content_type: "text/markdown" });
6 let i = 0;
19}
20
21function chunk(i: number) {
22 return `# Heading ${i}
23
33 * Returns your bot's settings
34 */
35async function getBotSettings(): Promise<BotSettings> {
36 return {
37 allow_attachments: true,
104) => void;
105
106function encodeEvent(event: string, data: any = {}) {
107 return new TextEncoder().encode(`event: ${event}\ndata: ${JSON.stringify(data)}\n\n`);
108}
109
110export default async function(req: Request): Promise<Response> {
111 const reqBody = await req.json()
112 .catch((e) => {

hnTopStorymain.tsx1 match

@stevekrouse•Updated 10 months ago
3
4// Get the title of the top story on Hacker News
5export async function hnTopStory() {
6 const topStories: Number[] = await fetch(
7 "https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty",

freshBeigeScorpionmain.tsx4 matches

@jeffreyyoung•Updated 10 months ago
2 * Returns a response to the user's query
3 */
4async function getResponse(req: Query, send: SendEventFn) {
5 send("meta", { content_type: "text/markdown" });
6 send("text", {
27 * Returns your bot's settings
28 */
29async function getBotSettings(): Promise<BotSettings> {
30 return {
31 allow_attachments: true,
98) => void;
99
100function encodeEvent(event: string, data: any = {}) {
101 return new TextEncoder().encode(`event: ${event}\ndata: ${JSON.stringify(data)}\n\n`);
102}
103
104export default async function(req: Request): Promise<Response> {
105 const reqBody = await req.json()
106 .catch((e) => {

bot1main.tsx4 matches

@jeffreyyoung•Updated 10 months ago
2 * Returns a response to the user's query
3 */
4async function getResponse(req: Query, send: SendEventFn) {
5 send("meta", { content_type: "text/markdown" });
6 const lastMessage = req.query.at(-1);
25 * Returns your bot's settings
26 */
27async function getBotSettings(): Promise<BotSettings> {
28 return {
29 allow_attachments: true,
87) => void;
88
89function encodeEvent(event: string, data: any = {}) {
90 return new TextEncoder().encode(`event: ${event}\ndata: ${JSON.stringify(data)}\n\n`);
91}
92
93export default async function(req: Request): Promise<Response> {
94 const reqBody = await req.json().catch((e) => {
95 console.error("body parse error", e);

literaryIvorySlugmain.tsx4 matches

@jeffreyyoung•Updated 10 months ago
2 * Returns a response to the user's query
3 */
4async function getResponse(req: Query, send: SendEventFn) {
5 send("meta", { content_type: "text/markdown" });
6 const lastMessage = req.query.at(-1);
19 * Returns your bot's settings
20 */
21async function getBotSettings(): Promise<BotSettings> {
22 return {
23 allow_attachments: true,
90) => void;
91
92function encodeEvent(event: string, data: any = {}) {
93 return new TextEncoder().encode(`event: ${event}\ndata: ${JSON.stringify(data)}\n\n`);
94}
95
96export default async function(req: Request): Promise<Response> {
97 const reqBody = await req.json().catch((e) => {
98 console.error("body parse error", e);

blobmain.tsx9 matches

@std•Updated 10 months ago
4
5/**
6 * Provides functions for interacting with your account's blob storage.
7 * Blobs can store any data type (text, JSON, images, etc.) and allow
8 * retrieval across different vals using the same key.
80};
81
82async function list(prefix?: string): Promise<{ key: string; size: number; lastModified: string }[]> {
83 let querystring = prefix ? `?prefix=${encodeURIComponent(prefix)}` : "";
84 const res = await fetch(`${API_URL}/v1/blob${querystring}`, {
94}
95
96async function delete_(key: string) {
97 const res = await fetch(`${API_URL}/v1/blob/${encodeURIComponent(key)}`, {
98 method: "DELETE",
107}
108
109async function get(key: string) {
110 const res = await fetch(`${API_URL}/v1/blob/${encodeURIComponent(key)}`, {
111 headers: {
123}
124
125async function set(key: string, value: BodyInit) {
126 const res = await fetch(`${API_URL}/v1/blob/${encodeURIComponent(key)}`, {
127 method: "POST",
137}
138
139async function copy(previous: string, next: string) {
140 const res = await get(previous);
141 await set(next, res.body);
142}
143
144async function move(previous: string, next: string) {
145 await copy(previous, next);
146 await delete_(previous);
147}
148
149async function getJSON<T = unknown>(key: string): Promise<T> {
150 try {
151 const res = await get(key);
159}
160
161async function setJSON(key: string, value: any) {
162 return set(key, JSON.stringify(value));
163}

quickjsmain.tsx1 match

@maxm•Updated 10 months ago
3const QuickJS = await newQuickJSWASMModuleFromVariant(releaseVariant);
4
5async function main() {
6 const vm = QuickJS.newContext();
7

ogImagemain.tsx1 match

@moe•Updated 10 months ago
3import satori from "npm:satori"
4
5export async function ogImage(body) {
6 const svg = await satori(
7 body,

notionRecurringTasksmain.tsx1 match

@ciebiada•Updated 10 months ago
12};
13
14export default async function(interval: Interval) {
15 const response = await notion.databases.query({
16 database_id: DATABASE_ID,

slogan_historymain.tsx2 matches

@timqian•Updated 10 months ago
58];
59
60function classNames(...classes) {
61 return classes.filter(Boolean).join(" ");
62}
114};
115
116function Hero() {
117 return (
118 <div className="relative isolate overflow-hidden bg-white">
tuna

tuna9 file matches

@jxnblk•Updated 2 weeks ago
Simple functional CSS library for Val Town

getFileEmail4 file matches

@shouser•Updated 2 months ago
A helper function to build a file's email
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.