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/$%7Burl%7D?q=function&page=2462&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 34573 results for "function"(9029ms)

componentmain.tsx7 matches

@web•Updated 3 months ago
3import React, { useEffect, useState } from "https://esm.sh/react@18.2.0";
4
5async function fetchComponentData(path: string[]) {
6 try {
7 const response = await fetch(`/component/${path.join('/')}`);
8 const { component, data } = await response.json();
9
10 const DynamicComponent = new Function('React', 'data', `
11 return ${component}
12 `)(React, data);
27}
28
29function App() {
30 const [Component, setComponent] = useState<React.ComponentType<{}>| null>(null);
31 const [error, setError] = useState<string | null>(null);
32
33 useEffect(() => {
34 async function loadComponent() {
35 try {
36 const path = window.location.pathname.split('/').filter(Boolean);
56}
57
58function client() {
59 createRoot(document.getElementById("root")).render(<App />);
60}
64}
65
66export default async function server(request: Request): Promise<Response> {
67 const { OpenAI } = await import("https://esm.town/v/std/openai");
68 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
121
122 const componentPrompt = `
123 Create a React functional component that visualizes the following JSON data.
124 Ensure the component handles potential data variations.
125 Respond with ONLY the complete React component code.

valjs_slop_examplemain.tsx4 matches

@ajax•Updated 3 months ago
39};
40
41// In-memory storage (note: this will reset between function invocations)
42const memory = new Map();
43
44// Route handler
45async function handleRequest(request) {
46 const url = new URL(request.url);
47 const path = url.pathname;
144}
145
146// Main handler function for Valtown
147export default async function(request) {
148 return await handleRequest(request);
149}

spagindex.html4 matches

@seventeenthmagpie•Updated 3 months ago
190 },
191 })
192 .then(function (stream) {
193 // uh oh... a promise
194 recorder = new MediaRecorder(stream);
251 );
252
253 async function fetchUploads() {
254 const response = await fetch("/api/list");
255 const data = await response.json();
257 }
258
259 async function pullUploads() {
260 refreshButton.disabled = true;
261 previewAllButton.hidden = true;
283
284 const uploadsElement = document.getElementById("uploads");
285 function renderUploads(_uploads) {
286 uploadsElement.innerHTML = "";
287

spagupload.ts1 match

@seventeenthmagpie•Updated 3 months ago
2import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
3
4export default async function(req: Request): Promise<Response> {
5 let json;
6 try {

spagserver.ts1 match

@seventeenthmagpie•Updated 3 months ago
5import upload from "./upload.ts";
6
7export default async function(req: Request): Promise<Response> {
8 const path = new URL(req.url).pathname;
9

spagLICENSE1 match

@seventeenthmagpie•Updated 3 months ago
300and execute modified versions of a covered work in that User Product from
301a modified version of its Corresponding Source. The information must
302suffice to ensure that the continued functioning of the modified object
303code is in no case prevented or interfered with solely because
304modification has been made.

spagdelete.ts1 match

@seventeenthmagpie•Updated 3 months ago
2import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
3
4export default async function(req: Request): Promise<Response> {
5 let json;
6 try {

spagindex.html4 matches

@froos•Updated 3 months ago
190 }
191 })
192 .then(function (stream) {
193 // uh oh... a promise
194 recorder = new MediaRecorder(stream);
251 );
252
253 async function fetchUploads() {
254 const response = await fetch("/api/list");
255 const data = await response.json();
257 }
258
259 async function pullUploads() {
260 refreshButton.disabled = true;
261 previewAllButton.hidden = true;
283
284 const uploadsElement = document.getElementById("uploads");
285 function renderUploads(_uploads) {
286 uploadsElement.innerHTML = "";
287

spagupload.ts1 match

@froos•Updated 3 months ago
2import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
3
4export default async function(req: Request): Promise<Response> {
5 let json;
6 try {

spagserver.ts1 match

@froos•Updated 3 months ago
5import upload from "./upload.ts";
6
7export default async function(req: Request): Promise<Response> {
8 const path = new URL(req.url).pathname;
9

discordWebhook2 file matches

@stevekrouse•Updated 2 weeks ago
Helper function to send Discord messages
tuna

tuna9 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.