UNPKG

traceperf

Version:

High-performance function execution tracking and monitoring for Node.js

69 lines (68 loc) 1.99 kB
/** * Proxy-based function tracking utility * * This module provides utilities for automatically tracking nested function calls * using JavaScript Proxies without modifying the original code structure. */ import { ITrackOptions } from '../types'; /** * Interface for a function that can track other functions */ export interface ITrackFunction { <T>(fn: () => T, options?: ITrackOptions): T; } /** * A tracking context that manages function tracking using proxies */ export declare class ProxyTracker { private _trackFn; private _originalFunctions; private _trackedFunctions; private _isEnabled; /** * Create a new ProxyTracker * * @param trackFn - The function to use for tracking */ constructor(trackFn: ITrackFunction); /** * Enable or disable tracking * * @param enabled - Whether tracking is enabled */ setEnabled(enabled: boolean): void; /** * Check if tracking is enabled * * @returns Whether tracking is enabled */ isEnabled(): boolean; /** * Make a function trackable * * @param fn - The function to make trackable * @param name - The name to use for tracking * @returns A tracked version of the function */ makeTrackable(fn: Function, name?: string): Function; /** * Create a proxy for an object to track all its methods * * @param obj - The object to proxy * @param namespace - The namespace to use for tracking * @returns A proxied version of the object */ createProxy<T extends object>(obj: T, namespace?: string): T; /** * Track a module's exports * * @param moduleExports - The module's exports * @param namespace - The namespace to use for tracking * @returns A proxied version of the module's exports */ trackModule<T extends object>(moduleExports: T, namespace: string): T; /** * Clear all tracked functions */ clear(): void; }