UNPKG

fortify2-js

Version:

MOST POWERFUL JavaScript Security Library! Military-grade cryptography + 19 enhanced object methods + quantum-resistant algorithms + perfect TypeScript support. More powerful than Lodash with built-in security.

203 lines (199 loc) 6.02 kB
'use strict'; var events = require('events'); var fortifiedFunctionCore = require('./core/fortified-function-core.js'); /** * FortifyJS - Legacy Fortified Function Wrapper * Backward compatibility wrapper that delegates to the optimized modular system */ /** * Legacy Fortified Function - Backward compatibility wrapper * Delegates to the optimized modular system while maintaining the same API */ class FortifiedFunction extends events.EventEmitter { constructor(fn, options = {}) { super(); // Create optimized instance and delegate to it this.optimizedInstance = fortifiedFunctionCore.FortifiedFunctionCore.create(fn, options); // Forward all events from the optimized instance this.optimizedInstance.on("execution_success", (data) => this.emit("execution_success", data)); this.optimizedInstance.on("execution_error", (data) => this.emit("execution_error", data)); this.optimizedInstance.on("execution_failed", (data) => this.emit("execution_failed", data)); this.optimizedInstance.on("context_created", (data) => this.emit("context_created", data)); this.optimizedInstance.on("context_cleaned", (data) => this.emit("context_cleaned", data)); this.optimizedInstance.on("cache_hit", (data) => this.emit("cache_hit", data)); this.optimizedInstance.on("cache_cleared", (data) => this.emit("cache_cleared", data)); this.optimizedInstance.on("cache_warmed", (data) => this.emit("cache_warmed", data)); this.optimizedInstance.on("memory_pressure_handled", (data) => this.emit("memory_pressure_handled", data)); this.optimizedInstance.on("auto_optimization_applied", (data) => this.emit("auto_optimization_applied", data)); this.optimizedInstance.on("options_updated", (data) => this.emit("options_updated", data)); this.optimizedInstance.on("destroyed", (data) => this.emit("destroyed", data)); } // ===== DELEGATED METHODS ===== /** * Execute the function with all optimizations */ async execute(...args) { return this.optimizedInstance.execute(...args); } /** * Get function statistics */ getStats() { return this.optimizedInstance.getStats(); } /** * Get audit log */ getAuditLog() { return this.optimizedInstance.getAuditLog(); } /** * Get cache statistics */ getCacheStats() { return this.optimizedInstance.getCacheStats(); } /** * Clear cache */ clearCache() { this.optimizedInstance.clearCache(); } /** * Clear audit log */ clearAuditLog() { this.optimizedInstance.clearAuditLog(); } /** * Get active executions count */ getActiveExecutionsCount() { return this.optimizedInstance.getActiveExecutionsCount(); } /** * Get analytics data */ getAnalyticsData() { return this.optimizedInstance.getAnalyticsData(); } /** * Get optimization suggestions */ getOptimizationSuggestions() { return this.optimizedInstance.getOptimizationSuggestions(); } /** * Get performance trends */ getPerformanceTrends() { return this.optimizedInstance.getPerformanceTrends(); } /** * Warm cache */ warmCache() { this.optimizedInstance.warmCache(); } /** * Handle memory pressure */ handleMemoryPressure(level) { this.optimizedInstance.handleMemoryPressure(level); } /** * Detect anomalies */ detectAnomalies() { return this.optimizedInstance.detectAnomalies(); } /** * Get detailed metrics */ getDetailedMetrics() { return this.optimizedInstance.getDetailedMetrics(); } /** * Get ultra-fast component metrics */ getUltraFastMetrics() { return this.optimizedInstance.getUltraFastMetrics(); } /** * Update function options dynamically */ updateOptions(newOptions) { this.optimizedInstance.updateOptions(newOptions); } /** * Optimize performance by applying recommended settings */ optimizePerformance() { this.optimizedInstance.optimizePerformance(); } // ===== PERFORMANCE TIMING METHODS ===== /** * Start timing a specific operation */ startTimer(label, metadata) { this.optimizedInstance.startTimer(label, metadata); } /** * End timing for a specific operation */ endTimer(label, additionalMetadata) { return this.optimizedInstance.endTimer(label, additionalMetadata); } /** * Measure delay between two points */ measureDelay(startPoint, endPoint) { return this.optimizedInstance.measureDelay(startPoint, endPoint); } /** * Time a function execution */ async timeFunction(label, fn, metadata) { return this.optimizedInstance.timeFunction(label, fn, metadata); } /** * Get timing statistics */ getTimingStats() { return this.optimizedInstance.getTimingStats(); } /** * Clear all timing measurements */ clearTimings() { this.optimizedInstance.clearTimings(); } /** * Get measurements by pattern */ getMeasurementsByPattern(pattern) { return this.optimizedInstance.getMeasurementsByPattern(pattern); } /** * Check if a timer is active */ isTimerActive(label) { return this.optimizedInstance.isTimerActive(label); } /** * Get active timers */ getActiveTimers() { return this.optimizedInstance.getActiveTimers(); } // ===== CLEANUP AND DESTRUCTION ===== /** * Destroy and clean up all resources */ destroy() { this.optimizedInstance.destroy(); this.removeAllListeners(); } } exports.FortifiedFunction = FortifiedFunction; //# sourceMappingURL=fortified-function.js.map