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=1515&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 17289 results for "function"(1207ms)

playgroundmain.tsx10 matches

@easrng•Updated 1 year ago
77 let styled: JSX.Element[] = [];
78 let css: string = "";
79 function flush() {
80 if (out.length) {
81 styled.push(css ? <span style={css}>{out}</span> : <>{out}</>);
166 );
167};
168function transpose(matrix) {
169 return matrix[0].map((col, i) => matrix.map((row) => row[i]));
170}
220 const value = resultData[k];
221 const primitive = value === null
222 || (typeof value !== "function" && typeof value !== "object");
223 if (properties === undefined && primitive) {
224 hasPrimitives = true;
379 return (
380 <li>
381 at {item.functionName
382 ? (
383 <>
384 {item.functionName} ({file})
385 </>
386 )
808 stack: string;
809};
810async function execute(code: string): Promise<{ logs: Log[] }> {
811 try {
812 const blob = new Blob([code], {
816 const markStackStart = crypto.randomUUID();
817 const markStackEnd = crypto.randomUUID();
818 function cleanStack(stack: string) {
819 let lines: string[] = [];
820 for (const line of stack.split("\n")) {
831 get(target, key) {
832 const real = target[key];
833 if (typeof real === "function" && typeof key === "string") {
834 const fn = function(...args: any[]) {
835 logs.push({
836 type: key,
849 },
850 });
851 async function run() {
852 try {
853 await import(url);

display_mermaidmain.tsx3 matches

@saolsen•Updated 1 year ago
1/// Create a handler function that displays the mermaid diagram.
2export function displayMermaid(mermaid: string): (req: Request) => Response {
3 function handler(req: Request): Response {
4 return new Response(
5 `

gfmmain.tsx1 match

@saolsen•Updated 1 year ago
32};
33
34export async function gfm(markdown: string, options?: { title?: string; favicon?: string }) {
35 const html = await unified()
36 .use(remarkParse)

display_markdownmain.tsx2 matches

@saolsen•Updated 1 year ago
1import { gfm } from "https://esm.town/v/saolsen/gfm";
2
3export async function displayMarkdown(markdown: string): Promise<(req: Request) => Response> {
4 const html = await gfm(markdown);
5 function handler(req: Request): Response {
6 return new Response(html, { headers: { "content-type": "text/html" } });
7 }

http_clientmain.tsx3 matches

@pomdtr•Updated 1 year ago
17};
18
19async function serializeRequest(request: Request): Promise<SerializedRequest> {
20 return {
21 url: request.url,
55};
56
57export function httpClient(next: (req: Request) => Response | Promise<Response>, options: {
58 path: string;
59 bookmarks: Bookmark[];
69}
70
71export default async function(req: Request) {
72 const bookmarks = [{ label: "Dummy Request", request: new Request("https://dummyjson.com/products") }];
73 return html(await getBody(bookmarks));

http_clientmain.tsx3 matches

@stevekrouse•Updated 1 year ago
17};
18
19async function serializeRequest(request: Request): Promise<SerializedRequest> {
20 return {
21 url: request.url,
55};
56
57export function httpClient(next: (req: Request) => Response | Promise<Response>, options: {
58 path: string;
59 bookmarks: Bookmark[];
69}
70
71export default async function(req: Request) {
72 const bookmarks = [{ label: "Dummy Request", request: new Request("https://dummyjson.com/products") }];
73 return html(await getBody(bookmarks));

reactExamplemain.tsx3 matches

@dm•Updated 1 year ago
2import { renderToString } from "npm:react-dom/server";
3
4function HelloWorld() {
5 return (
6 <h1 className="text-3xl font-bold underline">
10}
11
12function Html({ content }) {
13 return (
14 <>
26}
27
28function reactExample(request: Request) {
29 const renderedString = renderToString(<Html content={<HelloWorld />} />);
30

pollRSSFeedsmain.tsx1 match

@ni554n•Updated 1 year ago
6}
7
8export async function pollRSSFeeds({ lastRunAt }: Interval) {
9 return Promise.all(
10 Object.entries(rssFeeds).map(async ([name, url]) => {

viewSourcemain.tsx1 match

@reecer•Updated 1 year ago
3import { escape } from "npm:html-sloppy-escaper";
4
5export default async function viewSource(req: Request) {
6 const pathname = new URL(req.url).pathname;
7 const html = await fetchText(pathname === "/" ? "example.com" : pathname); // .then(prettifyHtml);

uuidsmain.tsx1 match

@camflan•Updated 1 year ago
1import { v1 as uuidv1, v4 as uuidv4 } from "npm:uuid";
2
3export default async function(req: Request): Promise<Response> {
4 return Response.json({
5 success: true,

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": "*",