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=2523&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 28709 results for "function"(3699ms)

sourceOnGithubExamplemain.tsx4 matches

@curtcox•Updated 10 months ago
1import { Hono } from "https://deno.land/x/hono@v4.2.9/mod.ts";
2import {
3 exported_function,
4 exported_function_with_parameters,
5 exported_number,
6 exported_string_constant,
16 <tr> <th>number </th> <td>${exported_number} </td> </tr>
17 <tr> <th>string </th> <td>${exported_string_constant}</td> </tr>
18 <tr> <th>function </th> <td>${exported_function()} </td> </tr>
19 <tr> <th>with params</th> <td>${exported_function_with_parameters(6, 7)}</td></tr>
20 <tr> <th>class </th> <td>${new ExportedClass()} </td></tr>
21 </table>

telegramWebhookEchoMessagemain.tsx1 match

@ghsaboias•Updated 10 months ago
24});
25
26async function sendMessage(chatId, text) {
27 try {
28 const url = `${TELEGRAM_API_URL}/sendMessage`;

illustratedPrimermain.tsx1 match

@nknj•Updated 10 months ago
4import { zodToJsonSchema } from "npm:zod-to-json-schema";
5
6export default async function handler(req: Request): Promise<Response> {
7 const input = new URL(req.url).searchParams.get("input") || "modernism";
8

salmonMolemain.tsx1 match

@nknj•Updated 10 months ago
59
60// Render streaming markdown
61export default async function handler(req: Request): Promise<Response> {
62 const renderMarkdown = (await import("https://esm.town/v/substrate/renderMarkdown")).default;
63 return renderMarkdown(stream);

openaiproxymain.tsx2 matches

@mmrech•Updated 10 months ago
17
18type User = { id: string; username: string; tier: string };
19export default async function(req: Request): Promise<Response> {
20 // Ensure only allowed pathnames are used
21 const { pathname, search } = new URL(req.url);
81
82// Free users are limited to gpt-4o-mini. Limit pro users to 10 expensive model requests.
83async function limitFreeModel(req: Request, user: User) {
84 const input = await req.json();
85 let model = "gpt-4o-mini";

dependencyLicensesmain.tsx9 matches

@kylem•Updated 10 months ago
16}
17
18// Function to fetch package info from NPM registry
19async function fetchPackageInfo(packageName: string) {
20 const url = `https://registry.npmjs.org/${packageName}`;
21 const response = await fetch(url);
26}
27
28// Function to extract license information from package info
29function extractLicenseInfo(packageInfo: any): string {
30 if (typeof packageInfo.license === "string") {
31 return packageInfo.license;
37}
38
39// Function to extract and normalize GitHub repo URL from package info
40function extractGitHubRepoUrl(packageInfo: any): string {
41 const repository = packageInfo.repository;
42 if (repository) {
63}
64
65function extractRepoNameFromUrl(url: string): string {
66 const match = url.match(/githubusercontent\.com\/[^\/]+\/([^\/]+)/);
67 return match ? match[1] : "";
68}
69
70async function checkPackageLicenses(packageJsonUrl: string): Promise<{ licenses: PackageLicense[]; repoName: string }> {
71 try {
72 const response = await fetch(packageJsonUrl);
98}
99
100function generateLicenseTable(licenses: PackageLicense[]): string {
101 let table = "| Package | Version | License |\n|---------|---------|--------|\n";
102 licenses.forEach(({ name, version, license, repoUrl }) => {

gitReleaseNotesmain.tsx10 matches

@kylem•Updated 10 months ago
16}
17
18// Function to fetch package info from NPM registry
19async function fetchPackageInfo(packageName: string) {
20 const url = `https://registry.npmjs.org/${packageName}`;
21 const response = await fetch(url);
26}
27
28// Function to extract GitHub repo URL from package info
29function extractGitHubRepoUrl(packageInfo: any): string | null {
30 const repository = packageInfo.repository;
31 if (repository && repository.url) {
38}
39
40// Function to get the GitHub repository path (owner/repo) from the URL
41function getGithubRepoPath(repoUrl: string): string | null {
42 const match = repoUrl.match(/github\.com\/([^\/]+\/[^\/]+)/);
43 return match ? match[1] : null;
44}
45
46async function getGithubReleases(repo: string): Promise<GithubRelease[]> {
47 const response = await fetch(`https://api.github.com/repos/${repo}/releases`);
48 if (!response.ok) {
52}
53
54function compareVersions(version1: string, version2: string): number {
55 const v1 = version1.replace(/^v/, "").split(".").map(Number);
56 const v2 = version2.replace(/^v/, "").split(".").map(Number);
63}
64
65async function getReleaseNotesBetweenVersions(repo: string, currentVersion: string): Promise<GithubRelease[]> {
66 const releases = await getGithubReleases(repo);
67
74}
75
76async function checkNpmUpdates(packageJsonUrl: string): Promise<string> {
77 try {
78 const response = await fetch(packageJsonUrl);

valledrawclientmain.tsx4 matches

@d3vobed•Updated 10 months ago
43} = tldraw;
44
45function MakeRealButton() {
46 const editor = useEditor();
47 const { addToast } = useToasts();
53 const { maxX, midY } = editor.getSelectionPageBounds();
54
55 const text = `export default async function main(req: Request): Promise<Response> {
56 return new Response("Hello, World!", {
57 headers: { "Content-Type": "text/plain" },
116}
117
118export function App() {
119 return (
120 <>
257];
258
259function getRotatedBoxShadow(rotation: number) {
260 const cssStrings = ROTATING_BOX_SHADOWS.map((shadow) => {
261 const { offsetX, offsetY, blur, spread, color } = shadow;

anthropicProxymain.tsx1 match

@cephalization•Updated 10 months ago
1import Anthropic from "npm:@anthropic-ai/sdk@0.24.3";
2
3export default async function(req: Request): Promise<Response> {
4 if (req.method === "OPTIONS") {
5 return new Response(null, {

infiniteSVGGraphmain.tsx6 matches

@maxm•Updated 10 months ago
35// Database querying.
36
37function parseResultSet<T>(row: ResultSet): T[] {
38 return row.rows.map((r) => Object.fromEntries(r.map((c, i) => [row.columns[i], c]))) as T[];
39}
67};
68
69// Client side javascript and template functions.
70
71const clientJavascript = async () => {
135 });
136
137 function createHeartBurst(event) {
138 const button = event.currentTarget;
139 const buttonContainer = button.closest(".heart-button-container");
174};
175
176function escapeHTML(html: string): string {
177 const escapeChars: { [char: string]: string } = {
178 "&": "&amp;",
408 let encoder = new TextEncoder();
409
410 function isValidSVG(svgString) {
411 const parser = new DOMParser({
412 errorHandler: {
488
489app.get("/:id/img.svg", async (c) => {
490 function addSVGNamespace(svgString) {
491 if (!/^<\?xml/.test(svgString)) svgString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + svgString;
492 if (!/xmlns="http:\/\/www.w3.org\/2000\/svg"/.test(svgString))

getFileEmail4 file matches

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

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