diff options
author | Florian Dold <florian.dold@gmail.com> | 2019-03-27 21:01:33 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2019-03-27 21:01:33 +0100 |
commit | cc97a4dd2a967e1c2273bd5f4c5f49a5bf2e2585 (patch) | |
tree | 92c5d88706a6ffc654d1b133618d357890e7096b /node_modules/common-path-prefix/index.js | |
parent | 3771b4d6b67b34c130f3a9a1a15f42deefdb2eda (diff) |
remove node_modules
Diffstat (limited to 'node_modules/common-path-prefix/index.js')
-rw-r--r-- | node_modules/common-path-prefix/index.js | 46 |
1 files changed, 0 insertions, 46 deletions
diff --git a/node_modules/common-path-prefix/index.js b/node_modules/common-path-prefix/index.js deleted file mode 100644 index c62acea9c..000000000 --- a/node_modules/common-path-prefix/index.js +++ /dev/null @@ -1,46 +0,0 @@ -'use strict' - -function getDirectoryComponents (path, sep) { - var components = path.split(sep) - - // Remove any trailing separators and the base component. - var last = '' - while (last === '') { - last = components.pop() - } - - return components -} - -module.exports = function commonPathPrefix (paths, sep) { - if (!sep) { - var m = /(\/|\\)/.exec(paths[0]) - // The first path did not contain any directory components. Bail now. - if (!m) return '' - sep = m[0] - } - - // Object to hold prefix strings formed of the directory components of each - // path. The value for each prefix string is the number of times that prefix - // occurred in the `paths` array. - var prefixes = Object.create(null) - for (var i = 0; i < paths.length; i++) { - var dirComponents = getDirectoryComponents(paths[i], sep) - var prefix = '' - for (var j = 0; j < dirComponents.length; j++) { - prefix += dirComponents[j] + sep - prefixes[prefix] = (prefixes[prefix] || 0) + 1 - } - } - - // Find the prefixes that occurred for each path and sort them by length - // (longest first). - var common = Object.keys(prefixes).filter(function (prefix) { - return prefixes[prefix] === paths.length - }).sort(function (a, b) { - return b.length - a.length - }) - - // Return the longest common path prefix, or the empty string. - return common[0] || '' -} |