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/$%7Bsuccess?q=function&page=1732&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 19304 results for "function"(1801ms)

listSqliteTablesmain.tsx1 match

@nbbaier•Updated 1 year ago
1import { sqlite } from "https://esm.town/v/std/sqlite?v=4";
2
3export async function listSqliteTables() {
4 return (await sqlite.execute(
5 `select name from sqlite_schema where type='table' and name != 'libsql_wasm_func_table' and name != 'sqlite_sequence'`,

test_explorer_uimain.tsx5 matches

@pomdtr•Updated 1 year ago
57};
58
59function TestItem({ test, run }: { test: Test; run: () => void }) {
60 return (
61 <div>
75}
76
77function groupBySlug(tests: Test[]): Record<string, Test[]> {
78 const groups = {};
79 for (const test of Object.values(tests)) {
89}
90
91function useTests(initialTests: Test[]) {
92 const id = (test: Test) => `${test.val.name}/${test.name}`;
93 const [tests, setTests] = useState(Object.fromEntries(initialTests.map((test) => {
118}
119
120function TestExplorerView({ tests }: Props) {
121 const { groups, runTest } = useTests(tests);
122 return (
187}
188
189export default function(props: { tests: Test[] }) {
190 return (
191 <>

valshotmain.tsx2 matches

@pomdtr•Updated 1 year ago
24export default router.fetch;
25
26export async function createScreenshot(code: string, theme: string = "dark-plus"): Promise<URL> {
27 const apiUrl = "https://sourcecodeshots.com/api/image/permalink";
28 const { url } = await ky.post(apiUrl, {
35}
36
37async function fetchValCode(alias: string): Promise<string> {
38 const prefixUrl = "https://api.val.town/v1/alias";
39 const { code } = await ky.get(alias, { prefixUrl }).json();

authDescribeScopesmain.tsx1 match

@postpostscript•Updated 1 year ago
3import { pathMatches } from "https://esm.town/v/postpostscript/pathAsScope";
4
5export async function authDescribeScopes(scopes: string[]) {
6 return Promise.all(scopes.map(async (scope) => {
7 const [author, name, ..._scopeName] = scope.slice(1).split("/");

filterValsREADME.md1 match

@nbbaier•Updated 1 year ago
1# filterVals
2
3This val exports a utility function that returns a list of all a user's val, filtered by a callback function.
4
5## Example

jwksmain.tsx2 matches

@postpostscript•Updated 1 year ago
20};
21
22export function publicKeys() {
23 try {
24 return JSON.parse(Deno.env.get("JWKS_PUBLIC"));
38});
39
40export default async function(req: Request) {
41 return Response.json(publicKeys());
42}

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}`;

getFileEmail4 file matches

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

tuna8 file matches

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