@bahulneel/rdflib
Version:
an RDF library for node.js. Suitable for client and server side.
76 lines (68 loc) • 2.01 kB
text/typescript
import {
IRDFlibDataFactory,
} from '../types'
import Literal from '../literal'
import Statement from '../statement'
import IndexedFormula from '../store'
import Fetcher from '../fetcher'
import ExtendedTermFactory from './extended-term-factory'
import { NamedNode, Quad_Subject, Quad_Predicate, Quad_Object, Quad_Graph } from '../tf-types'
/** Full RDFLib.js Data Factory */
const RDFlibDataFactory: IRDFlibDataFactory = {
...ExtendedTermFactory,
/**
* Creates a new fetcher
* @param store - The store to use
* @param options - The options
*/
fetcher (store: IndexedFormula, options: any): Fetcher {
return new Fetcher(store, options)
},
/**
* Creates a new graph (store)
*/
graph (features = undefined, opts = undefined): IndexedFormula {
return new IndexedFormula(features, opts || {rdfFactory: ExtendedTermFactory})
},
/**
* Creates a new literal node
* @param val The lexical value
* @param lang The language
* @param dt The datatype
* @deprecated use [[literal]] with the second and third argument combined
*/
lit (val: string, lang?: string, dt?: NamedNode): Literal {
return this.literal('' + val, lang || dt)
},
/**
* Creates a new statement
* @param subject The subject
* @param predicate The predicate
* @param object The object
* @param graph The containing graph
* @deprecated use [[quad]] instead
*/
st (
subject: Quad_Subject,
predicate: Quad_Predicate,
object: Quad_Object,
graph?: Quad_Graph
): Statement {
return this.quad(subject, predicate, object, graph)
},
/**
* Creates a new statement
* @param subject The subject
* @param predicate The predicate
* @param object The object
* @deprecated use [[quad]] without the last argument instead
*/
triple (
subject: Quad_Subject,
predicate: Quad_Predicate,
object: Quad_Object
): Statement {
return this.quad(subject, predicate, object)
},
}
export default RDFlibDataFactory