stackParser.d.ts 971 B

12345678910111213141516171819202122232425262728293031323334353637
  1. export declare type MissFunction = (key: string) => any;
  2. export declare type CacheOptions = {
  3. miss: MissFunction;
  4. ttl?: number;
  5. };
  6. export declare type StackContext = {
  7. callsite: string;
  8. context: string;
  9. };
  10. export declare type FrameMetadata = {
  11. line_number: number;
  12. file_name: string;
  13. };
  14. export declare class Cache {
  15. private cache;
  16. private ttlCache;
  17. private worker;
  18. private tllTime;
  19. private onMiss;
  20. constructor(opts: CacheOptions);
  21. workerFn(): void;
  22. get(key: string): any;
  23. set(key: string, value: any): boolean;
  24. reset(): void;
  25. }
  26. export declare type StackTraceParserOptions = {
  27. cache: Cache;
  28. contextSize: number;
  29. };
  30. export declare class StackTraceParser {
  31. private cache;
  32. private contextSize;
  33. constructor(options: StackTraceParserOptions);
  34. isAbsolute(path: any): boolean;
  35. parse(stack: FrameMetadata[]): StackContext | null;
  36. retrieveContext(error: Error): StackContext | null;
  37. }