Skip to content

Commit

Permalink
add depsSet to Statement to get object deps
Browse files Browse the repository at this point in the history
  • Loading branch information
yusefnapora committed Feb 22, 2017
1 parent ee2011a commit a2f87c1
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/model/statement.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ class Statement {
return this.body.refSet
}

get depsSet (): Set<string> {
return this.body.depsSet
}

get source (): string {
if (!(this.body instanceof EnvelopeStatementBody)) {
return this.publisher
Expand Down Expand Up @@ -233,6 +237,10 @@ class StatementBody {
return new Set()
}

get depsSet (): Set<string> {
return new Set()
}

get objectIds (): Array<string> {
return []
}
Expand Down Expand Up @@ -283,6 +291,10 @@ class SimpleStatementBody extends StatementBody {
return new Set(this.refs)
}

get depsSet (): Set<string> {
return new Set(this.deps)
}

inspect (_depth?: number, _opts?: Object) {
return this.toSimpleProtobuf()
}
Expand Down Expand Up @@ -326,6 +338,10 @@ class CompoundStatementBody extends StatementBody {
get refSet (): Set<string> {
return setUnion(...this.simpleBodies.map(b => b.refSet))
}

get depsSet (): Set<string> {
return setUnion(...this.simpleBodies.map(b => b.depsSet))
}
}

class EnvelopeStatementBody extends StatementBody {
Expand Down Expand Up @@ -364,6 +380,10 @@ class EnvelopeStatementBody extends StatementBody {
get refSet (): Set<string> {
return setUnion(...this.statements.map(stmt => stmt.refSet))
}

get depsSet (): Set<string> {
return setUnion(...this.statements.map(stmt => stmt.depsSet))
}
}

// Expanded statement bodies include the data that a SimpleStatementBody's `object` hash links to
Expand Down

0 comments on commit a2f87c1

Please sign in to comment.