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/image-url.jpg%20%22Image%20title%22?q=function&page=2705&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 29307 results for "function"(8068ms)

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}

dateMeRSSmain.tsx1 match

@stevekrouse•Updated 1 year ago
3import { zip } from "npm:lodash-es";
4
5export async function dateMeRSS(req: Request) {
6 let { columns, rows } = await sqlite.execute(`select * from datemedocs order by LastUpdated desc limit 20`);
7 const profiles = rows.map(row =>

rssFeedExamplemain.tsx1 match

@maxm•Updated 1 year ago
2import { valTownBlogJSON } from "https://esm.town/v/stevekrouse/valTownBlogJSON";
3
4export async function valTownBlogRSS() {
5 const json = await valTownBlogJSON();
6 return new Response(dataToRSS(

leaderboardmain.tsx1 match

@sqlite•Updated 1 year ago
4import stripAnsi from "npm:strip-ansi";
5
6export default async function() {
7 const res = await db.execute(
8 "SELECT author_username, COUNT(*) AS val_count FROM vals GROUP BY author_username ORDER BY 2 DESC LIMIT 10",
tuna

tuna9 file matches

@jxnblk•Updated 1 day ago
Simple functional CSS library for Val Town

getFileEmail4 file matches

@shouser•Updated 1 month ago
A helper function to build a file's email
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.