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=1486&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 17287 results for "function"(1773ms)

renderFormAndSaveDataREADME.md1 match

@adamwiggins•Updated 1 year 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.

invoice_schemamain.tsx9 matches

@pomdtr•Updated 1 year ago
79};
80
81function extractTitle(id: string, lang: Language) {
82 switch (lang) {
83 case "fr-FR":
88}
89
90function getTableColumns(lang: Language) {
91 switch (lang) {
92 case "fr-FR":
97}
98
99function formatPrice(price: Number, currency: Currency) {
100 switch (currency.code) {
101 case "USD":
106}
107
108function extractEntity(entity: Entity, lang: Language) {
109 const res: string[] = [];
110
120}
121
122function extractTable(invoice: Invoice, input: {
123 language: Language;
124 currency: Currency;
173}
174
175function formatDate(input: string, lang: Language) {
176 const date = new Date(input);
177 return new Intl.DateTimeFormat(lang, {
180}
181
182function extractNote(invoice: Invoice, lang: Language) {
183 if (typeof invoice.note == "string") {
184 return invoice.note;
187}
188
189function extractDetails(invoice: Invoice, lang: Language) {
190 switch (lang) {
191 case "en-US": {
204}
205
206export function extractParams(invoice: Invoice, input: {
207 currency: Currency;
208 language: Language;

generate_invoicemain.tsx1 match

@pomdtr•Updated 1 year ago
3import open from "npm:open";
4
5function printHelp() {
6 console.log("help");
7}

uploadTo0x0main.tsx1 match

@easrng•Updated 1 year ago
1export async function uploadTo0x0(data, name) {
2 const blob = new Blob([data]);
3 const formData = new FormData();

jsoninvoice_editor_scriptmain.tsx1 match

@pomdtr•Updated 1 year ago
10const currencySelector = document.getElementById("currencies") as HTMLSelectElement;
11
12async function updatePreview() {
13 try {
14 const code = JSON.parse(editor.code);

creativity_quotesmain.tsx1 match

@generatecoll•Updated 1 year ago
1import process from "node:process";
2
3export async function creativity_quote(request: Request): Promise<Response> {
4 const postgres = await import("https://deno.land/x/postgres/mod.ts");
5 const client = new postgres.Client(process.env.neon_url);

TodoAppmain.tsx6 matches

@summerboys•Updated 1 year ago
5import { Form, hydrate } from "https://esm.town/v/stevekrouse/ssr_react_mini?v=75";
6
7export async function loader(req: Request) {
8 const { sqlite } = await import("https://esm.town/v/std/sqlite?v=4");
9 const [, { columns, rows }] = await sqlite.batch([
20}
21
22export async function action(req: Request) {
23 const { sqlite } = await import("https://esm.town/v/std/sqlite?v=4");
24 const formData = await req.formData();
47}
48
49export function Component({ initialTodos, initialLogs }) {
50 const [todos, setTodos] = useState(initialTodos);
51 const [logs, setLogs] = useState(initialLogs);
54 useEffect(() => addLog(`Client rendered`), []);
55
56 function addTodo() {
57 setTodos([...todos, { text: newTodo }]);
58 setNewTodo("");
64 }
65
66 function toggleTodo(e) {
67 const formData = new FormData(e.target);
68 const id = parseInt(formData.get("id") as string);
71 }
72
73 function deleteTodo(e) {
74 const formData = new FormData(e.target);
75 const id = parseInt(formData.get("id") as string);

pollRSSFeedsmain.tsx1 match

@summerboys•Updated 1 year ago
3import { rssFeeds } from "https://esm.town/v/stevekrouse/rssFeeds";
4
5export async function pollRSSFeeds({ lastRunAt }: Interval) {
6 return Promise.all(
7 Object.entries(rssFeeds).map(async ([name, url]) => {

htmlExamplemain.tsx1 match

@summerboys•Updated 1 year ago
1// View at https://andreterron-htmlExample.web.val.run?name=Andre
2export default async function(req: Request): Promise<Response> {
3 const query = new URL(req.url).searchParams;
4

upload_urlmain.tsx2 matches

@stevekrouse•Updated 1 year ago
1// Function to upload data using Wormhole API and return the URL
2async function uploadToFileIo(file) {
3 const formData = new FormData();
4 formData.append("file", file);

getFileEmail4 file matches

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

tuna8 file matches

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