File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -24,18 +24,20 @@ export class TermWrapper {
2424
2525 protected singular < T > ( p : string , valueMapping : IValueMapping < T > ) : T {
2626 const predicate = this . factory . namedNode ( p )
27- const matches = this . dataset . match ( this . term , predicate )
27+ const matches = this . dataset . match ( this . term , predicate ) [ Symbol . iterator ] ( )
2828
2929 // TODO: Expose standard errors
30- if ( matches . size > 1 ) {
30+ const { value : first , done : none } = matches . next ( )
31+
32+ if ( none ) {
3133 throw new Error ( `More than one value for predicate ${ p } on term ${ this . term . value } ` )
3234 }
3335
34- for ( const q of matches ) {
35- return valueMapping ( new TermWrapper ( q . object , this . dataset , this . factory ) )
36+ if ( ! matches . next ( ) . done ) {
37+ throw new Error ( `No value found for predicate ${ p } on term ${ this . term . value } ` )
3638 }
3739
38- throw new Error ( `No value found for predicate ${ p } on term ${ this . term . value } ` )
40+ return valueMapping ( new TermWrapper ( first . object , this . dataset , this . factory ) )
3941 }
4042
4143 protected singularNullable < T > ( p : string , valueMapping : IValueMapping < T > ) : T | undefined {
You can’t perform that action at this time.
0 commit comments