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=1653&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 18794 results for "function"(2624ms)

enableButtonsScript_DEVmain.tsx2 matches

@nbbaier•Updated 1 year ago
9 const buttons = [csvBtn, jsonBtn, runBtn];
10
11 function checkForText() {
12 if (editor.view.state.doc.toString().trim() === "") {
13 buttons.forEach(btn => btn.disabled = true);
25 });
26
27 document.addEventListener("DOMContentLoaded", function() {
28 // Initial check
29 checkForText();

sqliteStudioSVGsmain.tsx3 matches

@nbbaier•Updated 1 year ago
3const iconSize = "1.125rem";
4
5export function RunSVG() {
6 return (
7 <svg
22}
23
24export function TableSVG() {
25 return (
26 <svg
41}
42
43export function ViewSVG() {
44 return (
45 <svg

codeOnValTownmain.tsx3 matches

@pomdtr•Updated 1 year ago
10 * @param val Define which val should open. Defaults to the root reference.
11 */
12export function modifyHtmlString(
13 bodyText: string,
14 { val, style }: { val?: ValRef; style?: string } = {},
41 * @param val Define which val should open
42 */
43export function modifyFetchHandler(
44 handler: (req: Request) => Response | Promise<Response>,
45 { val, style }: { val?: ValRef; style?: string } = {},
54
55export const honoMiddleware = (options: { val?: ValRef; style?: string } = {}): MiddlewareHandler => {
56 return async function(c, next) {
57 await next();
58 if (c.res.headers.get("Content-Type")?.startsWith("text/html")) {

codeOnValTownREADME.md1 match

@pomdtr•Updated 1 year ago
49### Linking to the val
50
51These functions infer the val using the call stack or the request URL. If the inference isn't working, or if you want to ensure it links to a specific val, pass the `val` argument:
52
53- `modifyFetchHandler(handler, {val: { handle: "andre", name: "foo" }})`

react_example_clientmain.tsx2 matches

@pomdtr•Updated 1 year ago
5import ReactDOM from "https://esm.sh/react-dom";
6
7function Counter() {
8 const [counter, setCounter] = React.useState(0);
9
19}
20
21export function App() {
22 return (
23 <>

expressHTMLExamplemain.tsx1 match

@destroytoday•Updated 1 year ago
1export async function expressHTMLExample(
2 req: express.Request,
3 res: express.Response,

open_in_fullscreenmain.tsx1 match

@pomdtr•Updated 1 year ago
1import { BrowserContext } from "https://esm.town/v/pomdtr/browser";
2
3export default async function(ctx) {
4 return {
5 type: "open",

webmention_discomain.tsx5 matches

@brianleroux•Updated 1 year ago
1import { parse } from "npm:parse5";
2
3/** function to discover a webmention endpoint */
4export default async function discover(source) {
5 // look for first Link in headers
6 let found = [];
25 let doc = parse(html);
26 let links = [];
27 (function walk(nodes) {
28 for (let n of nodes) {
29 if (n.childNodes) walk(n.childNodes);
51
52/** helper to extract a url from Link header value */
53function cleanHeader(src, h) {
54 let exp = /<([^>]*)>/;
55 let matches = h.match(exp);
69
70/** helper to extract a url from <link> tag href */
71function cleanTag(src, raw) {
72 // absolute path
73 if (raw.startsWith("/"))

pollermain.tsx3 matches

@pranjaldotdev•Updated 1 year ago
4
5// formats date in SQLITE format YYYY-MM-DD
6function formatDate(date: string) {
7 let [month, day, year] = date.split("/");
8 if (month.length == 1) month = "0" + month;
12
13// insert newsletter metadata in sqlite
14async function insertRow(articleNumber: number, title: string, date: string) {
15 try {
16 await sqlite.execute({
24
25// check if newsletter id exists
26async function checkNewsletterPresent(articleNumber: number) {
27 const data = await sqlite.execute({
28 sql: `SELECT EXISTS(SELECT 1 FROM newsletter WHERE article_number=:articleNumber)`,

myApimain.tsx1 match

@fahimfoysal•Updated 1 year ago
1export function myApi(data) {
2 return "hi " + data.name;
3}

getFileEmail4 file matches

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

tuna8 file matches

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