n3 1.17.6 → 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/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; }
@@ -413,8 +414,11 @@ class N3Store {
413
414
  return [...this.readQuads(subject, predicate, object, graph)];
414
415
  }
415
416
 
416
- // ### `readQuads` returns an generator of quads matching a pattern.
417
- // Setting any field to `undefined` or `null` indicates a wildcard.
417
+ /**
418
+ * `readQuads` returns a generator of quads matching a pattern.
419
+ * Setting any field to `undefined` or `null` indicates a wildcard.
420
+ * @deprecated Use `match` instead.
421
+ */
418
422
  *readQuads(subject, predicate, object, graph) {
419
423
  const graphs = this._getGraphs(graph);
420
424
  let content, subjectId, predicateId, objectId;
@@ -492,7 +496,7 @@ class N3Store {
492
496
  // Setting any field to `undefined` or `null` indicates a wildcard.
493
497
  forEach(callback, subject, predicate, object, graph) {
494
498
  this.some(quad => {
495
- callback(quad);
499
+ callback(quad, this);
496
500
  return false;
497
501
  }, subject, predicate, object, graph);
498
502
  }
@@ -501,12 +505,7 @@ class N3Store {
501
505
  // and returns `true` if it returns truthy for all them.
502
506
  // Setting any field to `undefined` or `null` indicates a wildcard.
503
507
  every(callback, subject, predicate, object, graph) {
504
- let some = false;
505
- const every = !this.some(quad => {
506
- some = true;
507
- return !callback(quad);
508
- }, subject, predicate, object, graph);
509
- return some && every;
508
+ return !this.some(quad => !callback(quad, this), subject, predicate, object, graph);
510
509
  }
511
510
 
512
511
  // ### `some` executes the callback on all quads,
@@ -740,6 +739,149 @@ class N3Store {
740
739
  return lists;
741
740
  }
742
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
+
743
885
  // ### Store is an iterable.
744
886
  // Can be used where iterables are expected: for...of loops, array spread operator,
745
887
  // `yield*`, and destructuring assignment (order is not guaranteed).
@@ -801,6 +943,60 @@ class DatasetCoreAndReadableStream extends _readableStream.Readable {
801
943
  this.push(value);
802
944
  }
803
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
+ }
804
1000
  add(quad) {
805
1001
  return this.filtered.add(quad);
806
1002
  }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _N3Store = _interopRequireDefault(require("./N3Store"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ class N3DatasetCoreFactory {
10
+ dataset(quads) {
11
+ return new _N3Store.default(quads);
12
+ }
13
+ }
14
+ exports.default = N3DatasetCoreFactory;
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
- return quads.map(t => {
140
- return this.quadToString(t.subject, t.predicate, t.object, t.graph);
141
- }).join('');
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/lib/index.js CHANGED
@@ -63,6 +63,12 @@ Object.defineProperty(exports, "Store", {
63
63
  return _N3Store.default;
64
64
  }
65
65
  });
66
+ Object.defineProperty(exports, "StoreFactory", {
67
+ enumerable: true,
68
+ get: function () {
69
+ return _N3StoreFactory.default;
70
+ }
71
+ });
66
72
  Object.defineProperty(exports, "StreamParser", {
67
73
  enumerable: true,
68
74
  get: function () {
@@ -117,6 +123,7 @@ var _N3Lexer = _interopRequireDefault(require("./N3Lexer"));
117
123
  var _N3Parser = _interopRequireDefault(require("./N3Parser"));
118
124
  var _N3Writer = _interopRequireDefault(require("./N3Writer"));
119
125
  var _N3Store = _interopRequireWildcard(require("./N3Store"));
126
+ var _N3StoreFactory = _interopRequireDefault(require("./N3StoreFactory"));
120
127
  var _N3StreamParser = _interopRequireDefault(require("./N3StreamParser"));
121
128
  var _N3StreamWriter = _interopRequireDefault(require("./N3StreamWriter"));
122
129
  var Util = _interopRequireWildcard(require("./N3Util"));
@@ -132,6 +139,8 @@ var _default = exports.default = {
132
139
  Parser: _N3Parser.default,
133
140
  Writer: _N3Writer.default,
134
141
  Store: _N3Store.default,
142
+ StoreFactory: _N3StoreFactory.default,
143
+ EntityIndex: _N3Store.N3EntityIndex,
135
144
  StreamParser: _N3StreamParser.default,
136
145
  StreamWriter: _N3StreamWriter.default,
137
146
  Util,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n3",
3
- "version": "1.17.6",
3
+ "version": "1.19.0",
4
4
  "description": "Lightning fast, asynchronous, streaming Turtle / N3 / RDF library.",
5
5
  "author": "Ruben Verborgh <ruben.verborgh@gmail.com>",
6
6
  "keywords": [
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
 
@@ -415,8 +416,11 @@ export default class N3Store {
415
416
  return [...this.readQuads(subject, predicate, object, graph)];
416
417
  }
417
418
 
418
- // ### `readQuads` returns an generator of quads matching a pattern.
419
- // Setting any field to `undefined` or `null` indicates a wildcard.
419
+ /**
420
+ * `readQuads` returns a generator of quads matching a pattern.
421
+ * Setting any field to `undefined` or `null` indicates a wildcard.
422
+ * @deprecated Use `match` instead.
423
+ */
420
424
  *readQuads(subject, predicate, object, graph) {
421
425
  const graphs = this._getGraphs(graph);
422
426
  let content, subjectId, predicateId, objectId;
@@ -508,7 +512,7 @@ export default class N3Store {
508
512
  // Setting any field to `undefined` or `null` indicates a wildcard.
509
513
  forEach(callback, subject, predicate, object, graph) {
510
514
  this.some(quad => {
511
- callback(quad);
515
+ callback(quad, this);
512
516
  return false;
513
517
  }, subject, predicate, object, graph);
514
518
  }
@@ -517,12 +521,7 @@ export default class N3Store {
517
521
  // and returns `true` if it returns truthy for all them.
518
522
  // Setting any field to `undefined` or `null` indicates a wildcard.
519
523
  every(callback, subject, predicate, object, graph) {
520
- let some = false;
521
- const every = !this.some(quad => {
522
- some = true;
523
- return !callback(quad);
524
- }, subject, predicate, object, graph);
525
- return some && every;
524
+ return !this.some(quad => !callback(quad, this), subject, predicate, object, graph);
526
525
  }
527
526
 
528
527
  // ### `some` executes the callback on all quads,
@@ -783,6 +782,158 @@ export default class N3Store {
783
782
  return lists;
784
783
  }
785
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
+
786
937
  // ### Store is an iterable.
787
938
  // Can be used where iterables are expected: for...of loops, array spread operator,
788
939
  // `yield*`, and destructuring assignment (order is not guaranteed).
@@ -828,6 +979,82 @@ class DatasetCoreAndReadableStream extends Readable {
828
979
  }
829
980
  }
830
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
+
831
1058
  add(quad) {
832
1059
  return this.filtered.add(quad);
833
1060
  }
@@ -0,0 +1,7 @@
1
+ import N3Store from './N3Store';
2
+
3
+ export default class N3DatasetCoreFactory {
4
+ dataset(quads) {
5
+ return new N3Store(quads);
6
+ }
7
+ }
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
- return quads.map(t => {
134
- return this.quadToString(t.subject, t.predicate, t.object, t.graph);
135
- }).join('');
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
package/src/index.js CHANGED
@@ -2,6 +2,7 @@ import Lexer from './N3Lexer';
2
2
  import Parser from './N3Parser';
3
3
  import Writer from './N3Writer';
4
4
  import Store, { N3EntityIndex as EntityIndex } from './N3Store';
5
+ import StoreFactory from './N3StoreFactory';
5
6
  import StreamParser from './N3StreamParser';
6
7
  import StreamWriter from './N3StreamWriter';
7
8
  import * as Util from './N3Util';
@@ -28,6 +29,7 @@ export {
28
29
  Parser,
29
30
  Writer,
30
31
  Store,
32
+ StoreFactory,
31
33
  EntityIndex,
32
34
  StreamParser,
33
35
  StreamWriter,
@@ -54,6 +56,8 @@ export default {
54
56
  Parser,
55
57
  Writer,
56
58
  Store,
59
+ StoreFactory,
60
+ EntityIndex,
57
61
  StreamParser,
58
62
  StreamWriter,
59
63
  Util,