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=2532&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 28846 results for "function"(1738ms)

subaudiomain.tsx4 matches

@kortina•Updated 10 months ago
22The first timestamp should be 0.`;
23
24async function processAudio(audio_uri) {
25 const substrate = new Substrate({ apiKey: Deno.env.get("SUBSTRATE_API_KEY") });
26 const opts = { cache_age: 60 * 60 * 24 * 7 };
91
92// Render site
93export default async function(req: Request): Promise<Response> {
94 const url = new URL(req.url);
95 const audio_uri = url.searchParams.get("url");
400 let currentChapterIndex = 0;
401
402 function updateText() {
403 const currentTime = audioPlayer.currentTime;
404 let segmentToDisplay = null;
515 const updateInterval = 1000 / 40;
516
517 function updateLoop(timestamp) {
518 if (timestamp - lastUpdateTime > updateInterval) {
519 updateText();

httpValErrorCatchermain.tsx13 matches

@janpaul123•Updated 10 months ago
6// Checks for minimum response size and presence of <html> tag.
7
8export default async function main(req: Request): Promise<Response> {
9 const url = new URL(req.url);
10 const valName = url.searchParams.get("val");
17 // Dynamically import the specified val
18 const module = await import(`https://esm.town/v/${valName}`);
19 const valFunction = module.default;
20
21 if (typeof valFunction !== "function") {
22 throw new Error("Imported val is not a function");
23 }
24
25 // Execute the imported val function
26 const response = await valFunction(req);
27 const originalHtml = await response.text();
28
42}
43
44function injectErrorHandlingScript(html: string): string {
45 const script = `
46 <script>
47 window.onerror = function(message, source, lineno, colno, error) {
48 window.parent.postMessage({ messageType: "valBrowserRuntimeError", errorString: "window.onerror: " + message }, "*");
49 };
50 window.addEventListener('unhandledrejection', function(event) {
51 window.parent.postMessage({ messageType: "valBrowserRuntimeError", errorString: "unhandledrejection: " + event.reason }, "*");
52 });
53 console.error = function(...args) {
54 window.parent.postMessage({ messageType: "valBrowserRuntimeError", errorString: "console.error: " + args.join(' ') }, "*");
55 };
56 window.addEventListener('load', function() {
57 setTimeout(function() {
58 window.parent.postMessage({ messageType: "success" }, "*");
59 }, 3000);
65}
66
67function createErrorResponse(errorString: string): Response {
68 const errorHtml = `
69 <html>

crypto_prices_infomain.tsx1 match

@ghsaboias•Updated 10 months ago
55};
56
57export default async function(interval) {
58 const cryptoPrices = await getCryptoPrices();
59 const formatted = formatCryptoPrices(cryptoPrices);

smallboatsapimain.tsx1 match

@joseph_c100•Updated 10 months ago
42console.log(jsonTable);
43
44export default async function(req: Request): Promise<Response> {
45 return new Response(JSON.stringify(jsonTable), {
46 headers: { "Content-Type": "application/json" },

sqliteExplorerAppREADME.md1 match

@nickgolden•Updated 10 months ago
33- [x] fix wonky sidebar separator height problem (thanks to @stevekrouse)
34- [x] make result tables scrollable
35- [x] add export to CSV, and JSON (CSV and JSON helper functions written in [this val](https://www.val.town/v/nbbaier/sqliteExportHelpers). Thanks to @pomdtr for merging the initial version!)
36- [x] add listener for cmd+enter to submit query

debugmain.tsx1 match

@moe•Updated 10 months ago
1export default async function(req: Request) {
2 return Response.json({ test: "Hello, world!", "import.meta.url": import.meta.url });
3}

streamwishmain.tsx3 matches

@tempguy•Updated 10 months ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3function unpack(p, a, c, k) {
4 while (c--) {
5 if (k[c]) {
9 return p;
10}
11function mat(r, l) {
12 return r.exec(l);
13}
14export async function streamwish(ctx) {
15 const _embed = await fetch(ctx.url);
16 const embed = await _embed.text();

amberPigmain.tsx4 matches

@tempguy•Updated 10 months ago
4const baseUrl = "https://d000d.com";
5import { blob } from "https://esm.town/v/std/blob";
6export async function doodstream(ctx: Context) {
7 let url = ctx.url;
8 if (ctx.url.includes("primewire")) {
68}
69
70export async function format(ctx) {
71 const url = ctx;
72 return {
90 };
91}
92export async function streamtape(ctx) {
93 // const _ = await blob.get("streamtapeLimit");
94 // if (Number(_) > 100000) throw new Error("limit reached");
128}
129
130export async function streamium(ctx) {
131 const _embed = await fetch(ctx.url);
132 // https://pump.watchfree.ax/start-play?imdbid=tt11389872&name=apple&season=&episode=

aimain.tsx1 match

@kakiagp•Updated 10 months ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2
3export default async function(req: Request): Promise<Response> {
4 if (req.method === "OPTIONS") {
5 return new Response(null, {

htmlExamplemain.tsx1 match

@greenlover1991•Updated 10 months ago
1// View at https://andreterron-htmlExample.web.val.run?name=Andre
2export default async function(req: Request): Promise<Response> {
3 const query = new URL(req.url).searchParams;
4
tuna

tuna9 file matches

@jxnblk•Updated 6 hours 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.