UNPKG

@stacksjs/dtsx

Version:

A modern, fast .d.ts generation tool, powered by Bun.

111 lines (110 loc) 3.02 kB
import type { Declaration, DtsGenerationConfig } from './types'; /** * Create memory-optimized configuration */ export declare function createMemoryOptimizedConfig(baseConfig: DtsGenerationConfig, memoryConfig?: MemoryConfig): DtsGenerationConfig & { memory: Required<MemoryConfig> }; /** * Estimate memory usage for a file */ export declare function estimateMemoryUsage(filePath: string): { fileSizeMB: number estimatedMemoryMB: number recommendedChunkSize: number }; /** * Format memory stats for display */ export declare function formatMemoryStats(stats: MemoryStats): string; /** * Create a streaming processor with default config */ export declare function createStreamingProcessor(config?: MemoryConfig): StreamingProcessor; /** * Memory configuration options */ export declare interface MemoryConfig { maxMemoryMB?: number chunkSize?: number aggressiveGC?: boolean maxDeclarationsInMemory?: number profile?: boolean cleanupInterval?: number } /** * Memory usage statistics */ export declare interface MemoryStats { heapUsed: number heapTotal: number external: number arrayBuffers: number rss: number heapUsedMB: number percentUsed: number } /** * Memory profiling entry */ export declare interface MemoryProfile { timestamp: number operation: string memoryBefore: MemoryStats memoryAfter: MemoryStats duration: number } /** * Streaming file processor for large files */ export declare class StreamingProcessor { constructor(config?: MemoryConfig); startMonitoring(): void; stopMonitoring(): void; triggerCleanup(): void; getMemoryStats(): MemoryStats; profile<T>(operation: string, fn: () => Promise<T>): Promise<T>; getProfiles(): MemoryProfile[]; clearProfiles(): void; *streamFile(filePath: string): AsyncGenerator<string, void, unknown>; processFileInChunks<T>(filePath: string, processor: (chunk: string[]) => Promise<T[]>, chunkLines?: number): Promise<T[]>; streamWrite(filePath: string, contentGenerator: AsyncGenerator<string>): Promise<void>; } /** * Declaration pool for memory-efficient declaration management */ export declare class DeclarationPool { constructor(maxSize?: number); add(key: string, declaration: Declaration): void; get(key: string): Declaration | undefined; has(key: string): boolean; delete(key: string): void; clear(): void; get size(): number; } /** * Lazy loading wrapper for large objects */ export declare class LazyLoader<T> { constructor(loader: () => T | Promise<T>); get(): Promise<T>; isLoaded(): boolean; unload(): void; } /** * String interning for memory efficiency */ export declare class StringInterner { constructor(maxSize?: number); intern(str: string): string; get size(): number; clear(): void; } /** * Object pool for reusing declaration objects */ export declare class ObjectPool<T> { constructor(factory: () => T, reset: (obj: T) => void, maxSize?: number); acquire(): T; release(obj: T): void; get size(): number; clear(): void; }