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

Function arrowReturn

src/resolution/frameworks/angular-router.ts:900–918  ·  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

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