| import type * as Tracer from "../Tracer.ts" | |
| export interface ErrorWithStackTraceLimit { | |
| stackTraceLimit?: number | undefined | |
| } | |
| /** @internal */ | |
| export const addSpanStackTrace = <A extends Tracer.TraceOptions>( | |
| options: A | undefined | |
| ): A => { | |
| if (options?.captureStackTrace === false) { | |
| return options | |
| } else if (options?.captureStackTrace !== undefined && typeof options.captureStackTrace !== "boolean") { | |
| return options | |
| } | |
| const limit = (Error as ErrorWithStackTraceLimit).stackTraceLimit | |
| ;(Error as ErrorWithStackTraceLimit).stackTraceLimit = 3 | |
| const traceError = new Error() | |
| ;(Error as ErrorWithStackTraceLimit).stackTraceLimit = limit | |
| return { | |
| ...options, | |
| captureStackTrace: spanCleaner(() => traceError.stack) | |
| } as A | |
| } | |
| /** @internal */ | |
| export const makeStackCleaner = (line: number) => (stack: () => string | undefined): () => string | undefined => { | |
| let cache: string | undefined | |
| return () => { | |
| if (cache !== undefined) return cache | |
| const trace = stack() | |
| if (!trace) return undefined | |
| const lines = trace.split("\n") | |
| if (lines[line] !== undefined) { | |
| cache = lines[line].trim() | |
| return cache | |
| } | |
| } | |
| } | |
| const spanCleaner = makeStackCleaner(3) | |
Xet Storage Details
- Size:
- 1.23 kB
- Xet hash:
- 725faeef725a518ea879b08b1438fa5d6b6819782779a769c7c2c92fc17ef31d
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.