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=968&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 15007 results for "function"(3069ms)

single_file_web_appmain.tsx3 matches

@matthamlin•Updated 2 months ago
3import React from "https://esm.sh/react@18.2.0";
4
5function App() {
6 return (
7 <div>
19}
20
21function client() {
22 createRoot(document.getElementById("root")).render(<App />);
23}
27}
28
29export default async function server(request: Request): Promise<Response> {
30 return new Response(
31 `

linkInBioTemplatemain.tsx1 match

@Sungjin•Updated 2 months ago
2import { renderToString } from "npm:react-dom/server";
3
4export default async function(req: Request) {
5 return new Response(
6 renderToString(

getWeatherREADME.md1 match

@charmaine•Updated 2 months ago
1## Get Weather
2
3Simple function to get weather data from the free [wttr.in](https://wttr.in/:help) service.
4
5```ts

getWeathermain.tsx1 match

@charmaine•Updated 2 months ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export async function getWeather(location: string): Promise<WeatherResponse> {
4 return fetchJSON(`https://wttr.in/${location}?format=j1`);
5}

runGetWeathermain.tsx1 match

@charmaine•Updated 2 months ago
1import { getWeather } from "https://esm.town/v/stevekrouse/getWeather";
2
3export default async function(interval: Interval) {
4 let weather = await getWeather("Brooklyn, NY");
5 console.log(weather.current_condition[0].FeelsLikeF);

comicalMaroonMastodonmain.tsx4 matches

@adofficial•Updated 2 months ago
22);
23
24function calculateLoanDetails(principal: number, annualRate: number, years: number) {
25 const monthlyRate = annualRate / 100 / 12;
26 const months = years * 12;
57}
58
59function App() {
60 const [principal, setPrincipal] = useState(200000);
61 const [rate, setRate] = useState(6.5);
200}
201
202function client() {
203 createRoot(document.getElementById("root")).render(<App />);
204}
205if (typeof document !== "undefined") { client(); }
206
207export default async function server(request: Request): Promise<Response> {
208 return new Response(`
209 <html>

chatmain.tsx1 match

@Newboon•Updated 2 months ago
23 });
24 const message = data.choices[0].message;
25 return message.function_call ? message.function_call : message.content;
26};

APIBuilderTemplatefocusedCoffeeClam1 match

@dcm31•Updated 2 months ago
3import "swagger-ui-dist/swagger-ui.css";
4
5export default async function (req: Request): Promise<Response> {
6 const ui = SwaggerUI({
7 url: "https://petstore.swagger.io/v2/swagger.json",

APIBuilderTemplatefieryYellowHornet1 match

@dcm31•Updated 2 months ago
1export default async function (req: Request): Promise<Response> {
2 return Response.json({ ok: true })
3}

APIBuilderTemplatequickMoccasinGoldfish1 match

@dcm31•Updated 2 months ago
1export default async function (req: Request): Promise<Response> {
2 return Response.json({ ok: true })
3}

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 1 week 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": "*",