| Current Path : /home/emeraadmin/public_html/4d695/ |
| Current File : /home/emeraadmin/public_html/4d695/common-ancestor-path.tar |
package.json 0000644 00000002031 15170145175 0007034 0 ustar 00 {
"_id": "common-ancestor-path@1.0.1",
"_inBundle": true,
"_location": "/npm/common-ancestor-path",
"_phantomChildren": {},
"_requiredBy": [
"/npm/@npmcli/arborist"
],
"author": {
"name": "Isaac Z. Schlueter",
"email": "i@izs.me",
"url": "https://izs.me"
},
"bugs": {
"url": "https://github.com/isaacs/common-ancestor-path/issues"
},
"description": "Find the common ancestor of 2 or more paths on Windows or Unix",
"devDependencies": {
"require-inject": "^1.4.4",
"tap": "^14.10.7"
},
"files": [
"index.js"
],
"homepage": "https://github.com/isaacs/common-ancestor-path#readme",
"license": "ISC",
"name": "common-ancestor-path",
"repository": {
"type": "git",
"url": "git+https://github.com/isaacs/common-ancestor-path.git"
},
"scripts": {
"postversion": "npm publish",
"prepublishOnly": "git push origin --follow-tags",
"preversion": "npm test",
"snap": "tap",
"test": "tap"
},
"tap": {
"check-coverage": true
},
"version": "1.0.1"
}
LICENSE 0000644 00000001354 15170145175 0005562 0 ustar 00 The ISC License
Copyright (c) Isaac Z. Schlueter
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
index.js 0000644 00000000731 15170145175 0006220 0 ustar 00 const {parse, sep, normalize: norm} = require('path')
function* commonArrayMembers (a, b) {
const [l, s] = a.length > b.length ? [a, b] : [b, a]
for (const x of s) {
if (x === l.shift())
yield x
else
break
}
}
const commonAncestorPath = (a, b) => a === b ? a
: parse(a).root !== parse(b).root ? null
: [...commonArrayMembers(norm(a).split(sep), norm(b).split(sep))].join(sep)
module.exports = (...paths) => paths.reduce(commonAncestorPath)