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/$%7Burl%7D?q=function&page=2640&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 29109 results for "function"(1867ms)

debugValEmbeddingsmain.tsx1 match

@janpaul123โ€ขUpdated 1 year ago
29import { email } from "https://esm.town/v/std/email?v=12";
30
31export default async function(interval: Interval) {
32 const dynamiclandWebsiteHash = await blob.getJSON("dynamiclandWebsiteHash");
33 const newHash = await getHashForUrl("https://dynamicland.org/");

gameIdeaApimain.tsx3 matches

@xkontiโ€ขUpdated 1 year ago
90const ideasKey = "game-ideas";
91
92async function getIdeas(): Promise<Idea[]> {
93 let ideas = await blob.getJSON(ideasKey) as Idea[];
94 if (ideas == null) ideas = [];
96}
97
98async function setIdeas(ideas: Idea[]): Promise<void> {
99 await blob.setJSON(ideasKey, ideas);
100}
101
102function getRandomElement<T>(array: T[]): T {
103 const randomIndex = Math.floor(Math.random() * array.length);
104 return array[randomIndex];

extractHttpEndpointmain.tsx1 match

@xkontiโ€ขUpdated 1 year ago
1export function extractHttpEndpoint(url: string | URL) {
2 const { pathname } = new URL(url);
3 const [author, filename] = pathname.split("/").slice(-2);

formatResumemain.tsx3 matches

@iamseeleyโ€ขUpdated 1 year ago
1export function formatResume(resumeDetails) {
2 function applyFormatting(text) {
3 if (typeof text === 'string') {
4 return text
9 }
10
11 function preprocessResumeDetails(details) {
12 if (Array.isArray(details)) {
13 return details.map(item => preprocessResumeDetails(item));

jadeMacawmain.tsx1 match

@janpaul123โ€ขUpdated 1 year ago
8import OpenAI from "npm:openai";
9
10export default async function semanticSearchPublicVals(query) {
11 const allValsBlobEmbeddingsMeta = (await blob.getJSON("allValsBlobEmbeddingsMeta")) ?? {};
12 const allBatchDataIndexes = _.uniq(Object.values(allValsBlobEmbeddingsMeta).map(item => item.batchDataIndex));

Title_Extractormain.tsx4 matches

@willthereaderโ€ขUpdated 1 year ago
2import { fetch } from "https://esm.town/v/std/fetch";
3
4// Helper function to retrieve CSRF token if needed
5async function getCsrfToken(url, cookies) {
6 try {
7 console.log("Fetching CSRF Token from URL:", url);
36}
37
38// Function to fetch HTML content and extract titles
39async function titleExtractor(url, cookies, csrfToken) {
40 try {
41 console.log("Fetching URL:", url);

indexValsTursomain.tsx2 matches

@janpaul123โ€ขUpdated 1 year ago
6import { truncateMessage } from "npm:openai-tokens";
7
8export default async function(interval: Interval) {
9 const sqlite = createClient({
10 url: "libsql://valsembeddings-jpvaltown.turso.io",
23 );
24
25 function idForVal(val: any): string {
26 return `${val.author_username}!!${val.name}!!${val.version}`;
27 }

bloomingButtonmain.tsx7 matches

@maxmโ€ขUpdated 1 year ago
1let active = false;
2
3function getRandomEmoji() {
4 const emojis = ["๐ŸŒณ", "๐ŸŒณ", "๐ŸŒฒ", "๐ŸŒฟ", "๐ŸŒฑ", "๐ŸŒพ", "๐Ÿ", "๐Ÿ‚", "๐Ÿƒ", "๐ŸŒท", "๐Ÿชป", "๐Ÿ„"];
5 const randomIndex = Math.floor(Math.random() * emojis.length);
7}
8
9function injectCSS(css: string) {
10 const style = document.createElement("style");
11 style.type = "text/css";
33const buttonBackgroundMap = new Map();
34
35// Function to create or get the background div
36function getBackgroundDiv(button) {
37 if (!buttonBackgroundMap.has(button)) {
38 const newDiv = document.createElement("div");
49}
50
51// Function to position the background div behind the button
52function positionDivBehindButton(button) {
53 const rect = button.getBoundingClientRect();
54 const newDiv = getBackgroundDiv(button);
63 window.addEventListener("scroll", () => positionDivBehindButton(button));
64
65 button.addEventListener("click", function() {
66 if (active) return;
67 active = true;

tinygoMandelbrotExampleREADME.md1 match

@stevekrouseโ€ขUpdated 1 year ago
18const resp = await fetch("https://maxm-wasmblobhost.web.val.run/jpxqvyy5tphiwehzklmioklpkpz4gpzs.wasm");
19const handler = await wasmHandler(new Uint8Array(await resp.arrayBuffer()));
20export default async function(req: Request): Promise<Response> {
21 return handler(req);
22}

gptApiFrameworkmain.tsx9 matches

@xkontiโ€ขUpdated 1 year ago
79
80 /**
81 * An optional function that returns the policy to be used available at `/privacypolicy`.
82 */
83 policyGetter?: (() => string) | (() => Promise<string>);
89 * @returns The generated JSON schema.
90 */
91function getSchemaDesc(schema: z.Schema | null) {
92 if (!schema) return null;
93 return zodToJsonSchema(schema, {
140 * @returns The paths of the OpenAPI spec.
141 */
142function getPathsDesc(endpoints: EndpointDefinition[]): Paths {
143 const paths: Paths = {};
144 for (const endpoint of endpoints) {
186 * @returns The OpenAPI spec.
187 */
188function getOpenApiSpec(
189 url: string,
190 title: string,
258 * only a status code.
259 * @param endpointDef Definition of the endpoint.
260 * @param handler Function that handles the request.
261 */
262 jsonToNothing<TRequestSchema extends z.Schema>(
290 * returns a specific JSON response.
291 * @param endpointDef Definition of the endpoint.
292 * @param handler Function that handles the request.
293 */
294 nothingToJson<TResponseSchema extends z.Schema>(
320 * returns a specific JSON response.
321 * @param endpointDef Definition of the endpoint.
322 * @param handler Function that handles the request.
323 */
324 jsonToJson<TRequestSchema extends z.Schema, TResponseSchema extends z.Schema>(
356 * Regusters a handler for a verb + path combo.
357 * @param endpointDef Definition of the endpoint.
358 * @param handler Function that handles the request.
359 */
360 private registerHandler(
388
389 /**
390 * Returns a function that can be used to serve the API.
391 *
392 * @example ValTown usage:
tuna

tuna9 file matches

@jxnblkโ€ขUpdated 1 day ago
Simple functional CSS library for Val Town

getFileEmail4 file matches

@shouserโ€ขUpdated 1 month ago
A helper function to build a file's email
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.