@@ -32,36 +32,36 @@ export default class N3Store {
3232 }
3333
3434 _termFromId ( id , factory ) {
35- if ( id [ 0 ] === '_ ' ) {
35+ if ( id [ 0 ] === '. ' ) {
3636 const entities = this . _entities ;
37- const terms = id . split ( '_ ' ) ;
37+ const terms = id . split ( '. ' ) ;
3838 const q = this . _factory . quad (
3939 this . _termFromId ( entities [ terms [ 1 ] ] ) ,
4040 this . _termFromId ( entities [ terms [ 2 ] ] ) ,
4141 this . _termFromId ( entities [ terms [ 3 ] ] ) ,
42- terms [ 4 ] && this . _termFromId ( entities [ terms [ 4 ] ] ) ,
43- )
42+ terms [ 4 ] && this . _termFromId ( entities [ terms [ 4 ] ] )
43+ ) ;
4444 return q ;
4545 }
4646 return termFromId ( id , factory ) ;
4747 }
4848
4949 _termToId ( term ) {
50- if ( term . termType === 'Quad' ) {
50+ if ( term && ( term . termType === 'Quad' ) ) {
5151 const subject = this . _termToId ( term . subject ) ,
52- predicate = this . _termToId ( term . predicate ) ,
53- object = this . _termToId ( term . object ) ,
54- graph = isDefaultGraph ( term . graph ) && this . _termToId ( term . graph ) ,
55- ids = this . _ids ,
56- entities = this . _entities ;
57-
58- const res = `_ ${
59- ids [ subject ] || ( ids [ entities [ ++ this . _id ] = subject ] = this . _id )
60- } _ ${
61- ids [ predicate ] || ( ids [ entities [ ++ this . _id ] = predicate ] = this . _id )
62- } _ ${
63- ids [ object ] || ( ids [ entities [ ++ this . _id ] = object ] = this . _id )
64- } ${ graph ? ( '_' + ( ids [ graph ] || ( ids [ entities [ ++ this . _id ] = graph ] = this . _id ) ) ) : '' } `;
52+ predicate = this . _termToId ( term . predicate ) ,
53+ object = this . _termToId ( term . object ) ,
54+ graph = ! isDefaultGraph ( term . graph ) && this . _termToId ( term . graph ) ,
55+ ids = this . _ids ,
56+ entities = this . _entities ;
57+
58+ const res = `. ${
59+ ids [ subject ] || ( ids [ entities [ ++ this . _id ] = subject ] = this . _id )
60+ } . ${
61+ ids [ predicate ] || ( ids [ entities [ ++ this . _id ] = predicate ] = this . _id )
62+ } . ${
63+ ids [ object ] || ( ids [ entities [ ++ this . _id ] = object ] = this . _id )
64+ } ${ graph ? ( `. ${ ids [ graph ] || ( ids [ entities [ ++ this . _id ] = graph ] = this . _id ) } ` ) : '' } `;
6565 return res ;
6666 }
6767 return termToId ( term ) ;
0 commit comments