mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-03-30 15:08:28 +00:00
Add printTree() to List
This commit is contained in:
parent
beead609c1
commit
f258a53bd7
@ -95,6 +95,18 @@ class List {
|
|||||||
static isReferencedInChain(all, item) {
|
static isReferencedInChain(all, item) {
|
||||||
return Lazy(all).reverse().find((e) => e.hasChild(item)) !== undefined;
|
return Lazy(all).reverse().find((e) => e.hasChild(item)) !== undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printTree() {
|
||||||
|
const printCurrent = (f, padding) => {
|
||||||
|
padding += " |";
|
||||||
|
let s = padding + "-" + f.compactId + " '" + f.data + "'\n";
|
||||||
|
if(f.next.length > 0) {
|
||||||
|
s += f.next.map((e) => printCurrent(e, padding)).join("");
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
console.log(" LIST\n" + this.items.reverse().map((e) => printCurrent(e, "")).join(""));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = List;
|
module.exports = List;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user