Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

common-ancestor-path

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

common-ancestor-path

Find the common ancestor of 2 or more paths on Windows or Unix

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.1M
increased by5.45%
Maintainers
1
Weekly downloads
 
Created
Source

common-ancestor-path

Find the common ancestor of 2 or more paths on Windows or Unix

USAGE

Give it two or more path strings, and it'll do the thing.

const ancestor = require('common-ancestor-path')

// output /a/b
console.log(ancestor('/a/b/c/d', '/a/b/x/y/z', '/a/b/c/i/j/k'))

// normalizes separators, but NOT cases, since it matters sometimes
console.log(ancestor('C:\\a\\b\\c', 'C:\\a\\b\\x'))

// no common ancestor on different windows drive letters
// so, this returns null
console.log(ancestor('c:\\a\\b\\c', 'd:\\d\\e\\f'))

API

commonAncestorPath(...paths)

Returns the nearest (deepest) common ancestor path, or null if on different roots on Windows.

FAQs

Package last updated on 25 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc