n3 1.18.0 → 1.19.0
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/README.md +3 -3
- package/browser/n3.min.js +1 -1
- package/lib/N3Store.js +200 -7
- package/lib/N3Writer.js +3 -3
- package/package.json +1 -1
- package/src/N3Store.js +231 -7
- package/src/N3Writer.js +4 -3
package/lib/N3Store.js
CHANGED
|
@@ -8,6 +8,7 @@ var _readableStream = require("readable-stream");
|
|
|
8
8
|
var _N3DataFactory = _interopRequireWildcard(require("./N3DataFactory"));
|
|
9
9
|
var _IRIs = _interopRequireDefault(require("./IRIs"));
|
|
10
10
|
var _N3Util = require("./N3Util");
|
|
11
|
+
var _N3Writer = _interopRequireDefault(require("./N3Writer"));
|
|
11
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
13
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
13
14
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -495,7 +496,7 @@ class N3Store {
|
|
|
495
496
|
// Setting any field to `undefined` or `null` indicates a wildcard.
|
|
496
497
|
forEach(callback, subject, predicate, object, graph) {
|
|
497
498
|
this.some(quad => {
|
|
498
|
-
callback(quad);
|
|
499
|
+
callback(quad, this);
|
|
499
500
|
return false;
|
|
500
501
|
}, subject, predicate, object, graph);
|
|
501
502
|
}
|
|
@@ -504,12 +505,7 @@ class N3Store {
|
|
|
504
505
|
// and returns `true` if it returns truthy for all them.
|
|
505
506
|
// Setting any field to `undefined` or `null` indicates a wildcard.
|
|
506
507
|
every(callback, subject, predicate, object, graph) {
|
|
507
|
-
|
|
508
|
-
const every = !this.some(quad => {
|
|
509
|
-
some = true;
|
|
510
|
-
return !callback(quad);
|
|
511
|
-
}, subject, predicate, object, graph);
|
|
512
|
-
return some && every;
|
|
508
|
+
return !this.some(quad => !callback(quad, this), subject, predicate, object, graph);
|
|
513
509
|
}
|
|
514
510
|
|
|
515
511
|
// ### `some` executes the callback on all quads,
|
|
@@ -743,6 +739,149 @@ class N3Store {
|
|
|
743
739
|
return lists;
|
|
744
740
|
}
|
|
745
741
|
|
|
742
|
+
/**
|
|
743
|
+
* Returns `true` if the current dataset is a superset of the given dataset; in other words, returns `true` if
|
|
744
|
+
* the given dataset is a subset of, i.e., is contained within, the current dataset.
|
|
745
|
+
*
|
|
746
|
+
* Blank Nodes will be normalized.
|
|
747
|
+
*/
|
|
748
|
+
addAll(quads) {
|
|
749
|
+
if (Array.isArray(quads)) this.addQuads(quads);else {
|
|
750
|
+
for (const quad of quads) this.add(quad);
|
|
751
|
+
}
|
|
752
|
+
return this;
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
/**
|
|
756
|
+
* Returns `true` if the current dataset is a superset of the given dataset; in other words, returns `true` if
|
|
757
|
+
* the given dataset is a subset of, i.e., is contained within, the current dataset.
|
|
758
|
+
*
|
|
759
|
+
* Blank Nodes will be normalized.
|
|
760
|
+
*/
|
|
761
|
+
contains(other) {
|
|
762
|
+
return other.every(quad => this.has(quad));
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
/**
|
|
766
|
+
* This method removes the quads in the current dataset that match the given arguments.
|
|
767
|
+
*
|
|
768
|
+
* The logic described in {@link https://rdf.js.org/dataset-spec/#quad-matching|Quad Matching} is applied for each
|
|
769
|
+
* quad in this dataset, to select the quads which will be deleted.
|
|
770
|
+
*
|
|
771
|
+
* @param subject The optional exact subject to match.
|
|
772
|
+
* @param predicate The optional exact predicate to match.
|
|
773
|
+
* @param object The optional exact object to match.
|
|
774
|
+
* @param graph The optional exact graph to match.
|
|
775
|
+
*/
|
|
776
|
+
deleteMatches(subject, predicate, object, graph) {
|
|
777
|
+
for (const quad of this.match(subject, predicate, object, graph)) this.removeQuad(quad);
|
|
778
|
+
return this;
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
/**
|
|
782
|
+
* Returns a new dataset that contains all quads from the current dataset that are not included in the given dataset.
|
|
783
|
+
*/
|
|
784
|
+
difference(other) {
|
|
785
|
+
return this.filter(quad => !other.has(quad));
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
/**
|
|
789
|
+
* Returns true if the current dataset contains the same graph structure as the given dataset.
|
|
790
|
+
*
|
|
791
|
+
* Blank Nodes will be normalized.
|
|
792
|
+
*/
|
|
793
|
+
equals(other) {
|
|
794
|
+
return other === this || this.size === other.size && this.contains(other);
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
/**
|
|
798
|
+
* Creates a new dataset with all the quads that pass the test implemented by the provided `iteratee`.
|
|
799
|
+
*
|
|
800
|
+
* This method is aligned with Array.prototype.filter() in ECMAScript-262.
|
|
801
|
+
*/
|
|
802
|
+
filter(iteratee) {
|
|
803
|
+
const store = new N3Store();
|
|
804
|
+
for (const quad of this) if (iteratee(quad, this)) store.add(quad);
|
|
805
|
+
return store;
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
/**
|
|
809
|
+
* Returns a new dataset containing all quads from the current dataset that are also included in the given dataset.
|
|
810
|
+
*/
|
|
811
|
+
intersection(other) {
|
|
812
|
+
return this.filter(quad => other.has(quad));
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
/**
|
|
816
|
+
* Returns a new dataset containing all quads returned by applying `iteratee` to each quad in the current dataset.
|
|
817
|
+
*/
|
|
818
|
+
map(iteratee) {
|
|
819
|
+
const store = new N3Store();
|
|
820
|
+
for (const quad of this) store.add(iteratee(quad, this));
|
|
821
|
+
return store;
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
/**
|
|
825
|
+
* This method calls the `iteratee` method on each `quad` of the `Dataset`. The first time the `iteratee` method
|
|
826
|
+
* is called, the `accumulator` value is the `initialValue`, or, if not given, equals the first quad of the `Dataset`.
|
|
827
|
+
* The return value of each call to the `iteratee` method is used as the `accumulator` value for the next call.
|
|
828
|
+
*
|
|
829
|
+
* This method returns the return value of the last `iteratee` call.
|
|
830
|
+
*
|
|
831
|
+
* This method is aligned with `Array.prototype.reduce()` in ECMAScript-262.
|
|
832
|
+
*/
|
|
833
|
+
reduce(callback, initialValue) {
|
|
834
|
+
const iter = this.readQuads();
|
|
835
|
+
let accumulator = initialValue === undefined ? iter.next().value : initialValue;
|
|
836
|
+
for (const quad of iter) accumulator = callback(accumulator, quad, this);
|
|
837
|
+
return accumulator;
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
/**
|
|
841
|
+
* Returns the set of quads within the dataset as a host-language-native sequence, for example an `Array` in
|
|
842
|
+
* ECMAScript-262.
|
|
843
|
+
*
|
|
844
|
+
* Since a `Dataset` is an unordered set, the order of the quads within the returned sequence is arbitrary.
|
|
845
|
+
*/
|
|
846
|
+
toArray() {
|
|
847
|
+
return this.getQuads();
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
/**
|
|
851
|
+
* Returns an N-Quads string representation of the dataset, preprocessed with the
|
|
852
|
+
* {@link https://json-ld.github.io/normalization/spec/|RDF Dataset Normalization} algorithm.
|
|
853
|
+
*/
|
|
854
|
+
toCanonical() {
|
|
855
|
+
throw new Error('not implemented');
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
/**
|
|
859
|
+
* Returns a stream that contains all quads of the dataset.
|
|
860
|
+
*/
|
|
861
|
+
toStream() {
|
|
862
|
+
return this.match();
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
/**
|
|
866
|
+
* Returns an N-Quads string representation of the dataset.
|
|
867
|
+
*
|
|
868
|
+
* No prior normalization is required, therefore the results for the same quads may vary depending on the `Dataset`
|
|
869
|
+
* implementation.
|
|
870
|
+
*/
|
|
871
|
+
toString() {
|
|
872
|
+
return new _N3Writer.default().quadsToString(this);
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
/**
|
|
876
|
+
* Returns a new `Dataset` that is a concatenation of this dataset and the quads given as an argument.
|
|
877
|
+
*/
|
|
878
|
+
union(quads) {
|
|
879
|
+
const store = new N3Store();
|
|
880
|
+
store.addAll(this);
|
|
881
|
+
store.addAll(quads);
|
|
882
|
+
return store;
|
|
883
|
+
}
|
|
884
|
+
|
|
746
885
|
// ### Store is an iterable.
|
|
747
886
|
// Can be used where iterables are expected: for...of loops, array spread operator,
|
|
748
887
|
// `yield*`, and destructuring assignment (order is not guaranteed).
|
|
@@ -804,6 +943,60 @@ class DatasetCoreAndReadableStream extends _readableStream.Readable {
|
|
|
804
943
|
this.push(value);
|
|
805
944
|
}
|
|
806
945
|
}
|
|
946
|
+
addAll(quads) {
|
|
947
|
+
return this.filtered.addAll(quads);
|
|
948
|
+
}
|
|
949
|
+
contains(other) {
|
|
950
|
+
return this.filtered.contains(other);
|
|
951
|
+
}
|
|
952
|
+
deleteMatches(subject, predicate, object, graph) {
|
|
953
|
+
return this.filtered.deleteMatches(subject, predicate, object, graph);
|
|
954
|
+
}
|
|
955
|
+
difference(other) {
|
|
956
|
+
return this.filtered.difference(other);
|
|
957
|
+
}
|
|
958
|
+
equals(other) {
|
|
959
|
+
return this.filtered.equals(other);
|
|
960
|
+
}
|
|
961
|
+
every(callback, subject, predicate, object, graph) {
|
|
962
|
+
return this.filtered.every(callback, subject, predicate, object, graph);
|
|
963
|
+
}
|
|
964
|
+
filter(iteratee) {
|
|
965
|
+
return this.filtered.filter(iteratee);
|
|
966
|
+
}
|
|
967
|
+
forEach(callback, subject, predicate, object, graph) {
|
|
968
|
+
return this.filtered.forEach(callback, subject, predicate, object, graph);
|
|
969
|
+
}
|
|
970
|
+
import(stream) {
|
|
971
|
+
return this.filtered.import(stream);
|
|
972
|
+
}
|
|
973
|
+
intersection(other) {
|
|
974
|
+
return this.filtered.intersection(other);
|
|
975
|
+
}
|
|
976
|
+
map(iteratee) {
|
|
977
|
+
return this.filtered.map(iteratee);
|
|
978
|
+
}
|
|
979
|
+
some(callback, subject, predicate, object, graph) {
|
|
980
|
+
return this.filtered.some(callback, subject, predicate, object, graph);
|
|
981
|
+
}
|
|
982
|
+
toCanonical() {
|
|
983
|
+
return this.filtered.toCanonical();
|
|
984
|
+
}
|
|
985
|
+
toStream() {
|
|
986
|
+
return this._filtered ? this._filtered.toStream() : this.n3Store.match(this.subject, this.predicate, this.object, this.graph);
|
|
987
|
+
}
|
|
988
|
+
union(quads) {
|
|
989
|
+
return this._filtered ? this._filtered.union(quads) : this.n3Store.match(this.subject, this.predicate, this.object, this.graph).addAll(quads);
|
|
990
|
+
}
|
|
991
|
+
toArray() {
|
|
992
|
+
return this._filtered ? this._filtered.toArray() : this.n3Store.getQuads(this.subject, this.predicate, this.object, this.graph);
|
|
993
|
+
}
|
|
994
|
+
reduce(callback, initialValue) {
|
|
995
|
+
return this.filtered.reduce(callback, initialValue);
|
|
996
|
+
}
|
|
997
|
+
toString() {
|
|
998
|
+
return new _N3Writer.default().quadsToString(this);
|
|
999
|
+
}
|
|
807
1000
|
add(quad) {
|
|
808
1001
|
return this.filtered.add(quad);
|
|
809
1002
|
}
|
package/lib/N3Writer.js
CHANGED
|
@@ -136,9 +136,9 @@ class N3Writer {
|
|
|
136
136
|
|
|
137
137
|
// ### `quadsToString` serializes an array of quads as a string
|
|
138
138
|
quadsToString(quads) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
139
|
+
let quadsString = '';
|
|
140
|
+
for (const quad of quads) quadsString += this.quadToString(quad.subject, quad.predicate, quad.object, quad.graph);
|
|
141
|
+
return quadsString;
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
// ### `_encodeSubject` represents a subject
|
package/package.json
CHANGED
package/src/N3Store.js
CHANGED
|
@@ -3,6 +3,7 @@ import { Readable } from 'readable-stream';
|
|
|
3
3
|
import { default as N3DataFactory, termToId, termFromId } from './N3DataFactory';
|
|
4
4
|
import namespaces from './IRIs';
|
|
5
5
|
import { isDefaultGraph } from './N3Util';
|
|
6
|
+
import N3Writer from './N3Writer';
|
|
6
7
|
|
|
7
8
|
const ITERATOR = Symbol('iter');
|
|
8
9
|
|
|
@@ -511,7 +512,7 @@ export default class N3Store {
|
|
|
511
512
|
// Setting any field to `undefined` or `null` indicates a wildcard.
|
|
512
513
|
forEach(callback, subject, predicate, object, graph) {
|
|
513
514
|
this.some(quad => {
|
|
514
|
-
callback(quad);
|
|
515
|
+
callback(quad, this);
|
|
515
516
|
return false;
|
|
516
517
|
}, subject, predicate, object, graph);
|
|
517
518
|
}
|
|
@@ -520,12 +521,7 @@ export default class N3Store {
|
|
|
520
521
|
// and returns `true` if it returns truthy for all them.
|
|
521
522
|
// Setting any field to `undefined` or `null` indicates a wildcard.
|
|
522
523
|
every(callback, subject, predicate, object, graph) {
|
|
523
|
-
|
|
524
|
-
const every = !this.some(quad => {
|
|
525
|
-
some = true;
|
|
526
|
-
return !callback(quad);
|
|
527
|
-
}, subject, predicate, object, graph);
|
|
528
|
-
return some && every;
|
|
524
|
+
return !this.some(quad => !callback(quad, this), subject, predicate, object, graph);
|
|
529
525
|
}
|
|
530
526
|
|
|
531
527
|
// ### `some` executes the callback on all quads,
|
|
@@ -786,6 +782,158 @@ export default class N3Store {
|
|
|
786
782
|
return lists;
|
|
787
783
|
}
|
|
788
784
|
|
|
785
|
+
/**
|
|
786
|
+
* Returns `true` if the current dataset is a superset of the given dataset; in other words, returns `true` if
|
|
787
|
+
* the given dataset is a subset of, i.e., is contained within, the current dataset.
|
|
788
|
+
*
|
|
789
|
+
* Blank Nodes will be normalized.
|
|
790
|
+
*/
|
|
791
|
+
addAll(quads) {
|
|
792
|
+
if (Array.isArray(quads))
|
|
793
|
+
this.addQuads(quads);
|
|
794
|
+
else {
|
|
795
|
+
for (const quad of quads)
|
|
796
|
+
this.add(quad);
|
|
797
|
+
}
|
|
798
|
+
return this;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
|
|
802
|
+
/**
|
|
803
|
+
* Returns `true` if the current dataset is a superset of the given dataset; in other words, returns `true` if
|
|
804
|
+
* the given dataset is a subset of, i.e., is contained within, the current dataset.
|
|
805
|
+
*
|
|
806
|
+
* Blank Nodes will be normalized.
|
|
807
|
+
*/
|
|
808
|
+
contains(other) {
|
|
809
|
+
return other.every(quad => this.has(quad));
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
/**
|
|
813
|
+
* This method removes the quads in the current dataset that match the given arguments.
|
|
814
|
+
*
|
|
815
|
+
* The logic described in {@link https://rdf.js.org/dataset-spec/#quad-matching|Quad Matching} is applied for each
|
|
816
|
+
* quad in this dataset, to select the quads which will be deleted.
|
|
817
|
+
*
|
|
818
|
+
* @param subject The optional exact subject to match.
|
|
819
|
+
* @param predicate The optional exact predicate to match.
|
|
820
|
+
* @param object The optional exact object to match.
|
|
821
|
+
* @param graph The optional exact graph to match.
|
|
822
|
+
*/
|
|
823
|
+
deleteMatches(subject, predicate, object, graph) {
|
|
824
|
+
for (const quad of this.match(subject, predicate, object, graph))
|
|
825
|
+
this.removeQuad(quad);
|
|
826
|
+
return this;
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
/**
|
|
830
|
+
* Returns a new dataset that contains all quads from the current dataset that are not included in the given dataset.
|
|
831
|
+
*/
|
|
832
|
+
difference(other) {
|
|
833
|
+
return this.filter(quad => !other.has(quad));
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
/**
|
|
837
|
+
* Returns true if the current dataset contains the same graph structure as the given dataset.
|
|
838
|
+
*
|
|
839
|
+
* Blank Nodes will be normalized.
|
|
840
|
+
*/
|
|
841
|
+
equals(other) {
|
|
842
|
+
return other === this || (this.size === other.size && this.contains(other));
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
/**
|
|
846
|
+
* Creates a new dataset with all the quads that pass the test implemented by the provided `iteratee`.
|
|
847
|
+
*
|
|
848
|
+
* This method is aligned with Array.prototype.filter() in ECMAScript-262.
|
|
849
|
+
*/
|
|
850
|
+
filter(iteratee) {
|
|
851
|
+
const store = new N3Store();
|
|
852
|
+
for (const quad of this)
|
|
853
|
+
if (iteratee(quad, this))
|
|
854
|
+
store.add(quad);
|
|
855
|
+
return store;
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
/**
|
|
859
|
+
* Returns a new dataset containing all quads from the current dataset that are also included in the given dataset.
|
|
860
|
+
*/
|
|
861
|
+
intersection(other) {
|
|
862
|
+
return this.filter(quad => other.has(quad));
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
/**
|
|
866
|
+
* Returns a new dataset containing all quads returned by applying `iteratee` to each quad in the current dataset.
|
|
867
|
+
*/
|
|
868
|
+
map(iteratee) {
|
|
869
|
+
const store = new N3Store();
|
|
870
|
+
for (const quad of this)
|
|
871
|
+
store.add(iteratee(quad, this));
|
|
872
|
+
return store;
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
/**
|
|
876
|
+
* This method calls the `iteratee` method on each `quad` of the `Dataset`. The first time the `iteratee` method
|
|
877
|
+
* is called, the `accumulator` value is the `initialValue`, or, if not given, equals the first quad of the `Dataset`.
|
|
878
|
+
* The return value of each call to the `iteratee` method is used as the `accumulator` value for the next call.
|
|
879
|
+
*
|
|
880
|
+
* This method returns the return value of the last `iteratee` call.
|
|
881
|
+
*
|
|
882
|
+
* This method is aligned with `Array.prototype.reduce()` in ECMAScript-262.
|
|
883
|
+
*/
|
|
884
|
+
reduce(callback, initialValue) {
|
|
885
|
+
const iter = this.readQuads();
|
|
886
|
+
let accumulator = initialValue === undefined ? iter.next().value : initialValue;
|
|
887
|
+
for (const quad of iter)
|
|
888
|
+
accumulator = callback(accumulator, quad, this);
|
|
889
|
+
return accumulator;
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
/**
|
|
893
|
+
* Returns the set of quads within the dataset as a host-language-native sequence, for example an `Array` in
|
|
894
|
+
* ECMAScript-262.
|
|
895
|
+
*
|
|
896
|
+
* Since a `Dataset` is an unordered set, the order of the quads within the returned sequence is arbitrary.
|
|
897
|
+
*/
|
|
898
|
+
toArray() {
|
|
899
|
+
return this.getQuads();
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
/**
|
|
903
|
+
* Returns an N-Quads string representation of the dataset, preprocessed with the
|
|
904
|
+
* {@link https://json-ld.github.io/normalization/spec/|RDF Dataset Normalization} algorithm.
|
|
905
|
+
*/
|
|
906
|
+
toCanonical() {
|
|
907
|
+
throw new Error('not implemented');
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
/**
|
|
911
|
+
* Returns a stream that contains all quads of the dataset.
|
|
912
|
+
*/
|
|
913
|
+
toStream() {
|
|
914
|
+
return this.match();
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
/**
|
|
918
|
+
* Returns an N-Quads string representation of the dataset.
|
|
919
|
+
*
|
|
920
|
+
* No prior normalization is required, therefore the results for the same quads may vary depending on the `Dataset`
|
|
921
|
+
* implementation.
|
|
922
|
+
*/
|
|
923
|
+
toString() {
|
|
924
|
+
return (new N3Writer()).quadsToString(this);
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
/**
|
|
928
|
+
* Returns a new `Dataset` that is a concatenation of this dataset and the quads given as an argument.
|
|
929
|
+
*/
|
|
930
|
+
union(quads) {
|
|
931
|
+
const store = new N3Store();
|
|
932
|
+
store.addAll(this);
|
|
933
|
+
store.addAll(quads);
|
|
934
|
+
return store;
|
|
935
|
+
}
|
|
936
|
+
|
|
789
937
|
// ### Store is an iterable.
|
|
790
938
|
// Can be used where iterables are expected: for...of loops, array spread operator,
|
|
791
939
|
// `yield*`, and destructuring assignment (order is not guaranteed).
|
|
@@ -831,6 +979,82 @@ class DatasetCoreAndReadableStream extends Readable {
|
|
|
831
979
|
}
|
|
832
980
|
}
|
|
833
981
|
|
|
982
|
+
addAll(quads) {
|
|
983
|
+
return this.filtered.addAll(quads);
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
contains(other) {
|
|
987
|
+
return this.filtered.contains(other);
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
deleteMatches(subject, predicate, object, graph) {
|
|
991
|
+
return this.filtered.deleteMatches(subject, predicate, object, graph);
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
difference(other) {
|
|
995
|
+
return this.filtered.difference(other);
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
equals(other) {
|
|
999
|
+
return this.filtered.equals(other);
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
every(callback, subject, predicate, object, graph) {
|
|
1003
|
+
return this.filtered.every(callback, subject, predicate, object, graph);
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
filter(iteratee) {
|
|
1007
|
+
return this.filtered.filter(iteratee);
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
forEach(callback, subject, predicate, object, graph) {
|
|
1011
|
+
return this.filtered.forEach(callback, subject, predicate, object, graph);
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
import(stream) {
|
|
1015
|
+
return this.filtered.import(stream);
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
intersection(other) {
|
|
1019
|
+
return this.filtered.intersection(other);
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
map(iteratee) {
|
|
1023
|
+
return this.filtered.map(iteratee);
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
some(callback, subject, predicate, object, graph) {
|
|
1027
|
+
return this.filtered.some(callback, subject, predicate, object, graph);
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
toCanonical() {
|
|
1031
|
+
return this.filtered.toCanonical();
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
toStream() {
|
|
1035
|
+
return this._filtered ?
|
|
1036
|
+
this._filtered.toStream()
|
|
1037
|
+
: this.n3Store.match(this.subject, this.predicate, this.object, this.graph);
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
union(quads) {
|
|
1041
|
+
return this._filtered ?
|
|
1042
|
+
this._filtered.union(quads)
|
|
1043
|
+
: this.n3Store.match(this.subject, this.predicate, this.object, this.graph).addAll(quads);
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
toArray() {
|
|
1047
|
+
return this._filtered ? this._filtered.toArray() : this.n3Store.getQuads(this.subject, this.predicate, this.object, this.graph);
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
reduce(callback, initialValue) {
|
|
1051
|
+
return this.filtered.reduce(callback, initialValue);
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
toString() {
|
|
1055
|
+
return (new N3Writer()).quadsToString(this);
|
|
1056
|
+
}
|
|
1057
|
+
|
|
834
1058
|
add(quad) {
|
|
835
1059
|
return this.filtered.add(quad);
|
|
836
1060
|
}
|
package/src/N3Writer.js
CHANGED
|
@@ -130,9 +130,10 @@ export default class N3Writer {
|
|
|
130
130
|
|
|
131
131
|
// ### `quadsToString` serializes an array of quads as a string
|
|
132
132
|
quadsToString(quads) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
133
|
+
let quadsString = '';
|
|
134
|
+
for (const quad of quads)
|
|
135
|
+
quadsString += this.quadToString(quad.subject, quad.predicate, quad.object, quad.graph);
|
|
136
|
+
return quadsString;
|
|
136
137
|
}
|
|
137
138
|
|
|
138
139
|
// ### `_encodeSubject` represents a subject
|