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=2660&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 29356 results for "function"(6054ms)

telegrammain.tsx4 matches

@austinm911•Updated 1 year ago
10 * @param authorization
11 */
12export async function telegramText(text: string, options?: TextOptions, authorization?: string) {
13 return telegramRequest("text", { text, options }, authorization);
14}
20 * @param authorization
21 */
22export async function telegramPhoto(options: PhotoOptions, authorization?: string) {
23 return telegramRequest("photo", { options }, authorization);
24}
25
26async function telegramRequest(path, body, authorization?: string) {
27 const response = await fetch("https://stevekrouse-telegramValTownAPI.web.val.run/" + path, {
28 method: "POST",
47 * @deprecated since 4/20/2024
48 */
49export async function telegram(secret: string, text: string, options?: MergedOptions) {
50 return runVal("stevekrouse.telegramValTownBot", secret, text, options);
51}

guestmain.tsx1 match

@pomdtr•Updated 1 year ago
1export default function() {
2 return fetch("file:///opt/render/project/src/guest/index.ts");
3}

API_URLmain.tsx2 matches

@pomdtr•Updated 1 year ago
1function envOrUndefined(key: string): string | undefined {
2 // try/catch prevents crashes if the script doesn't have env access
3 try {
6}
7
8export function getApiUrl(): string {
9 return envOrUndefined("VALTOWN_API_URL") ?? "https://api.val.town";
10}

HTreeTreePmain.tsx8 matches

@maxm•Updated 1 year ago
27const TIMEOUT = 5 * oneSecond;
28
29const DEFAULT_HANDLER = `export default async function (req: Request): Promise<Response> {
30 console.log(req.url)
31 return Response.json([1, 1+1, 12/4, parseInt("4")]);
41`;
42
43function parseResultSet<T>(row: ResultSet): T[] {
44 return row.rows.map((r) => Object.fromEntries(r.map((c, i) => [row.columns[i], c]))) as T[];
45}
55 get(target, key) {
56 const real = target[key];
57 if (typeof real === "function" && typeof key === "string") {
58 const fn = function(...args: any[]) {
59 logs.push({
60 level: key,
317
318// The script we run within the worker. Don't reference anything
319// outside of this function as it won't be available within the worker.
320const workerScript = () => {
321 const requests: FetchInfo[] = [];
390 get(target, key) {
391 const real = target[key];
392 if (typeof real === "function" && typeof key === "string") {
393 const fn = function(...args: any[]) {
394 logs.push({
395 level: key,
404 },
405 });
406 async function evaluate(url) {
407 try {
408 const _ = await import(url);

reacttldrawclientmain.tsx2 matches

@iamseeley•Updated 1 year ago
4import React, { useState, useEffect } from "https://esm.sh/react@18.0.0";
5
6function TestComponent() {
7 return <div>Test Component</div>;
8}
9
10export function App() {
11 const [isReady, setIsReady] = useState(false);
12

setEnvmain.tsx2 matches

@pomdtr•Updated 1 year ago
5 * that simulates the same interface as Deno.env
6 */
7export function createDenoEnvStub(
8 input: Record<string, string>,
9): typeof Deno.env {
27}
28
29export function setEnv(key: string, value: string) {
30 const env = Deno.env.toObject();
31 // @ts-ignore

honoReactExportModeScriptmain.tsx3 matches

@tfayyaz•Updated 1 year ago
2import { useState } from "https://esm.sh/react@18.2.0";
3
4function MyButton() {
5 const [count, setCount] = useState(0);
6
7 function handleClick() {
8 setCount(count + 1);
9 }
16}
17
18export function MyApp() {
19 return (
20 <div>

datme_home_geomain.tsx2 matches

@stevekrouse•Updated 1 year ago
5import { Hono } from "npm:hono@3";
6
7// export default function Home(c) {
8function Home(c) {
9 return c.html(
10 <Layout activeTab={new URL(c.req.url).pathname}>

reloadOnSavemain.tsx4 matches

@stevekrouse•Updated 1 year ago
8
9// this script runs client-side
10export const reloadOnVals = async function(vals: ValRef[]) {
11 const valVersions = await Promise.all(vals.map(getCurrentValVersionNumber));
12 // console.log("initialValVersions: ", valVersions);
22
23// experimental - don't use this
24export function reloadOnSaveHonoMiddleware(vals: ValRef[] = [rootValRef()]): MiddlewareHandler {
25 return async function(c, next) {
26 await next();
27 // don't reload on custom domains, only reload on val.run URLs
40 * @param vals to watch
41 */
42export function reloadOnSaveFetchMiddleware(
43 handler: (req: Request) => Response | Promise<Response>,
44 vals = [rootValRef()],

devtoolsmain.tsx1 match

@pomdtr•Updated 1 year ago
2import { api } from "https://esm.town/v/pomdtr/api";
3
4export function devtools(handler: (req: Request) => Response | Promise<Response>, options?: {
5 val?: {
6 handle: string;
tuna

tuna9 file matches

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

getFileEmail4 file matches

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