MCPcopy Index your code
hub / github.com/apache/pouchdb / rootToLeaf

Function rootToLeaf

lib/index.es.js:955–977  ·  view source on GitHub ↗
(revs)

Source from the content-addressed store, hash-verified

953
954// build up a list of all the paths to the leafs in this revision tree
955function rootToLeaf(revs) {
956 var paths = [];
957 var toVisit = revs.slice();
958 var node;
959 while ((node = toVisit.pop())) {
960 var pos = node.pos;
961 var tree = node.ids;
962 var id = tree[0];
963 var opts = tree[1];
964 var branches = tree[2];
965 var isLeaf = branches.length === 0;
966
967 var history = node.history ? node.history.slice() : [];
968 history.push({id, opts});
969 if (isLeaf) {
970 paths.push({pos: (pos + 1 - history.length), ids: history});
971 }
972 for (var i = 0, len = branches.length; i < len; i++) {
973 toVisit.push({pos: pos + 1, ids: branches[i], history});
974 }
975 }
976 return paths.reverse();
977}
978
979// for a better overview of what this is doing, read:
980

Callers 2

stemFunction · 0.70
_setupMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…