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=1468&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 19140 results for "function"(2715ms)

dailyStandupBotmain.tsx1 match

@princetonpoh•Updated 7 months ago
1import { discordWebhook } from "https://esm.town/v/stevekrouse/discordWebhook";
2
3export default async function() {
4 discordWebhook({
5 url: Deno.env.get("engDiscord"),

pretendingToBeRunmain.tsx4 matches

@maxm•Updated 7 months ago
1export default async function(req: Request): Promise<Response> {
2 // Fork and enable me if you'd like, I did not want to expose my private vals.
3 return new Response("disabled", { status: 500 });
13 });
14 }
15 if (typeof resp.value !== "function") {
16 return Response.json({
17 error: { message: "The first export of this val is not a function and cannot be run with args" },
18 }, {});
19 }
22}
23
24function getMainExport(
25 mod: any,
26): { ok: true; value: any } | { ok: false; error: Error } {

distancemain.tsx1 match

@panphora•Updated 7 months ago
1export default async function distance(req) {
2 const searchParams = new URL(req.url).searchParams;
3 const destinationA = encodeURIComponent(String(searchParams.get("a")).trim());

aqimain.tsx1 match

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

ingeniousSapphireWildebeestmain.tsx1 match

@maxm•Updated 7 months ago
1export default function(a: number, b: number) {
2 return a + b;
3}

sillifierSlangifiermain.tsx3 matches

@yawnxyz•Updated 7 months ago
4import { createRoot } from "https://esm.sh/react-dom/client";
5
6function App() {
7 const [htmlInput, setHtmlInput] = useState("<h1>Hello, World!</h1>"); const [silliness, setSilliness] = useState(0);
8 const [slang, setSlang] = useState(0);
90}
91
92function client() {
93 createRoot(document.getElementById("root")).render(<App />);
94}
98}
99
100async function server(request: Request): Promise<Response> {
101 if (request.method === "POST" && new URL(request.url).pathname === "/api/modify") {
102 const { html, silliness, slang } = await request.json();

leadership_styles_inventorymain.tsx4 matches

@jaredsilver•Updated 7 months ago
41];
42
43function shuffleArray(array) {
44 const shuffled = [...array];
45 for (let i = shuffled.length - 1; i > 0; i--) {
50}
51
52function App() {
53 const [questions, setQuestions] = useState([]);
54 const [currentQuestion, setCurrentQuestion] = useState(0);
222}
223
224function client() {
225 createRoot(document.getElementById("root")).render(<App />);
226}
230}
231
232export default async function server(request: Request): Promise<Response> {
233 return new Response(`
234 <html>

dailyScheduleTrackermain.tsx4 matches

@vandermerwed•Updated 7 months ago
236};
237
238function AnalogueScheduleClock({
239 schedule = defaultSchedule,
240 todoList = defaultTodoList,
340}
341
342function App() {
343 return <AnalogueScheduleClock />;
344}
345
346function client() {
347 const rootElement = document.getElementById("root");
348 if (rootElement) {
357}
358
359export default async function server(request: Request): Promise<Response> {
360 return new Response(
361 `

transformEvalCodemain.tsx9 matches

@maxm•Updated 7 months ago
2import ts from "npm:typescript";
3
4function createSourceFile(code: string) {
5 return ts.createSourceFile(
6 "index.tsx",
11}
12
13function getInterestingChildren(node: ts.Node) {
14 const children: ts.Node[] = [];
15 node.forEachChild((c) => {
20
21// From https://github.com/microsoft/TypeScript/blob/b3770e78527a379d2345412bbab5acc0bafe0090/src/compiler/utilitiesPublic.ts#L2313
22function isDeclarationStatementKind(kind: ts.SyntaxKind) {
23 return (
24 kind === ts.SyntaxKind.FunctionDeclaration
25 || kind === ts.SyntaxKind.MissingDeclaration
26 || kind === ts.SyntaxKind.ClassDeclaration
39// Returns true if `node` is a ECMAScript StatementListItem, otherwise false.
40// See §14.2 Block (https://tc39.es/ecma262/#sec-block) in the spec.
41function isESStatementListItem(node: ts.Node) {
42 /*
43 Some notes about the differences between the ECMAScript spec and what the
52 return (
53 (ts.isStatement(node) && !isDeclarationStatementKind(node.kind))
54 || ts.isFunctionDeclaration(node)
55 || ts.isVariableDeclaration(node)
56 || ts.isClassDeclaration(node)
58}
59
60function hasModifier(node: ts.Node, kw: ts.SyntaxKind) {
61 if (ts.canHaveModifiers(node)) {
62 const modifiers = ts.getModifiers(node) ?? [];
68const { ExportKeyword, DeclareKeyword } = ts.SyntaxKind;
69
70export function transform(code: string): string {
71 const sourceFile = createSourceFile(code);
72 const moduleItems = getInterestingChildren(sourceFile);
103 if (ts.isVariableStatement(item)) {
104 convertedCode.appendLeft(item.getStart(), "export ");
105 } else if (ts.isFunctionDeclaration(item) || ts.isClassDeclaration(item)) {
106 convertedCode.appendLeft(item.getStart(), "export ");
107 } else if (ts.isExpressionStatement(item)) {

routineTrackerAppmain.tsx5 matches

@cpdis•Updated 7 months ago
21];
22
23// Simple hash function for the password
24const simpleHash = (str) => {
25 let hash = 0;
130};
131
132function App() {
133 const [completedTasks, setCompletedTasks] = useState([]);
134 const [timerStates, setTimerStates] = useState(routineTasks.map(task => ({
149 };
150
151 function fire(particleRatio, opts) {
152 confetti({
153 ...defaults,
363}
364
365function client() {
366 createRoot(document.getElementById("root")).render(<App />);
367}
368if (typeof document !== "undefined") { client(); }
369
370async function server(request: Request): Promise<Response> {
371 return new Response(
372 `

getFileEmail4 file matches

@shouser•Updated 2 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
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": "*",