ancestor-directories
Version:
Iterate over all parent directories of a given path
30 lines (18 loc) • 573 B
Markdown
Iterate over all parent directories of a given path
* Node.js ≥ 8.9.0
```typescript
declare function allAncestorDirectories (path: string): IterableIterator<string>
```
### Example
```javascript
import process from 'process'
import {allAncestorDirectories} from 'ancestor-directories'
const ancestors = [...allAncestorDirectories(process.cwd())]
console.log('All ancestors of cwd', ancestors)
```
[](https://git.io/vhaEz) © [Hoàng Văn Khải](https://github.com/KSXGitHub)