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/$%7Bsuccess?q=function&page=1666&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 20505 results for "function"(2161ms)

iangac_validatormain.tsx1 match

@pfeffunit•Updated 8 months ago
4const app = new Hono();
5
6function analyzeJSON(jsonData) {
7 const images = jsonData.images;
8 const allIds = new Set(images.map(img => img.id));

globalIncrementmain.tsx6 matches

@benjiwheeler•Updated 8 months ago
1// This val uses Val Town's Blob storage to maintain a shared global integer value.
2// We'll use the val's URL as the storage key for consistency.
3// The main function handles both GET requests to retrieve the current value
4// and POST requests to increment the value.
5// We're using Promises with .then() instead of async/await for asynchronous operations.
10const KEY = "Ben Wheeler globalIncrement test key";
11
12export function getValue(): Promise<number> {
13 return blob.getJSON(KEY)
14 .then(value => typeof value === "number" ? value : 0)
16}
17
18export function increment(): Promise<number> {
19 return getValue()
20 .then(currentValue => {
28}
29
30export default async function(req: Request): Promise<Response> {
31 if (req.method === "POST") {
32 return increment()
39}
40
41export function checkIfWorking(req: Request): Promise<Response> {
42 console.log("working");
43}
44
45// export function main(req: Request): Promise<Response> {
46// }

sqlitemain.tsx7 matches

@nkohari•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>,

webhook1main.tsx1 match

@benjiwheeler•Updated 8 months ago
3};
4
5export function webhook2(a, b) {
6 return a + b;
7}

pglitemain.tsx1 match

@iamseeley•Updated 8 months ago
11`);
12
13export default async function(req: Request): Promise<Response> {
14 const res = await db.query(`
15 UPDATE test

genimagemain.tsx3 matches

@motyar•Updated 8 months ago
10type GeneratedImage = { imageUrl: string; prompt: string };
11
12function App() {
13 const [prompt, setPrompt] = useState("");
14 const [imageUrl, setImageUrl] = useState("");
92}
93
94function client() {
95 createRoot(document.getElementById("root")).render(<App />);
96}
100}
101
102export default async function server(request: Request): Promise<Response> {
103 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
104 const url = new URL(request.url);

pglitemain.tsx1 match

@samwillis•Updated 8 months ago
11`);
12
13export default async function(req: Request): Promise<Response> {
14 const res = await db.query(`
15 UPDATE test

stagingdailyschedulemain.tsx2 matches

@keenanzucker•Updated 8 months ago
5import moment from "npm:moment";
6
7export default async function(req: Request): Promise<Response> {
8 // ============= Data Fetching =================
9 const today = new Date();
63 };
64
65 function groupSchedulesByDate(schedules) {
66 return schedules.reduce((acc, schedule) => {
67 const date = schedule.interval.start.split("T")[0];

aqi_lefkadamain.tsx1 match

@pj0•Updated 8 months ago
2import { easyAQI } from "https://esm.town/v/stevekrouse/easyAQI?v=5";
3
4export async function aqi(interval: Interval) {
5 const location = "lefkada greece"; // <-- change to place, city, or zip code
6 const data = await easyAQI({ location });

concentricCirclesAppmain.tsx4 matches

@kaz•Updated 8 months ago
3 * Below each section, there's a text input field. Each color section can have up to 8 values.
4 * It uses React for the UI and CSS for styling the gradient line and inputs.
5 * It includes a reorder functionality for the items in each section and an expandable "Learn more" section.
6 */
7/** @jsxImportSource https://esm.sh/react */
9import { createRoot } from "https://esm.sh/react-dom/client";
10
11function App() {
12 const [redItems, setRedItems] = useState<string[]>([]);
13 const [yellowItems, setYellowItems] = useState<string[]>([]);
186}
187
188function client() {
189 createRoot(document.getElementById("root")).render(<App />);
190}
191if (typeof document !== "undefined") { client(); }
192
193async function server(request: Request): Promise<Response> {
194
195 return new Response(`

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 3 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.