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=1440&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 18794 results for "function"(1617ms)

stripFencesmain.tsx1 match

@stevekrouse•Updated 7 months ago
1export default function stripFences(content: string) {
2 return content.replace(/```[\s\S]*?\n([\s\S]*?)\n```/g, "$1");
3}

monacoEditormain.tsx2 matches

@yawnxyz•Updated 7 months ago
54 // Initialize Monaco Editor without RequireJS
55 window.require.config({ paths: { 'vs': 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.51.0/min/vs' } });
56 window.require(['vs/editor/editor.main'], function () {
57 // Define a custom Monokai Light theme
58 monaco.editor.defineTheme('monokai-light', {
66 { token: 'number', foreground: 'ae81ff' },
67 { token: 'type', foreground: '66d9ef' }, // Lightened blue
68 { token: 'function', foreground: 'a6e22e' }, // Lightened green
69 ],
70 colors: {

GDI_ClientInfomain.tsx3 matches

@rozek•Updated 7 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 const [details, setDetails] = useState("");
7 const [isLoading, setIsLoading] = useState(false);
40}
41
42function client() {
43 createRoot(document.getElementById("root")).render(<App />);
44}
48}
49
50export default async function server(request: Request): Promise<Response> {
51 return new Response(
52 `

GDI_ClientInfoServicemain.tsx1 match

@rozek•Updated 7 months ago
1export default async function (req: Request): Promise<Response> {
2 const headers = req.headers;
3 const url = new URL(req.url);

GDI_AIChatCompletionmain.tsx3 matches

@rozek•Updated 7 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 const [systemMessage, setSystemMessage] = useState("You are a helpful assistant");
7 const [userMessage, setUserMessage] = useState("");
73}
74
75function client() {
76 createRoot(document.getElementById("root")).render(<App />);
77}
81}
82
83export default async function server(request: Request): Promise<Response> {
84 return new Response(
85 `

GDI_AIChatCompletionServicemain.tsx1 match

@rozek•Updated 7 months ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2
3export default async function (req: Request): Promise<Response> {
4 if (req.method !== "POST") {
5 return new Response("Method Not Allowed", { status: 405 });

GDI_GoodMorningmain.tsx3 matches

@rozek•Updated 7 months ago
1import { email } from "https://esm.town/v/std/email";
2
3async function getWeather() {
4 const response = await fetch(
5 "https://api.open-meteo.com/v1/forecast?latitude=48.7758&longitude=9.1829&current=temperature_2m,weathercode&daily=weathercode,temperature_2m_max,temperature_2m_min&timezone=Europe%2FBerlin"
8}
9
10function getWeatherDescription(weathercode: number) {
11 const weatherCodes: { [key: number]: string } = {
12 0: "Clear sky",
30}
31
32export default async function (interval: Interval) {
33 const now = new Date();
34 const dayOfWeek = now.getDay();

GDI_AITranslatorServicemain.tsx1 match

@rozek•Updated 7 months ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2
3export default async function (req: Request): Promise<Response> {
4 // Check if the request method is POST
5 if (req.method !== "POST") {

GDI_EMailSendermain.tsx3 matches

@rozek•Updated 7 months ago
4import { email } from "https://esm.town/v/std/email";
5
6function App() {
7 const [subject, setSubject] = useState("");
8 const [message, setMessage] = useState("");
67}
68
69function client() {
70 createRoot(document.getElementById("root")).render(<App />);
71}
73if (typeof document !== "undefined") { client(); }
74
75export default async function server(request: Request): Promise<Response> {
76 if (request.method === "POST" && new URL(request.url).pathname === "/send-email") {
77 const { subject, message } = await request.json();

GDI_FormUploadmain.tsx3 matches

@rozek•Updated 7 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 const initialFormData = useMemo(() => ({
7 textInput: '',
193}
194
195function client() {
196 const root = document.getElementById("root");
197 if (root) {
204}
205
206export default async function server(request: Request): Promise<Response> {
207 return new Response(
208 `

getFileEmail4 file matches

@shouser•Updated 2 weeks 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
webup
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.
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": "*",