openpanel/packages/devtools-internal/src/clean-stack.ts
Stefan Pejcic 09f9f9502d packages
2024-11-07 19:03:37 +01:00

16 lines
380 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;
};