MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / arrowReturn

Function arrowReturn

src/resolution/frameworks/angular-router.ts:902–920  ·  view source on GitHub ↗

The array an arrow function returns: `(id) => ['/x', id]` or `(id) => { return ['/x', id]; }`.

(fn: string)

Source from the content-addressed store, hash-verified

900
901/** The array an arrow function returns: `(id) => ['/x', id]` or `(id) => { return ['/x', id]; }`. */
902function arrowReturn(fn: string): string | null {
903 const arrow = fn.indexOf('=>');
904 if (arrow < 0) return null;
905 let i = arrow + 2;
906 while (i < fn.length && /\s/.test(fn[i]!)) i++;
907 if (fn[i] === '(') i++;
908 if (fn[i] === '[') {
909 const end = matchBracket(fn, i);
910 return end > i ? fn.slice(i, end + 1) : null;
911 }
912 if (fn[i] === '{') {
913 const ret = /\breturn\s*\[/.exec(fn.slice(i));
914 if (!ret) return null;
915 const open = i + ret.index + ret[0].length - 1;
916 const end = matchBracket(fn, open);
917 return end > open ? fn.slice(open, end + 1) : null;
918 }
919 return null;
920}
921
922/**
923 * Where an Angular destination expression leads — the argument of

Callers 1

destinationOfFunction · 0.85

Calls 2

matchBracketFunction · 0.90
execMethod · 0.65

Tested by

no test coverage detected