11// **N3Store** objects store N3 quads by graph in memory.
2- import N3DataFactory from './N3DataFactory' ;
2+ import { default as N3DataFactory , termToId , termFromId } from './N3DataFactory' ;
33import { Readable } from 'stream' ;
44import namespaces from './IRIs' ;
55
6- const { toId, fromId } = N3DataFactory . internal ;
7-
86// ## Constructor
97export default class N3Store {
108 constructor ( quads , options ) {
@@ -111,11 +109,11 @@ export default class N3Store {
111109 // Create quads for all items found in index 2.
112110 for ( var l = 0 ; l < values . length ; l ++ ) {
113111 var parts = { subject : null , predicate : null , object : null } ;
114- parts [ name0 ] = fromId ( entity0 , this . _factory ) ;
115- parts [ name1 ] = fromId ( entity1 , this . _factory ) ;
116- parts [ name2 ] = fromId ( entityKeys [ values [ l ] ] , this . _factory ) ;
112+ parts [ name0 ] = termFromId ( entity0 , this . _factory ) ;
113+ parts [ name1 ] = termFromId ( entity1 , this . _factory ) ;
114+ parts [ name2 ] = termFromId ( entityKeys [ values [ l ] ] , this . _factory ) ;
117115 var quad = this . _factory . quad (
118- parts . subject , parts . predicate , parts . object , fromId ( graph , this . _factory ) ) ;
116+ parts . subject , parts . predicate , parts . object , termFromId ( graph , this . _factory ) ) ;
119117 if ( array )
120118 array . push ( quad ) ;
121119 else if ( callback ( quad ) )
@@ -204,7 +202,7 @@ export default class N3Store {
204202 return function ( id ) {
205203 if ( ! ( id in uniqueIds ) ) {
206204 uniqueIds [ id ] = true ;
207- callback ( fromId ( entities [ id ] ) ) ;
205+ callback ( termFromId ( entities [ id ] ) ) ;
208206 }
209207 } ;
210208 }
@@ -220,10 +218,10 @@ export default class N3Store {
220218 predicate = subject . predicate , subject = subject . subject ;
221219
222220 // Convert terms to internal string representation
223- subject = toId ( subject ) ;
224- predicate = toId ( predicate ) ;
225- object = toId ( object ) ;
226- graph = toId ( graph ) ;
221+ subject = termToId ( subject ) ;
222+ predicate = termToId ( predicate ) ;
223+ object = termToId ( object ) ;
224+ graph = termToId ( graph ) ;
227225
228226 // Find the graph that will contain the triple
229227 var graphItem = this . _graphs [ graph ] ;
@@ -274,10 +272,10 @@ export default class N3Store {
274272 predicate = subject . predicate , subject = subject . subject ;
275273
276274 // Convert terms to internal string representation
277- subject = toId ( subject ) ;
278- predicate = toId ( predicate ) ;
279- object = toId ( object ) ;
280- graph = toId ( graph ) ;
275+ subject = termToId ( subject ) ;
276+ predicate = termToId ( predicate ) ;
277+ object = termToId ( object ) ;
278+ graph = termToId ( graph ) ;
281279
282280 // Find internal identifiers for all components
283281 // and verify the quad exists.
@@ -329,10 +327,10 @@ export default class N3Store {
329327 // Setting any field to `undefined` or `null` indicates a wildcard.
330328 getQuads ( subject , predicate , object , graph ) {
331329 // Convert terms to internal string representation
332- subject = subject && toId ( subject ) ;
333- predicate = predicate && toId ( predicate ) ;
334- object = object && toId ( object ) ;
335- graph = graph && toId ( graph ) ;
330+ subject = subject && termToId ( subject ) ;
331+ predicate = predicate && termToId ( predicate ) ;
332+ object = object && termToId ( object ) ;
333+ graph = graph && termToId ( graph ) ;
336334
337335 var quads = [ ] , graphs = this . _getGraphs ( graph ) , content ,
338336 ids = this . _ids , subjectId , predicateId , objectId ;
@@ -393,10 +391,10 @@ export default class N3Store {
393391 // Setting any field to `undefined` or `null` indicates a wildcard.
394392 countQuads ( subject , predicate , object , graph ) {
395393 // Convert terms to internal string representation
396- subject = subject && toId ( subject ) ;
397- predicate = predicate && toId ( predicate ) ;
398- object = object && toId ( object ) ;
399- graph = graph && toId ( graph ) ;
394+ subject = subject && termToId ( subject ) ;
395+ predicate = predicate && termToId ( predicate ) ;
396+ object = object && termToId ( object ) ;
397+ graph = graph && termToId ( graph ) ;
400398
401399 var count = 0 , graphs = this . _getGraphs ( graph ) , content ,
402400 ids = this . _ids , subjectId , predicateId , objectId ;
@@ -458,10 +456,10 @@ export default class N3Store {
458456 // Setting any field to `undefined` or `null` indicates a wildcard.
459457 some ( callback , subject , predicate , object , graph ) {
460458 // Convert terms to internal string representation
461- subject = subject && toId ( subject ) ;
462- predicate = predicate && toId ( predicate ) ;
463- object = object && toId ( object ) ;
464- graph = graph && toId ( graph ) ;
459+ subject = subject && termToId ( subject ) ;
460+ predicate = predicate && termToId ( predicate ) ;
461+ object = object && termToId ( object ) ;
462+ graph = graph && termToId ( graph ) ;
465463
466464 var graphs = this . _getGraphs ( graph ) , content ,
467465 ids = this . _ids , subjectId , predicateId , objectId ;
@@ -526,9 +524,9 @@ export default class N3Store {
526524 // Setting any field to `undefined` or `null` indicates a wildcard.
527525 forSubjects ( callback , predicate , object , graph ) {
528526 // Convert terms to internal string representation
529- predicate = predicate && toId ( predicate ) ;
530- object = object && toId ( object ) ;
531- graph = graph && toId ( graph ) ;
527+ predicate = predicate && termToId ( predicate ) ;
528+ object = object && termToId ( object ) ;
529+ graph = graph && termToId ( graph ) ;
532530
533531 var ids = this . _ids , graphs = this . _getGraphs ( graph ) , content , predicateId , objectId ;
534532 callback = this . _uniqueEntities ( callback ) ;
@@ -572,9 +570,9 @@ export default class N3Store {
572570 // Setting any field to `undefined` or `null` indicates a wildcard.
573571 forPredicates ( callback , subject , object , graph ) {
574572 // Convert terms to internal string representation
575- subject = subject && toId ( subject ) ;
576- object = object && toId ( object ) ;
577- graph = graph && toId ( graph ) ;
573+ subject = subject && termToId ( subject ) ;
574+ object = object && termToId ( object ) ;
575+ graph = graph && termToId ( graph ) ;
578576
579577 var ids = this . _ids , graphs = this . _getGraphs ( graph ) , content , subjectId , objectId ;
580578 callback = this . _uniqueEntities ( callback ) ;
@@ -618,9 +616,9 @@ export default class N3Store {
618616 // Setting any field to `undefined` or `null` indicates a wildcard.
619617 forObjects ( callback , subject , predicate , graph ) {
620618 // Convert terms to internal string representation
621- subject = subject && toId ( subject ) ;
622- predicate = predicate && toId ( predicate ) ;
623- graph = graph && toId ( graph ) ;
619+ subject = subject && termToId ( subject ) ;
620+ predicate = predicate && termToId ( predicate ) ;
621+ graph = graph && termToId ( graph ) ;
624622
625623 var ids = this . _ids , graphs = this . _getGraphs ( graph ) , content , subjectId , predicateId ;
626624 callback = this . _uniqueEntities ( callback ) ;
0 commit comments