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/$%7Burl%7D?q=function&page=28&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 33882 results for "function"(8157ms)

utils-saasproject.test.ts3 matches

@stevekrouse•Updated 1 day ago
118}
119
120function runTest(test: TestCase) {
121 let pass, message;
122 let start = performance.now();
135}
136
137function renderBadge({ label, passedCount, testCount }: { label?: string; passedCount: number; testCount: number }) {
138 return makeBadge({
139 label: label ?? "Tests",
143}
144
145function renderTestResults(tests: TestCase[], outputs: TestOutput[]) {
146 const passedCount = outputs.filter((output: TestOutput) => output.pass).length;
147 const testCount = tests.length;

utils-saasmain.tsx1 match

@stevekrouse•Updated 1 day ago
2import { serveFile } from "../index.ts";
3
4export function staticHTTPServer(importMetaURL: string) {
5 const app = new Hono();
6 app.get("/", () => serveFile("/index.html", importMetaURL));

utils-saasindex.tsx7 matches

@stevekrouse•Updated 1 day ago
13interface TestCase {
14 name: string;
15 function: () => void;
16}
17
18interface TestCaseResult {
19 name: string;
20 function: () => void;
21 passed: boolean;
22 duration: number;
23}
24
25async function runTest(test: TestCase) {
26 let pass, message;
27 let start = performance.now();
28 try {
29 await test.function();
30 pass = true;
31 } catch (e: any) {
40}
41
42function renderBadge({ label, passedCount, testCount }: { label?: string; passedCount: number; testCount: number }) {
43 return makeBadge({
44 label: label ?? "Tests",
48}
49
50function Badge({ label, passedCount, testCount }: { label?: string; passedCount: number; testCount: number }) {
51 const svgMarkup = renderBadge({ label, passedCount, testCount });
52 const srcDoc = `<body style="margin: 0"}>${svgMarkup}</body>`;
62}
63
64function renderTestResults(testGroups: TestGroup[], outputs: { [groupName: string]: TestOutput[] }) {
65 const totalPassed = Object.values(outputs).flat().filter((output: TestOutput) => output.pass).length;
66 const totalTests = testGroups.reduce((sum, group) => sum + group.tests.length, 0);

utils-saasindex.ts3 matches

@stevekrouse•Updated 1 day ago
2import { parseProject } from "../parseImportMeta/project.ts";
3
4export async function readFile(path: string, metaImportUrl: string) {
5 const project = parseProject(metaImportUrl);
6 let pathFragment = path.startsWith("/") ? path.slice(1) : path; // remove the leading slash
15}
16
17export async function listFiles(metaImportUrl: string) {
18 const vt = new ValTown();
19
35}
36
37export async function fetchTranspiledJavaScript(url: string) {
38 if (!url.startsWith("https://esm.town")) throw Error("Can only fetch from https://esm.town");
39 const res = await fetch(url, {

utils-saasexample.test.ts4 matches

@stevekrouse•Updated 1 day ago
8 {
9 name: "no-op",
10 function: () => {
11 return true;
12 },
14 {
15 name: "passing test",
16 function: () => {
17 expect(1).toBe(1);
18 },
20 {
21 name: "Failing test",
22 function: () => {
23 expect(1).toBe(2);
24 },
31 {
32 name: "passing test 2",
33 function: () => {
34 expect(1).toBe(1);
35 },

persistentSignalREADME.md1 match

@novari•Updated 1 day ago
11const userName = persistentSignal("username", "USERNAME-UNKNOWN"); //uses localStorage, so all values are turned into strings
12
13function App(){
14 const user = useLiveSignal(userName);
15 if (user == "USERNAME-UNKNOWN") return ( <RequestName signal={user}/> );
10const EDIT_LINK = `([edit val](<${import.meta.url.replace("esm", "val")}>))`;
11
12export default async function (_interval: Interval) {
13 const count = await clerkClient.users.getCount();
14 const lastCount: { count: number } = await blob.getJSON(BLOB_KEY);

persistentSignalmain.tsx3 matches

@novari•Updated 1 day ago
1function track(key, signal, ms) {
2 let t;
3 return () => {
9}
10
11export default function setup(library, { keyify = "sig-", delay = 250 } = {}) {
12 keyify = typeof keyify === "string" ? () => keyify : keyify;
13 return function persistentSignal(key, initialValue) {
14 key = keyify(key);
15 if (localStorage.getItem(key) !== null) initialValue = localStorage.getItem(key);

storyBuilderstory-builder-app.jsx5 matches

@nmsilva•Updated 1 day ago
155];
156
157function generateWithPollinations(prompt) {
158 const encodedPrompt = encodeURIComponent(prompt);
159 const imageUrl = `https://image.pollinations.ai/prompt/${encodedPrompt}`;
165 * Main React component
166 * -------------------------------------------------------------------------*/
167function StoryOptionsApp() {
168 const [tags, setTags] = useState("");
169 const [lang, setLang] = useState("portugal");
533}
534
535function App() {
536 return (
537 <>
541}
542
543function client() {
544 createRoot(document.getElementById("root")).render(<App />);
545}
546if (typeof document !== "undefined") { client(); }
547
548export default async function server(request: Request): Promise<Response> {
549 return new Response(
550 `

OCRmain.tsx1 match

@novari•Updated 1 day ago
8);
9
10export default async function(req: Request): Promise<Response> {
11 const html = render(<App />);
12 return new Response(html, {

discordWebhook2 file matches

@stevekrouse•Updated 1 week ago
Helper function to send Discord messages
tuna

tuna9 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.