rdflib 2.2.22 → 2.2.23-6384f9a2

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