@socketsecurity/lib
Version:
Core utilities and infrastructure for Socket.dev security tools
93 lines (92 loc) • 2.97 kB
TypeScript
// Type definitions
interface DebugOptions {
namespaces?: string;
spinner?: {
isSpinning: boolean;
stop(): void;
start(): void;
};
[key: string]: unknown;
}
type NamespacesOrOptions = string | DebugOptions;
interface InspectOptions {
depth?: number | null;
colors?: boolean;
[key: string]: unknown;
}
export type { DebugOptions, NamespacesOrOptions, InspectOptions };
/**
* Debug output for object inspection with caller info.
*/
declare function debugDirNs(namespacesOrOpts: NamespacesOrOptions, obj: unknown, inspectOpts?: InspectOptions | undefined): void;
/**
* Debug output with caller info.
*/
declare function debugNs(namespacesOrOpts: NamespacesOrOptions, ...args: unknown[]): void;
/**
* Debug logging function with caller info.
*/
declare function debugLogNs(namespacesOrOpts: NamespacesOrOptions, ...args: unknown[]): void;
/**
* Debug output for cache operations with caller info.
* First argument is the operation type (hit/miss/set/clear).
* Second argument is the cache key or message.
* Optional third argument is metadata object.
*/
declare function debugCacheNs(namespacesOrOpts: NamespacesOrOptions, operation: string, key: string, meta?: unknown | undefined): void;
/**
* Cache debug function with caller info.
*/
/*@__NO_SIDE_EFFECTS__*/
export declare function debugCache(operation: string, key: string, meta?: unknown | undefined): void;
/**
* Check if debug mode is enabled.
*/
/*@__NO_SIDE_EFFECTS__*/
declare function isDebugNs(namespaces: string | undefined): boolean;
/**
* Debug output with caller info (wrapper for debugNs with default namespace).
*/
declare function debug(...args: unknown[]): void;
/**
* Debug output for object inspection (wrapper for debugDirNs with default namespace).
*/
declare function debugDir(obj: unknown, inspectOpts?: InspectOptions | undefined): void;
/**
* Debug logging function (wrapper for debugLogNs with default namespace).
*/
declare function debugLog(...args: unknown[]): void;
/**
* Check if debug mode is enabled.
*/
/*@__NO_SIDE_EFFECTS__*/
declare function isDebug(): boolean;
/**
* Create a Node.js util.debuglog compatible function.
* Returns a function that conditionally writes debug messages to stderr.
*/
/*@__NO_SIDE_EFFECTS__*/
declare function debuglog(section: string): import("util").DebugLogger;
/**
* Create timing functions for measuring code execution time.
* Returns an object with start() and end() methods, plus a callable function.
*/
/*@__NO_SIDE_EFFECTS__*/
declare function debugtime(label: string): {
(): void;
start: () => void;
end: () => void;
};
// Export main debug functions with caller info.
export { debug };
// debugCache is already exported directly above
export { debugCacheNs };
export { debugDir };
export { debugDirNs };
export { debugLog };
export { debuglog };
export { debugLogNs };
export { debugNs };
export { debugtime };
export { isDebug };
export { isDebugNs };