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=2589&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 28936 results for "function"(2028ms)

linkInBioTemplatemain.tsx1 match

@tdecelle•Updated 11 months ago
2import { renderToString } from "npm:react-dom/server";
3
4export default async function(req: Request) {
5 return new Response(
6 renderToString(

databaseRunnermain.tsx7 matches

@nicosuave•Updated 11 months ago
22const MAX_ROWS_PER_CHUNK = 10000;
23
24export default async function(req: Request): Promise<Response> {
25 console.log("Received request");
26 let requestBody: QueryRequest;
99}
100
101async function executePostgresQuery(url: string, query: string): Promise<any[]> {
102 console.log("Connecting to PostgreSQL");
103 const client = new pg.Client({
136}
137
138async function executeMysqlQuery(url: string, query: string): Promise<any[]> {
139 console.log("Connecting to MySQL");
140 const connection = await mysql.createConnection(url);
163}
164
165async function introspectPostgresSchema(url: string): Promise<any[]> {
166 const query = `
167 SELECT
181}
182
183async function introspectMysqlSchema(url: string): Promise<any[]> {
184 const query = `
185 SELECT
199}
200
201function splitIntoChunks(results: any[], maxRowsPerChunk: number): any[][] {
202 console.log(`Splitting ${results.length} rows into chunks of ${maxRowsPerChunk}`);
203 const chunks = [];
209}
210
211async function createGzipFile(chunk: any[], index: number, shouldGzip: boolean, introspection: boolean): Promise<any> {
212 console.log(`Creating ${shouldGzip ? "gzip" : ""} file for chunk ${index + 1}`);
213 const csv = parse(chunk);

multiplayerCirclesmain.tsx6 matches

@Llad•Updated 11 months ago
37// });
38
39function parseResultSet<T>(row: ResultSet): T[] {
40 return row.rows.map((r) => Object.fromEntries(r.map((c, i) => [row.columns[i], c]))) as T[];
41}
51};
52
53function diffCircles(array1: Circle[], array2: Circle[]): Circle[] {
54 const changes: Circle[] = [];
55
74
75 const drag = (() => {
76 function dragstarted() {
77 d3.select(this).attr("stroke", "black");
78 }
79
80 function dragged(event, d) {
81 d3.select(this).raise().attr("cx", d.x = event.x).attr("cy", d.y = event.y);
82 }
83
84 function dragended() {
85 const x = d3.select(this).attr("cx");
86 const y = d3.select(this).attr("cy");
105 .call(drag)
106 .on("click", clicked);
107 function clicked(event, d) {
108 if (event.defaultPrevented) return; // dragged
109

SolanaJupiterSwapEventParsermain.tsx4 matches

@ryoid•Updated 11 months ago
11`);
12
13export function publicKey(data: Uint8Array, offset: number) {
14 return base58.encode(data.subarray(offset, offset + 32));
15}
16
17export function u64(view: DataView, offset: number) {
18 return view.getBigUint64(offset, true);
19}
20
21export function parseSwapEvent(data: Uint8Array) {
22 const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
23 return {
32console.log(parseSwapEvent(input));
33
34function bytes(str: string): Uint8Array {
35 return base16.decode(str.replaceAll(/\s/g, "").toUpperCase());
36}

forwardermain.tsx1 match

@natashatherobot•Updated 11 months ago
1import { email } from "https://esm.town/v/std/email?v=11";
2
3export function forwarder(e: {
4 from: string;
5 to: string[];

socialMetaTestmain.tsx1 match

@jesusgollonet•Updated 11 months ago
2import { renderToString } from "npm:react-dom/server";
3
4export default async function(req: Request) {
5 const description = "social meta test";
6 const title = "JGB Test";

blobREADME.md1 match

@natashatherobot•Updated 11 months ago
57### Utilities
58
59Our Blob SDK also includes some utility functions to make working with blobs easier.
60
61##### Copy

blobmain.tsx9 matches

@natashatherobot•Updated 11 months ago
4
5/**
6 * Provides functions for interacting with your account's blob storage.
7 * Blobs can store any data type (text, JSON, images, etc.) and allow
8 * retrieval across different vals using the same key.
80};
81
82async function list(prefix?: string): Promise<{ key: string; size: number; lastModified: string }[]> {
83 let querystring = prefix ? `?prefix=${encodeURIComponent(prefix)}` : "";
84 const res = await fetch(`${API_URL}/v1/blob${querystring}`, {
94}
95
96async function delete_(key: string) {
97 const res = await fetch(`${API_URL}/v1/blob/${encodeURIComponent(key)}`, {
98 method: "DELETE",
107}
108
109async function get(key: string) {
110 const res = await fetch(`${API_URL}/v1/blob/${encodeURIComponent(key)}`, {
111 headers: {
123}
124
125async function set(key: string, value: BodyInit) {
126 const res = await fetch(`${API_URL}/v1/blob/${encodeURIComponent(key)}`, {
127 method: "POST",
137}
138
139async function copy(previous: string, next: string) {
140 const res = await get(previous);
141 await set(next, res.body);
142}
143
144async function move(previous: string, next: string) {
145 await copy(previous, next);
146 await delete_(previous);
147}
148
149async function getJSON(key: string) {
150 try {
151 const res = await get(key);
159}
160
161async function setJSON(key: string, value: any) {
162 return set(key, JSON.stringify(value));
163}

dubLinksUpsertmain.tsx1 match

@steventey•Updated 11 months ago
6});
7
8export default async function(req: Request): Promise<Response> {
9 const { shortLink } = await dub.links.upsert({
10 url: "https://www.val.town/v/steventey/dubLinksUpsert",

blobbyFacemain.tsx4 matches

@rupello•Updated 11 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 },
tuna

tuna9 file matches

@jxnblk•Updated 16 hours ago
Simple functional CSS library for Val Town

getFileEmail4 file matches

@shouser•Updated 1 month ago
A helper function to build a file's email
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": "*",
webup
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.