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/$2?q=function&page=2470&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 27790 results for "function"(5757ms)

streammain.tsx3 matches

@tempguy•Updated 10 months ago
13 };
14}
15function getSeasonEpisode(text) {
16 const pattern = /s(\d{1,3})e(\d{1,4})/i;
17 const match = text.match(pattern);
112 return c.json(apiResponse);
113});
114async function scrapeMoviesFiles(directoryList, febboxId: string) {
115 return directoryList;
116}
117async function scrapeSeriesFiles(directoryList, febboxId: string, season: number, episode: number) {
118 for (const [i, item] of directoryList["data"]["file_list"].entries()) {
119 if (item.file_icon === "dir_icon" && item.file_name.includes("eason")) {

googleGenerativeAIStreamingExamplemain.tsx1 match

@tr3ntg•Updated 10 months ago
1import { GoogleGenerativeAI } from "npm:@google/generative-ai";
2export default async function(req: Request): Promise<Response> {
3 const genAI = new GoogleGenerativeAI(Deno.env.get("your-api-key"));
4 const generativeModel = genAI.getGenerativeModel({

reactClientDemomain.tsx1 match

@wilhelm•Updated 10 months ago
26}
27
28export default async function(req: Request): Promise<Response> {
29 const { renderToReadableStream } = await import("https://esm.sh/react-dom/server");
30 const stream = await renderToReadableStream(<App />, { bootstrapModules: [import.meta.url] });

duckdbExamplemain.tsx1 match

@ychahwan•Updated 11 months ago
2
3export let duckdbExample = (async () => {
4 async function createWorker(url: string) {
5 const workerScript = await fetch(url);
6 const workerURL = URL.createObjectURL(await workerScript.blob());

servicefactorymain.tsx5 matches

@dglazkov•Updated 11 months ago
115};
116
117export type InvokeFunction = (inputs: InputValues) => Promise<OutputValues>;
118export type DescribeFunction = (
119 inputs?: InputValues,
120) => Promise<NodeDescriberResult> | NodeDescriberResult;
192
193export const service = (
194 describe: DescribeFunction,
195 invoke: InvokeFunction,
196 options?: ServiceOptions,
197) => {
198 return async function(req: Request): Promise<Response> {
199 const url = new URL(req.url);
200 const path = url.pathname;

openAiProxymain.tsx2 matches

@ashryanio•Updated 11 months ago
8 * @returns {Promise<Response>} - The response object.
9 */
10export default async function(req: Request): Promise<Response> {
11 // Handle POST request
12 // This is the primary path for the API
62 * @returns {Promise<string>} - The response from the language model.
63 */
64async function getLlmResponse(prompt: string) {
65 const completion = await openai.chat.completions.create({
66 "messages": [

openAiProxyREADME.md2 matches

@ashryanio•Updated 11 months ago
3## Overview
4
5This val is a proxy server that interacts with the OpenAI API to generate responses based on prompts in the request body. The function handles incoming HTTP POST requests, processes the prompt, and returns a response generated by the LLM.
6
7## Prerequisites
14### Endpoint
15
16The primary endpoint for this function is designed to handle HTTP POST requests.
17
18### Request

plumOwlmain.tsx1 match

@tempguy•Updated 11 months ago
11 };
12}
13export default async function(req: Request): Promise<Response> {
14 const showbox = await Fetch("https://www.showbox.media/index/share_link?id=55137&type=1", {
15 headers: {

tripsmain.tsx2 matches

@mxdvl•Updated 11 months ago
9};
10
11async function to_line_string(
12 coordinates: readonly Coordinates[],
13 en_route = false,
32}
33
34export async function* trips(
35 coordinates: readonly Coordinates[],
36 distance_threshold = 120,

discordBotREADME.md1 match

@dglazkov•Updated 11 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:

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.