lowest-common-ancestor
v2.0.1
Published
Finds the deepest shared file path
Downloads
39
Readme
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'