# common-dir

> Returns the parent directory common to each path

Latest version **3.0.1** (published 2021-03-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install common-dir
pnpm add common-dir
yarn add common-dir
bun add common-dir
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.1 |
| Published | 2021-03-13 |
| First published | 2014-06-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8 |
| Dependencies | 1 |
| Unpacked size | 4.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Lloyd Brookes |
| Maintainers | 75lb |
| Keywords | common, directory, parent, folder |

## Links

- npm: https://www.npmjs.com/package/common-dir
- Repository: https://github.com/75lb/common-dir
- Homepage: https://github.com/75lb/common-dir#readme
- Issues: https://github.com/75lb/common-dir/issues
- npm.io page: https://npm.io/package/common-dir

## Dependencies (1)

- [common-sequence](https://npm.io/package/common-sequence.md) ^2.0.0

## Alternatives

- [@mdxeditor/editor](https://npm.io/package/@mdxeditor/editor.md) — 962.4K weekly downloads
- [mmdb-lib](https://npm.io/package/mmdb-lib.md) — 680.9K weekly downloads
- [playcanvas](https://npm.io/package/playcanvas.md) — 36.2K weekly downloads
- [@glw907/cairn-cms](https://npm.io/package/@glw907/cairn-cms.md) — 967 weekly downloads
- [markdown-to-confluence](https://npm.io/package/markdown-to-confluence.md) — 103 weekly downloads

## Recent versions

- 3.0.1 (latest) — 2021-03-13
- 3.0.0 — 2019-10-21
- 2.0.2 — 2018-05-12
- 1.0.1 — 2016-12-06
- 1.0.0 — 2016-02-13
- 0.1.4 — 2014-07-02
- 0.1.3 — 2014-06-13
- 0.1.2 — 2014-06-11
- 0.1.1 — 2014-06-08
- 0.1.0 — 2014-06-08

## README

[![view on npm](https://badgen.net/npm/v/common-dir)](https://www.npmjs.org/package/common-dir)
[![npm module downloads](https://badgen.net/npm/dt/common-dir)](https://www.npmjs.org/package/common-dir)
[![Gihub repo dependents](https://badgen.net/github/dependents-repo/75lb/common-dir)](https://github.com/75lb/common-dir/network/dependents?dependent_type=REPOSITORY)
[![Gihub package dependents](https://badgen.net/github/dependents-pkg/75lb/common-dir)](https://github.com/75lb/common-dir/network/dependents?dependent_type=PACKAGE)
[![Build Status](https://travis-ci.org/75lb/common-dir.svg?branch=master)](https://travis-ci.org/75lb/common-dir)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](https://github.com/feross/standard)

<a name="module_common-dir"></a>

## common-dir
<a name="exp_module_common-dir--commonDir"></a>

### commonDir(files) ⇒ <code>string</code> ⏏
Returns the parent directory common to each path.

**Kind**: Exported function  
**Returns**: <code>string</code> - A single path ending with the path separator, e.g. '/user/some/folder/'  

| Param | Type | Description |
| --- | --- | --- |
| files | <code>Array</code> | An array of file paths to inspect |

**Example**  
```js
> const commonDir = require('common-dir')
> files = [
  '/Users/75lb/one/package.json',
  '/Users/75lb/one/test',
  '/Users/75lb/two/test/main.js'
]
> commonDir(files)
'/Users/75lb/'
```

* * *

&copy; 2014-21 Lloyd Brookes <75pound@gmail.com>. Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).

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