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/$%7Bsuccess?q=function&page=1723&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 19409 results for "function"(2922ms)

sqlmain.tsx3 matches

@easrng•Updated 1 year ago
1import { type InStatement, type InValue, type ResultSet, sqlite } from "https://esm.town/v/std/sqlite?v=5";
2let batch: { statement: InStatement; promise: ReturnType<typeof Promise.withResolvers<ResultSet>> }[] | null = null;
3async function flush() {
4 const currentBatch = batch;
5 batch = null;
16}
17const joined = new WeakMap<TemplateStringsArray, string>();
18function cachedJoin(strings) {
19 let result = joined.get(strings);
20 if (typeof result === "string") {
25 return result;
26}
27export function sql(query: TemplateStringsArray, ...args: InValue[]): Promise<ResultSet> {
28 if (batch === null) {
29 setTimeout(flush);

bronzeParrotfishmain.tsx1 match

@shouryaravula19•Updated 1 year ago
2
3// Fetches a random joke.
4function fetchRandomJoke() {
5 const SAMPLE_JOKE = {
6 "setup": "What do you call a group of disorganized cats?",

honoBasicAuthmain.tsx5 matches

@mmcc•Updated 1 year ago
1function extractToken(authorization) {
2 const parts = authorization.split(" ");
3 if (parts[0] == "Bearer") {
18};
19
20async function fetchUser(token: string): Promise<User> {
21 const resp = await fetch("https://api.val.town/v1/me", {
22 headers: {
32}
33
34async function isTokenValid(token) {
35 try {
36 const [visitor, owner] = await Promise.all([fetchUser(token), fetchUser(Deno.env.get("valtown"))]);
41}
42
43async function isRequestAuthenticated(req) {
44 if (!req.headers.has("authorization")) {
45 return false;
50}
51
52export function basicAuth() {
53 return async (c, next) => {
54 if (c.req.headers.get("referer") == "https://www.val.town/") {

jupiterPerpetualsmain.tsx1 match

@rwev•Updated 1 year ago
6// const rows = await getJupiterPerpsPnLForWallet(wallet);
7
8export async function handleJupPerpsRequest(req: Request) {
9 const wallet = parseUrlParam(req, "w");
10 console.log(wallet);

apricotSlothmain.tsx1 match

@tmcw•Updated 1 year ago
4
5const { result } = core.runJavascript({
6 code: "function name() { return \"Hello\"; }",
7 "name": "name",
8});

date_me_docs_tablemain.tsx3 matches

@stevekrouse•Updated 1 year ago
17];
18
19function httpsIfy(url: string) {
20 if (!url.startsWith("http://") && !url.startsWith("https://")) {
21 return `https://${url}`;
24}
25
26function renderCell(header, row) {
27 let data = row[header];
28 if (header === "Name") {
38}
39
40export async function docs_table() {
41 const docs = await getDocs();
42 return (

dateme_layoutmain.tsx1 match

@stevekrouse•Updated 1 year ago
4const tabs = { "/": "Home", "/browse": "Browse", "/faq": "FAQ" };
5
6export default function({ activeTab, children }: PropsWithChildren<{ activeTab: string }>) {
7 return (
8 <html>

dateme_homemain.tsx1 match

@stevekrouse•Updated 1 year ago
4import Layout from "https://esm.town/v/stevekrouse/dateme_layout";
5
6export default function Home(c) {
7 return c.html(
8 <Layout activeTab={new URL(c.req.url).pathname}>

tanChimpanzeemain.tsx1 match

@stevekrouse•Updated 1 year ago
2import { reloadOnSaveMiddleware } from "https://esm.town/v/stevekrouse/reloadOnSave";
3
4export default reloadOnSaveMiddleware(async function(req: Request): Promise<Response> {
5 return html(`<h1>Hello 3!!</h1>`);
6});

ReloadScriptmain.tsx1 match

@stevekrouse•Updated 1 year ago
3import { parentReference } from "https://esm.town/v/stevekrouse/parentReference";
4
5export const reloadOnVals = async function(vals: { userHandle: string; valName: string }[]) {
6 const valVersions = await Promise.all(vals.map(getCurrentValVersionNumber));
7 // console.log("initialValVersions: ", valVersions);

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 3 weeks 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.