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=1657&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 18733 results for "function"(2779ms)

dot_commain.tsx3 matches

@horatiothomas•Updated 1 year ago
15const dateClass = "text-xs text-gray-400 font-mono mr-1 hidden sm:inline-block";
16
17async function getHits() {
18 const [, , { rows: [[allHits]] }, { rows: [[todayHits]] }] = await sqlite.batch([
19 "CREATE TABLE IF NOT EXISTS stevekrouse_com_hits (timestamp DATETIME DEFAULT CURRENT_TIMESTAMP)",
192 <li className="pb-2 sm:pb-1">
193 <span className={dateClass}>2016 Jul -</span>
194 <Link href="https://medium.com/@stevekrouse/the-trick-to-teach-anonymous-functions-to-11-year-olds-558b697d7a53">
195 The Trick to Teach Anonymous Functions to 11-Year-Olds
196 </Link>
197 </li>

dream_interpretermain.tsx1 match

@horatiothomas•Updated 1 year ago
1export default async function(interval) {
2 // Sample phrases and words that are likely to appear in dream descriptions
3 const introPhrases = [

framemain.tsx1 match

@nlnw•Updated 1 year ago
6const app = new Hono();
7
8async function renderImage(s: string, color: string) {
9 const fontArrayBuf = await fetch(
10 "https://cdn.jsdelivr.net/npm/roboto-font@0.1.0/fonts/Roboto/roboto-regular-webfont.ttf",

handleSavePageFormmain.tsx1 match

@rwev•Updated 1 year ago
3import { email } from "https://esm.town/v/std/email?v=11";
4
5export async function handleSavePageForm(req: Request) {
6 const formData = await req.formData();
7 const text = formData.get("text");

pageEntriesDbmain.tsx3 matches

@rwev•Updated 1 year ago
2import { sqlite } from "https://esm.town/v/std/sqlite";
3
4export async function getLatestPageEntryDb() {
5 let latestVersion = await sqlite.execute(`select * from pages where id = (select max(id) from pages);`);
6 return sqliteRowsAsObject(latestVersion)[0];
7}
8
9export async function getAllPageEntriesDb() {
10 let allVersions = await sqlite.execute(`select * from pages order by id desc`);
11 return sqliteRowsAsObject(allVersions);
12}
13
14export async function savePageEntryDb(textValue) {
15 const insertResult = await sqlite.execute({
16 sql: `insert into pages (value) values (:value)`,

viewSourcemain.tsx1 match

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

orangeAngelfishmain.tsx1 match

@wannli•Updated 1 year ago
1export async function getFieldValue(req) {
2 const url = new URL(req.url);
3 let symbol = url.searchParams.get("symbol") || "";
3
4/** creates a signed token */
5function create(data) {
6 data = data || Buffer.from(randomUUID().replace(/-/g, ""));
7 const secret = "changeme";
11
12/** ensures payload is valid token that hasn't expired */
13function verify(payload) {
14 const [data, ts, sig] = payload.split(".");
15 const elapsed = Date.now() - ts;

ssr_a_web_component_for_funmain.tsx2 matches

@brianleroux•Updated 1 year ago
1import enhance from "jsr:@enhance/ssr";
2
3export default async function() {
4 let html = enhance({
5 elements: {
6 "my-tag": function({ html }) {
7 return html`<b><slot></slot></b>`;
8 },

tapMochaToNodemain.tsx9 matches

@barelyhuman•Updated 1 year ago
6run();
7
8async function run() {
9 if (!import.meta.main) return;
10
42}
43
44export function transform(code: string, { typescript = false } = {}) {
45 const parserOptions: Partial<recast.Options> = {};
46
125}
126
127function removeMochaGlobal(
128 path: NodePath,
129 tapImportIdentifier: string,
161}
162
163function makeBlocksAsync(
164 path: NodePath,
165 {
188
189 const fnNode = path.node.arguments[1];
190 makeFunctionNodeAsync(fnNode, { asserts });
191 awaitNestedStatements(path, { asserts, builder });
192
194}
195
196function makeFunctionNodeAsync(
197 node: any,
198 {
204 if (
205 !(
206 asserts.ArrowFunctionExpression.check(node) ||
207 asserts.FunctionExpression.check(node)
208 )
209 ) {
214}
215
216function awaitNestedStatements(
217 path: NodePath,
218 {

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