* Reduce an array of path components to a more simplified path by navigating any * `"."` or `".."` entries in the path.
(components)
| 7877 | * `"."` or `".."` entries in the path. |
| 7878 | */ |
| 7879 | function reducePathComponents(components) { |
| 7880 | if (!ts.some(components)) |
| 7881 | return []; |
| 7882 | var reduced = [components[0]]; |
| 7883 | for (var i = 1; i < components.length; i++) { |
| 7884 | var component = components[i]; |
| 7885 | if (!component) |
| 7886 | continue; |
| 7887 | if (component === ".") |
| 7888 | continue; |
| 7889 | if (component === "..") { |
| 7890 | if (reduced.length > 1) { |
| 7891 | if (reduced[reduced.length - 1] !== "..") { |
| 7892 | reduced.pop(); |
| 7893 | continue; |
| 7894 | } |
| 7895 | } |
| 7896 | else if (reduced[0]) |
| 7897 | continue; |
| 7898 | } |
| 7899 | reduced.push(component); |
| 7900 | } |
| 7901 | return reduced; |
| 7902 | } |
| 7903 | ts.reducePathComponents = reducePathComponents; |
| 7904 | /** |
| 7905 | * Combines paths. If a path is absolute, it replaces any previous path. Relative paths are not simplified. |
no test coverage detected
searching dependent graphs…