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=1497&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 16864 results for "function"(1485ms)

recommendsmain.tsx3 matches

@postpostscript•Updated 1 year ago
1import { html } from "https://esm.town/v/postpostscript/html";
2
3export async function randomLike() {
4 const { data } = await fetch("https://api.val.town/v1/me/likes", {
5 headers: {
11}
12
13export async function randomLikeLink() {
14 try {
15 const { author: { username }, name } = await randomLike();
25}
26
27export async function recommends() {
28 return html`
29 Check out a random Val I've liked!

vuemain.tsx2 matches

@postpostscript•Updated 1 year ago
5export { Vue };
6
7export function vueSfc(name: string, template: string) {
8 window.moduleCache ??= {
9 vue: Vue,
52}
53
54export function vueSfcInline(strings: TemplateStringsArray, ...replacements: any[]) {
55 const id = rawHtml`vueSfcInline-${Math.random().toString().slice(3)}`;
56

fetchBlueskyPostmain.tsx1 match

@vladimyr•Updated 1 year ago
3import ky from "npm:ky";
4
5export async function fetchPost(url: string | URL) {
6 const postURL = new URL(url);
7 if (postURL.hostname !== "bsky.app") {

pinkGuanacomain.tsx3 matches

@vladimyr•Updated 1 year ago
2
3const { greet } = await import(jsm`
4export function greet(name) {
5 console.log(\`Hello \${name}!\`);
6}
10
11const { sum } = await import(tsm`
12export function sum(a: number, b: number): number {
13 return a + b;
14}
17
18const { shout } = await import(createModuleURL(
19 `export function shout(name: string) {
20 console.log(\`HELLO \${name.toUpperCase()}!\`);
21 }`,

htmlmain.tsx2 matches

@postpostscript•Updated 1 year ago
16}
17
18export function htmlEscape(text: string | RawHTML | unknown) {
19 if (text instanceof RawHTML) {
20 return text;
28}
29
30export function coerceString(value: unknown) {
31 if (typeof value === "string") {
32 return value;

emptyValUtilsmain.tsx2 matches

@nbbaier•Updated 1 year ago
2import { deleteVal } from "https://esm.town/v/neverstew/deleteVal";
3
4export async function listEmptyVals(id: string) {
5 const token = Deno.env.get("valtown");
6 const res = await fetchPaginatedData(`https://api.val.town/v1/users/${id}/vals`, {
10}
11
12export async function deleteEmptyVals(id: string) {
13 const token = Deno.env.get("valtown");
14 const res = await fetchPaginatedData(`https://api.val.town/v1/users/${id}/vals`, {

emptyValUtilsREADME.md1 match

@nbbaier•Updated 1 year ago
1# Empty Val Utils
2
3Handy utility functions to see if you have vals with no code lying around your account and to delete them (if you want to).
4
5## Usage

ReloadScriptmain.tsx1 match

@postpostscript•Updated 1 year ago
9const id = ({ userHandle, valName }) => `${userHandle}/${valName}`;
10
11export const reloadOnVals = async function(vals: { userHandle: string; valName: string }[], delay = 500) {
12 const initialVersions = Object.fromEntries(
13 await Promise.all(vals.map(async (val) => {

vtIdeaListmain.tsx1 match

@nbbaier•Updated 1 year ago
6import { html } from "https://esm.town/v/stevekrouse/html?v=5";
7
8export async function examplePost(req: Request) {
9 const { author, name } = extractValInfo(import.meta.url);
10

astmain.tsx7 matches

@postpostscript•Updated 1 year ago
7};
8
9export function getSourceAST(source: string, parseOptions = {
10 syntax: "typescript",
11 tsx: true,
34}
35
36export function findASTNode(parent: Node | Node[], method: (node: Node) => Node, recursive = false) {
37 const nodes = parent instanceof Array
38 ? parent
54}
55
56export function findASTNodes<T>(parent: Node | Node[], method: (node: Node) => T | T[] | undefined, recursive = false) {
57 const nodes = parent instanceof Array
58 ? parent
78}
79
80export function findASTValueDefinition(ast: Node | Node[], name: string) {
81 let check = (node: Node) => {
82 if (node.type === "ExportDeclaration") {
86 return findASTValueDefinition(node.declarations, name);
87 }
88 if (node.type === "FunctionDeclaration" && node.identifier?.value === name) {
89 return node;
90 }
106}
107
108export function findIndexLineNumber(source: string, index: number) {
109 return (source.slice(0, index).match(/\n/g)?.length ?? 0) + 1;
110}
111
112export function findSpanLocation(source: string, ast: Node, span: Span) {
113 const offset = offsetState.map.get(ast) ?? 1;
114 return {

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