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/$%7Bsuccess?q=function&page=2407&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 28542 results for "function"(3667ms)

lastloginmain.tsx4 matches

@elliotbraem•Updated 7 months ago
1/** @jsxImportSource npm:hono/jsx */
2async function createSession(email: string, hostname: string) {
3 const { zip } = await import("https://esm.town/v/pomdtr/sql");
4 const { sqlite } = await import("https://esm.town/v/std/sqlite");
23}
24
25async function getSession(sessionID: string, hostname: string) {
26 const { zip } = await import("https://esm.town/v/pomdtr/sql");
27 const { sqlite } = await import("https://esm.town/v/std/sqlite");
52}
53
54async function deleteSession(sessionID: string) {
55 const { sqlite } = await import("https://esm.town/v/std/sqlite");
56
64const OAUTH_COOKIE = "oauth_store";
65
66export function lastlogin(
67 handler: (req: Request) => Response | Promise<Response>,
68) {

iosMobileConfigMultipleWebClipmain.tsx8 matches

@g•Updated 7 months ago
9import { v4 as uuidv4 } from 'https://esm.sh/uuid';
10
11function html() {
12 /*
13<!DOCTYPE html>
100}
101
102function css() {
103 /*
104body {
229}
230
231function js() {
232 /*
233import { v4 as uuidv4 } from 'https://esm.sh/uuid';
244addWebClipButton.addEventListener('click', addWebClip);
245
246function addWebClip() {
247 const webClip = document.createElement('div');
248 webClip.className = 'web-clip';
281}
282
283function attachIconChoiceListeners(index) {
284 const useDefaultIcon = document.getElementById(`useDefaultIcon-${index}`);
285 const useCustomIcon = document.getElementById(`useCustomIcon-${index}`);
290}
291
292function toggleCustomIconGroup(customIconGroup) {
293 customIconGroup.style.display = customIconGroup.style.display === 'none' ? 'block' : 'none';
294}
338});
339
340async function convertToBase64(file) {
341 return new Promise((resolve, reject) => {
342 const reader = new FileReader();
347}
348
349function generateMobileConfig(data, webClips) {
350 const webClipConfigs = webClips.map((clip, index) => `
351 <dict>

markdown_downloadmain.tsx10 matches

@taras•Updated 7 months ago
16 * @returns markdown in string
17 */
18export async function html2markdown(html: string): Promise<string> {
19 if (AgentMarkdownImport) {
20 // TurndownService doesn't work on cf
34 * @returns markdown in string
35 */
36export async function readability2markdown(html: string): Promise<{ title: string; markdown: string }> {
37 const doc = await (new DOMParser().parseFromString(html, "text/html"));
38
44}
45
46function response(message: string, contentType = "text/markdown"): Response {
47 const headers = new Headers();
48 headers.set("Access-Control-Allow-Origin", "*");
64}
65
66function err(msg: string): Response {
67 const errorMessage = JSON.stringify({
68 error: {
74}
75
76function fudgeURL(url: string) {
77 try {
78 return new URL(url);
83}
84
85async function processInput(req: Request) {
86 let ret = {
87 url: undefined as undefined | URL,
129}
130
131export async function youtube2markdown(url: URL): Promise<string | undefined> {
132 function getYoutubeVideoID(url: URL): string | null {
133 const regExp = /(?:youtube\.com\/(?:[^/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?/\s]{11})/i;
134 const match = url.href.match(regExp);
161 * Simple UI that takes a url
162 */
163export function generate_ui(input_description: string, link: string, link_text: string): string {
164 const html = `
165<!DOCTYPE html>
195}
196
197export default async function(req: Request): Promise<Response> {
198 const action = await processInput(req);
199 const url = action.url;
102];
103
104function App() {
105 const [selectedItem, setSelectedItem] = useState(null);
106 const [showWords, setShowWords] = useState(true);
176}
177
178function client() {
179 createRoot(document.getElementById("root")).render(<App />);
180}
184}
185
186export default async function server(request: Request): Promise<Response> {
187 const randomColor = Math.floor(Math.random() * 16777215).toString(16);
188 return new Response(
111) Interactive vocabulary grid
12
132) Real-time search functionality
14
153) Word visibility toggle

RobotBackupCallGraphmain.tsx15 matches

@lev_greshilov•Updated 7 months ago
2import { thisWebURL } from "https://esm.town/v/stevekrouse/thisWebURL?v=2";
3
4export default async function server(req: Request): Promise<Response> {
5 // Handle GET requests
6 if (req.method === "GET") {
288 layout: {
289 name: 'preset',
290 positions: function(node) {
291 return { x: 0, y: 0 }; // Initial positions, will be overwritten
292 }
297 });
298
299 // Custom layout function
300 function customLayout() {
301 const mainGraph = cy.elements().not('#isolated, #isolated > node');
302 const isolatedGraph = cy.getElementById('isolated');
349
350 // Add event listeners for highlighting
351 cy.on('mouseover', 'node', function(e) {
352 const node = e.target;
353 highlightNodeChildrenAndParents(node);
354 });
355
356 cy.on('mouseout', 'node', function(e) {
357 unhighlightAll();
358 });
359
360 cy.on('click', 'node', function(e) {
361 const node = e.target;
362 if (node.hasClass('highlighted') || node.hasClass('parent-highlighted')) {
368 });
369
370 function highlightNodeChildrenAndParents(node) {
371 const children = node.outgoers();
372 const parents = node.incomers();
376 }
377
378 function unhighlightAll() {
379 cy.elements().removeClass('highlighted');
380 cy.elements().removeClass('parent-highlighted');
529 let match;
530 while ((match = callRegex.exec(line)) !== null) {
531 const calledFunction = match[1].toLowerCase();
532 relationships.get(caller).add(calledFunction);
533 allNodes.add(calledFunction);
534 }
535 });
545
546 const edges = [];
547 relationships.forEach((calledFunctions, file) => {
548 calledFunctions.forEach(calledFunction => {
549 edges.push({
550 data: {
551 source: file,
552 target: calledFunction,
553 },
554 });

wakatime-readme-chartmain.tsx7 matches

@loading•Updated 7 months ago
12}
13
14function roundRect(
15 ctx: any,
16 x: any,
39}
40
41function roundRectTop(
42 ctx: any,
43 x: any,
64}
65
66function App() {
67 const [chartUrl, setChartUrl] = useState<string | null>(null);
68
81}
82
83function client() {
84 createRoot(document.getElementById("root")!).render(<App />);
85}
89}
90
91async function fetchWakaTimeData(): Promise<DataPoint[]> {
92 const response = await fetch("https://wakatime.com/share/@load1n9/899abefd-d814-4e99-b603-e94af0305d4a.json");
93 const data = await response.json();
98}
99
100async function generateChart(data: DataPoint[]): Promise<string> {
101 const width = 1000;
102 const height = 600;
150}
151
152export default async function server(request: Request): Promise<Response> {
153 const url = new URL(request.url);
154

translatemain.tsx5 matches

@yieldray•Updated 7 months ago
1if (import.meta.main) Deno.serve(translate);
2
3export async function translate(req: Request) {
4 if (req.method === "POST") {
5 const { code: status, data } = await fetch("https://deepl.deno.dev/translate", {
46 };
47
48 translate = async function () {
49 this.setState({ loading: true, translation: "" });
50 const { text, source_lang, target_lang } = this.state;
53 }.bind(this);
54
55 swap = function () {
56 if (this.state.source_lang.toLowerCase() === "auto") {
57 this.setState({ source_lang: "en" });
63 }.bind(this);
64
65 handleShortcut = function (e) {
66 if (this.state.loading !== true && e.ctrlKey && e.key === "Enter") {
67 this.translate();
126 render(html\`<\${App} page="All" />\`, document.body);
127
128 async function translate({ text, source_lang, target_lang }) {
129 const Options = z.object({
130 text: z.string(),

cronmain.tsx8 matches

@with_heart•Updated 7 months ago
6const EMAIL_INTERVAL_DAYS = 14 // Send email every 2 weeks
7
8async function ensureTableExists() {
9 await sqlite.execute(`
10 CREATE TABLE IF NOT EXISTS ${KEY}_xstate_downloads_${SCHEMA_VERSION} (
24}
25
26async function fetchAndProcessData() {
27 const response = await fetch(
28 'https://api.npmjs.org/versions/xstate/last-week',
60}
61
62async function isTableEmpty() {
63 const result = await sqlite.execute(`
64 SELECT COUNT(*) as count FROM ${KEY}_xstate_downloads_${SCHEMA_VERSION}
67}
68
69async function getStats() {
70 const results = await sqlite.execute(`
71 SELECT
90}
91
92async function checkAndSendEmail() {
93 const lastSentResult = await sqlite.execute(`
94 SELECT last_sent_date FROM ${KEY}_email_log_${SCHEMA_VERSION}
141}
142
143export default async function server(req: Request,): Promise<Response> {
144 await ensureTableExists()
145
155}
156
157export default async function cron(interval: Interval,): Promise<void> {
158 await ensureTableExists()
159 await fetchAndProcessData()
160}
161
162// Schedule the function to run once per day starting from tomorrow
163const tomorrow = new Date()
164tomorrow.setDate(tomorrow.getDate() + 1,)

selfDestructmain.tsx1 match

@codemore•Updated 7 months ago
2import { fetchValInfo } from "https://esm.town/v/pomdtr/fetchValInfo?v=2";
3
4export async function selfDestruct(importMetaUrl: string) {
5 const { id } = await fetchValInfo(importMetaUrl);
6 const { vals } = new ValTown();

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.