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//%22https:/unpkg.com/@alenaksu/json-viewer@2.1.0/dist/json-viewer.bundle.js/%22?q=function&page=1&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 40533 results for "function"(1753ms)

campanhapsdalcoframain.ts3 matches

@nmsilva•Updated 46 mins ago
446};
447
448function App() {
449 return (
450 <>
454}
455
456function client() {
457 createRoot(document.getElementById("root")).render(<App />);
458}
462}
463
464export default async function server(request: Request): Promise<Response> {
465 return new Response(
466 `

untitled-8620main.ts9 matches

@know•Updated 52 mins ago
11
12const DECONSTRUCT_FACT_PROMPT = `
13You are 'Principia', an expert logician specializing in epistemology. Your function is to deconstruct a given factual statement into its immediate, necessary, and sufficient prerequisite facts. You must adhere to the principle of strict logical entailment.
14
15- Analyze the provided {Target Fact}.
82 },
83 {
84 "fact": "The operation '+' (addition) is defined as repeatedly applying the successor function.",
85 "justification": "This is necessary because the symbol '+' must have a defined operational meaning."
86 }
127 * Calls the specified AI with a given prompt and fact.
128 */
129async function callAI(fact: string, prompt: string): Promise<Prerequisite[]> {
130 try {
131 const completion = await openai.chat.completions.create({
149 * Recursively builds the prerequisite tree, with an Auditor check.
150 */
151async function buildTreeRecursive(
152 node: FactNode,
153 jobId: string,
196 * This prevents race conditions when writing to blob storage.
197 */
198async function buildTreeInBackground(jobId: string, rootNode: FactNode) {
199 try {
200 let currentLevelNodes = [rootNode];
260}
261
262function generateHtml(sourceUrl: string): string {
263 return `<!DOCTYPE html>
264<html lang="en">
447 const POLLING_INTERVAL = 2000;
448
449 function TreeNode({ node }) {
450 const [isCollapsed, setIsCollapsed] = useState(false);
451
478 }
479
480 function App() {
481 const [view, setView] = useState('input'); // 'input', 'processing', 'tree'
482 const [jobId, setJobId] = useState(null);
618
619// --- HTTP REQUEST HANDLER ---
620export default async function (req: Request): Promise<Response> {
621 const url = new URL(req.url);
622 const path = url.pathname;

untitled-8620main.ts6 matches

@realtime•Updated 1 hour ago
59const openai = new OpenAI();
60
61async function callAI(fact: string, prompt: string): Promise<Prerequisite[]> {
62 try {
63 const completion = await openai.chat.completions.create({
83 * Tracks processed nodes to avoid redundant API calls and circular dependencies.
84 */
85async function buildTreeInBackground(jobId: string, rootNode: FactNode) {
86 try {
87 // This Map will store all nodes ever created, keyed by their fact string.
160// --- FRONTEND & ROUTER (No changes needed below this line) ---
161
162function generateHtml(sourceUrl: string): string {
163 return `<!DOCTYPE html>
164<html lang="en">
347 const POLLING_INTERVAL = 2000;
348
349 function TreeNode({ node, seenIds = new Set() }) {
350 const [isCollapsed, setIsCollapsed] = useState(false);
351
395 }
396
397 function App() {
398 const [view, setView] = useState('input'); // 'input', 'processing', 'tree'
399 const [jobId, setJobId] = useState(null);
534}
535
536export default async function (req: Request): Promise<Response> {
537 const url = new URL(req.url);
538 const path = url.pathname;

bella-cleaningmain.ts1 match

@zoltan•Updated 2 hours ago
2
3// ✅ Images Inside Text Spans
4$("[data='spanWrapper']").each(function (index) {
5 let relatedEl = $("[data='spanElement']").eq(index);
6 relatedEl.appendTo($(this));

brew_countermain.ts1 match

@lazysous•Updated 2 hours ago
21`);
22
23export default async function (req: Request): Promise<Response> {
24 const url = new URL(req.url);
25

untitled-8264Main2.ts12 matches

@ziggyware•Updated 3 hours ago
1export default async function (req: Request): Promise<Response> {
2 const fftSize = 2048;
3 const TWO_PI = 2.0 * 3.141592653579;
74
75
76 function showError(e) {
77 console.error(e);
78 errorBox.style.display = "block";
81
82 // DPR-aware resize
83 function resize() {
84 const dpr = Math.min(window.devicePixelRatio || 1, 2);
85 const w = Math.floor(window.innerWidth * dpr);
196 \`;
197
198 function compileShader(type, src) {
199 const s = gl.createShader(type);
200 gl.shaderSource(s, src);
222 gl.bindVertexArray(vao);
223
224 function createAttrib(data, attribName, usage) {
225 const loc = gl.getAttribLocation(program, attribName);
226 if (loc === -1) throw new Error("Attrib not found or optimized out: " + attribName);
248
249 // Matrices
250 function mat4Perspective(fovDeg, aspect, near, far) {
251 const f = 1.0 / Math.tan((fovDeg * Math.PI) / 360);
252 const nf = 1 / (near - far);
259 return out;
260 }
261 function subtract(a, b) { return [a[0]-b[0], a[1]-b[1], a[2]-b[2]]; }
262 function normalize(v) {
263 const l = Math.hypot(v[0], v[1], v[2]) || 1;
264 return [v[0]/l, v[1]/l, v[2]/l];
265 }
266 function cross(a, b) {
267 return [a[1]*b[2] - a[2]*b[1], a[2]*b[0] - a[0]*b[2], a[0]*b[1] - a[1]*b[0]];
268 }
269 function dot(a, b) { return a[0]*b[0] + a[1]*b[1] + a[2]*b[2]; }
270 function mat4LookAt(eye, target, up) {
271 const z = normalize(subtract(eye, target));
272 const x = normalize(cross(up, z));
314
315 // Render loop
316 function render(ts) {
317 // Update audio only if ready
318 if (analyser) {

TownieValTownLogo.tsx1 match

@Skywalker•Updated 3 hours ago
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2
3export function ValTownLogo () {
4 return (
5 <svg

Townieval-summary.ts1 match

@Skywalker•Updated 3 hours ago
5 * Get usage data for a specific val
6 */
7export async function getValSummary(valId: string) {
8 // Get summary data for the val from the usage table
9 const usageSummaryResult = await sqlite.execute(`

Townieval-detail.ts1 match

@Skywalker•Updated 3 hours ago
36}
37
38export function renderValDetail(valId: string, summary: ValSummary, requests: UsageRequest[] = []): string {
39 // Generate the content
40 const content = `

TownieuseUser.tsx1 match

@Skywalker•Updated 3 hours ago
3const USER_ENDPOINT = "/api/user";
4
5export function useUser() {
6 const [data, setData] = useState<any>(null);
7 const [loading, setLoading] = useState(true);

ratelimit4 file matches

@unkey•Updated 1 month ago
Rate limit your serverless functions

discordWebhook2 file matches

@stevekrouse•Updated 2 months ago
Helper function to send Discord messages
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.