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/image-url.jpg?q=function&page=22&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 29123 results for "function"(4725ms)

SON-GOKUMarketplace.tsx1 match

@Itssongokuโ€ขUpdated 13 hours ago
80];
81
82export default function Marketplace() {
83 const [products, setProducts] = useState<Product[]>(SAMPLE_PRODUCTS);
84 const [searchTerm, setSearchTerm] = useState("");

EEPPortalmediaMonitoring.tsx6 matches

@solomonferedeโ€ขUpdated 13 hours ago
31}
32
33function MediaMonitoringTab({ user }: { user: CurrentUser | null }) {
34 const [entries, setEntries] = useState<MediaEntry[]>([]);
35 const [platform, setPlatform] = useState("");
198 };
199
200 // Function to open the edit modal
201 const handleEditClick = (entry: MediaEntry) => {
202 setEditingEntry(entry);
217 };
218
219 // Helper function to format dates for input[type="date"]
220 const formatDateForInput = (dateString: string) => {
221 const date = new Date(dateString);
223 };
224
225 // Function to close the edit modal
226 const handleCloseEditModal = () => {
227 setIsEditModalOpen(false);
241 };
242
243 // Function to handle changes in the edit modal form
244 const handleEditFormChange = (e: React.ChangeEvent<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>) => {
245 const { name, value } = e.target;
250 };
251
252 // Function to save the edited entry
253 const handleSaveEdit = async () => {
254 // Validate required fields from editFormData

EEPPortalsetting.tsx1 match

@solomonferedeโ€ขUpdated 14 hours ago
55 }, []);
56
57 // Function to calculate experience based on dateOfEmployment
58 const calculateExperience = (dateOfEmployment) => {
59 if (!dateOfEmployment) return "N/A";

EEPPortalprofileTab.tsx1 match

@solomonferedeโ€ขUpdated 14 hours ago
51 };
52
53 // Function to fetch supervisor's name by their ID
54 const fetchSupervisorName = async (supervisorId) => {
55 if (!supervisorId) {

untitled-6797main.tsx1 match

@Ruba2โ€ขUpdated 14 hours ago
1import React, { useState } from "react"; import { Card, CardContent } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { Button } from "@/components/ui/button";
2
3export default function ResearcTreeApp() { const [file, setFile] = useState(null); const [report, setReport] = useState(null); const [loading, setLoading] = useState(false); const [page, setPage] = useState("home");
4
5const handleUpload = async () => { if (!file) return; setLoading(true); const formData = new FormData(); formData.append("file", file);

leximain.tsx27 matches

@legalโ€ขUpdated 15 hours ago
82}
83
84function generateHtmlShell(initialQuery, sourceUrl) {
85 const escapedQuery = initialQuery.replace(/</g, "&lt;").replace(/>/g, "&gt;");
86 return `
92<title>Lexi - AI Legal Assistant</title>
93<style>
94@keyframes fadeIn{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}:root{--sidebar-expanded-width:260px;--sidebar-collapsed-width:70px;--sidebar-transition-duration:0.3s}body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;margin:0;background-color:#f4f7f9;color:#333a40;display:flex;min-height:100vh;font-size:16px;overflow-x:hidden}.app-container{display:flex;width:100%}.sidebar{width:var(--sidebar-expanded-width);background-color:#2d3748;color:#e2e8f0;height:100vh;position:fixed;left:0;top:0;box-shadow:3px 0 10px rgba(0,0,0,.1);display:flex;flex-direction:column;transition:width var(--sidebar-transition-duration) ease-in-out;z-index:100}.sidebar.collapsed{width:var(--sidebar-collapsed-width)}.sidebar.collapsed .sidebar-header h2,.sidebar.collapsed .sidebar-header .tagline,.sidebar.collapsed .nav-item .nav-item-text-main,.sidebar.collapsed .sidebar-footer .footer-text{display:none}.sidebar .nav-item svg{margin-right:12px;width:20px;height:20px;opacity:.8;flex-shrink:0}.sidebar.collapsed .nav-item svg{margin-right:0}.sidebar.collapsed .nav-item{justify-content:center;padding-left:0;padding-right:0}.sidebar-header{text-align:center;padding:0 20px;margin-bottom:25px}.sidebar-header h2{font-size:2em;color:#4299e1;font-weight:600;letter-spacing:.5px;margin:0}.sidebar-header .tagline{font-size:.8em;color:#a0aec0;margin-top:2px}.hamburger-container{display:flex;align-items:center;justify-content:flex-start;padding:10px 20px;height:40px}.sidebar.collapsed .hamburger-container{justify-content:center;padding:10px 0}.hamburger-menu{display:inline-block;cursor:pointer;background:0 0;border:none;padding:10px;position:relative;width:30px;height:22px;box-sizing:content-box}.hamburger-box{width:30px;height:22px;display:inline-block;position:relative}.hamburger-inner{display:block;top:50%;margin-top:-1px}.hamburger-inner,.hamburger-inner::after,.hamburger-inner::before{width:30px;height:2px;background-color:#e2e8f0;border-radius:4px;position:absolute;transition-property:transform;transition-duration:.15s;transition-timing-function:ease}.hamburger-inner::after,.hamburger-inner::before{content:"";display:block}.hamburger-inner::before{top:-8px}.hamburger-inner::after{bottom:-8px}.sidebar:not(.collapsed) .hamburger-menu .hamburger-inner{transform:rotate(180deg)}.sidebar:not(.collapsed) .hamburger-menu .hamburger-inner::before{transform:translateY(8px) rotate(45deg)}.sidebar:not(.collapsed) .hamburger-menu .hamburger-inner::after{transform:translateY(-8px) rotate(-45deg)}.nav-menu{list-style:none;padding:0;margin:0;flex-grow:1}.nav-item{display:flex;align-items:center;padding:14px 20px;margin-bottom:8px;cursor:pointer;transition:background-color .2s ease,color .2s ease;font-weight:500;white-space:nowrap;position:relative}.nav-item-text-main{transition:opacity .2s ease-in-out}.nav-item-text-hover{display:none}.sidebar.collapsed .nav-item .nav-item-text-main{opacity:0}.nav-item:hover{background-color:#4a5568;color:#fff}.nav-item.active{background-color:#4299e1;color:#fff;font-weight:600}.nav-item.active svg{opacity:1}.sidebar.collapsed .nav-item .nav-item-text-hover{position:absolute;left:calc(var(--sidebar-collapsed-width) - 10px);top:50%;transform:translateY(-50%) translateX(-15px) scale(.9);background-color:#4a5568;color:#fff;padding:10px 15px;border-radius:4px;font-size:.9em;white-space:nowrap;z-index:110;opacity:0;pointer-events:none;transition:opacity .2s ease,transform .2s ease;box-shadow:2px 2px 8px rgba(0,0,0,.2)}.sidebar.collapsed .nav-item:hover .nav-item-text-hover{opacity:1;transform:translateY(-50%) translateX(0) scale(1);pointer-events:auto}.sidebar-footer{font-size:.8em;color:#a0aec0;text-align:center;padding:15px 20px;border-top:1px solid #4a5568;white-space:nowrap}.sidebar-footer a{color:#7f9cf5;text-decoration:none}.sidebar-footer a:hover{text-decoration:underline}.main-content{margin-left:var(--sidebar-expanded-width);padding:30px 40px;flex-grow:1;overflow-y:auto;transition:margin-left var(--sidebar-transition-duration) ease-in-out;width:calc(100% - var(--sidebar-expanded-width))}.sidebar.collapsed+.main-content{margin-left:var(--sidebar-collapsed-width);width:calc(100% - var(--sidebar-collapsed-width))}.view{display:none;animation:fadeIn .4s ease-out}.view.active-view{display:block}.view>h1{font-size:2.2em;color:#2d3748;margin-bottom:25px;border-bottom:2px solid #e2e8f0;padding-bottom:15px}.card{background-color:#fff;border-radius:8px;padding:25px;margin-bottom:25px;box-shadow:0 4px 12px rgba(0,0,0,.07);border:1px solid #e2e8f0}.card h2,.card h3{color:#2d3748;margin-top:0;border-bottom:1px solid #edf2f7;padding-bottom:10px;margin-bottom:15px}button,.button{padding:10px 18px;border:none;border-radius:5px;font-size:1rem;font-weight:500;cursor:pointer;transition:background-color .2s ease,transform .1s ease;display:inline-flex;align-items:center;justify-content:center;gap:8px;text-decoration:none}.button-primary{background-color:#3182ce;color:#fff}.button-primary:hover{background-color:#2b6cb0;transform:translateY(-1px)}.button-primary:disabled{background-color:#a0aec0;cursor:not-allowed}.button-primary .spinner{display:none;width:16px;height:16px;border:2px solid hsla(0,0%,100%,.3);border-radius:50%;border-top-color:#fff;animation:spin .8s linear infinite}.button-primary.loading .spinner{display:inline-block}.button-primary.loading span{margin-right:8px}.button-secondary{background-color:#e2e8f0;color:#2d3748}.button-secondary:hover{background-color:#cbd5e0}.button-danger{background-color:#e53e3e;color:#fff}.button-danger:hover{background-color:#c53030}label{display:block;margin-bottom:8px;font-weight:600;color:#4a5568}input[type=file],input[type=text],textarea{width:calc(100% - 22px);padding:10px;margin-bottom:15px;border:1px solid #cbd5e0;border-radius:4px;font-size:1rem;box-sizing:border-box}input[type=file]{padding:8px;background-color:#f7fafc}textarea{min-height:100px;resize:vertical}#status-container{margin-top:20px;font-family:monospace;font-size:.9em;line-height:1.4;max-height:250px;overflow-y:auto;padding:10px;border:1px solid #e2e8f0;border-radius:4px;background-color:#f7fafc}.status-entry{margin-bottom:8px;padding:10px 15px;border-radius:4px;white-space:pre-wrap;word-wrap:break-word;animation:fadeIn .3s ease-out;font-size:.95em}.status-entry.info{background-color:#ebf8ff;color:#3182ce;border-left:4px solid #3182ce}.status-entry.error{background-color:#fff5f5;color:#c53030;border-left:4px solid #c53030;font-weight:700}.status-entry.progress{background-color:#f0fff4;color:#38a169;border-left:4px solid #38a169}#structured-results-container{margin-top:20px}.result-block{margin-bottom:20px;padding:20px;background-color:#f9fafb;border:1px solid #e2e8f0;border-radius:6px}.result-block h3{margin-top:0;color:#2d3748;font-size:1.25em;border-bottom:1px solid #e2e8f0;padding-bottom:8px;margin-bottom:12px}.result-block p{margin:6px 0;line-height:1.6}.result-block p strong{color:#2d3748;min-width:170px;display:inline-block}.result-block pre{background-color:#edf2f7;padding:12px;border-radius:4px;white-space:pre-wrap;word-wrap:break-word;font-size:.9em;max-height:280px;overflow-y:auto;border:1px solid #cbd5e0}.finding-card{border:1px solid #d1dce5;border-radius:6px;padding:18px;margin-bottom:18px;background-color:#fff;box-shadow:0 2px 6px rgba(0,0,0,.05)}.finding-card h4{margin-top:0;margin-bottom:10px;color:#2b6cb0;font-size:1.1em}.finding-card p{font-size:.95em;margin:5px 0}.finding-card p strong{color:#4a5568;min-width:140px}.disclaimer{font-size:.8em;color:#718096;text-align:center;margin-top:12px;padding:8px;background-color:#edf2f7;border-radius:4px}.history-list{list-style:none;padding:0}.history-item{display:flex;flex-direction:column;padding:20px;margin-bottom:15px;border:1px solid #e2e8f0;border-radius:6px;background-color:#fff;box-shadow:0 2px 5px rgba(0,0,0,.05)}.history-item strong{font-size:1.1em;color:#2d3748;margin-bottom:5px;display:block}.history-item .meta{font-size:.9em;color:#718096;margin-bottom:12px}.history-item .actions{margin-top:15px;display:flex;gap:10px;flex-wrap:wrap}.suggestion-group{margin-bottom:15px}.suggestion-group-header{display:flex;align-items:center;margin-bottom:8px;background-color:#e9f0f7;padding:8px 12px;border-radius:4px;cursor:pointer}.suggestion-group-header input[type=checkbox]{margin-right:10px;height:17px;width:17px}.suggestion-group-header label{font-weight:600;font-size:1.05em;color:#2d3748;margin-bottom:0;flex-grow:1;cursor:pointer}.suggestion-group-tasks{padding-left:20px}#iq-suggested-tasks-list-container{margin-bottom:10px}#iq-task-selection-info{font-size:.9em;color:#718096;margin-bottom:15px}#iq-suggested-tasks-list{max-height:350px;overflow-y:auto;border:1px solid #cbd5e0;padding:10px;border-radius:4px;background-color:#fdfdfd}.suggestion-item-label{display:flex;align-items:center;width:100%;margin-bottom:6px;font-weight:400;padding:10px;border-radius:4px;cursor:pointer;transition:background-color .2s;border:1px solid transparent;background-color:#fff;box-shadow:0 1px 2px rgba(0,0,0,.05)}.suggestion-item-label:hover{background-color:#f0f4f8}.suggestion-item-label.high-priority-task{background-color:#e6fffa;border-left:3px solid #38a169}.suggestion-item-label input[type=checkbox]{margin-right:10px;vertical-align:middle;accent-color:#3182ce;height:16px;width:16px;flex-shrink:0}.suggestion-item-label .task-text{flex-grow:1}.iq-input-method{margin-bottom:20px;padding-bottom:15px;border-bottom:1px solid #edf2f7}.iq-input-method:last-child{border-bottom:none;margin-bottom:0;padding-bottom:0}.iq-input-method h3{font-size:1.1em;color:#4a5568;margin-bottom:10px}@media (max-width:992px){:root{--sidebar-expanded-width:220px;--sidebar-collapsed-width:60px}}@media (max-width:768px){.sidebar:not(.expanded-mobile){width:var(--sidebar-collapsed-width)}.sidebar.expanded-mobile{width:250px;box-shadow:0 0 15px rgba(0,0,0,.2)}.sidebar.collapsed:not(.expanded-mobile) .sidebar-header h2,.sidebar.collapsed:not(.expanded-mobile) .sidebar-header .tagline,.sidebar.collapsed:not(.expanded-mobile) .nav-item .nav-item-text-main,.sidebar.collapsed:not(.expanded-mobile) .sidebar-footer .footer-text{display:none}.main-content{margin-left:var(--sidebar-collapsed-width);width:calc(100% - var(--sidebar-collapsed-width))}.view>h1{font-size:1.8em}}
95</style>
96</head>
119</div>
120<script>
121(function() {
122const DOCS_KEY = 'lexi_docs_v2', ANALYSES_KEY = 'lexi_analyses_v2', MAX_SUGGESTIONS = 15;
123let currentView, iqPhase, iqDocText, iqDocSource, iqTask, iqDocId, iqAnalysisResult;
138});
139
140function navigateTo(viewId, params = {}) {
141 currentView = viewId;
142 for (const key in views) { views[key].classList.remove('active-view'); }
159}
160
161function setupEventListeners() {
162 hamburgerToggle.addEventListener('click', () => {
163 const isExpanded = sidebar.classList.contains('expanded-mobile') || !sidebar.classList.contains('collapsed');
219const esc = (unsafe) => (unsafe === null || typeof unsafe === 'undefined') ? '' : String(unsafe).replace(/[&<>"']/g, c => ({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#039;'})[c]);
220
221function renderDashboard() {
222 const docs = getStore(DOCS_KEY);
223 const analyses = getStore(ANALYSES_KEY);
240}
241
242function renderNewInquiryView(params = {}) {
243 views['new-inquiry'].innerHTML = \`<h1>New Inquiry</h1><form id="iq-form"><div class="card" id="iq-doc-input-section"><h2>Step 1: Provide Document</h2><p style="margin-bottom:20px;color:#555;">Upload the legal PDF document you want to analyze.</p><div class="iq-input-method"><label for="iq-doc-file">Select PDF (Max 10MB):</label><input type="file" id="iq-doc-file" accept=".pdf"></div></div><div class="card" id="iq-task-section" style="display:none;"><h2>Step 2: Define Task(s)</h2><p id="iq-task-selection-info"></p><div id="iq-suggested-tasks-list-container"><label>Suggested Tasks (click category to select/deselect all):</label><div id="iq-suggested-tasks-list"><p><em>Processing document...</em></p></div></div><label for="iq-custom-task-query">Your Legal Task(s) / Query:</label><textarea id="iq-custom-task-query" placeholder="E.g., 'Identify all termination clauses and their conditions.'"></textarea></div><div class="card" style="padding-top:10px;"><button type="submit" id="iq-submit-btn" class="button button-primary"><span id="iq-submit-btn-text">Process & Get Suggestions</span><div class="spinner"></div></button></div></form><div class="card" id="iq-results-section" style="display:none;"><h2>Analysis Status & Results</h2><div id="status-container"></div><div id="structured-results-container" style="display:none;"></div><button id="iq-save-btn" class="button button-primary" data-action="save-analysis" style="display:none;margin-top:15px;">Save Analysis</button></div>\`;
244
285};
286
287async function fetchAndPopulateSuggestions(docSample) {
288 iqTasksListDiv.innerHTML = '<p><em>Fetching task suggestions...</em></p>';
289 const formData = new FormData();
302}
303
304function populateSuggestedTasks(groups = {}) {
305 iqTasksListDiv.innerHTML = '';
306 updateTaskSelectionInfo();
342}
343
344function handleGroupCheckboxChange(event) {
345 const groupCheckbox = event.target;
346 const category = groupCheckbox.dataset.category;
361}
362
363function handleSuggestionCheckboxChange() {
364 if (this.checked) {
365 const selectedCount = iqTasksListDiv.querySelectorAll('input[name="iq_suggested_task"]:checked').length;
375}
376
377function enforceMaxSelections() {
378 const allTaskCheckboxes = Array.from(iqTasksListDiv.querySelectorAll('input[name="iq_suggested_task"]'));
379 const selectedCount = allTaskCheckboxes.filter(cb => cb.checked).length;
390}
391
392function updateAllGroupCheckboxesStates() {
393 iqTasksListDiv.querySelectorAll('input[id^="group-"]').forEach(gcb => {
394 const category = gcb.dataset.category;
405const updateTaskSelectionInfo = () => { if (!iqTaskInfo) return; const count = iqTasksListDiv.querySelectorAll('input[name="iq_suggested_task"]:checked').length; iqTaskInfo.textContent = \`Selected: \${count} / \${MAX_SUGGESTIONS}. Selections populate query box below.\`; };
406
407async function handleDocInputAndSuggest() {
408 const file = iqFileInput.files[0];
409 if (!file) return addStatus('Please upload a PDF file.', 'error');
441}
442
443async function handleFinalAnalysis() {
444 iqTask = iqCustomTaskInput.value.trim();
445 if (!iqTask) return addStatus('Please define or select a legal task.', 'error');
478}
479
480function renderAnalysisResults(data) {
481 if (!data || typeof data !== 'object') return '<p>Invalid analysis results data.</p>';
482 let html = '';
503}
504
505function saveCurrentAnalysis() {
506 if (iqAnalysisResult && iqDocId && iqTask) {
507 const analyses = getStore(ANALYSES_KEY);
515}
516
517function renderHistoryView() {
518 const docs = getStore(DOCS_KEY);
519 const analyses = getStore(ANALYSES_KEY);
542}
543
544function deleteDocument(docId) {
545 let docs = getStore(DOCS_KEY);
546 let analyses = getStore(ANALYSES_KEY);
550}
551
552function deleteAnalysis(analysisId) {
553 let analyses = getStore(ANALYSES_KEY);
554 setStore(ANALYSES_KEY, analyses.filter(an => an.id !== analysisId));
556}
557
558function renderDocumentDetailView(docId) {
559 const doc = getStore(DOCS_KEY).find(d => d.id === docId);
560 const dv = views['document-detail'];
574}
575
576function renderAnalysisDetailView(analysisId) {
577 const an = getStore(ANALYSES_KEY).find(a => a.id === analysisId);
578 const dv = views['analysis-detail'];
583}
584
585function renderSettingsView() {
586 views.settings.innerHTML = \`<h1>Settings</h1><div class="card"><h3>Manage Local Data</h3><p>Documents and analyses are stored in your browser. Data does not leave your computer unless sent for AI analysis.</p><p><strong>Warning: This is irreversible.</strong></p><button class="button button-danger" data-action="clear-local-storage">Clear All Local Data</button></div>\`;
587}
592}
593
594export default async function(req: Request) {
595 const { OpenAI } = await import("https://esm.town/v/std/openai");
596 const { PDFExtract } = await import("npm:pdf.js-extract");
611 const MAX_TEXT_ANALYZE = 30000;
612
613 async function extractPdfText(data: ArrayBuffer, fileName: string, log: LogEntry[]): Promise<string | null> {
614 log.push({ agent: "PDF", type: "step", message: `Processing: ${fileName}` });
615 try {
630 }
631
632 async function callAI(
633 systemPrompt: string,
634 userMessage: string,
660 }
661
662 async function ingestDocument(file: File, log: LogEntry[]): Promise<{ text: string | null; sourceDesc: string }> {
663 if (!file) {
664 log.push({ agent: "Ingest", type: "error", message: "No file provided." });

min-md-blogREADME.md7 matches

@arfanโ€ขUpdated 15 hours ago
61โ”œโ”€โ”€ routes.ts # Request routing and page rendering
62โ”œโ”€โ”€ config.ts # Shared configuration and types
63โ”œโ”€โ”€ utils.ts # Utility functions
64โ”œโ”€โ”€ components.tsx # Reusable UI components
65โ”œโ”€โ”€ App.tsx # Homepage component
87- Icon-enhanced headings for better visual hierarchy
88- Proper list indentation and task list checkboxes
89- Code blocks with copy functionality
90- Responsive table rendering
91- Support for remark-gfm (GitHub Flavored Markdown)
94- Removed KaTeX dependencies
95- Streamlined CSS and JavaScript loading
96- Maintained theme management functionality
97
98## Refactoring Results
99
100### Code Improvements
101- **Enhanced Markdown**: Better visual hierarchy and functionality
102- **Removed Dependencies**: KaTeX scripts eliminated
103- **Better UX**: Copy buttons, proper checkboxes, responsive tables
109- โŒ Plain text task lists
110- โŒ Poor list indentation
111- โŒ Basic code blocks without copy functionality
112
113### New Features
1253. Task lists with `- [ ]` and `- [x]` syntax
1264. Tables with proper header/body structure
1275. Code blocks with automatic copy functionality
1286. Click post cards to view full content
1297. Use theme selector to change appearance
139- **Accessibility**: Proper ARIA labels and semantic HTML
140
141The blog now provides a superior markdown experience with better visual design, enhanced functionality, and cleaner code architecture.

min-md-blogshowcase.md2 matches

@arfanโ€ขUpdated 15 hours ago
41
42```javascript
43function greet(name) {
44 console.log(`Hello, ${name}!`);
45 return `Welcome to our blog, ${name}`;
46}
47
48// Call the function
49greet("World");
50```

min-md-blogLayout.tsx5 matches

@arfanโ€ขUpdated 15 hours ago
4// Simplified theme management script
5const THEME_SCRIPT = `
6function switchTheme(el) {
7 document.documentElement.setAttribute('data-theme', el.value);
8 localStorage.setItem('blog-theme', el.value);
9}
10
11document.addEventListener('DOMContentLoaded', function() {
12 const savedTheme = localStorage.getItem('blog-theme');
13 const themeSelect = document.getElementById('theme');
19
20 if (themeSelect) {
21 themeSelect.addEventListener('change', function() { switchTheme(this); });
22 }
23});
27 * Simple layout wrapper
28 */
29export function Layout({ children }: { children: ReactNode }) {
30 return <div className="space-y-6">{children}</div>;
31}
34 * Creates complete HTML document with DaisyUI styling
35 */
36export function createHtmlDocument(bodyContent: string): string {
37 return `<!DOCTYPE html>
38<html lang="en">

SON-GOKUutils.ts22 matches

@Itssongokuโ€ขUpdated 15 hours ago
57
58// Luhn Algorithm Implementation
59export function luhnChecksum(cardNumber: string): number {
60 let sum = 0;
61 let alternate = false;
79}
80
81export function generateValidCardNumber(type: CardType, customBin?: string): string {
82 const cardInfo = cardTypes[type];
83
112}
113
114export function generateCVV(length: number): string {
115 let cvv = '';
116 for (let i = 0; i < length; i++) {
120}
121
122export function generateExpiryDate(): { month: string; year: string } {
123 const currentYear = new Date().getFullYear();
124 const month = Math.floor(Math.random() * 12) + 1;
131}
132
133export function generateHolderName(): string {
134 const firstNames = [
135 'ALEX', 'JORDAN', 'TAYLOR', 'CASEY', 'MORGAN', 'RILEY', 'AVERY', 'QUINN',
149}
150
151export function generateCardData(type: CardType, customBin?: string): CardData {
152 const cardInfo = cardTypes[type];
153 const number = generateValidCardNumber(type, customBin);
166}
167
168export function formatCardNumber(number: string): string {
169 // Format card number with spaces for better readability
170 if (number.length === 15) {
177}
178
179export function validateBin(bin: string, type: CardType): { valid: boolean; message: string } {
180 if (!bin || bin.trim() === '') {
181 return { valid: true, message: 'Using default BIN' };
213}
214
215export function validateCardNumber(number: string): boolean {
216 // Remove spaces and validate using Luhn algorithm
217 const cleanNumber = number.replace(/\s/g, '');
228}
229
230export function parseBulkFormat(input: string): BulkCardFormat {
231 // Support formats like:
232 // 5678990|01|2028|000
257}
258
259function isPlaceholder(value: string): boolean {
260 const trimmed = value.trim().toLowerCase();
261 return trimmed === 'xxx' || trimmed === 'xx' || trimmed === 'xxxx' || trimmed === '';
262}
263
264export function generateCardDataFromFormat(type: CardType, format: BulkCardFormat): CardData {
265 const cardInfo = cardTypes[type];
266
331}
332
333export function validateBulkFormat(input: string): { valid: boolean; message: string; format?: BulkCardFormat } {
334 if (!input || !input.trim()) {
335 return { valid: false, message: 'Format string is required' };
390}
391
392export function getFormatExamples(): string[] {
393 return [
394 '424242|12|2028|123',
401}
402
403export function getFormatDescription(): string {
404 return `Format: BIN|MONTH|YEAR|CVV
405โ€ข Use 'xxx' or 'xx' for random values
423}
424
425export function generateMultipleCards(options: BulkGenerationOptions): BulkGenerationResult {
426 const startTime = Date.now();
427 const cards: CardData[] = [];
462}
463
464export function validateQuantity(quantity: number, mode: 'default' | 'custom'): { valid: boolean; message: string } {
465 if (!Number.isInteger(quantity) || quantity < 1) {
466 return { valid: false, message: 'Quantity must be a positive integer' };
487}
488
489export function exportCardsAsCSV(cards: CardData[]): string {
490 const headers = ['Card Number', 'CVV', 'Expiry Month', 'Expiry Year', 'Cardholder Name', 'Card Type'];
491 const csvRows = [headers.join(',')];
506}
507
508export function exportCardsAsJSON(cards: CardData[]): string {
509 return JSON.stringify(cards, null, 2);
510}
511
512export function exportCardsAsText(cards: CardData[]): string {
513 return cards.map((card, index) => {
514 return `Card ${index + 1}:
522}
523
524export function exportCardsAsList(cards: CardData[]): string {
525 return cards.map(card => {
526 // Convert 4-digit year to 2-digit year
530}
531
532export function detectCardType(bin: string): CardType | null {
533 const cleanBin = bin.replace(/\s/g, '');
534
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.