MCPcopy
hub / github.com/refined-github/refined-github / parseFeatureNameFromStack

Function parseFeatureNameFromStack

source/helpers/errors.ts:20–29  ·  view source on GitHub ↗
(stack: string = new Error('stack').stack!)

Source from the content-addressed store, hash-verified

18
19// Reads from path like assets/features/NAME.js
20export function parseFeatureNameFromStack(stack: string = new Error('stack').stack!): FeatureId | undefined {
21 // The stack may show other features due to cross-feature imports, but we want the top-most caller so we need to reverse it
22 const match = stack
23 .split('\n')
24 .toReversed()
25 .join('\n')
26 // eslint-disable-next-line @typescript-eslint/prefer-regexp-exec -- Linear code is best
27 .match(/assets\/features\/(?<id>.+)\.js/);
28 return match?.groups?.id as FeatureId | undefined;
29}
30
31/* Log errors only once */
32const loggedStacks = new Set<string>();

Callers 2

logErrorFunction · 0.85
observeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected