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=1634&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 18319 results for "function"(3823ms)

hono_countermain.tsx1 match

@pomdtr•Updated 1 year ago
3import { useState } from "https://esm.sh/hono/jsx/dom";
4
5export default function Counter(props: { initialCount?: number }) {
6 const [count, setCount] = useState(props.initialCount || 0);
7 return (

test_explorer_historymain.tsx3 matches

@pomdtr•Updated 1 year ago
10};
11
12export async function createHistory() {
13 const resp = await sqlite.execute(`CREATE TABLE test_history (
14 val_slug TEXT,
20}
21
22export async function readHistory(): Promise<HistoryEntry[]> {
23 const { columns, rows } = await sqlite.execute("SELECT * from test_history");
24 const history = rows.map(row =>
31}
32
33export async function writeHistory(entries: HistoryEntry[]) {
34 const resp = await sqlite.execute(
35 sql`INSERT OR REPLACE INTO test_history (val_slug, test_name, status, last_run_at) VALUES ${

honoExamplemain.tsx1 match

@bis•Updated 1 year ago
8});
9
10function capitalize(string) {
11 return string.charAt(0).toUpperCase() + string.slice(1);
12}

metamain.tsx10 matches

@postpostscript•Updated 1 year ago
5const moduleSourceCache = new Map<string, string>();
6
7export async function importModule<ModuleType>(moduleName: string, checkPrivacy = true) {
8 const url = moduleName[0] === "@"
9 ? `https://esm.town/v/${moduleName.slice(1)}`
30}
31
32export function moduleSource(moduleName: string) {
33 const url = moduleName[0] === "@"
34 ? `https://esm.town/v/${moduleName.slice(1)}`
45}
46
47export async function moduleSourceHash(moduleName: string) {
48 return sha(await moduleSource(moduleName));
49}
50
51export async function call<ModuleType, const TMethod extends string | string[]>(
52 moduleName: string,
53 methodName: TMethod,
59 const module = await importModule<ModuleType>(moduleName);
60 const method = accessDeep(module, methodName);
61 if (!(method instanceof Function)) {
62 const key = methodName instanceof Array
63 ? methodName.join(".")
68}
69
70export function getValNameFromUrl(url: string) {
71 // https://esm.town/v/postpostscript/meta?v=11
72 // @^^^^^^^^^^^^^^^^^^^
74}
75
76export function getValEmailFromUrl(url: string) {
77 // e.g. postpostscript.callbackEmail@valtown.email
78 const name = url.split("?")[0].split("/").slice(4, 6).join(".");
80}
81
82export function getValEndpointFromUrl(url: string) {
83 // https://esm.town/v/postpostscript/meta?v=11
84 // ^^^^^^^^^^^^^^^^^^^
86}
87
88export function getValEndpointFromName(url: string) {
89 const [handle, name] = url.split(/[^\w]/g).filter(Boolean);
90 return `https://${[handle, name].join("-").toLowerCase()}.web.val.run`;
91}
92
93export function getValUrlFromName(name: string, domain = "esm.town") {
94 const _name = name.replace("@", "");
95 return `https://${domain}/v/${_name}`;

provideBlobToHtmlmain.tsx1 match

@postpostscript•Updated 1 year ago
4export { provideBlob } from "https://esm.town/v/postpostscript/provideBlob";
5
6export function provideBlobToHtml(jsPromise: RawHTML, placeholder?: unknown) {
7 const id = "provideBlobHtml-" + Math.random().toString().slice(3);
8 return html`

search_liked_valsmain.tsx1 match

@pomdtr•Updated 1 year ago
2import { valToListItem } from "https://esm.town/v/pomdtr/val_to_listitem";
3
4export default async function(ctx: BrowserContext<{ user: string }>) {
5 const { user: userID } = ctx.params;
6 const resp = await fetch(`https://api.val.town/v1/me/likes?limit=100`, {

recommendsmain.tsx3 matches

@postpostscript•Updated 1 year ago
1import { html } from "https://esm.town/v/postpostscript/html";
2
3export async function randomLike() {
4 const { data } = await fetch("https://api.val.town/v1/me/likes", {
5 headers: {
11}
12
13export async function randomLikeLink() {
14 try {
15 const { author: { username }, name } = await randomLike();
25}
26
27export async function recommends() {
28 return html`
29 Check out a random Val I've liked!

vuemain.tsx2 matches

@postpostscript•Updated 1 year ago
5export { Vue };
6
7export function vueSfc(name: string, template: string) {
8 window.moduleCache ??= {
9 vue: Vue,
52}
53
54export function vueSfcInline(strings: TemplateStringsArray, ...replacements: any[]) {
55 const id = rawHtml`vueSfcInline-${Math.random().toString().slice(3)}`;
56

fetchBlueskyPostmain.tsx1 match

@vladimyr•Updated 1 year ago
3import ky from "npm:ky";
4
5export async function fetchPost(url: string | URL) {
6 const postURL = new URL(url);
7 if (postURL.hostname !== "bsky.app") {

pinkGuanacomain.tsx3 matches

@vladimyr•Updated 1 year ago
2
3const { greet } = await import(jsm`
4export function greet(name) {
5 console.log(\`Hello \${name}!\`);
6}
10
11const { sum } = await import(tsm`
12export function sum(a: number, b: number): number {
13 return a + b;
14}
17
18const { shout } = await import(createModuleURL(
19 `export function shout(name: string) {
20 console.log(\`HELLO \${name.toUpperCase()}!\`);
21 }`,

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 2 weeks ago
Simple functional CSS library for Val Town
webup
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.
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": "*",