add more comments
This commit is contained in:
parent
25c2816a85
commit
0647d374a3
@ -39,6 +39,7 @@ export function getEarliestCommonAncestorFrom(paths: Array<NodePath>): NodePath
|
|||||||
for (var ancestry of (ancestries: Array)) {
|
for (var ancestry of (ancestries: Array)) {
|
||||||
var path = ancestry[i + 1];
|
var path = ancestry[i + 1];
|
||||||
|
|
||||||
|
// first path
|
||||||
if (!earliest) {
|
if (!earliest) {
|
||||||
earliest = path;
|
earliest = path;
|
||||||
continue;
|
continue;
|
||||||
@ -46,7 +47,7 @@ export function getEarliestCommonAncestorFrom(paths: Array<NodePath>): NodePath
|
|||||||
|
|
||||||
// handle containers
|
// handle containers
|
||||||
if (path.listKey && earliest.listKey === path.listKey) {
|
if (path.listKey && earliest.listKey === path.listKey) {
|
||||||
// we're in the same container so check
|
// we're in the same container so check if we're earlier
|
||||||
if (path.key < earliest.key) {
|
if (path.key < earliest.key) {
|
||||||
earliest = path;
|
earliest = path;
|
||||||
continue;
|
continue;
|
||||||
@ -57,7 +58,7 @@ export function getEarliestCommonAncestorFrom(paths: Array<NodePath>): NodePath
|
|||||||
var earliestKeyIndex = keys.indexOf(earliest.parentKey);
|
var earliestKeyIndex = keys.indexOf(earliest.parentKey);
|
||||||
var currentKeyIndex = keys.indexOf(path.parentKey);
|
var currentKeyIndex = keys.indexOf(path.parentKey);
|
||||||
if (earliestKeyIndex > currentKeyIndex) {
|
if (earliestKeyIndex > currentKeyIndex) {
|
||||||
// key appears after
|
// key appears before so it's earlier
|
||||||
earliest = path;
|
earliest = path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -117,6 +118,7 @@ export function getDeepestCommonAncestorFrom(paths: Array<NodePath>, filter?: Fu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// next iteration may break so store these so they can be returned
|
||||||
lastCommonIndex = i;
|
lastCommonIndex = i;
|
||||||
lastCommon = shouldMatch;
|
lastCommon = shouldMatch;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user