@mlightcad/common
Version:
The common package provides shared utilities and base classes that are used across the RealDWG-Web ecosystem. This package contains fundamental components for color management, event handling, logging, performance monitoring, and file loading operations.
68 lines • 2.26 kB
TypeScript
/**
* A performance entry containing a unique name, associated data,
* and a method to format the data into a human-readable string.
*
* @template T The type of the performance data.
*/
export interface AcCmPerformanceEntry<T> {
/** Unique name of this performance entry. */
name: string;
/** Performance data to be recorded. */
data: T;
/**
* Converts the performance data into a formatted string.
* @returns A string representing the performance data.
*/
format(): string;
}
/**
* A singleton class for collecting and managing performance data.
* All entries must have a unique name. Entries are stored in a Map.
*/
export declare class AcCmPerformanceCollector {
/** The singleton instance. */
private static instance;
/** Map of performance entries keyed by their unique name. */
private entries;
/**
* Private constructor to enforce singleton pattern.
*/
private constructor();
/**
* Retrieves the singleton instance of the AcCmPerformanceCollector.
* @returns The shared AcCmPerformanceCollector instance.
*/
static getInstance(): AcCmPerformanceCollector;
/**
* Adds or replaces a performance entry by name.
* @template T The type of the performance data.
* @param entry A performance entry object with name, data, and format method.
*/
collect<T>(entry: AcCmPerformanceEntry<T>): void;
/**
* Logs all performance entries to the console using their format method.
*/
printAll(): void;
/**
* Clears all collected performance entries.
*/
clear(): void;
/**
* Retrieves all entries as an array.
* @returns A copy of all performance entries.
*/
getAll(): AcCmPerformanceEntry<unknown>[];
/**
* Gets a single entry by name.
* @param name The unique name of the entry.
* @returns The matching entry or undefined.
*/
getEntry(name: string): AcCmPerformanceEntry<unknown> | undefined;
/**
* Removes an entry by name.
* @param name The name of the entry to remove.
* @returns True if the entry was removed; false if not found.
*/
remove(name: string): boolean;
}
//# sourceMappingURL=AcCmPerformanceCollector.d.ts.map