# walk-up-path

> Given a path string, return a generator that walks up the path, emitting each dirname.

Latest version **4.0.0** (published 2024-07-08) · ISC license · 0 weekly downloads

## Install

```sh
npm install walk-up-path
pnpm add walk-up-path
yarn add walk-up-path
bun add walk-up-path
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2024-07-08 |
| First published | 2020-05-24 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | 20 \|\| >=22 |
| Dependencies | 0 |
| Unpacked size | 5.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11 |
| Author | Isaac Z. Schlueter |
| Maintainers | isaacs |

## Links

- npm: https://www.npmjs.com/package/walk-up-path
- Repository: https://github.com/isaacs/walk-up-path
- Homepage: https://github.com/isaacs/walk-up-path#readme
- Issues: https://github.com/isaacs/walk-up-path/issues
- npm.io page: https://npm.io/package/walk-up-path

## Recent versions

- 4.0.0 (latest) — 2024-07-08
- 3.0.1 — 2023-04-10
- 3.0.0 — 2023-04-09
- 2.0.0 — 2023-04-05
- 1.0.0 — 2020-05-24

## README

# walk-up-path

Given a path string, return a generator that walks up the path, emitting
each dirname.

So, to get a platform-portable walk up, instead of doing something like
this:

```js
for (let p = dirname(path); p;) {

  // ... do stuff ...

  const pp = dirname(p)
  if (p === pp)
    p = null
  else
    p = pp
}
```

Or this:

```js
for (let p = dirname(path); !isRoot(p); p = dirname(p)) {
  // ... do stuff ...
}
```

You can do this:

```js
const { walkUpPath } = require('walk-up-path')
for (const p of walkUpPath(path)) {
  // ... do stuff ..
}
```

## API

```js
const { walkUpPath } = require('walk-up-path')
```

Give the fn a string, it'll yield all the directories walking up to the
root.

---
_Source: https://npm.io/package/walk-up-path · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
