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/$%7Bart_info.art.src%7D?q=function&page=1642&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 18949 results for "function"(1957ms)

sampleVanSSRmain.tsx3 matches

@reosablo•Updated 1 year ago
3
4/** load client HTML */
5async function loadClientHtml() {
6 // import VanJS framework and App component
7 const [{ default: van }, { default: App }] = await Promise.all([
28
29/** load client script for App component hydration */
30async function loadClientScript() {
31 // import esbuild and plugins
32 const [{ build }, { denoPlugins }] = await Promise.all([
49}
50
51export default async function fetch(req: Request) {
52 try {
53 const { pathname } = new URL(req.url);

uuidGeneratorStreammain.tsx1 match

@reosablo•Updated 1 year ago
1export default async function fetch(req: Request) {
2 const countParam = new URL(req.url).searchParams.get("count");
3 if (countParam === null) {

sampleVanIslandmain.tsx1 match

@reosablo•Updated 1 year ago
9const appId = "3753aa97-a7cf-41d0-bcf4-0ed59d25cd26";
10
11export default function App(props: { van: VanObj }) {
12 const { van } = props;
13 const {

cors_example_backendmain.tsx1 match

@stevekrouse•Updated 1 year ago
1export default async function(req: Request) {
2 const url = new URL(req.url);
3 if (url.pathname === "/default") {

react_httpREADME.md1 match

@stevekrouse•Updated 1 year ago
8import react_http from "https://esm.town/v/stevekrouse/react_http?v=6";
9
10export function App() {
11 const [count, setCount] = useState(0);
12 return (

clone_my_vals_to_sqlitemain.tsx2 matches

@stevekrouse•Updated 1 year ago
21);`;
22
23function valToRow(val) {
24 return [
25 val.id,
35}
36
37async function insertRows(rows) {
38 const query =
39 sql`INSERT OR REPLACE INTO all_my_vals (id, name, code, version, privacy, public, run_start_at, run_end_at, created_at) VALUES ${

fetch_timeoutmain.tsx1 match

@git•Updated 1 year ago
1async function fetchWithTimeout(timeout = 2_000) {
2 const abortSignal = AbortSignal.timeout(timeout);
3

val_town_clientmain.tsx1 match

@stevekrouse•Updated 1 year ago
8 * @param options.token - API token (if null, no token will be used, if undefined, the token from the environment variable "valtown" will be used)
9 */
10export default function createClient(options: {
11 baseUrl?: string;
12 token?: string | null | undefined;

getColormain.tsx2 matches

@stevekrouse•Updated 1 year ago
5const PERCENT_COVERAGE = 10; // lower is faster, but higher is more accurate
6
7function getPixelIndex(numToRound) {
8 // Each pixel is 4 units long: r,g,b,a
9 const remainder = numToRound % 4;
12}
13
14export async function getColor(src: string = EXAMPLE_URL): Promise<string> {
15 const { default: Jimp } = await import("npm:jimp");
16 const image = await Jimp.read(src);

niceSnippetPostmanCodegenmain.tsx15 matches

@mark05e•Updated 1 year ago
1export default async function handler(request: Request) {
2 if (request.method !== "POST") {
3 return Response.json({ message: "This val responds to POST requests." }, { status: 400 });
17}
18
19function writeLog(text = "Hello World") {
20 console.log(text);
21}
22
23function generateSnippet(inputText) {
24 console.clear();
25 // Frontend protection
88}
89
90function genUrlCode(jsonObj) {
91 // console.log(jsonObj)
92 let url = getUrl(jsonObj);
122}
123
124function getUrl(jsonObj) {
125 let protocol = jsonObj["protocol"] || "https";
126 let host = jsonObj["host"].join(".");
148}
149
150function getQueryString(jsonObj) {
151 if (jsonObj["query"] === undefined) {
152 return null;
171}
172
173function genHeaderCode(jsonObj, skipRestProxy = false) {
174 // console.log({jsonObj}) // Array of Object
175 // discoveryProxy.ContentType = "application/json"
208}
209
210function genMethodCode(jsonObj) {
211 // console.log({jsonObj})
212 // Only allowed - GET, POST, PUT, DELETE
220}
221
222function genBodyCode(jsonObj) {
223 // console.log({jsonObj})
224 // console.log(Object.keys(jsonObj).length)
308}
309
310function insertNewLine() {
311 // https://www.cs.cmu.edu/~pattis/15-1XX/common/handouts/ascii.html
312 let enable = true;
318}
319
320function findInsideCurly(line) {
321 // Check for postman vars
322 // https://stackoverflow.com/questions/413071/regex-to-get-string-between-curly-braces
338}
339
340function escapeStrings(line) {
341 let result = JSON.stringify(line);
342 result = line.substring(1);
359}
360
361function genTriggerCode() {
362 let triggerCode =
363 "ASSIGN RestProxy_Response = RestProxy.MakeRestRequest(RestProxy_Url, RestProxy_Body, RestProxy_AcceptType, RestProxy_Method)";
388}
389
390function genAuthCode(jsonObj) {
391 let authCode = "";
392 console.log({ jsonObj });
428}
429
430function isRunningInGoogleAppsScript() {
431 return typeof ScriptApp !== "undefined";
432}

getFileEmail4 file matches

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

tuna8 file matches

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