( fromFile: string, candidates: readonly T[], pathOf: (candidate: T) => string )
| 15 | * order. A file at the project root has no folder to prefer, so it gets none. |
| 16 | */ |
| 17 | export function inReferencingFolder<T>( |
| 18 | fromFile: string, |
| 19 | candidates: readonly T[], |
| 20 | pathOf: (candidate: T) => string |
| 21 | ): T[] { |
| 22 | const cut = fromFile.lastIndexOf('/'); |
| 23 | if (cut < 0) return []; |
| 24 | const folder = fromFile.slice(0, cut + 1); |
| 25 | return candidates.filter((candidate) => pathOf(candidate).startsWith(folder)); |
| 26 | } |
no test coverage detected