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=2455&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"(3387ms)

zestyJadeReptilemain.tsx1 match

@dm3agv•Updated 8 months ago
3import process from "node:process";
4
5export async function serverlessMatrixEchoBot(
6 req: express.Request,
7 res: express.Response,

capturePostHogEventmain.tsx1 match

@ianvph•Updated 8 months ago
1export async function capturePostHogEvent(
2 key: string,
3 distinct_id: string,

peculiarTanMouseREADME.md1 match

@jamisonl•Updated 8 months ago
1Bot for Cama discord server. To initialize new slash commands, you have to run a separate bit of code. This is for modifying their functionality

calculateTransitTimeValmain.tsx9 matches

@rochambeau314•Updated 8 months ago
8import { createRoot } from "https://esm.sh/react-dom/client";
9
10function App() {
11 const [origin, setOrigin] = useState("");
12 const [results, setResults] = useState([]);
149}
150
151function client() {
152 createRoot(document.getElementById("root")).render(<App />);
153}
157}
158
159export default async function server(request: Request): Promise<Response> {
160 console.log("Received request:", request.url);
161 const url = new URL(request.url);
285 });
286 } catch (error) {
287 console.error("Error in server function:", error);
288 return new Response(
289 JSON.stringify({ error: "An error occurred while calculating travel times", details: error.message }),
315}
316
317async function findNearest(origin: string, locations: any[], apiKey: string): Promise<any> {
318 console.log(`Finding nearest location among ${locations.length} options`);
319 const batchSize = 25; // Google Maps API typically allows up to 25 destinations per request
359}
360
361async function getDrivingTime(
362 origin: string,
363 destination: string,
388}
389
390async function getTransitTime(origin: string, destination: string, apiKey: string): Promise<string> {
391 const directionsUrl = `https://maps.googleapis.com/maps/api/directions/json?origin=${
392 encodeURIComponent(origin)
405}
406
407async function getZipCode(address: string, apiKey: string): Promise<string> {
408 const geocodeUrl = `https://maps.googleapis.com/maps/api/geocode/json?address=${
409 encodeURIComponent(address)
422}
423
424function getNextDayOfWeek(date: Date, dayOfWeek: string): Date {
425 const days = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"];
426 const targetDay = days.indexOf(dayOfWeek.toLowerCase());

free_open_routermain.tsx7 matches

@taras•Updated 8 months ago
59}
60
61// Factory function to create the appropriate KV instance
62export function createKV(): KV {
63 return isValTown ? new ValTownKV() : new DenoDeployKV();
64}
66const kv = createKV();
67
68function err(msg): Response {
69 return new Response(
70 JSON.stringify({
84}
85
86function isFreeModel(model: any) {
87 if (model.id.endsWith(":free")) {
88 return true;
98}
99
100function getModelValue(modelId: string): int {
101 const preferences = [
102 [/70b-versatile/],
132}
133
134async function listFreeModels(req: Request) {
135 // Get the current timestamp
136 const timestamp = Date.now();
227}
228
229export default async function(req: Request): Promise<Response> {
230 const url = new URL(req.url);
231 const pathname = url.pathname;

celinewaitlistmain.tsx1 match

@mbo•Updated 8 months ago
5 */
6
7async function server(request: Request): Promise<Response> {
8 const { blob } = await import("https://esm.town/v/std/blob");
9 const KEY = "celinewaitlist";

openapi_playgroundmain.tsx1 match

@stainless_em•Updated 8 months ago
237 return c.html(<App code={code} />);
238});
239function template(code: string) {
240 return `import { makeServer } from "https://esm.town/v/stainless_em/openapiPlaygroundServer"\nexport default makeServer(${
241 JSON.stringify(YAML.parse(code))

runmain.tsx2 matches

@websandbox•Updated 8 months ago
15 body: string;
16};
17export async function handle(req: Request) {
18 const id = new URL(req.url).hostname.match(/^websandbox-(play_[^\.]+)/)[1];
19 const code = await (await blob.get(id)).text();
49 }
50}
51export async function inner(serializedRequest: SerializedRequest, code: string): Promise<SerializedResponse> {
52 try {
53 const req = new Request(serializedRequest.url, {

createAPImain.tsx1 match

@websandbox•Updated 8 months ago
7 "access-control-allow-headers": "*",
8};
9export default async function(req: Request): Promise<Response> {
10 try {
11 if (req.method === "OPTIONS") {

pasetomain.tsx1 match

@maxm•Updated 8 months ago
6// console.log(await V4.generateKey("public", { format: "keyobject" }));
7
8function uuidToHex(uuid: string): string {
9 // Remove hyphens from the UUID
10 const cleanUuid = uuid.replace(/-/g, "");

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.