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/$1?q=function&page=2353&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 27812 results for "function"(9437ms)

renderFormAndSaveDataREADME.md1 match

@nicosql•Updated 8 months ago
1# Render form and save data
2
3This val provides a web-based interface for collecting email addresses. It features a dual-functionality approach: when accessed via a web browser using a GET request, it serves an HTML form where users can submit their email address. If the script receives a POST request, it implies that the form has been submitted, and it proceeds to handle the incoming data.
4
5Fork this val to customize it and use it on your account.

harshAquamarineRoostermain.tsx7 matches

@nicosql•Updated 8 months ago
31
32// ------------
33// Functions
34// ------------
35
36async function execute(statement: InStatement, args?: InArgs): Promise<ResultSet> {
37 const res = await fetch(`${API_URL}/v1/sqlite/execute`, {
38 method: "POST",
49}
50
51async function batch(statements: InStatement[], mode?: TransactionMode): Promise<ResultSet[]> {
52 const res = await fetch(`${API_URL}/v1/sqlite/batch`, {
53 method: "POST",
64}
65
66function createResError(body: string) {
67 try {
68 const e = zLibsqlError.parse(JSON.parse(body));
85}
86
87function normalizeStatement(statement: InStatement, args?: InArgs) {
88 if (Array.isArray(statement)) {
89 // for the case of an array of arrays
107}
108
109function upgradeResultSet(results: ImpoverishedResultSet): ResultSet {
110 return {
111 ...results,
116// adapted from
117// https://github.com/tursodatabase/libsql-client-ts/blob/17dd996b840c950dd22b871adfe4ba0eb4a5ead3/packages/libsql-client/src/sqlite3.ts#L314C1-L337C2
118function rowFromSql(
119 sqlRow: Array<unknown>,
120 columns: Array<string>,

hexmazemain.tsx6 matches

@pperi•Updated 8 months ago
14let colorIndex: number
15
16export function setup() {
17 console.log("setup")
18 // variables
77}
78
79function hexagon(x, y, r, c) {
80 let hx = (i) => x + sin((i * 2 * PI) / 6) * (i < 0 ? 0 : r)
81 let hy = (i) => y + cos((i * 2 * PI) / 6) * (i < 0 ? 0 : r)
201}
202
203function drawBorder(border, strokeW = 0) {
204 strokeWeight(0)
205 rect(0, 0, border, height)
216}
217
218export function draw() {}
219
220export function keyPressed() {
221 if (key == "i") {
222 saveCanvas("p5js-" + new Date().getTime(), "png")
226 }
227}
228// export function touchEnded() {
229// saveCanvas("p5js-" + new Date().getTime(), "png");
230// }

blobbymain.tsx3 matches

@yawnxyz•Updated 8 months ago
7export class Blobby {
8 // by default we have no prefixes or scope, whicm neans these will need to be managed by
9 // the setters / calling function. These are used as shortcuts, but they can cause a lot of confusion
10 // if you forget they were set (oops)
11
66 return bloblist.map((blob) => blob.slice(prefix.length + scope.length));
67 }
68 // prefer using the static version to strip instead, on the calling function
69 static strip(bloblist, prefix?, scope?) {
70 return bloblist.map((blob) => blob.slice(prefix.length + scope.length));
216}
217
218function getContentType(key: string): string {
219 const extension = key.split(".").pop()?.toLowerCase();
220 switch (extension) {

convertEmailToBlogDraftmain.tsx1 match

@georgemandis•Updated 8 months ago
19import { email } from "https://esm.town/v/std/email";
20
21export default async function(emailData: Email) {
22 // Extract email content
23 const htmlContent = emailData.text;

LetterMatchmain.tsx3 matches

@efoley•Updated 8 months ago
35};
36
37function App() {
38 const [currentLetter, setCurrentLetter] = useState('');
39 const [options, setOptions] = useState([]);
124}
125
126function client() {
127 createRoot(document.getElementById("root")).render(<App />);
128}
130if (typeof document !== "undefined") { client(); }
131
132export default async function server(request: Request): Promise<Response> {
133 return new Response(`
134 <html>

jsonVisualizerAppmain.tsx3 matches

@all•Updated 8 months ago
8SyntaxHighlighter.registerLanguage('json', json);
9
10function App() {
11 const [jsonInput, setJsonInput] = useState('');
12 const [parsedJson, setParsedJson] = useState('');
57}
58
59function client() {
60 createRoot(document.getElementById("root")).render(<App />);
61}
63if (typeof document !== "undefined") { client(); }
64
65export default async function server(request: Request): Promise<Response> {
66 return new Response(`
67 <html>

oddSalmonCrayfishmain.tsx4 matches

@matthamlin•Updated 8 months ago
12]
13
14function shuffleArray(arr) {
15 return arr.toSorted(() => {
16 return Math.random() > 0.5 ? 1 : -1
26];
27
28function reducer(state) {
29 return state + 1;
30}
31
32function App() {
33 let [count, dispatch] = useReducer(reducer, 0);
34
43}
44
45export function renderApp() {
46 let root = createRoot(document.getElementById("root")!);
47

bbrunmain.tsx2 matches

@kenbarrett•Updated 8 months ago
2
3/**
4 * You can supply these options as a second argument to the `proxy` function.
5 * These options are used to configure the frontend.
6 */
135
136export const proxy = (url: string, options?: FrontendOptions) => {
137 return async function(req: Request): Promise<Response> {
138 if (req.method === "GET") {
139 return renderFrontend(url, options);

BrowserbaseFetcherFromURLmain.tsx1 match

@willthereader•Updated 8 months ago
4const TIMEOUT = 30000; // 30 seconds timeout
5
6export default async function server(request: Request): Promise<Response> {
7 // Array of URLs to scrape
8 const urls = [

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 1 month ago
Simple functional CSS library for Val Town
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.