lowest-common-ancestor
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/lowest-common-ancestor package

2.0.1 • Public • Published

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'

/lowest-common-ancestor/

    Package Sidebar

    Install

    npm i lowest-common-ancestor

    Weekly Downloads

    25

    Version

    2.0.1

    License

    ISC

    Last publish

    Collaborators

    • seb