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=1316&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 18324 results for "function"(1288ms)

cekdatatruckmain.tsx5 matches

@nirwan•Updated 5 months ago
16const transportTypes = ["Industri", "SPBU", "Kero"];
17
18function AddVehicleForm({ company, onVehicleAdded, onCancel }) {
19 const [formData, setFormData] = useState({
20 plateNumber: "",
115}
116
117function AllVehiclesTable({ onClose }) {
118 const [vehicles, setVehicles] = useState([]);
119 const [sortConfig, setSortConfig] = useState({ key: null, direction: "ascending" });
202}
203
204function App() {
205 const [selectedCompany, setSelectedCompany] = useState(null);
206 const [showScanner, setShowScanner] = useState(false);
450}
451
452function client() {
453 createRoot(document.getElementById("root")).render(<App />);
454}
456if (typeof document !== "undefined") { client(); }
457
458export default async function server(request: Request): Promise<Response> {
459 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
460 const SCHEMA_VERSION = 2;

qualityBrownTyrannosaurusmain.tsx3 matches

@natsa•Updated 5 months ago
5const STORAGE_KEY = "nodeJSLearningPath";
6
7function NodeJSLearningRoadmap() {
8 const [learningPath, setLearningPath] = useState(() => {
9 const savedPath = localStorage.getItem(STORAGE_KEY);
168}
169
170function client() {
171 createRoot(document.getElementById("root")).render(<NodeJSLearningRoadmap />);
172}
173if (typeof document !== "undefined") { client(); }
174
175export default async function server(request: Request): Promise<Response> {
176 return new Response(
177 `

email_jokemain.tsx1 match

@kswang06•Updated 5 months ago
2
3// Fetches a random joke.
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",

blobREADME.md1 match

@bons•Updated 5 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

@bons•Updated 5 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<T = unknown>(key: string): Promise<T> {
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}

sqliteExplorerAppREADME.md1 match

@lecoto•Updated 5 months ago
33- [x] fix wonky sidebar separator height problem (thanks to @stevekrouse)
34- [x] make result tables scrollable
35- [x] add export to CSV, and JSON (CSV and JSON helper functions written in [this val](https://www.val.town/v/nbbaier/sqliteExportHelpers). Thanks to @pomdtr for merging the initial version!)
36- [x] add listener for cmd+enter to submit query

blob_adminmain.tsx1 match

@lecoto•Updated 5 months ago
18const PASSWORD_KEY = `${"blob_admin"}_admin_password`;
19
20async function getOrSetPassword() {
21 try {
22 const storedPassword = await blob.get(PASSWORD_KEY);

tidyRedWhalemain.tsx3 matches

@websrai•Updated 5 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function AssistantChat() {
6 const [messages, setMessages] = useState<{role: string, content: string}[]>([
7 { role: 'system', content: 'You are a helpful AI assistant named ValAI, capable of understanding and assisting with various tasks.' }
77}
78
79function client() {
80 createRoot(document.getElementById("root")).render(<AssistantChat />);
81}
82if (typeof document !== "undefined") { client(); }
83
84export default async function server(request: Request): Promise<Response> {
85 if (request.method === 'POST' && new URL(request.url).pathname === '/chat') {
86 const { OpenAI } = await import("https://esm.town/v/std/openai");

ImageSummaryEmailmain.tsx3 matches

@jackd•Updated 5 months ago
2import { email } from "https://esm.town/v/std/email";
3
4export default async function(e: Email) {
5 console.log("Email received!", e.from, e.subject);
6
32}
33
34function formatEmailContent(observations: string[]): string {
35 const listItems = observations
36 .map(obs => `<li style="margin-bottom: 8px;">${obs}</li>`)
46}
47
48async function sendReply(to: string, subject: string, body: string) {
49 await email({
50 subject,

generateImageSummarymain.tsx1 match

@jackd•Updated 5 months ago
2import { fileToDataURL } from "https://esm.town/v/stevekrouse/fileToDataURL";
3
4export async function generateImageSummary(image: File): Promise<string[]> {
5 const openai = new OpenAI();
6 const dataURL = await fileToDataURL(image);

getFileEmail4 file matches

@shouser•Updated 1 week 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
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.