openpanel/packages/devtools-internal/src/clean-stack.ts
Stefan Pejcic 8595a9f4e5 back
2024-05-08 19:58:53 +02:00

16 lines
398 B
TypeScript

import type { StackFrame } from "error-stack-parser";
const unrelatedFunctionName = "renderWithHooks";
export const cleanStack = (stack: StackFrame[]) => {
const firstUnrelatedIndex = stack.findIndex(
(frame) => frame.functionName === unrelatedFunctionName,
);
if (firstUnrelatedIndex !== -1) {
return stack.slice(0, firstUnrelatedIndex);
}
return stack;
};