mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-06-27 00:12:29 +00:00
Fix hasChild of Node and OrbitNode
This commit is contained in:
parent
f258a53bd7
commit
491b578490
@ -9,6 +9,15 @@ class Node {
|
||||
this.next = next ? next.map((f) => f.compactId ? f.compactId : f) : [];
|
||||
}
|
||||
|
||||
hasChild(a) {
|
||||
const id = a.compactId;
|
||||
for(let i = 0; i < this.next.length; i++) {
|
||||
if(this.next[i] === id)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
get compactId() {
|
||||
return "" + this.id + "." + this.seq + "." + this.ver;
|
||||
}
|
||||
@ -24,15 +33,6 @@ class Node {
|
||||
static equals(a, b) {
|
||||
return a.id === b.id && a.seq === b.seq && a.ver === b.ver;
|
||||
}
|
||||
|
||||
hasChild(a) {
|
||||
const id = a.compactId;
|
||||
for(let i = 0; i < this.next.length; i++) {
|
||||
if(this.next[i] === id)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Node;
|
||||
|
@ -30,6 +30,15 @@ class OrbitNode extends Node {
|
||||
}));
|
||||
}
|
||||
|
||||
hasChild(a) {
|
||||
const id = a.compactId;
|
||||
for(let i = 0; i < this.next.length; i++) {
|
||||
if(this.next[i].compactId === id)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
_commit() {
|
||||
if(!this.hash) {
|
||||
const r = await(ipfsAPI.putObject(this._ipfs, JSON.stringify(this.asJson)));
|
||||
|
Loading…
x
Reference in New Issue
Block a user