UNPKG

@opensubtitles/video-metadata-extractor

Version:

A comprehensive NPM package for video metadata extraction and subtitle processing using FFmpeg WASM. Supports metadata extraction, individual subtitle extraction, batch subtitle extraction with ZIP downloads, and memory-safe processing of files of any siz

82 lines 2.81 kB
/** * Common utility functions used across the application * Centralizes reusable functionality to eliminate duplication */ import { Result, FileValidationResult, ProcessingStats } from '../types/index.js'; /** * Async retry utility with exponential backoff */ export declare function withRetry<T>(operation: () => Promise<T>, maxAttempts?: number, baseDelay?: number): Promise<T>; /** * Safe async operation wrapper that returns Result type */ export declare function safeAsync<T>(operation: () => Promise<T>): Promise<Result<T>>; /** * Sleep utility for delays */ export declare const sleep: (ms: number) => Promise<void>; /** * Format file size in human-readable format * Eliminates duplication across multiple files */ export declare function formatFileSize(bytes: number): string; /** * Format duration from seconds to human-readable format */ export declare function formatDuration(seconds: number | string): string; /** * Get file format from filename */ export declare function getFormatFromFileName(filename: string): string; /** * Validate file extension and properties */ export declare function validateFile(file: File): FileValidationResult; /** * Generate subtitle filename with language code and metadata */ export declare function generateSubtitleFilename(movieFilename: string, language?: string, isForced?: boolean, codecName?: string): { filename: string; extension: string; }; /** * Safely decode data for preview with proper error handling */ export declare function safeDecodePreview(data: Uint8Array | string, maxLength?: number): string; /** * Create processing statistics tracker */ export declare function createProcessingStats(fileSize: number): ProcessingStats; /** * Update processing statistics */ export declare function updateProcessingStats(stats: ProcessingStats, chunksProcessed: number, memoryUsed?: number): ProcessingStats; /** * Calculate processing duration */ export declare function getProcessingDuration(stats: ProcessingStats): number; /** * Debounce function for performance optimization */ export declare function debounce<T extends (...args: any[]) => any>(func: T, wait: number): (...args: Parameters<T>) => void; /** * Throttle function for performance optimization */ export declare function throttle<T extends (...args: any[]) => any>(func: T, limit: number): (...args: Parameters<T>) => void; /** * Deep clone utility for objects */ export declare function deepClone<T>(obj: T): T; /** * Check if running in browser environment */ export declare const isBrowser: () => boolean; /** * Check if WebAssembly is supported */ export declare const isWebAssemblySupported: () => boolean; /** * Generate unique ID for operations */ export declare function generateUniqueId(): string; //# sourceMappingURL=common.d.ts.map