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=1621&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 18324 results for "function"(1469ms)

viewSourcemain.tsx1 match

@neverstew•Updated 1 year ago
3import { escape } from "npm:html-sloppy-escaper";
4
5export default async function viewSource(req: Request) {
6 const pathname = new URL(req.url).pathname;
7 const html = await fetchText(pathname === "/" ? "example.com" : pathname).then(prettifyHtml);

example_ssrmain.tsx3 matches

@pomdtr•Updated 1 year ago
3
4// will run on both client and server
5export function Demo(props: { items: string[] }) {
6 const [items, setItems] = useState(props.items);
7 useEffect(() => {
26}
27
28// You server code should be contained in this function
29export default async function (req: Request) {
30 const url = new URL(req.url);
31 if (url.pathname == "/api/item") {

islandmain.tsx1 match

@pomdtr•Updated 1 year ago
3import React from "https://esm.sh/react";
4
5export function Island({
6 src,
7 name,

observable_esmmain.tsx1 match

@mootari•Updated 1 year ago
6import * as module from ${JSON.stringify(url)};
7
8export default function define(runtime, observer) {
9 const main = runtime.module();
10 main.variable(observer("__module")).define("__module", () => module);

renderFormAndSaveDataREADME.md1 match

@andreterron•Updated 1 year ago
1# Render form and save data
2
3This val provides a web-based interface for collecting email addresses. It features a dual-functionality approach: when accessed via a web browser using a GET request, it serves an HTML form where users can submit their email address. If the script receives a POST request, it implies that the form has been submitted, and it proceeds to handle the incoming data.
4
5Fork this val to customize it and use it on your account.

myApimain.tsx1 match

@tonycheal•Updated 1 year ago
1export function myApi(name) {
2 return "hi " + name;
3}

httpMockingExamplemain.tsx1 match

@tmcw•Updated 1 year ago
4 * member.
5 */
6export const httpHandler = async function(req: Request): Promise<Response> {
7 if (req.method !== "POST") return new Response("Bad request: only POST allowed", { status: 400 });
8 const body = await req.json();

httpMockingExamplemain.tsx1 match

@tmcw•Updated 1 year ago
4 * member.
5 */
6export const httpHandler = async function(req: Request): Promise<Response> {
7 if (req.method !== "POST") return new Response("Bad request: only POST allowed", { status: 400 });
8 const body = await req.json();
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export default async function(request: Request): Promise<Response> {
4 const cheerio = await import("https://esm.sh/cheerio@1.0.0-rc.12");
5 const response = await fetch("https://releases.1password.com/linux/beta/");

getLatestGitCoreVersionmain.tsx1 match

@freecrayon•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export default async function(request: Request): Promise<Response> {
4 const url = new URL(request.url);
5 const query = url.searchParams.get("query") ?? "";

getFileEmail4 file matches

@shouser•Updated 1 week ago
A helper function to build a file's email
tuna

tuna8 file matches

@jxnblk•Updated 2 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.