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=2578&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 28709 results for "function"(2469ms)

getValCodemain.tsx1 match

@janpaul123•Updated 11 months ago
1import { db as allValsDb } from "https://esm.town/v/sqlite/db?v=9";
2
3export default async function getValCode(val) {
4 let code = undefined;
5 for (let attempt = 1; true; attempt++) {

textToImagePlaygroundmain.tsx2 matches

@iamseeley•Updated 11 months ago
60 <script type="module" src="https://esm.town/v/iamseeley/realtimeFormLogic"></script>
61 <script>
62 document.getElementById('generationType').addEventListener('change', function() {
63 const type = this.value;
64 if (type === 'regular') {
82`;
83
84export default async function handler(req: Request): Promise<Response> {
85 const url = new URL(req.url);
86

realtimeFormLogicmain.tsx2 matches

@iamseeley•Updated 11 months ago
11 });
12
13 async function generateImages() {
14 resultDiv.innerHTML = ''; // Clear previous results
15
59 }
60
61 function appendImage(imageUrl, model) {
62 const imgElement = new Image();
63 imgElement.src = imageUrl;

fetchAPImain.tsx1 match

@pomdtr•Updated 11 months ago
1import { API_URL } from "https://esm.town/v/std/API_URL";
2
3export async function fetchAPI(
4 path: string,
5 options?: RequestInit & {

caloriesmain.tsx2 matches

@chriswmartin•Updated 11 months ago
5import { Hono } from "npm:hono@3";
6
7function esmTown(url) {
8 return fetch(url, {
9 headers: {
92});
93
94export async function calorieEstimate(file: File) {
95 const dataURL = await fileToDataURL(file);
96 try {

fileToDataURLmain.tsx1 match

@chriswmartin•Updated 11 months ago
1export async function fileToDataURL(file) {
2 // Read the file as an ArrayBuffer
3 const arrayBuffer = await file.arrayBuffer();

uploadImagemain.tsx2 matches

@chriswmartin•Updated 11 months ago
4 * @returns {string} - uploaded image url
5 */
6export async function uploadImage(image: Blob): Promise<string> {
7 const fd = new FormData();
8 fd.append(
23 return data.result.variants[0];
24}
25async function getUploadURL(): Promise<string> {
26 const data = await (await fetch("https://www.val.town/api/trpc/generateImageUploadUrl", {
27 "headers": {

linkInBioTemplatemain.tsx1 match

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

pwamain.tsx1 match

@pomdtr•Updated 11 months ago
12export type Handler = (req: Request) => Response | Promise<Response>;
13
14export function pwa(handler: Handler, manifest: Partial<ManifestOptions>): Handler {
15 return async (req: Request) => {
16 const url = new URL(req.url);

staleGithubPRsEmailmain.tsx2 matches

@glesica•Updated 11 months ago
5// Sends an email with all the open PRs that have not had any activity
6// for specified period of days
7// Set up this function to run every day (or any interval)
8export async function staleGithubPRsEmail() {
9 // Set up a secret named githubRepos with all the repos you want to analyze (comma separated)
10 let repos = Deno.env.get("githubRepos")?.split(",").filter((r) => r.trim()) ?? [];

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.