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/$1?q=function&page=2453&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 28772 results for "function"(1865ms)

extractValInfomain.tsx1 match

@nicosql•Updated 8 months ago
1export function extractValInfo(url: string | URL) {
2 const { pathname, search } = new URL(url);
3 const [author, filename] = pathname.split("/").slice(-2);

sqlitemain.tsx7 matches

@nicosql•Updated 8 months ago
31
32// ------------
33// Functions
34// ------------
35
36async function execute(statement: InStatement, args?: InArgs): Promise<ResultSet> {
37 const res = await fetch(`${API_URL}/v1/sqlite/execute`, {
38 method: "POST",
49}
50
51async function batch(statements: InStatement[], mode?: TransactionMode): Promise<ResultSet[]> {
52 const res = await fetch(`${API_URL}/v1/sqlite/batch`, {
53 method: "POST",
64}
65
66function createResError(body: string) {
67 try {
68 const e = zLibsqlError.parse(JSON.parse(body));
85}
86
87function normalizeStatement(statement: InStatement, args?: InArgs) {
88 if (Array.isArray(statement)) {
89 // for the case of an array of arrays
107}
108
109function upgradeResultSet(results: ImpoverishedResultSet): ResultSet {
110 return {
111 ...results,
116// adapted from
117// https://github.com/tursodatabase/libsql-client-ts/blob/17dd996b840c950dd22b871adfe4ba0eb4a5ead3/packages/libsql-client/src/sqlite3.ts#L314C1-L337C2
118function rowFromSql(
119 sqlRow: Array<unknown>,
120 columns: Array<string>,

createGitHubContribGraphmain.tsx4 matches

@tmcw•Updated 8 months ago
172}
173
174function App() {
175 const [username, setUsername] = useState("stevekrouse")
176 const [contributionData, setContributionData] = useState<any>(null)
360}
361
362function client() {
363 createRoot(document.getElementById("root")).render(<App />)
364}
365if (typeof document !== "undefined") { client() }
366
367export default async function server(request: Request): Promise<Response> {
368 if (request.method === "POST" && new URL(request.url).pathname === "/contributions") {
369 const { username } = await request.json()
395}
396
397async function fetchGitHubContributions(username: string) {
398 const query = `
399 query($username: String!) {

versionLogggerREADME.md1 match

@willthereader•Updated 8 months ago
1This helper function logs the version number of the val.
2
3```ts

immenseBlushSpidermain.tsx2 matches

@ngmi•Updated 8 months ago
2const API_URL = "https://build.wield.xyz/farcaster/v2/feed";
3
4export default async function server(request: Request): Promise<Response> {
5 let feedItems = [];
6 let error = null;
9 error = "API key is not set. Please configure the FARCASTER_API_KEY environment variable.";
10 } else {
11 async function fetchFeedItems() {
12 try {
13 const response = await fetch(`${API_URL}?limit=50`, {

jealousMagentaFleamain.tsx1 match

@ngmi•Updated 8 months ago
2import { easyAQI } from "https://esm.town/v/stevekrouse/easyAQI?v=5";
3
4export async function aqi(interval: Interval) {
5 const location = "downtown brooklyn"; // <-- change to place, city, or zip code
6 const data = await easyAQI({ location });

disgustedAzureChinchillamain.tsx1 match

@ngmi•Updated 8 months ago
2import { easyAQI } from "https://esm.town/v/stevekrouse/easyAQI?v=5";
3
4export async function aqi(interval: Interval) {
5 const location = "downtown brooklyn"; // <-- change to place, city, or zip code
6 const data = await easyAQI({ location });

violentGoldSnakemain.tsx1 match

@ngmi•Updated 8 months ago
2import { easyAQI } from "https://esm.town/v/stevekrouse/easyAQI?v=5";
3
4export async function aqi(interval: Interval) {
5 const location = "downtown brooklyn"; // <-- change to place, city, or zip code
6 const data = await easyAQI({ location });

chatmain.tsx1 match

@lt_07•Updated 8 months ago
23 });
24 const message = data.choices[0].message;
25 return message.function_call ? message.function_call : message.content;
26};

naughtyRedTunamain.tsx4 matches

@maxjoygit•Updated 8 months ago
3import { email } from "https://esm.town/v/std/email";
4
5async function fetchStories(type: string, count: number) {
6 const response = await fetch(`https://hacker-news.firebaseio.com/v0/${type}stories.json`);
7 const storyIds = await response.json();
15}
16
17function createStoryHTML(story: any) {
18 return `
19 <li>
28}
29
30function createEmailContent(
31 topStories: any[],
32 newStories: any[],
118}
119
120export default async function server(req: Request) {
121 try {
122 const topStories = await fetchStories("top", 10);

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 1 month 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.