The array an arrow function returns: `(id) => ['/x', id]` or `(id) => { return ['/x', id]; }`.
(fn: string)
| 898 | |
| 899 | /** The array an arrow function returns: `(id) => ['/x', id]` or `(id) => { return ['/x', id]; }`. */ |
| 900 | function 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 |
no test coverage detected