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/$%7Bart_info.art.src%7D?q=function&page=1597&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 19450 results for "function"(2630ms)

anthropicProxymain.tsx1 match

@cephalization•Updated 9 months ago
1import Anthropic from "npm:@anthropic-ai/sdk@0.24.3";
2
3export default async function(req: Request): Promise<Response> {
4 if (req.method === "OPTIONS") {
5 return new Response(null, {

infiniteSVGGraphmain.tsx6 matches

@maxm•Updated 9 months ago
35// Database querying.
36
37function parseResultSet<T>(row: ResultSet): T[] {
38 return row.rows.map((r) => Object.fromEntries(r.map((c, i) => [row.columns[i], c]))) as T[];
39}
67};
68
69// Client side javascript and template functions.
70
71const clientJavascript = async () => {
135 });
136
137 function createHeartBurst(event) {
138 const button = event.currentTarget;
139 const buttonContainer = button.closest(".heart-button-container");
174};
175
176function escapeHTML(html: string): string {
177 const escapeChars: { [char: string]: string } = {
178 "&": "&amp;",
408 let encoder = new TextEncoder();
409
410 function isValidSVG(svgString) {
411 const parser = new DOMParser({
412 errorHandler: {
488
489app.get("/:id/img.svg", async (c) => {
490 function addSVGNamespace(svgString) {
491 if (!/^<\?xml/.test(svgString)) svgString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + svgString;
492 if (!/xmlns="http:\/\/www.w3.org\/2000\/svg"/.test(svgString))

discordBotREADME.md1 match

@augustveix•Updated 9 months ago
1A simple Discord Bot scaffolding, a slight rev on the one in the [valtown guide](https://docs.val.town/integrations/discord/how-to-make-a-discord-bot-hosted-24-7-for-free-in-/).
2
3The `discordBot` function takes in an object where each key is a Discord command and the value is a function to handle the command. If the function returns a `Promise`, it will be handled as a deferred interaction with a [followup message](https://discord.com/developers/docs/interactions/receiving-and-responding#followup-messages).
4
5Usage:

codeOnValTownmain.tsx2 matches

@stevekrouse•Updated 9 months ago
9 * @param val Define which val should open. Defaults to the root reference
10 */
11export function modifyHtmlString(
12 bodyText: string,
13 { val, style }: { val?: ValRef; style?: string } = {},
40 * @param val Define which val should open
41 */
42export function modifyFetchHandler(
43 handler: (req: Request) => Response | Promise<Response>,
44 { val, style }: { val?: ValRef; style?: string } = {},

codeOnValTownREADME.md1 match

@stevekrouse•Updated 9 months ago
49### Linking to the val
50
51These functions infer the val using the call stack or the request URL. If the inference isn't working, or if you want to ensure it links to a specific val, pass the `val` argument:
52
53- `modifyFetchHandler(handler, {val: { handle: "andre", name: "foo" }})`

coralPumaREADME.md1 match

@willthereader•Updated 9 months ago
49### Linking to the val
50
51These functions infer the val using the call stack or the request URL. If the inference isn't working, or if you want to ensure it links to a specific val, pass the `val` argument:
52
53- `modifyFetchHandler(handler, {val: { handle: "andre", name: "foo" }})`

coralPumamain.tsx2 matches

@willthereader•Updated 9 months ago
9 * @param val Define which val should open. Defaults to the root reference.
10 */
11export function modifyHtmlString(
12 bodyText: string,
13 { val, style }: { val?: ValRef; style?: string } = {},
40 * @param val Define which val should open
41 */
42export function modifyFetchHandler(
43 handler: (req: Request) => Response | Promise<Response>,
44 { val, style }: { val?: ValRef; style?: string } = {},

codeOnValTownREADME.md1 match

@willthereader•Updated 9 months ago
49### Linking to the val
50
51These functions infer the val using the call stack or the request URL. If the inference isn't working, or if you want to ensure it links to a specific val, pass the `val` argument:
52
53- `modifyFetchHandler(handler, {val: { handle: "andre", name: "foo" }})`

codeOnValTownmain.tsx2 matches

@willthereader•Updated 9 months ago
9 * @param val Define which val should open. Defaults to the root reference.
10 */
11export function modifyHtmlString(
12 bodyText: string,
13 { val, style }: { val?: ValRef; style?: string } = {},
40 * @param val Define which val should open
41 */
42export function modifyFetchHandler(
43 handler: (req: Request) => Response | Promise<Response>,
44 { val, style }: { val?: ValRef; style?: string } = {},

twitterAlertmain.tsx1 match

@tmcw•Updated 9 months ago
3const query = "\"val.town\" OR \"val town\" -_ValTown_ -is:retweet"
4
5export async function twitterAlert({ lastRunAt }: Interval) {
6 const results = await twitterSearch({
7 query,

getFileEmail4 file matches

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