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=767&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 7804 results for "function"(488ms)

compileAndUploadTinygoWasmmain.tsx1 match

@maxm•Updated 11 months ago
59const resp = await fetch("${url}");
60const handler = await wasmHandler(new Uint8Array(await resp.arrayBuffer()));
61export default async function(req: Request): Promise<Response> {
62 return handler(req);
63}`);

tinygoWasmHelloWorldmain.tsx1 match

@maxm•Updated 11 months ago
2const resp = await fetch("https://maxm-wasmBlobHost.web.val.run/jpxqvyy5tphiwehzklmioklpkpz4gpzs.wasm");
3const handler = await wasmHandler(new Uint8Array(await resp.arrayBuffer()));
4export default async function(req: Request): Promise<Response> {
5 return handler(req);
6}

wasmBlobHostmain.tsx7 matches

@maxm•Updated 11 months ago
10const WASM_BLOB_PREFIX = `${author}-${name}-wasm-wasm-blob-v1-`;
11
12async function readAllBytes(stream: ReadableStream<Uint8Array>): Promise<Buffer> {
13 const reader = stream.getReader();
14 const chunks: Uint8Array[] = [];
25}
26
27function getSha256Hash(buffer: Buffer): string {
28 return base32Encode(
29 createHash("sha256").update(buffer).digest().slice(0, 20),
32 ).toLowerCase();
33}
34function trimPrefix(str, prefix) {
35 if (str.startsWith(prefix)) {
36 return str.slice(prefix.length);
38 return str;
39}
40function trimSuffix(str, suffix) {
41 if (str.endsWith(suffix)) {
42 return str.slice(0, -suffix.length);
52};
53
54function formatBytes(bytes: number): string {
55 if (bytes === 0) return "0B";
56
64}
65
66function relativeTimeFromNow(dateString: string): string {
67 const now = new Date();
68 const date = new Date(dateString);
83}
84
85export default async function(req: Request): Promise<Response> {
86 if (req.method === "POST") {
87 const body = await readAllBytes(req.body);

compileAndUploadTinygoWasmREADME.md1 match

@maxm•Updated 11 months ago
36const resp = await fetch("https://maxm-wasmBlobHost.web.val.run/jpxqvyy5tphiwehzklmioklpkpz4gpzs.wasm");
37const handler = await wasmHandler(new Uint8Array(await resp.arrayBuffer()));
38export default async function(req: Request): Promise<Response> {
39 return handler(req);
40}

tinygoHttpmain.tsx5 matches

@maxm•Updated 11 months ago
40}
41
42function callHandlerWithString(
43 instance: WebAssembly.Instance,
44 payload: string,
47 return callHandlerWithBytes(instance, bytes);
48}
49function callHandlerWithJson(instance: WebAssembly.Instance, payload: any) {
50 const bytes = new TextEncoder("utf8").encode(JSON.stringify(payload));
51 return callHandlerWithBytes(instance, bytes);
54const MASK = 2n ** 32n - 1n;
55
56function callHandlerWithBytes(
57 instance: WebAssembly.Instance,
58 bytes: Uint8Array,
88}
89
90async function handleRequest(
91 instance: WebAssembly.Instance,
92 req: Request,
108}
109
110export async function wasmHandler(wasmBytes: Uint8Array): Promise<(Request) => Promise<Response>> {
111 const init = async (wasmBytes: Uint8Array) => {
112 const context = new Context({ args: [], env: Deno.env.toObject() });

wasmBlobHostmain.tsx4 matches

@tmcw•Updated 11 months ago
9const WASM_BLOB_PREFIX = `${author}-${name}-wasm-wasm-blob`;
10
11async function readAllBytes(stream: ReadableStream<Uint8Array>): Promise<Buffer> {
12 const reader = stream.getReader();
13 const chunks: Uint8Array[] = [];
24}
25
26function getSha256Hash(buffer: Buffer): string {
27 const hash = createHash("sha256");
28 hash.update(buffer);
29 return hash.digest("hex");
30}
31function trimPrefix(str, prefix) {
32 if (str.startsWith(prefix)) {
33 return str.slice(prefix.length);
39};
40
41export default async function(req: Request): Promise<Response> {
42 if (req.method === "POST") {
43 const body = await readAllBytes(req.body);

valTownBadgeMiddlewaremain.tsx2 matches

@jxnblk•Updated 11 months ago
1import valTownBadge from "https://esm.town/v/jxnblk/valTownBadge02";
2
3export default function badgeMiddleware(handler, url: string) {
4 return async function(req: Request): Promise<Response> {
5 if (req.method !== "GET") return await handler(req);
6

valTownBadgemain.tsx2 matches

@jxnblk•Updated 11 months ago
1function getHREF(mod) {
2 const url = new URL(mod);
3 return `https://val.town${url.pathname}`;
8}
9
10export default function GetBadgeHTML(url: string, opts: BadgeOptions = {}): string {
11 const href = getHREF(url);
12 const {

imgGenUrlmain.tsx1 match

@maxm•Updated 11 months ago
6};
7
8export default async function(req: Request): Promise<Response> {
9 let key = new URL(req.url).pathname;
10 let url = await blob.getJSON(genKey(key));

valTownBadgeExamplemain.tsx1 match

@jxnblk•Updated 11 months ago
4import { render } from "npm:preact-render-to-string";
5
6function handler(req: Request): Promise<Response> {
7 const body = render(
8 <div>

getFileEmail4 file matches

@shouser•Updated 6 days ago
A helper function to build a file's email

TwilioHelperFunctions

@vawogbemi•Updated 2 months ago