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=789&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 8323 results for "function"(526ms)

test_explorer_routermain.tsx2 matches

@maxm•Updated 10 months ago
63});
64
65async function loadTests(): Promise<TestType[]> {
66 const query = `https://esm.town/v/${author}/test_explorer`;
67 const { data: vals } = await api(`/v1/search/vals?query=${query}`, { authenticated: true });
90}
91
92async function loadHistory(): Promise<HistoryEntry[]> {
93 try {
94 const entries = await readHistory();

routermain.tsx2 matches

@maxm•Updated 10 months ago
62});
63
64async function loadTests(): Promise<TestType[]> {
65 const query = `https://esm.town/v/${author}/test_explorer`;
66 const { data: vals } = await api(`/v1/search/vals?query=${query}`, { authenticated: true });
89}
90
91async function loadHistory(): Promise<HistoryEntry[]> {
92 try {
93 const entries = await readHistory();

blobbyFacemain.tsx4 matches

@stevekrouse•Updated 10 months ago
17
18
19async function streamToBuffer(stream) {
20 const chunks = [];
21 const reader = stream.getReader();
32}
33
34async function detectFileType(buffer) {
35 const type = await fileTypeFromBuffer(buffer);
36 // return type ? type.mime : 'unknown';
42
43
44export async function get(key, c) {
45 let result = await blobby.get(key);
46 // console.log('raw result for key:', result, typeof result);
185 newKeyName: '',
186
187 init: async function() {
188 console.log('blobby:', this.blobby);
189 },

counterTownmain.tsx6 matches

@stevekrouse•Updated 10 months ago
4import { Hono } from "npm:hono";
5
6function setupTable() {
7 return sqlite.execute(`create table if not exists counter_town (
8 time timestamp default current_timestamp,
21// TODO - we should probably not expose this to our users
22// this rewrite removes that and stores the url underneath
23function removeCustomDomainRewriter(req) {
24 const servedFor = req.headers.get("x-served-for");
25 return req.url.replace("saascustomdomains.val.run", servedFor);
26}
27
28function countRequest(req: Request) {
29 console.log(req);
30 return sqlite.execute({
41}
42
43export function counterTownMiddleware(handler) {
44 return async function(req: Request) {
45 // don't await this so it doesn't add to the timing
46 countRequest(req).catch(e => console.error(e));
125
126// zipped execute
127async function execute(sql) {
128 const results = await sqlite.execute(sql);
129 return results.rows.map(row =>

slack_cleanermain.tsx12 matches

@stevekrouse•Updated 10 months ago
1export function slackHTMLToMarkdown(html) {
2 removeAbsolutePositioning();
3
9 let markdown = "";
10
11 function convertMessage(messageElement) {
12 function safeGetAttribute(selector, attribute) {
13 const element = messageElement.querySelector(selector);
14 return element ? element.getAttribute(attribute) : "";
28 let messageMarkdown = "";
29
30 function processNode(node) {
31 if (node.nodeType === Node.TEXT_NODE) {
32 return node.textContent;
122 // -----
123
124 function postProcessMarkdown(markdown) {
125 // Split the markdown into lines
126 let lines = markdown.split("\n");
155 }
156
157 function parseTimestamp(ariaLabel) {
158 const now = new Date();
159 const months = [
203 }
204
205 function removeAbsolutePositioning() {
206 // Get all elements on the page
207 var allElements = document.getElementsByTagName("*");
333 import { marked } from "https://cdn.jsdelivr.net/npm/marked/lib/marked.esm.js";
334
335 window.convertToMarkdown = function() {
336 const htmlInput = document.getElementById("htmlInput").innerHTML;
337 const markdown = slackHTMLToMarkdown(htmlInput);
341 }
342
343 function copyToClipboard(selector, { html }) {
344 const target = document.querySelector(selector);
345
352 }
353
354 function copyMarkdownAndHTMLToClipboard() {
355 const mdTarget = document.querySelector('#markdownOutput');
356 const htmlTarget = document.querySelector('#renderedMarkdown');
364 }
365
366 async function pasteFromClipboard() {
367 const clipboardItems = await navigator.clipboard.read();
368 for (const clipboardItem of clipboardItems) {
407`;
408
409export default async function(req: Request) {
410 return new Response(html, {
411 headers: {

wikiOGmain.tsx3 matches

@stevekrouse•Updated 10 months ago
1async function getWikipediaInfo(url: string) {
2 // Extract the title from the URL
3 const title = url.split("/wiki/")[1];
25}
26
27export default async function(req: Request): Promise<Response> {
28 const url = new URL(req.url);
29 const path = url.pathname.replace(/^\/proxy/, "");
51 ${ogMetaTags}
52 <script type="text/javascript">
53 setTimeout(function() {
54 window.location.href = "${wikipediaUrl}";
55 }, 0);

yellowSpidermain.tsx1 match

@stevekrouse•Updated 10 months ago
1import { jsPython } from "npm:jspython-interpreter";
2const interpreter = jsPython()
3 .addFunction("fetch", fetch);
4const script = `
5 print(fetch("https://datasette.simonwillison.net/simonwillisonblog/blog_quotation.json?_labels=on&_shape=objects").text())

dateme_router_hydratedmain.tsx3 matches

@stevekrouse•Updated 10 months ago
9
10// Generic loader that forwards on requests for that page's JSON data
11function loader({ request }) {
12 return fetch(request, {
13 headers: {
18
19// Generic action that forwards on non-get Requests
20function action({ request }) {
21 if (request.method === "GET") { throw Error("GET not expected here - something is wrong."); }
22 return fetch(request);
23}
24
25function makeClientSide(routes) {
26 return routes.map(route => {
27 return {

dateme_routesmain.tsx1 match

@stevekrouse•Updated 10 months ago
37];
38
39function Success() {
40 return (
41 <div className="max-w-md text-lg mx-auto p-6">

dateme_home_reactmain.tsx3 matches

@stevekrouse•Updated 10 months ago
2import { useEffect, useState } from "https://esm.sh/react@18.2.0";
3
4async function getCurrentPosition(opts): Promise<GeolocationPosition> {
5 return new Promise((resolve, reject) => {
6 if (!navigator?.geolocation) {
12}
13
14async function reverseGeocodeNominat(lat, lng) {
15 const url = `https://nominatim.openstreetmap.org/reverse?format=json&lat=${lat}&lon=${lng}&zoom=13`;
16 const response = await fetch(url);
19}
20
21export default function Home() {
22 const [locationName, setLocationName] = useState("");
23 useEffect(() => {

getFileEmail4 file matches

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

TwilioHelperFunctions

@vawogbemi•Updated 2 months ago