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=1521&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 17289 results for "function"(1208ms)

blobCountermain.tsx1 match

@stevekrouse•Updated 1 year ago
1import { blob } from "https://esm.town/v/std/blob?v=11";
2
3export default async function(req: Request): Promise<Response> {
4 const count = (await blob.getJSON("blobCounter") ?? 0) + 1;
5 await blob.setJSON("blobCounter", count);

dbmain.tsx1 match

@sqlite•Updated 1 year ago
2import type { ResultSet } from "npm:@libsql/client";
3
4async function execute(statement: InStatement): Promise<ResultSet> {
5 const resp = await fetch("https://sqlite-execute.web.val.run", {
6 method: "POST",

leaderboardmain.tsx1 match

@pomdtr•Updated 1 year ago
4import stripAnsi from "npm:strip-ansi";
5
6export default async function() {
7 const res = await db.execute(
8 "SELECT author_username, COUNT(*) AS val_count FROM vals GROUP BY author_username ORDER BY 2 DESC LIMIT 10",

sqliteBlobmain.tsx2 matches

@postpostscript•Updated 1 year ago
3import { blob as blobAPI } from "https://esm.town/v/std/blob";
4
5export async function sqliteBlob(options: SqliteBlobOptions = {}) {
6 const schema = sqliteBlobSchema(options);
7 const sqlite = createSqlite();
10}
11
12export async function sqliteBlobSchema(
13 { prefix = undefined, table = Statement`blobs`, blob = blobAPI }: SqliteBlobOptions = {},
14) {

sqliteUniversemain.tsx5 matches

@postpostscript•Updated 1 year ago
16};
17
18export function sqliteUniverseWithOptions(options: SqliteUniverseOptions) {
19 return {
20 execute(statement: InStatement) {
27}
28
29async function execute(
30 statement: InStatement,
31 options: SqliteUniverseOptions = {},
35}
36
37async function batch(
38 statements: InStatement[],
39 options: SqliteUniverseOptions = {},
83}
84
85async function createSqliteFromEndpointTables(
86 endpointTableMap: EndpointTableMap,
87 { interfaces = defaultInterfaces }: SqliteUniverseOptions = {},
90 let sqlite = await interfaces.exact?.[endpoint];
91
92 if (sqlite instanceof Function) {
93 sqlite = await sqlite({ endpoint, tables });
94 }

duckdbExamplemain.tsx1 match

@neverstew•Updated 1 year ago
3
4export let duckdbExample = (async () => {
5 async function createWorker(url: string) {
6 const workerScript = await fetch(url);
7 const workerURL = URL.createObjectURL(await workerScript.blob());

sqliteBuilderBetamain.tsx1 match

@postpostscript•Updated 1 year ago
83}
84
85export function Statement(
86 strings: TemplateStringsArray,
87 ...replacements: (InValue | StatementInstance)[]

extractImportsmain.tsx2 matches

@pomdtr•Updated 1 year ago
2import ts from "npm:typescript";
3
4export function extractImports(code: string): string[] {
5 const sourceFile = ts.createSourceFile(
6 "val.ts",
10 const imports = [];
11
12 function visitNode(node: ts.Node) {
13 if (ts.isImportDeclaration(node)) {
14 const importClause = node.importClause;

webhookHandlermain.tsx1 match

@mux•Updated 1 year ago
8});
9
10export default async function(req: Request): Promise<Response> {
11 if (req.method === "GET") {
12 return Response.json({ ignored: true });

blogSqliteUniversePart2main.tsx1 match

@postpostscript•Updated 1 year ago
2import { getValEndpointFromName } from "https://esm.town/v/postpostscript/meta";
3
4export default function(req: Request) {
5 const { author, name } = extractValInfo(import.meta.url);
6 const blogEndpoint = getValEndpointFromName(`@${author}/blog`);

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
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": "*",