✨ Features: - App iOS completa para leer manga sin publicidad - Scraper con WKWebView para manhwaweb.com - Sistema de descargas offline - Lector con zoom y navegación - Favoritos y progreso de lectura - Compatible con iOS 15+ y Sideloadly/3uTools 📦 Contenido: - Backend Node.js con Puppeteer (opcional) - App iOS con SwiftUI - Scraper de capítulos e imágenes - Sistema de almacenamiento local - Testing completo - Documentación exhaustiva 🧪 Prueba: Capítulo 789 de One Piece descargado exitosamente - 21 páginas descargadas - 4.68 MB total - URLs verificadas y funcionales 🎉 Generated with Claude Code (https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
45 lines
852 B
JavaScript
45 lines
852 B
JavaScript
/**
|
|
* Throttle decorator
|
|
* @param {Function} fn
|
|
* @param {Number} freq
|
|
* @return {Function}
|
|
*/
|
|
function throttle(fn, freq) {
|
|
let timestamp = 0;
|
|
let threshold = 1000 / freq;
|
|
let lastArgs;
|
|
let timer;
|
|
|
|
const invoke = (args, now = Date.now()) => {
|
|
timestamp = now;
|
|
lastArgs = null;
|
|
if (timer) {
|
|
clearTimeout(timer);
|
|
timer = null;
|
|
}
|
|
fn(...args);
|
|
}
|
|
|
|
const throttled = (...args) => {
|
|
const now = Date.now();
|
|
const passed = now - timestamp;
|
|
if ( passed >= threshold) {
|
|
invoke(args, now);
|
|
} else {
|
|
lastArgs = args;
|
|
if (!timer) {
|
|
timer = setTimeout(() => {
|
|
timer = null;
|
|
invoke(lastArgs)
|
|
}, threshold - passed);
|
|
}
|
|
}
|
|
}
|
|
|
|
const flush = () => lastArgs && invoke(lastArgs);
|
|
|
|
return [throttled, flush];
|
|
}
|
|
|
|
export default throttle;
|