2.0.1 • Published 6 years ago

lowest-common-ancestor v2.0.1

Weekly downloads
6
License
ISC
Repository
gitlab
Last release
6 years ago

lowest-common-ancestor

lowestCommonAncestor(...filepaths)

Finds the deepest shared file path.

The OS-dependent directory separator (e.g. / or \) is respected.

filepaths

Multiple relative or absolute file system paths.

Usage

import {lowestCommonAncestor} from 'lowest-common-ancestor'
lowestCommonAncestor(
  '/foo/bar/abc',
  '/foo/bar/def',
  '/foo/xyz'
)

// -> '/foo'
const paths = new Set([
  '/foo/bar/abc',
  '/foo/bar/def',
  '/foo/xyz'
])

lowestCommonAncestor(...paths)

// -> '/foo'
2.0.1

6 years ago

2.0.0

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago