rdflib 2.2.35 → 2.2.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/dist/rdflib.min.js +1 -1
  2. package/dist/rdflib.min.js.LICENSE.txt +0 -2
  3. package/dist/rdflib.min.js.map +1 -1
  4. package/esm/blank-node.js +57 -82
  5. package/esm/class-order.js +1 -1
  6. package/esm/collection.js +70 -103
  7. package/esm/default-graph.js +13 -30
  8. package/esm/empty.js +8 -23
  9. package/esm/factories/canonical-data-factory.js +33 -29
  10. package/esm/factories/extended-term-factory.js +18 -13
  11. package/esm/factories/factory-types.js +1 -1
  12. package/esm/factories/rdflib-data-factory.js +9 -11
  13. package/esm/fetcher.js +1366 -1651
  14. package/esm/formula.js +631 -736
  15. package/esm/index.js +31 -48
  16. package/esm/jsonldparser.js +19 -26
  17. package/esm/jsonparser.js +1 -1
  18. package/esm/lists.js +38 -86
  19. package/esm/literal.js +120 -154
  20. package/esm/log.js +7 -7
  21. package/esm/n3parser.js +1009 -1086
  22. package/esm/named-node.js +69 -96
  23. package/esm/namespace.js +2 -4
  24. package/esm/node-internal.js +73 -96
  25. package/esm/node.js +1 -1
  26. package/esm/parse.js +3 -3
  27. package/esm/patch-parser.js +1 -1
  28. package/esm/query.js +15 -16
  29. package/esm/rdfaparser.js +775 -841
  30. package/esm/rdfxmlparser.js +348 -364
  31. package/esm/serialize.js +2 -2
  32. package/esm/serializer.js +835 -877
  33. package/esm/statement.js +52 -71
  34. package/esm/store.js +853 -957
  35. package/esm/types.js +21 -21
  36. package/esm/update-manager.js +965 -1100
  37. package/esm/updates-via.js +104 -132
  38. package/esm/uri.js +3 -3
  39. package/esm/utils/default-graph-uri.js +2 -2
  40. package/esm/utils/terms.js +4 -5
  41. package/esm/utils-js.js +5 -5
  42. package/esm/utils.js +6 -6
  43. package/esm/variable.js +32 -55
  44. package/esm/xsd.js +2 -2
  45. package/lib/blank-node.js +57 -80
  46. package/lib/class-order.js +1 -1
  47. package/lib/collection.js +70 -101
  48. package/lib/default-graph.js +14 -29
  49. package/lib/empty.js +9 -22
  50. package/lib/factories/canonical-data-factory.js +35 -31
  51. package/lib/factories/extended-term-factory.js +18 -13
  52. package/lib/factories/factory-types.js +1 -1
  53. package/lib/factories/rdflib-data-factory.js +9 -11
  54. package/lib/fetcher.js +1375 -1654
  55. package/lib/formula.js +632 -735
  56. package/lib/index.js +80 -84
  57. package/lib/jsonldparser.js +21 -32
  58. package/lib/jsonparser.js +1 -1
  59. package/lib/lists.js +47 -87
  60. package/lib/literal.js +121 -153
  61. package/lib/log.js +7 -7
  62. package/lib/n3parser.js +1012 -1090
  63. package/lib/named-node.js +70 -95
  64. package/lib/namespace.js +2 -4
  65. package/lib/node-internal.js +73 -94
  66. package/lib/node.js +1 -1
  67. package/lib/parse.js +5 -6
  68. package/lib/patch-parser.js +1 -1
  69. package/lib/query.js +20 -18
  70. package/lib/rdfaparser.js +778 -843
  71. package/lib/rdfxmlparser.js +351 -365
  72. package/lib/serialize.js +2 -2
  73. package/lib/serializer.js +840 -880
  74. package/lib/statement.js +55 -73
  75. package/lib/store.js +860 -958
  76. package/lib/types.js +21 -21
  77. package/lib/update-manager.js +970 -1102
  78. package/lib/updates-via.js +107 -132
  79. package/lib/uri.js +3 -3
  80. package/lib/utils/default-graph-uri.js +2 -2
  81. package/lib/utils/terms.js +4 -6
  82. package/lib/utils-js.js +8 -9
  83. package/lib/utils.js +6 -6
  84. package/lib/variable.js +35 -57
  85. package/lib/xsd.js +2 -2
  86. package/package.json +2 -2
  87. package/src/n3parser.js +1 -1
  88. package/src/serializer.js +1 -1
  89. package/src/update-manager.ts +2 -1
  90. package/.babelrc +0 -20
package/esm/blank-node.js CHANGED
@@ -1,11 +1,4 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
4
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
5
- import _inherits from "@babel/runtime/helpers/inherits";
6
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
7
- function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
8
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
9
2
  import ClassOrder from './class-order';
10
3
  import Node from './node-internal';
11
4
  import { BlankNodeTermType } from './types';
@@ -13,101 +6,83 @@ import { BlankNodeTermType } from './types';
13
6
  * An RDF blank node is a Node without a URI
14
7
  * @link https://rdf.js.org/data-model-spec/#blanknode-interface
15
8
  */
16
- var BlankNode = /*#__PURE__*/function (_Node) {
9
+ export default class BlankNode extends Node {
10
+ static getId(id) {
11
+ if (id) {
12
+ if (typeof id !== 'string') {
13
+ throw new Error('Bad id argument to new blank node: ' + id);
14
+ }
15
+ if (id.includes('#')) {
16
+ // Is a URI with hash fragment
17
+ let fragments = id.split('#');
18
+ return fragments[fragments.length - 1];
19
+ }
20
+ return id;
21
+ }
22
+ return 'n' + BlankNode.nextId++;
23
+ }
17
24
  /**
18
25
  * Initializes this node
19
26
  * @param [id] The identifier for the blank node
20
27
  */
21
- function BlankNode(id) {
22
- var _this;
23
- _classCallCheck(this, BlankNode);
24
- _this = _callSuper(this, BlankNode, [BlankNode.getId(id)]);
25
- _defineProperty(_this, "termType", BlankNodeTermType);
26
- _defineProperty(_this, "classOrder", ClassOrder.BlankNode);
28
+ constructor(id) {
29
+ super(BlankNode.getId(id));
30
+ _defineProperty(this, "termType", BlankNodeTermType);
31
+ _defineProperty(this, "classOrder", ClassOrder.BlankNode);
27
32
  /** Whether this is a blank node */
28
- _defineProperty(_this, "isBlank", 1);
33
+ _defineProperty(this, "isBlank", 1);
29
34
  /**
30
35
  * This type of node is a variable.
31
36
  *
32
37
  * Note that the existence of this property already indicates that it is a variable.
33
38
  */
34
- _defineProperty(_this, "isVar", 1);
35
- return _this;
39
+ _defineProperty(this, "isVar", 1);
36
40
  }
37
41
 
38
42
  /**
39
43
  * The identifier for the blank node
40
44
  */
41
- _inherits(BlankNode, _Node);
42
- return _createClass(BlankNode, [{
43
- key: "id",
44
- get: function get() {
45
- return this.value;
46
- },
47
- set: function set(value) {
48
- this.value = value;
49
- }
50
- }, {
51
- key: "compareTerm",
52
- value: function compareTerm(other) {
53
- if (this.classOrder < other.classOrder) {
54
- return -1;
55
- }
56
- if (this.classOrder > other.classOrder) {
57
- return +1;
58
- }
59
- if (this.id < other.id) {
60
- return -1;
61
- }
62
- if (this.id > other.id) {
63
- return +1;
64
- }
65
- return 0;
66
- }
67
-
68
- /**
69
- * Gets a copy of this blank node in the specified formula
70
- * @param formula The formula
71
- */
72
- }, {
73
- key: "copy",
74
- value: function copy(formula) {
75
- // depends on the formula
76
- var bnodeNew = new BlankNode();
77
- formula.copyTo(this, bnodeNew);
78
- return bnodeNew;
45
+ get id() {
46
+ return this.value;
47
+ }
48
+ set id(value) {
49
+ this.value = value;
50
+ }
51
+ compareTerm(other) {
52
+ if (this.classOrder < other.classOrder) {
53
+ return -1;
79
54
  }
80
- }, {
81
- key: "toCanonical",
82
- value: function toCanonical() {
83
- return BlankNode.NTAnonymousNodePrefix + this.value;
55
+ if (this.classOrder > other.classOrder) {
56
+ return +1;
84
57
  }
85
- }, {
86
- key: "toString",
87
- value: function toString() {
88
- return BlankNode.NTAnonymousNodePrefix + this.id;
58
+ if (this.id < other.id) {
59
+ return -1;
89
60
  }
90
- }], [{
91
- key: "getId",
92
- value: function getId(id) {
93
- if (id) {
94
- if (typeof id !== 'string') {
95
- throw new Error('Bad id argument to new blank node: ' + id);
96
- }
97
- if (id.includes('#')) {
98
- // Is a URI with hash fragment
99
- var fragments = id.split('#');
100
- return fragments[fragments.length - 1];
101
- }
102
- return id;
103
- }
104
- return 'n' + BlankNode.nextId++;
61
+ if (this.id > other.id) {
62
+ return +1;
105
63
  }
106
- }]);
107
- }(Node);
64
+ return 0;
65
+ }
66
+
67
+ /**
68
+ * Gets a copy of this blank node in the specified formula
69
+ * @param formula The formula
70
+ */
71
+ copy(formula) {
72
+ // depends on the formula
73
+ var bnodeNew = new BlankNode();
74
+ formula.copyTo(this, bnodeNew);
75
+ return bnodeNew;
76
+ }
77
+ toCanonical() {
78
+ return BlankNode.NTAnonymousNodePrefix + this.value;
79
+ }
80
+ toString() {
81
+ return BlankNode.NTAnonymousNodePrefix + this.id;
82
+ }
83
+ }
108
84
  /**
109
85
  * The next unique identifier for blank nodes
110
86
  */
111
87
  _defineProperty(BlankNode, "nextId", 0);
112
- _defineProperty(BlankNode, "NTAnonymousNodePrefix", '_:');
113
- export { BlankNode as default };
88
+ _defineProperty(BlankNode, "NTAnonymousNodePrefix", '_:');
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Class orders
3
3
  */
4
- var ClassOrder = {
4
+ const ClassOrder = {
5
5
  'Literal': 1,
6
6
  'Collection': 3,
7
7
  'Graph': 4,
package/esm/collection.js CHANGED
@@ -1,11 +1,4 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
4
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
5
- import _inherits from "@babel/runtime/helpers/inherits";
6
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
7
- function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
8
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
9
2
  import RdflibBlankNode from './blank-node';
10
3
  import ClassOrder from './class-order';
11
4
  import Literal from './literal';
@@ -39,111 +32,85 @@ export function fromValue(value) {
39
32
  *
40
33
  * Use generic T to control the contents of the array.
41
34
  */
42
- var Collection = /*#__PURE__*/function (_Node) {
43
- function Collection(initial) {
44
- var _this;
45
- _classCallCheck(this, Collection);
46
- _this = _callSuper(this, Collection, [(RdflibBlankNode.nextId++).toString()]);
47
- _defineProperty(_this, "termType", CollectionTermType);
48
- _defineProperty(_this, "classOrder", ClassOrder.Collection);
49
- _defineProperty(_this, "closed", false);
50
- _defineProperty(_this, "compareTerm", RdflibBlankNode.prototype.compareTerm);
35
+ export default class Collection extends Node {
36
+ constructor(initial) {
37
+ super((RdflibBlankNode.nextId++).toString());
38
+ _defineProperty(this, "termType", CollectionTermType);
39
+ _defineProperty(this, "classOrder", ClassOrder.Collection);
40
+ _defineProperty(this, "closed", false);
41
+ _defineProperty(this, "compareTerm", RdflibBlankNode.prototype.compareTerm);
51
42
  /**
52
43
  * The nodes in this collection
53
44
  */
54
- _defineProperty(_this, "elements", []);
55
- _defineProperty(_this, "isVar", 0);
45
+ _defineProperty(this, "elements", []);
46
+ _defineProperty(this, "isVar", 0);
56
47
  if (initial && initial.length > 0) {
57
- initial.forEach(function (element) {
58
- _this.elements.push(fromValue(element));
48
+ initial.forEach(element => {
49
+ this.elements.push(fromValue(element));
59
50
  });
60
51
  }
61
- return _this;
62
52
  }
63
- _inherits(Collection, _Node);
64
- return _createClass(Collection, [{
65
- key: "id",
66
- get: function get() {
67
- return this.value;
68
- },
69
- set: function set(value) {
70
- this.value = value;
71
- }
53
+ get id() {
54
+ return this.value;
55
+ }
56
+ set id(value) {
57
+ this.value = value;
58
+ }
72
59
 
73
- /**
74
- * Appends an element to this collection
75
- * @param element - The new element
76
- */
77
- }, {
78
- key: "append",
79
- value: function append(element) {
80
- return this.elements.push(element);
81
- }
60
+ /**
61
+ * Appends an element to this collection
62
+ * @param element - The new element
63
+ */
64
+ append(element) {
65
+ return this.elements.push(element);
66
+ }
82
67
 
83
- /**
84
- * Closes this collection
85
- */
86
- }, {
87
- key: "close",
88
- value: function close() {
89
- this.closed = true;
90
- return this.closed;
91
- }
68
+ /**
69
+ * Closes this collection
70
+ */
71
+ close() {
72
+ this.closed = true;
73
+ return this.closed;
74
+ }
92
75
 
93
- /**
94
- * Removes the first element from the collection (and return it)
95
- */
96
- }, {
97
- key: "shift",
98
- value: function shift() {
99
- return this.elements.shift();
100
- }
76
+ /**
77
+ * Removes the first element from the collection (and return it)
78
+ */
79
+ shift() {
80
+ return this.elements.shift();
81
+ }
101
82
 
102
- /**
103
- * Creates a new Collection with the substituting bindings applied
104
- * @param bindings - The bindings to substitute
105
- */
106
- }, {
107
- key: "substitute",
108
- value: function substitute(bindings) {
109
- var elementsCopy = this.elements.map(function (ea) {
110
- return ea.substitute(bindings);
111
- });
112
- return new Collection(elementsCopy);
113
- }
114
- }, {
115
- key: "toNT",
116
- value: function toNT() {
117
- return Collection.toNT(this);
118
- }
119
- }, {
120
- key: "toString",
121
- value:
122
- /**
123
- * Serializes the collection to a string.
124
- * Surrounded by (parentheses) and separated by spaces.
125
- */
126
- function toString() {
127
- return '(' + this.elements.join(' ') + ')';
128
- }
83
+ /**
84
+ * Creates a new Collection with the substituting bindings applied
85
+ * @param bindings - The bindings to substitute
86
+ */
87
+ substitute(bindings) {
88
+ const elementsCopy = this.elements.map(ea => ea.substitute(bindings));
89
+ return new Collection(elementsCopy);
90
+ }
91
+ toNT() {
92
+ return Collection.toNT(this);
93
+ }
94
+ static toNT(collection) {
95
+ // return '(' + collection.elements.map(x => x.toNT()).join(' ') + ')'
96
+ // As lists are not in NT and toNT() must be a reversible function, we kludge it for a list
97
+ return RdflibBlankNode.NTAnonymousNodePrefix + collection.id;
98
+ }
129
99
 
130
- /**
131
- * Prepends the specified element to the collection's front
132
- * @param element - The element to prepend
133
- */
134
- }, {
135
- key: "unshift",
136
- value: function unshift(element) {
137
- return this.elements.unshift(element);
138
- }
139
- }], [{
140
- key: "toNT",
141
- value: function toNT(collection) {
142
- // return '(' + collection.elements.map(x => x.toNT()).join(' ') + ')'
143
- // As lists are not in NT and toNT() must be a reversible function, we kludge it for a list
144
- return RdflibBlankNode.NTAnonymousNodePrefix + collection.id;
145
- }
146
- }]);
147
- }(Node);
148
- _defineProperty(Collection, "termType", CollectionTermType);
149
- export { Collection as default };
100
+ /**
101
+ * Serializes the collection to a string.
102
+ * Surrounded by (parentheses) and separated by spaces.
103
+ */
104
+ toString() {
105
+ return '(' + this.elements.join(' ') + ')';
106
+ }
107
+
108
+ /**
109
+ * Prepends the specified element to the collection's front
110
+ * @param element - The element to prepend
111
+ */
112
+ unshift(element) {
113
+ return this.elements.unshift(element);
114
+ }
115
+ }
116
+ _defineProperty(Collection, "termType", CollectionTermType);
@@ -1,40 +1,23 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
4
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
5
- import _inherits from "@babel/runtime/helpers/inherits";
6
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
7
- function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
8
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
9
2
  import Node from './node-internal';
10
3
  import { DefaultGraphTermType } from './types';
11
4
  import { defaultGraphURI } from './utils/default-graph-uri';
12
5
 
13
6
  /** The RDF default graph */
14
- var DefaultGraph = /*#__PURE__*/function (_Node) {
15
- function DefaultGraph() {
16
- var _this;
17
- _classCallCheck(this, DefaultGraph);
18
- _this = _callSuper(this, DefaultGraph, ['']);
19
- _defineProperty(_this, "value", '');
20
- _defineProperty(_this, "termType", DefaultGraphTermType);
21
- _defineProperty(_this, "uri", defaultGraphURI);
22
- return _this;
7
+ export default class DefaultGraph extends Node {
8
+ constructor() {
9
+ super('');
10
+ _defineProperty(this, "value", '');
11
+ _defineProperty(this, "termType", DefaultGraphTermType);
12
+ _defineProperty(this, "uri", defaultGraphURI);
23
13
  }
24
- _inherits(DefaultGraph, _Node);
25
- return _createClass(DefaultGraph, [{
26
- key: "toCanonical",
27
- value: function toCanonical() {
28
- return this.value;
29
- }
30
- }, {
31
- key: "toString",
32
- value: function toString() {
33
- return 'DefaultGraph';
34
- }
35
- }]);
36
- }(Node);
37
- export { DefaultGraph as default };
14
+ toCanonical() {
15
+ return this.value;
16
+ }
17
+ toString() {
18
+ return 'DefaultGraph';
19
+ }
20
+ }
38
21
  export function isDefaultGraph(object) {
39
22
  return !!object && object.termType === DefaultGraphTermType;
40
23
  }
package/esm/empty.js CHANGED
@@ -1,30 +1,15 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
4
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
5
- import _inherits from "@babel/runtime/helpers/inherits";
6
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
7
- function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
8
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
9
2
  import Node from './node-internal';
10
3
  import { EmptyTermType } from './types';
11
4
  /**
12
5
  * An empty node
13
6
  */
14
- var Empty = /*#__PURE__*/function (_Node) {
15
- function Empty() {
16
- var _this;
17
- _classCallCheck(this, Empty);
18
- _this = _callSuper(this, Empty, ['']);
19
- _defineProperty(_this, "termType", EmptyTermType);
20
- return _this;
7
+ export default class Empty extends Node {
8
+ constructor() {
9
+ super('');
10
+ _defineProperty(this, "termType", EmptyTermType);
21
11
  }
22
- _inherits(Empty, _Node);
23
- return _createClass(Empty, [{
24
- key: "toString",
25
- value: function toString() {
26
- return '()';
27
- }
28
- }]);
29
- }(Node);
30
- export { Empty as default };
12
+ toString() {
13
+ return '()';
14
+ }
15
+ }
@@ -1,4 +1,3 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
1
  import BlankNode from '../blank-node';
3
2
  import Literal from '../literal';
4
3
  import NamedNode from '../named-node';
@@ -13,25 +12,31 @@ export { defaultGraphURI } from '../utils/default-graph-uri';
13
12
  /**
14
13
  * Gets the default graph
15
14
  */
16
- var _defaultGraph = new DefaultGraph();
15
+ const defaultGraph = new DefaultGraph();
17
16
 
18
17
  /** A basic internal RDFlib datafactory, which does not support Collections */
19
- var CanonicalDataFactory = {
20
- supports: _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, Feature.collections, false), Feature.defaultGraphType, false), Feature.equalsMethod, true), Feature.identity, false), Feature.id, true), Feature.reversibleId, false), Feature.variableType, true),
18
+ const CanonicalDataFactory = {
19
+ supports: {
20
+ [Feature.collections]: false,
21
+ [Feature.defaultGraphType]: false,
22
+ [Feature.equalsMethod]: true,
23
+ [Feature.identity]: false,
24
+ [Feature.id]: true,
25
+ [Feature.reversibleId]: false,
26
+ [Feature.variableType]: true
27
+ },
21
28
  /**
22
29
  * Creates a new blank node
23
30
  * @param value - The blank node's identifier
24
31
  */
25
- blankNode: function blankNode(value) {
32
+ blankNode(value) {
26
33
  return new BlankNode(value);
27
34
  },
28
- defaultGraph: function defaultGraph() {
29
- return _defaultGraph;
30
- },
35
+ defaultGraph: () => defaultGraph,
31
36
  /**
32
37
  * Compares to (rdf) objects for equality.
33
38
  */
34
- equals: function equals(a, b) {
39
+ equals(a, b) {
35
40
  if (a === b || !a || !b) {
36
41
  return true;
37
42
  }
@@ -54,7 +59,7 @@ var CanonicalDataFactory = {
54
59
  * @example Use this to associate data with a term in an object
55
60
  * { obj[id(term)] = "myData" }
56
61
  */
57
- id: function id(term) {
62
+ id(term) {
58
63
  if (!term) {
59
64
  return 'undefined';
60
65
  }
@@ -67,14 +72,14 @@ var CanonicalDataFactory = {
67
72
  case VariableTermType:
68
73
  return Variable.toString(term);
69
74
  default:
70
- var nq = this.termToNQ(term);
75
+ const nq = this.termToNQ(term);
71
76
  if (nq) {
72
77
  return nq;
73
78
  }
74
- throw new Error("Can't id term with type '".concat(term.termType, "'"));
79
+ throw new Error(`Can't id term with type '${term.termType}'`);
75
80
  }
76
81
  },
77
- isQuad: function isQuad(obj) {
82
+ isQuad(obj) {
78
83
  return obj instanceof Statement;
79
84
  },
80
85
  /**
@@ -82,11 +87,11 @@ var CanonicalDataFactory = {
82
87
  * @param value - The lexical value
83
88
  * @param languageOrDatatype - Either the language or the datatype
84
89
  */
85
- literal: function literal(value, languageOrDatatype) {
90
+ literal(value, languageOrDatatype) {
86
91
  if (typeof value !== "string" && !languageOrDatatype) {
87
92
  return Literal.fromValue(value);
88
93
  }
89
- var strValue = typeof value === 'string' ? value : '' + value;
94
+ const strValue = typeof value === 'string' ? value : '' + value;
90
95
  if (typeof languageOrDatatype === 'string') {
91
96
  if (languageOrDatatype.indexOf(':') === -1) {
92
97
  return new Literal(strValue, languageOrDatatype);
@@ -101,7 +106,7 @@ var CanonicalDataFactory = {
101
106
  * Creates a new named node
102
107
  * @param value - The new named node
103
108
  */
104
- namedNode: function namedNode(value) {
109
+ namedNode(value) {
105
110
  return new NamedNode(value);
106
111
  },
107
112
  /**
@@ -111,8 +116,8 @@ var CanonicalDataFactory = {
111
116
  * @param object - The object
112
117
  * @param graph - The containing graph
113
118
  */
114
- quad: function quad(subject, predicate, object, graph) {
115
- return new Statement(subject, predicate, object, graph || _defaultGraph);
119
+ quad(subject, predicate, object, graph) {
120
+ return new Statement(subject, predicate, object, graph || defaultGraph);
116
121
  },
117
122
  /**
118
123
  * Creates a new statement
@@ -121,14 +126,14 @@ var CanonicalDataFactory = {
121
126
  * @param object - The object
122
127
  * @param graph - The containing graph
123
128
  */
124
- triple: function triple(subject, predicate, object, graph) {
129
+ triple(subject, predicate, object, graph) {
125
130
  return this.quad(subject, predicate, object, graph);
126
131
  },
127
- quadToNQ: function quadToNQ(q) {
128
- return "".concat(this.termToNQ(q.subject), " ").concat(this.termToNQ(q.predicate), " ").concat(this.termToNQ(q.object), " ").concat(this.termToNQ(q.graph), " .");
132
+ quadToNQ(q) {
133
+ return `${this.termToNQ(q.subject)} ${this.termToNQ(q.predicate)} ${this.termToNQ(q.object)} ${this.termToNQ(q.graph)} .`;
129
134
  },
130
- /** Stringify a {term} to n-quads serialization. */termToNQ: function termToNQ(term) {
131
- var _this = this;
135
+ /** Stringify a {term} to n-quads serialization. */
136
+ termToNQ(term) {
132
137
  switch (term.termType) {
133
138
  case BlankNodeTermType:
134
139
  return '_:' + term.value;
@@ -142,14 +147,13 @@ var CanonicalDataFactory = {
142
147
  case NamedNodeTermType:
143
148
  return '<' + term.value + '>';
144
149
  case CollectionTermType:
145
- return '(' + term.elements.map(function (t) {
146
- return _this.termToNQ(t);
147
- }).join(' ') + ')';
150
+ return '(' + term.elements.map(t => this.termToNQ(t)).join(' ') + ')';
148
151
  default:
149
- throw new Error("Can't serialize nonstandard term type (was '".concat(term.termType, "')"));
152
+ throw new Error(`Can't serialize nonstandard term type (was '${term.termType}')`);
150
153
  }
151
154
  },
152
- /** Convert an rdf object (term or quad) to n-quads serialization. */toNQ: function toNQ(term) {
155
+ /** Convert an rdf object (term or quad) to n-quads serialization. */
156
+ toNQ(term) {
153
157
  if (this.isQuad(term)) {
154
158
  return this.quadToNQ(term);
155
159
  }
@@ -159,7 +163,7 @@ var CanonicalDataFactory = {
159
163
  * Creates a new variable
160
164
  * @param name - The name for the variable
161
165
  */
162
- variable: function variable(name) {
166
+ variable(name) {
163
167
  return new Variable(name);
164
168
  }
165
169
  };