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=972&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"(2675ms)

regexWordSearchPagemain.tsx4 matches

@jrunning•Updated 2 months ago
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function App() {
6 const [searchTerm, setSearchTerm] = useState("");
7 const [words, setWords] = useState<string[]>([]);
15
16 useEffect(() => {
17 async function fetchWords() {
18 try {
19 const response = await fetch('https://raw.githubusercontent.com/dwyl/english-words/refs/heads/master/words.txt');
241};
242
243function client() {
244 createRoot(document.getElementById("root")).render(<App />);
245}
246if (typeof document !== "undefined") { client(); }
247
248export default async function server(request: Request): Promise<Response> {
249 return new Response(`
250 <html>

Hello_Worldmain.tsx1 match

@rozek•Updated 2 months ago
5const Granularity = 15*60*1000
6
7export default async function (Request:Request):Promise<Response> {
8 if (Request.method !== 'GET') {
9 return new Response('Method Not Allowed', { status:405 })

parseTransactionsmain.tsx3 matches

@bao•Updated 2 months ago
3import React, { useEffect, useState } from "https://esm.sh/react@18.2.0";
4
5function TransactionParser() {
6 const [inputLog, setInputLog] = useState("");
7 const [transactions, setTransactions] = useState([]);
264};
265
266function client() {
267 createRoot(document.getElementById("root")).render(<TransactionParser />);
268}
269if (typeof document !== "undefined") { client(); }
270
271export default async function server(request: Request): Promise<Response> {
272 return new Response(
273 `

TestProjectintimateIndigoRook1 match

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

DenoProject1visionaryFuchsiaMongoose1 match

@vyatka•Updated 3 months ago
1export default async function (interval: Interval) {
2
3}

githubParsermain.tsx19 matches

@yawnxyz•Updated 3 months ago
182 const repoList = document.getElementById('repoList');
183 const ignoredPatternsTextarea = document.getElementById('ignoredPatterns');
184 async function updateRepoList() {
185 const repos = await db.repositories.toArray();
186 repoList.innerHTML = repos.map(repo =>
211 });
212
213 function displayRepoData(repo) {
214 resultArea.value = repo.content;
215 updateStats(repo.content);
217 }
218
219 function updateStats(content) {
220 const bytes = new TextEncoder().encode(content).length;
221 const kb = bytes / 1024;
227 }
228
229 function updateTokenCounts(tokenCounts) {
230 tokenCountCl100k.textContent = tokenCounts.cl100k_base.toLocaleString();
231 tokenCountP50k.textContent = tokenCounts.p50k_base.toLocaleString();
234 }
235
236 // Add this new function to parse the patterns
237 function parseIgnoredPatterns() {
238 return ignoredPatternsTextarea.value
239 .split('\\n')
243
244
245 async function fetchFileTypes(repoUrl) {
246 const response = await fetch('/file-types', {
247 method: 'POST',
257 }
258
259 function displayFileTypeSelector(fileTypes, ignoredPatterns) {
260 const fileTypeSelectorDiv = document.getElementById('fileTypeSelector');
261 const fileTypeList = document.getElementById('fileTypeList');
528});
529
530function getTiktokenSegments(encoder, inputText) {
531 try {
532 const tokens = encoder.encode(inputText);
566}
567
568function getFileExtension(filename) {
569 const parts = filename.split('.');
570 return parts.length > 1 ? '.' + parts.pop().toLowerCase() : 'no-extension';
572
573
574function getFileType(path) {
575 // Handle directories
576 if (path.endsWith('/')) {
587}
588
589async function fetchRepositoryContent(owner, repo, specifiedBranch = null, ignoredPatterns, selectedTypes = null) {
590 // First, try to get the default branch or use the specified branch
591 const repoInfoUrl = `https://api.github.com/repos/${owner}/${repo}`;
661}
662
663async function fetchFileContent(owner, repo, path, branch) {
664 const apiUrl = `https://api.github.com/repos/${owner}/${repo}/contents/${path}`;
665 const response = await fetch(apiUrl, {
678}
679
680function getIgnoredPatterns() {
681 return [
682 // Folders
754}
755
756function shouldIgnoreFile(path, ignoredPatterns) {
757 // Special case for README.md
758 if (path.toLowerCase() === 'readme.md') {
763}
764
765async function countTokens(text) {
766 const encoders = {
767 cl100k_base: get_encoding("cl100k_base"),
780}
781
782async function getTokenizedText(text) {
783 const encoder = get_encoding("cl100k_base");
784 const tokens = encoder.encode(text);
819});
820
821// Add new function to get repository file types
822async function getRepositoryFileTypes(owner, repo, specifiedBranch = null) {
823 const repoInfoUrl = `https://api.github.com/repos/${owner}/${repo}`;
824 const repoInfoResponse = await fetch(repoInfoUrl, {

appmain.tsx2 matches

@RIKKAEBI•Updated 3 months ago
8};
9
10function App() {
11 const [isPending, startTransition] = useTransition();
12 const [likes, setLikes] = useState(0);
43}
44
45export default async function server(request: Request): Promise<Response> {
46 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
47 const KEY = "app";

talkAbouttalkAbout1 match

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

OpenRouterChatCompletion_Testmain.tsx1 match

@rozek•Updated 3 months ago
1/**** a simple smoke test for val "OpenRouterChatCompletion" ****/
2
3 export default async function (Request:Request):Promise<Response> {
4 const OpenAIRequest = {
5 messages: [

clearMagentaFlyingfishmain.tsx1 match

@Amr0111•Updated 3 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": "*",