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=1510&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"(2496ms)

readabilityHTTPProxymain.tsx2 matches

@nbbaier•Updated 1 year ago
56};
57
58export default async function(req: Request): Promise<Response> {
59 const JSDOM = jsdom.JSDOM;
60 const url = new URL(req.url);
77
78 <script>
79 document.getElementById('nameForm').onsubmit = function(event) {
80 event.preventDefault();
81 const targetURL = document.getElementById("name").value

sslCertificatesmain.tsx1 match

@agmm•Updated 1 year ago
12};
13
14export async function getCertificates(domain: string) {
15 const url = `https://crt.sh/json?q=${domain}`;
16 const response = await fetch(url);

indigoMockingbirdmain.tsx1 match

@tsoongg•Updated 1 year ago
10});
11// Fetches a random joke.
12async function fetchRandomJoke() {
13 const response = await fetch(
14 "https://official-joke-api.appspot.com/random_joke",

parseBearerStringmain.tsx1 match

@andreterron•Updated 1 year ago
1export function parseBearerString(bearerString: string): string | undefined {
2 if (!bearerString.match(/^Bearer\s+/)) {
3 return undefined;

turquoiseTunamain.tsx1 match

@megansitz•Updated 1 year ago
1function x() {
2 console.log("Welcome to CS1200!");
3}

Jokemain.tsx1 match

@zoeecheung•Updated 1 year ago
2
3// Fetches a random joke.
4async function fetchRandomJoke() {
5 const response = fetch(
6 "https://official-joke-api.appspot.com/random_joke",

dateme_sqlitemain.tsx3 matches

@stevekrouse•Updated 1 year ago
4import { thisWebURL } from "https://esm.town/v/stevekrouse/thisWebURL";
5
6export function createTable() {
7 return sqlite.execute(`
8 CREATE TABLE IF NOT EXISTS DateMeDocs (
29 (:Id, :Name, :Profile, :Gender, :Age, :Contact, :LastUpdated, :InterestedIn, :Location, :Style, :LocationFlexibility, :Community)`;
30
31export default async function() {
32 let docs = await getDocs();
33 return Response.json(docs);
34}
35
36export async function setupDatabase() {
37 await createTable();
38 const docs = await fetchJSON(thisWebURL());

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/") {

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