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.
- package/dist/rdflib.min.js +1 -1
- package/dist/rdflib.min.js.LICENSE.txt +0 -2
- package/dist/rdflib.min.js.map +1 -1
- package/esm/blank-node.js +57 -82
- package/esm/class-order.js +1 -1
- package/esm/collection.js +70 -103
- package/esm/default-graph.js +13 -30
- package/esm/empty.js +8 -23
- package/esm/factories/canonical-data-factory.js +33 -29
- package/esm/factories/extended-term-factory.js +18 -13
- package/esm/factories/factory-types.js +1 -1
- package/esm/factories/rdflib-data-factory.js +9 -11
- package/esm/fetcher.js +1366 -1651
- package/esm/formula.js +631 -736
- package/esm/index.js +31 -48
- package/esm/jsonldparser.js +19 -26
- package/esm/jsonparser.js +1 -1
- package/esm/lists.js +38 -86
- package/esm/literal.js +120 -154
- package/esm/log.js +7 -7
- package/esm/n3parser.js +1009 -1086
- package/esm/named-node.js +69 -96
- package/esm/namespace.js +2 -4
- package/esm/node-internal.js +73 -96
- package/esm/node.js +1 -1
- package/esm/parse.js +3 -3
- package/esm/patch-parser.js +1 -1
- package/esm/query.js +15 -16
- package/esm/rdfaparser.js +775 -841
- package/esm/rdfxmlparser.js +348 -364
- package/esm/serialize.js +2 -2
- package/esm/serializer.js +835 -877
- package/esm/statement.js +52 -71
- package/esm/store.js +853 -957
- package/esm/types.js +21 -21
- package/esm/update-manager.js +965 -1100
- package/esm/updates-via.js +104 -132
- package/esm/uri.js +3 -3
- package/esm/utils/default-graph-uri.js +2 -2
- package/esm/utils/terms.js +4 -5
- package/esm/utils-js.js +5 -5
- package/esm/utils.js +6 -6
- package/esm/variable.js +32 -55
- package/esm/xsd.js +2 -2
- package/lib/blank-node.js +57 -80
- package/lib/class-order.js +1 -1
- package/lib/collection.js +70 -101
- package/lib/default-graph.js +14 -29
- package/lib/empty.js +9 -22
- package/lib/factories/canonical-data-factory.js +35 -31
- package/lib/factories/extended-term-factory.js +18 -13
- package/lib/factories/factory-types.js +1 -1
- package/lib/factories/rdflib-data-factory.js +9 -11
- package/lib/fetcher.js +1375 -1654
- package/lib/formula.js +632 -735
- package/lib/index.js +80 -84
- package/lib/jsonldparser.js +21 -32
- package/lib/jsonparser.js +1 -1
- package/lib/lists.js +47 -87
- package/lib/literal.js +121 -153
- package/lib/log.js +7 -7
- package/lib/n3parser.js +1012 -1090
- package/lib/named-node.js +70 -95
- package/lib/namespace.js +2 -4
- package/lib/node-internal.js +73 -94
- package/lib/node.js +1 -1
- package/lib/parse.js +5 -6
- package/lib/patch-parser.js +1 -1
- package/lib/query.js +20 -18
- package/lib/rdfaparser.js +778 -843
- package/lib/rdfxmlparser.js +351 -365
- package/lib/serialize.js +2 -2
- package/lib/serializer.js +840 -880
- package/lib/statement.js +55 -73
- package/lib/store.js +860 -958
- package/lib/types.js +21 -21
- package/lib/update-manager.js +970 -1102
- package/lib/updates-via.js +107 -132
- package/lib/uri.js +3 -3
- package/lib/utils/default-graph-uri.js +2 -2
- package/lib/utils/terms.js +4 -6
- package/lib/utils-js.js +8 -9
- package/lib/utils.js +6 -6
- package/lib/variable.js +35 -57
- package/lib/xsd.js +2 -2
- package/package.json +2 -2
- package/src/n3parser.js +1 -1
- package/src/serializer.js +1 -1
- package/src/update-manager.ts +2 -1
- package/.babelrc +0 -20
package/esm/index.js
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
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 BlankNode from './blank-node';
|
|
10
3
|
import Collection from './collection';
|
|
11
4
|
import Empty from './empty';
|
|
@@ -38,30 +31,30 @@ import Variable from './variable';
|
|
|
38
31
|
import DataFactory from './factories/rdflib-data-factory';
|
|
39
32
|
|
|
40
33
|
// Prepare bound versions of data factory methods for export
|
|
41
|
-
|
|
42
|
-
for (
|
|
34
|
+
const boundDataFactory = {};
|
|
35
|
+
for (const name in DataFactory) {
|
|
43
36
|
if (typeof DataFactory[name] === 'function') boundDataFactory[name] = DataFactory[name].bind(DataFactory);
|
|
44
37
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
38
|
+
const {
|
|
39
|
+
fetcher,
|
|
40
|
+
graph,
|
|
41
|
+
lit,
|
|
42
|
+
st,
|
|
43
|
+
namedNode,
|
|
44
|
+
variable,
|
|
45
|
+
blankNode,
|
|
46
|
+
defaultGraph,
|
|
47
|
+
literal,
|
|
48
|
+
quad,
|
|
49
|
+
triple
|
|
50
|
+
} = boundDataFactory;
|
|
51
|
+
const formula = new Formula();
|
|
52
|
+
const fromNT = str => formula.fromNT(str);
|
|
53
|
+
const term = Node.fromValue;
|
|
61
54
|
|
|
62
55
|
// TODO: this export is broken;
|
|
63
56
|
// it exports the _current_ value of nextId, which is always 0
|
|
64
|
-
|
|
57
|
+
const NextId = BlankNode.nextId;
|
|
65
58
|
export * from './utils/terms';
|
|
66
59
|
export { BlankNode, Collection, DataFactory, Empty, Fetcher, Formula, Store, jsonParser, Literal, log, N3Parser, NamedNode, Namespace, Node, parse, Query, queryToSPARQL, RDFaProcessor, RDFParser, serialize, Serializer, SPARQLToQuery, sparqlUpdateParser, Statement, term, UpdateManager, UpdatesSocket, UpdatesVia, uri, Util, Variable, Store as IndexedFormula,
|
|
67
60
|
// Alias
|
|
@@ -70,27 +63,17 @@ NextId, fromNT, fetcher, graph, lit, st, namedNode as sym,
|
|
|
70
63
|
// RDFJS DataFactory interface
|
|
71
64
|
blankNode, defaultGraph, literal, namedNode, quad, triple, variable };
|
|
72
65
|
export { termValue } from './utils/termValue';
|
|
73
|
-
export
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
_defineProperty(_this, "fetcher", void 0);
|
|
79
|
-
_this.fetcher = new Fetcher(_this, {});
|
|
80
|
-
return _this;
|
|
66
|
+
export class ConnectedStore extends Store {
|
|
67
|
+
constructor(features) {
|
|
68
|
+
super(features);
|
|
69
|
+
_defineProperty(this, "fetcher", void 0);
|
|
70
|
+
this.fetcher = new Fetcher(this, {});
|
|
81
71
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
_classCallCheck(this, LiveStore);
|
|
89
|
-
_this2 = _callSuper(this, LiveStore, [features]);
|
|
90
|
-
_defineProperty(_this2, "updater", void 0);
|
|
91
|
-
_this2.updater = new UpdateManager(_this2);
|
|
92
|
-
return _this2;
|
|
72
|
+
}
|
|
73
|
+
export class LiveStore extends ConnectedStore {
|
|
74
|
+
constructor(features) {
|
|
75
|
+
super(features);
|
|
76
|
+
_defineProperty(this, "updater", void 0);
|
|
77
|
+
this.updater = new UpdateManager(this);
|
|
93
78
|
}
|
|
94
|
-
|
|
95
|
-
return _createClass(LiveStore);
|
|
96
|
-
}(ConnectedStore);
|
|
79
|
+
}
|
package/esm/jsonldparser.js
CHANGED
|
@@ -35,11 +35,9 @@ export function jsonldObjectToTerm(kb, obj) {
|
|
|
35
35
|
* Adds the statements in a json-ld list object to {kb}.
|
|
36
36
|
*/
|
|
37
37
|
function listToStatements(kb, obj) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
});
|
|
42
|
-
var statements = arrayToStatements(kb.rdfFactory, listId, items);
|
|
38
|
+
const listId = obj['@id'] ? nodeType(kb, obj) : kb.rdfFactory.blankNode();
|
|
39
|
+
const items = obj['@list'].map(listItem => jsonldObjectToTerm(kb, listItem));
|
|
40
|
+
const statements = arrayToStatements(kb.rdfFactory, listId, items);
|
|
43
41
|
kb.addAll(statements);
|
|
44
42
|
return listId;
|
|
45
43
|
}
|
|
@@ -47,9 +45,7 @@ function listToCollection(kb, obj) {
|
|
|
47
45
|
if (!Array.isArray(obj)) {
|
|
48
46
|
throw new TypeError("Object must be an array");
|
|
49
47
|
}
|
|
50
|
-
return kb.rdfFactory.collection(obj.map(
|
|
51
|
-
return jsonldObjectToTerm(kb, o);
|
|
52
|
-
}));
|
|
48
|
+
return kb.rdfFactory.collection(obj.map(o => jsonldObjectToTerm(kb, o)));
|
|
53
49
|
}
|
|
54
50
|
|
|
55
51
|
/**
|
|
@@ -58,17 +54,15 @@ function listToCollection(kb, obj) {
|
|
|
58
54
|
* Ensure that {kb.rdfFactory} is a DataFactory.
|
|
59
55
|
*/
|
|
60
56
|
export default function jsonldParser(str, kb, base, callback) {
|
|
61
|
-
|
|
62
|
-
return import('jsonld').then(
|
|
57
|
+
const baseString = base && Object.prototype.hasOwnProperty.call(base, 'termType') ? base.value : base;
|
|
58
|
+
return import('jsonld').then(jsonld => {
|
|
63
59
|
return jsonld.flatten(JSON.parse(str), null, {
|
|
64
60
|
base: baseString
|
|
65
61
|
});
|
|
66
|
-
}).then(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}, kb);
|
|
71
|
-
}).then(callback).catch(callback);
|
|
62
|
+
}).then(flattened => flattened.reduce((store, flatResource) => {
|
|
63
|
+
kb = processResource(kb, base, flatResource);
|
|
64
|
+
return kb;
|
|
65
|
+
}, kb)).then(callback).catch(callback);
|
|
72
66
|
}
|
|
73
67
|
function nodeType(kb, obj) {
|
|
74
68
|
if (obj['@id'].startsWith('_:')) {
|
|
@@ -80,27 +74,26 @@ function nodeType(kb, obj) {
|
|
|
80
74
|
}
|
|
81
75
|
}
|
|
82
76
|
function processResource(kb, base, flatResource) {
|
|
83
|
-
|
|
84
|
-
for (
|
|
85
|
-
var property = _Object$keys[_i];
|
|
77
|
+
const id = flatResource['@id'] ? nodeType(kb, flatResource) : kb.rdfFactory.blankNode();
|
|
78
|
+
for (const property of Object.keys(flatResource)) {
|
|
86
79
|
if (property === '@id') {
|
|
87
80
|
continue;
|
|
88
81
|
} else if (property == '@graph') {
|
|
89
82
|
// the JSON-LD flattened structure may contain nested graphs
|
|
90
83
|
// the id value for this object is the new base (named graph id) for all nested flat resources
|
|
91
|
-
|
|
84
|
+
const graphId = id;
|
|
92
85
|
// this is an array of resources
|
|
93
|
-
|
|
86
|
+
const nestedFlatResources = flatResource[property];
|
|
94
87
|
|
|
95
88
|
// recursively process all flat resources in the array, but with the graphId as base.
|
|
96
|
-
for (
|
|
89
|
+
for (let i = 0; i < nestedFlatResources.length; i++) {
|
|
97
90
|
kb = processResource(kb, graphId, nestedFlatResources[i]);
|
|
98
91
|
}
|
|
99
92
|
}
|
|
100
|
-
|
|
93
|
+
const value = flatResource[property];
|
|
101
94
|
if (Array.isArray(value)) {
|
|
102
|
-
for (
|
|
103
|
-
kb.addStatement(createStatement(kb, id, property, value[
|
|
95
|
+
for (let i = 0; i < value.length; i++) {
|
|
96
|
+
kb.addStatement(createStatement(kb, id, property, value[i], base));
|
|
104
97
|
}
|
|
105
98
|
} else {
|
|
106
99
|
kb.addStatement(createStatement(kb, id, property, value, base));
|
|
@@ -118,7 +111,7 @@ function processResource(kb, base, flatResource) {
|
|
|
118
111
|
* @return quad statement
|
|
119
112
|
*/
|
|
120
113
|
function createStatement(kb, id, property, value, base) {
|
|
121
|
-
|
|
114
|
+
let predicate, object;
|
|
122
115
|
if (property === "@type") {
|
|
123
116
|
predicate = kb.rdfFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
|
|
124
117
|
object = kb.rdfFactory.namedNode(value);
|
package/esm/jsonparser.js
CHANGED
package/esm/lists.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
2
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
3
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
4
1
|
/* Lists form conversion
|
|
5
2
|
*/
|
|
6
3
|
|
|
@@ -25,7 +22,7 @@ import Statement from './statement';
|
|
|
25
22
|
// import { Quad } from './tf-types'
|
|
26
23
|
|
|
27
24
|
import Namespace from './namespace';
|
|
28
|
-
|
|
25
|
+
const RDF = Namespace('http://www.w3.org/1999/02/22-rdf-syntax-ns#');
|
|
29
26
|
|
|
30
27
|
/* Replace a given node with another node throughout a given document
|
|
31
28
|
*
|
|
@@ -33,83 +30,38 @@ var RDF = Namespace('http://www.w3.org/1999/02/22-rdf-syntax-ns#');
|
|
|
33
30
|
*/
|
|
34
31
|
export function substituteInDoc(store, x, y, doc) {
|
|
35
32
|
// console.log(`substituteInDoc put ${x} for ${y} in ${doc}}`)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
var quad = _step.value;
|
|
41
|
-
var newStatement = new Statement(x, quad.predicate, quad.object, doc);
|
|
42
|
-
store.remove(quad);
|
|
43
|
-
store.add(newStatement);
|
|
44
|
-
}
|
|
45
|
-
} catch (err) {
|
|
46
|
-
_iterator.e(err);
|
|
47
|
-
} finally {
|
|
48
|
-
_iterator.f();
|
|
33
|
+
for (const quad of store.statementsMatching(y, null, null, doc)) {
|
|
34
|
+
const newStatement = new Statement(x, quad.predicate, quad.object, doc);
|
|
35
|
+
store.remove(quad);
|
|
36
|
+
store.add(newStatement);
|
|
49
37
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
var _quad = _step2.value;
|
|
55
|
-
store.remove(_quad);
|
|
56
|
-
// console.log(` substituteInDoc predicate ${x} in ${quad}}`)
|
|
57
|
-
store.add(new Statement(_quad.subject, x, _quad.object, doc));
|
|
58
|
-
}
|
|
59
|
-
} catch (err) {
|
|
60
|
-
_iterator2.e(err);
|
|
61
|
-
} finally {
|
|
62
|
-
_iterator2.f();
|
|
38
|
+
for (const quad of store.statementsMatching(null, y, null, doc)) {
|
|
39
|
+
store.remove(quad);
|
|
40
|
+
// console.log(` substituteInDoc predicate ${x} in ${quad}}`)
|
|
41
|
+
store.add(new Statement(quad.subject, x, quad.object, doc));
|
|
63
42
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
68
|
-
var _quad2 = _step3.value;
|
|
69
|
-
store.remove(_quad2);
|
|
70
|
-
store.add(new Statement(_quad2.subject, _quad2.predicate, x, doc));
|
|
71
|
-
}
|
|
72
|
-
} catch (err) {
|
|
73
|
-
_iterator3.e(err);
|
|
74
|
-
} finally {
|
|
75
|
-
_iterator3.f();
|
|
43
|
+
for (const quad of store.statementsMatching(null, null, y, doc)) {
|
|
44
|
+
store.remove(quad);
|
|
45
|
+
store.add(new Statement(quad.subject, quad.predicate, x, doc));
|
|
76
46
|
}
|
|
77
47
|
}
|
|
78
48
|
|
|
79
49
|
/* Change all lone rdf:nil nodes into empty Collections
|
|
80
50
|
*/
|
|
81
51
|
export function substituteNillsInDoc(store, doc) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
var quad = _step4.value;
|
|
88
|
-
store.remove(quad);
|
|
89
|
-
var y = new Collection();
|
|
90
|
-
store.add(new Statement(y, quad.predicate, quad.object, doc));
|
|
91
|
-
}
|
|
92
|
-
} catch (err) {
|
|
93
|
-
_iterator4.e(err);
|
|
94
|
-
} finally {
|
|
95
|
-
_iterator4.f();
|
|
52
|
+
const x = RDF('nil');
|
|
53
|
+
for (const quad of store.statementsMatching(x, null, null, doc)) {
|
|
54
|
+
store.remove(quad);
|
|
55
|
+
const y = new Collection();
|
|
56
|
+
store.add(new Statement(y, quad.predicate, quad.object, doc));
|
|
96
57
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
// If not a tail
|
|
104
|
-
store.remove(_quad3);
|
|
105
|
-
var _y = new Collection();
|
|
106
|
-
store.add(new Statement(_quad3.subject, _quad3.predicate, _y, doc));
|
|
107
|
-
}
|
|
58
|
+
for (const quad of store.statementsMatching(null, null, x, doc)) {
|
|
59
|
+
if (!quad.predicate.sameTerm(RDF('rest'))) {
|
|
60
|
+
// If not a tail
|
|
61
|
+
store.remove(quad);
|
|
62
|
+
const y = new Collection();
|
|
63
|
+
store.add(new Statement(quad.subject, quad.predicate, y, doc));
|
|
108
64
|
}
|
|
109
|
-
} catch (err) {
|
|
110
|
-
_iterator5.e(err);
|
|
111
|
-
} finally {
|
|
112
|
-
_iterator5.f();
|
|
113
65
|
}
|
|
114
66
|
}
|
|
115
67
|
/**
|
|
@@ -124,34 +76,34 @@ export function substituteNillsInDoc(store, doc) {
|
|
|
124
76
|
export function convertFirstRestNil(store, doc // Do whole store?
|
|
125
77
|
) {
|
|
126
78
|
function preceding(ele, listSoFar, trash) {
|
|
127
|
-
|
|
128
|
-
if (rests.length !== 1) throw new Error(
|
|
129
|
-
|
|
130
|
-
if (firsts.length !== 1) throw new Error(
|
|
131
|
-
|
|
132
|
-
|
|
79
|
+
const rests = store.statementsMatching(ele, RDF('rest'), null, doc);
|
|
80
|
+
if (rests.length !== 1) throw new Error(`Bad list structure: no rest at ${ele}`);
|
|
81
|
+
const firsts = store.statementsMatching(ele, RDF('first'), null, doc);
|
|
82
|
+
if (firsts.length !== 1) throw new Error(`Bad list structure: rest but ${firsts.length} firsts at ${ele}`);
|
|
83
|
+
const value = firsts[0].object;
|
|
84
|
+
const total = [value].concat(listSoFar);
|
|
133
85
|
// console.log(' List now is: ', total)
|
|
134
|
-
|
|
135
|
-
|
|
86
|
+
const totalTrash = trash.concat(rests).concat(firsts);
|
|
87
|
+
const pres = store.statementsMatching(null, RDF('rest'), ele, doc);
|
|
136
88
|
if (pres.length === 0) {
|
|
137
89
|
// Head of the list
|
|
138
|
-
|
|
90
|
+
const newList = new Collection(total);
|
|
139
91
|
store.remove(totalTrash);
|
|
140
92
|
// Replace old list with new list:
|
|
141
93
|
substituteInDoc(store, newList, ele, doc);
|
|
142
94
|
return;
|
|
143
95
|
}
|
|
144
|
-
if (pres.length !== 1) throw new Error(
|
|
145
|
-
|
|
146
|
-
if (pre.termType !== 'BlankNode') throw new Error(
|
|
96
|
+
if (pres.length !== 1) throw new Error(`Bad list structure: ${pres.length} pres at ${ele}`);
|
|
97
|
+
const pre = pres[0].subject;
|
|
98
|
+
if (pre.termType !== 'BlankNode') throw new Error(`Bad list element node ${pre} type: ${pre.termType} `);
|
|
147
99
|
preceding(pre, total, totalTrash);
|
|
148
100
|
return;
|
|
149
101
|
}
|
|
150
102
|
substituteNillsInDoc(store, doc); // lone ones only
|
|
151
103
|
|
|
152
|
-
|
|
153
|
-
tails.forEach(
|
|
154
|
-
if (tail.subject.termType !== 'BlankNode') throw new Error(
|
|
104
|
+
const tails = store.statementsMatching(null, RDF('rest'), RDF('nil'), doc);
|
|
105
|
+
tails.forEach(tail => {
|
|
106
|
+
if (tail.subject.termType !== 'BlankNode') throw new Error(`Bad list element node ${tail.subject} type: ${tail.subject.termType} `);
|
|
155
107
|
preceding(tail.subject, [], []);
|
|
156
108
|
});
|
|
157
109
|
}
|