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