forked from rdf-ext/rdf-ext
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rdf-ext.js
70 lines (51 loc) · 1.56 KB
/
rdf-ext.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* global window */
var rdf = require('rdf-graph-array')
var InMemoryStore = require('rdf-store-inmemory')
var Parsers = require('./lib/parsers')
var Serializers = require('./lib/serializers')
var mixin = function (rdf, options) {
options = options || {}
require('./lib/environment')(rdf)
if (typeof window !== 'undefined') {
window.rdf = rdf
}
rdf.defaultRequest = null
rdf.corsProxyRequest = null
require('./lib/utils')(rdf)
if (typeof process !== 'undefined' && process.versions && process.versions.node) {
require('./lib/utils-node')(rdf)
} else {
require('./lib/utils-browser')(rdf)
}
rdf.createBlankNode = function () {
return new rdf.BlankNode()
}
rdf.createNamedNode = function (iri) {
return new rdf.NamedNode(iri)
}
rdf.createLiteral = function (value, language, datatype) {
return new rdf.Literal(value, language, datatype)
}
rdf.createTriple = function (subject, predicate, object) {
return new rdf.Triple(subject, predicate, object)
}
rdf.createQuad = function (subject, predicate, object, graph) {
return new rdf.Quad(subject, predicate, object, graph)
}
rdf.createGraph = function (triples) {
return new rdf.Graph(triples)
}
// Use InMemoryStore as default store
rdf.createStore = function (options) {
options = options || {}
options.rdf = options.rdf || rdf
return new InMemoryStore(options)
}
rdf.Parsers = Parsers
rdf.parsers = new Parsers()
rdf.Serializers = Serializers
rdf.serializers = new Serializers()
return rdf
}
mixin(rdf)
module.exports = rdf