rdflib 2.2.25 → 2.2.26

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 (197) hide show
  1. package/.babelrc +0 -0
  2. package/README.md +0 -0
  3. package/dist/670.rdflib.min.js +1 -0
  4. package/dist/730.rdflib.min.js +3 -0
  5. package/dist/730.rdflib.min.js.LICENSE.txt +58 -0
  6. package/dist/730.rdflib.min.js.map +1 -0
  7. package/dist/rdflib.min.js +1 -1
  8. package/dist/rdflib.min.js.LICENSE.txt +0 -59
  9. package/dist/rdflib.min.js.map +1 -1
  10. package/esm/blank-node.js +0 -0
  11. package/esm/class-order.js +0 -0
  12. package/esm/collection.js +4 -3
  13. package/esm/default-graph.js +0 -0
  14. package/esm/empty.js +0 -0
  15. package/esm/factories/canonical-data-factory.js +0 -0
  16. package/esm/factories/extended-term-factory.js +0 -0
  17. package/esm/factories/factory-types.js +0 -0
  18. package/esm/factories/rdflib-data-factory.js +0 -0
  19. package/esm/fetcher.js +3 -2
  20. package/esm/formula.js +0 -0
  21. package/esm/index.js +0 -0
  22. package/esm/jsonldparser.js +4 -3
  23. package/esm/jsonparser.js +0 -0
  24. package/esm/lists.js +0 -0
  25. package/esm/literal.js +0 -0
  26. package/esm/log.js +0 -0
  27. package/esm/n3parser.js +0 -0
  28. package/esm/named-node.js +0 -0
  29. package/esm/namespace.js +0 -0
  30. package/esm/node-internal.js +0 -0
  31. package/esm/node.js +0 -0
  32. package/esm/parse.js +0 -0
  33. package/esm/patch-parser.js +0 -0
  34. package/esm/query-to-sparql.js +0 -0
  35. package/esm/query.js +0 -0
  36. package/esm/rdfaparser.js +0 -0
  37. package/esm/rdfxmlparser.js +0 -0
  38. package/esm/serialize.js +1 -1
  39. package/esm/serializer.js +10 -12
  40. package/esm/sparql-to-query.js +0 -0
  41. package/esm/statement.js +0 -0
  42. package/esm/store.js +4 -4
  43. package/esm/tf-types.js +0 -0
  44. package/esm/types.js +0 -0
  45. package/esm/update-manager.js +0 -0
  46. package/esm/updates-via.js +0 -0
  47. package/esm/uri.js +0 -0
  48. package/esm/utils/default-graph-uri.js +0 -0
  49. package/esm/utils/termValue.js +0 -0
  50. package/esm/utils/terms.js +0 -0
  51. package/esm/utils-js.js +0 -0
  52. package/esm/utils.js +0 -0
  53. package/esm/variable.js +0 -0
  54. package/esm/xsd-internal.js +0 -0
  55. package/esm/xsd.js +0 -0
  56. package/lib/blank-node.d.ts +0 -0
  57. package/lib/blank-node.js +0 -0
  58. package/lib/class-order.d.ts +0 -0
  59. package/lib/class-order.js +0 -0
  60. package/lib/collection.d.ts +0 -0
  61. package/lib/collection.js +4 -3
  62. package/lib/default-graph.d.ts +0 -0
  63. package/lib/default-graph.js +0 -0
  64. package/lib/empty.d.ts +0 -0
  65. package/lib/empty.js +0 -0
  66. package/lib/factories/canonical-data-factory.d.ts +0 -0
  67. package/lib/factories/canonical-data-factory.js +0 -0
  68. package/lib/factories/extended-term-factory.d.ts +0 -0
  69. package/lib/factories/extended-term-factory.js +0 -0
  70. package/lib/factories/factory-types.d.ts +0 -0
  71. package/lib/factories/factory-types.js +0 -0
  72. package/lib/factories/rdflib-data-factory.d.ts +0 -0
  73. package/lib/factories/rdflib-data-factory.js +0 -0
  74. package/lib/fetcher.d.ts +0 -0
  75. package/lib/fetcher.js +3 -2
  76. package/lib/formula.d.ts +0 -0
  77. package/lib/formula.js +0 -0
  78. package/lib/index.d.ts +0 -0
  79. package/lib/index.js +0 -0
  80. package/lib/jsonldparser.d.ts +0 -0
  81. package/lib/jsonldparser.js +9 -3
  82. package/lib/jsonparser.d.ts +0 -0
  83. package/lib/jsonparser.js +0 -0
  84. package/lib/lists.d.ts +0 -0
  85. package/lib/lists.js +0 -0
  86. package/lib/literal.d.ts +0 -0
  87. package/lib/literal.js +0 -0
  88. package/lib/log.d.ts +0 -0
  89. package/lib/log.js +0 -0
  90. package/lib/n3parser.d.ts +0 -0
  91. package/lib/n3parser.js +0 -0
  92. package/lib/named-node.d.ts +0 -0
  93. package/lib/named-node.js +0 -0
  94. package/lib/namespace.d.ts +0 -0
  95. package/lib/namespace.js +0 -0
  96. package/lib/node-internal.d.ts +0 -0
  97. package/lib/node-internal.js +0 -0
  98. package/lib/node.d.ts +0 -0
  99. package/lib/node.js +0 -0
  100. package/lib/parse.d.ts +0 -0
  101. package/lib/parse.js +0 -0
  102. package/lib/patch-parser.d.ts +0 -0
  103. package/lib/patch-parser.js +0 -0
  104. package/lib/query-to-sparql.d.ts +0 -0
  105. package/lib/query-to-sparql.js +0 -0
  106. package/lib/query.d.ts +0 -0
  107. package/lib/query.js +0 -0
  108. package/lib/rdfaparser.d.ts +0 -0
  109. package/lib/rdfaparser.js +0 -0
  110. package/lib/rdfxmlparser.d.ts +0 -0
  111. package/lib/rdfxmlparser.js +0 -0
  112. package/lib/serialize.d.ts +0 -0
  113. package/lib/serialize.js +1 -1
  114. package/lib/serializer.d.ts +0 -0
  115. package/lib/serializer.js +10 -13
  116. package/lib/sparql-to-query.d.ts +0 -0
  117. package/lib/sparql-to-query.js +0 -0
  118. package/lib/statement.d.ts +0 -0
  119. package/lib/statement.js +0 -0
  120. package/lib/store.d.ts +1 -1
  121. package/lib/store.js +4 -4
  122. package/lib/tf-types.d.ts +0 -0
  123. package/lib/tf-types.js +0 -0
  124. package/lib/types.d.ts +0 -0
  125. package/lib/types.js +0 -0
  126. package/lib/update-manager.d.ts +0 -0
  127. package/lib/update-manager.js +0 -0
  128. package/lib/updates-via.d.ts +0 -0
  129. package/lib/updates-via.js +0 -0
  130. package/lib/uri.d.ts +0 -0
  131. package/lib/uri.js +0 -0
  132. package/lib/utils/default-graph-uri.d.ts +0 -0
  133. package/lib/utils/default-graph-uri.js +0 -0
  134. package/lib/utils/termValue.d.ts +0 -0
  135. package/lib/utils/termValue.js +0 -0
  136. package/lib/utils/terms.d.ts +0 -0
  137. package/lib/utils/terms.js +0 -0
  138. package/lib/utils-js.d.ts +0 -0
  139. package/lib/utils-js.js +0 -0
  140. package/lib/utils.d.ts +0 -0
  141. package/lib/utils.js +0 -0
  142. package/lib/variable.d.ts +0 -0
  143. package/lib/variable.js +0 -0
  144. package/lib/xsd-internal.d.ts +0 -0
  145. package/lib/xsd-internal.js +0 -0
  146. package/lib/xsd.d.ts +0 -0
  147. package/lib/xsd.js +0 -0
  148. package/package.json +7 -7
  149. package/src/blank-node.ts +0 -0
  150. package/src/class-order.ts +0 -0
  151. package/src/collection.ts +3 -3
  152. package/src/default-graph.ts +0 -0
  153. package/src/empty.ts +0 -0
  154. package/src/factories/canonical-data-factory.ts +0 -0
  155. package/src/factories/extended-term-factory.ts +0 -0
  156. package/src/factories/factory-types.ts +0 -0
  157. package/src/factories/rdflib-data-factory.ts +0 -0
  158. package/src/fetcher.ts +2 -2
  159. package/src/formula.ts +0 -0
  160. package/src/index.ts +0 -0
  161. package/src/jsonldparser.js +2 -4
  162. package/src/jsonparser.js +0 -0
  163. package/src/lists.ts +0 -0
  164. package/src/literal.ts +0 -0
  165. package/src/log.js +0 -0
  166. package/src/n3parser.js +0 -0
  167. package/src/named-node.ts +0 -0
  168. package/src/namespace.ts +0 -0
  169. package/src/node-internal.ts +0 -0
  170. package/src/node.ts +0 -0
  171. package/src/parse.ts +0 -0
  172. package/src/patch-parser.js +0 -0
  173. package/src/query-to-sparql.js +0 -0
  174. package/src/query.js +0 -0
  175. package/src/rdfaparser.js +0 -0
  176. package/src/rdfxmlparser.js +0 -0
  177. package/src/serialize.ts +1 -1
  178. package/src/serializer.js +4 -6
  179. package/src/sparql-to-query.js +0 -0
  180. package/src/statement.ts +0 -0
  181. package/src/store.ts +6 -5
  182. package/src/tf-types.ts +0 -0
  183. package/src/types.ts +0 -0
  184. package/src/update-manager.ts +0 -0
  185. package/src/updates-via.js +0 -0
  186. package/src/uri.ts +0 -0
  187. package/src/utils/default-graph-uri.ts +0 -0
  188. package/src/utils/termValue.ts +0 -0
  189. package/src/utils/terms.ts +0 -0
  190. package/src/utils-js.js +0 -0
  191. package/src/utils.ts +0 -0
  192. package/src/variable.ts +0 -0
  193. package/src/xsd-internal.js +0 -0
  194. package/src/xsd.js +0 -0
  195. package/esm/convert.js +0 -60
  196. package/lib/convert.d.ts +0 -2
  197. package/lib/convert.js +0 -71
package/lib/variable.js CHANGED
File without changes
File without changes
File without changes
package/lib/xsd.d.ts CHANGED
File without changes
package/lib/xsd.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rdflib",
3
3
  "description": "an RDF library for node.js. Suitable for client and server side.",
4
- "version": "2.2.25",
4
+ "version": "2.2.26",
5
5
  "private": false,
6
6
  "browserslist": [
7
7
  "> 0.5%"
@@ -48,7 +48,7 @@
48
48
  "@frogcat/ttl2jsonld": "^0.0.9",
49
49
  "@xmldom/xmldom": "^0.8.6",
50
50
  "cross-fetch": "^3.1.5",
51
- "jsonld": "^5.2.0",
51
+ "jsonld": "^8.1.0",
52
52
  "n3": "^1.16.3",
53
53
  "solid-namespace": "^0.5.2"
54
54
  },
@@ -62,16 +62,16 @@
62
62
  "@babel/register": "^7.18.9",
63
63
  "@types/chai": "^4.3.4",
64
64
  "@types/dirty-chai": "^2.0.2",
65
- "@types/express": "^4.17.16",
65
+ "@types/express": "^4.17.17",
66
66
  "@types/jsonld": "^1.5.8",
67
67
  "@types/sinon-chai": "^3.2.9",
68
68
  "babel-loader": "^9.1.2",
69
69
  "chai": "^4.3.7",
70
70
  "diff": "^5.1.0",
71
71
  "dirty-chai": "^2.0.1",
72
- "eslint": "^8.33.0",
72
+ "eslint": "^8.34.0",
73
73
  "fs-grep": "0.0.5",
74
- "locate-path": "^7.1.1",
74
+ "locate-path": "^7.2.0",
75
75
  "mocha": "^10.2.0",
76
76
  "nock": "^13.3.0",
77
77
  "node-fetch": "^3.3.0",
@@ -81,7 +81,7 @@
81
81
  "sinon-chai": "^3.7.0",
82
82
  "source-map-loader": "^4.0.1",
83
83
  "ts-node": "^10.9.1",
84
- "typedoc": "^0.23.24",
84
+ "typedoc": "^0.23.25",
85
85
  "typescript": "^4.9.5",
86
86
  "webpack": "^5.75.0",
87
87
  "webpack-cli": "^5.0.1",
@@ -94,7 +94,7 @@
94
94
  "build:types": "tsc --emitDeclarationOnly -d --moduleResolution node --declarationDir lib",
95
95
  "build:all": "npm run build && npm run build:types && npm run build:browser && npm run build:esm",
96
96
  "doc": "typedoc --out ./doc ./src/index.ts --excludePrivate --excludeInternal --tsconfig ./tsconfig.json",
97
- "prepublishOnly": "npm ci && npm run build:all && npm run doc && npm run test",
97
+ "ignore:prepublishOnly": "npm ci && npm run build:all && npm run doc && npm run test",
98
98
  "postversion": "git push --follow-tags",
99
99
  "start": "webpack serve --port 4800",
100
100
  "test": "npm run test:unit && npm run test:serialize && npm run test:types",
package/src/blank-node.ts CHANGED
File without changes
File without changes
package/src/collection.ts CHANGED
@@ -102,9 +102,9 @@ export default class Collection<
102
102
  * @param bindings - The bindings to substitute
103
103
  */
104
104
  substitute (bindings: Bindings) {
105
- const elementsCopy = this.elements.map((ea) => ea.substitute(bindings))
106
-
107
- return new Collection(elementsCopy) as Collection<Node | Collection<any> | Literal | Variable>
105
+ let collection = new Collection();
106
+ this.elements.forEach((ea) => {collection.append(ea.substitute(bindings))})
107
+ return collection as Collection<Node | Collection<any> | Literal | Variable>;
108
108
  }
109
109
 
110
110
  toNT () {
File without changes
package/src/empty.ts CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
package/src/fetcher.ts CHANGED
@@ -1551,13 +1551,13 @@ export default class Fetcher implements CallbackifyInterface {
1551
1551
  const fetcher = this
1552
1552
  // @ts-ignore
1553
1553
  if (fetcher.fetchQueue && fetcher.fetchQueue[uri]) {
1554
- console.log('Internal error - fetchQueue exists ' + uri)
1554
+ // console.log('Internal error - fetchQueue exists ' + uri)
1555
1555
  var promise = fetcher.fetchQueue[uri]
1556
1556
  if (promise['PromiseStatus'] === 'resolved') {
1557
1557
  delete fetcher.fetchQueue[uri]
1558
1558
  } else { // pending
1559
1559
  delete fetcher.fetchQueue[uri]
1560
- console.log('*** Fetcher: pending fetchQueue deleted ' + uri)
1560
+ // console.log('*** Fetcher: pending fetchQueue deleted ' + uri)
1561
1561
  }
1562
1562
  } if (fetcher.requested[uri] && fetcher.requested[uri] !== 'done' &&
1563
1563
  fetcher.requested[uri] !== 'failed' && fetcher.requested[uri] !== 404) {
package/src/formula.ts CHANGED
File without changes
package/src/index.ts CHANGED
File without changes
@@ -1,5 +1,3 @@
1
- import jsonld from 'jsonld'
2
-
3
1
  import { arrayToStatements } from './utils'
4
2
 
5
3
  /**
@@ -70,8 +68,8 @@ export default function jsonldParser (str, kb, base, callback) {
70
68
  ? base.value
71
69
  : base
72
70
 
73
- return jsonld
74
- .flatten(JSON.parse(str), null, { base: baseString })
71
+ return import('jsonld')
72
+ .then(jsonld => { return jsonld.flatten(JSON.parse(str), null, { base: baseString }) })
75
73
  .then((flattened) => flattened.reduce((store, flatResource) => {
76
74
 
77
75
  kb = processResource(kb, base, flatResource)
package/src/jsonparser.js CHANGED
File without changes
package/src/lists.ts CHANGED
File without changes
package/src/literal.ts CHANGED
File without changes
package/src/log.js CHANGED
File without changes
package/src/n3parser.js CHANGED
File without changes
package/src/named-node.ts CHANGED
File without changes
package/src/namespace.ts CHANGED
File without changes
File without changes
package/src/node.ts CHANGED
File without changes
package/src/parse.ts CHANGED
File without changes
File without changes
File without changes
package/src/query.js CHANGED
File without changes
package/src/rdfaparser.js CHANGED
File without changes
File without changes
package/src/serialize.ts CHANGED
@@ -80,7 +80,7 @@ export default function serialize (
80
80
  documentString = sz.statementsToNTriples(newSts)
81
81
  return executeCallback(null, documentString)
82
82
  case JSONLDContentType:
83
- sz.setFlags('si') // use turtle parameters
83
+ sz.setFlags('si dr') // turtle + dr (means no default, no relative prefix)
84
84
  documentString = sz.statementsToJsonld(newSts) // convert via turtle
85
85
  return executeCallback(null, documentString)
86
86
  case NQuadsContentType:
package/src/serializer.js CHANGED
@@ -12,7 +12,6 @@ import * as Util from './utils-js'
12
12
  import CanonicalDataFactory from './factories/canonical-data-factory'
13
13
  import { createXSD } from './xsd'
14
14
  import solidNs from 'solid-namespace'
15
- // import * as jsonld from 'jsonld'
16
15
  import * as ttl2jsonld from '@frogcat/ttl2jsonld'
17
16
 
18
17
 
@@ -502,7 +501,7 @@ export class Serializer {
502
501
 
503
502
  function prefixDirectivesMethod () {
504
503
  var str = ''
505
- if (this.defaultNamespace) {
504
+ if (this.flags.indexOf('d') < 0 && this.defaultNamespace) {
506
505
  str += '@prefix : ' + this.explicitURI(this.defaultNamespace) + '.\n'
507
506
  }
508
507
  for (var ns in this.prefixes) {
@@ -1016,8 +1015,8 @@ export class Serializer {
1016
1015
 
1017
1016
  statementsToJsonld (sts) {
1018
1017
  // ttl2jsonld creates context keys for all ttl prefix
1019
- // context keys must be full IRI
1020
- function findId (itemObj) {
1018
+ // context keys must be absolute IRI ttl2jsonld@0.0.8
1019
+ /* function findId (itemObj) {
1021
1020
  if (itemObj['@id']) {
1022
1021
  const item = itemObj['@id'].split(':')
1023
1022
  if (keys[item[0]]) itemObj['@id'] = jsonldObj['@context'][item[0]] + item[1]
@@ -1028,10 +1027,9 @@ export class Serializer {
1028
1027
  findId(itemValues[i])
1029
1028
  }
1030
1029
  }
1031
- }
1030
+ } */
1032
1031
  const turtleDoc = this.statementsToN3(sts)
1033
1032
  const jsonldObj = ttl2jsonld.parse(turtleDoc)
1034
-
1035
1033
  return JSON.stringify(jsonldObj, null, 2)
1036
1034
  }
1037
1035
 
File without changes
package/src/statement.ts CHANGED
File without changes
package/src/store.ts CHANGED
@@ -253,7 +253,7 @@ export default class IndexedFormula extends Formula { // IN future - allow pass
253
253
  applyPatch(
254
254
  patch: {
255
255
  delete?: ReadonlyArray<Statement>,
256
- patch?: ReadonlyArray<Statement>,
256
+ insert?: ReadonlyArray<Statement>,
257
257
  where?: any
258
258
  },
259
259
  target: TFNamedNode,
@@ -270,9 +270,9 @@ export default class IndexedFormula extends Formula { // IN future - allow pass
270
270
  // console.log('ds before substitute: ' + ds)
271
271
  if (binding) ds = ds.substitute(binding)
272
272
  // console.log('applyPatch: delete: ' + ds)
273
- ds = ds.statements as Statement[]
273
+
274
274
  var bad: Quad[] = []
275
- var ds2 = ds.map(function (st: Quad) { // Find the actual statements in the store
275
+ var ds2 = ds.elements.map(function (st: Quad) { // Find the actual statements in the store
276
276
  var sts = targetKB.statementsMatching(st.subject, st.predicate, st.object, target)
277
277
  if (sts.length === 0) {
278
278
  // log.info("NOT FOUND deletable " + st)
@@ -296,8 +296,8 @@ export default class IndexedFormula extends Formula { // IN future - allow pass
296
296
  // log.info("doPatch insert "+patch['insert'])
297
297
  ds = patch['insert']
298
298
  if (binding) ds = ds.substitute(binding)
299
- ds = ds.statements
300
- ds.map(function (st: Quad) {
299
+
300
+ ds.elements.map(function (st: Quad) {
301
301
  st.graph = target
302
302
  targetKB.add(st.subject, st.predicate, st.object, st.graph)
303
303
  })
@@ -315,6 +315,7 @@ export default class IndexedFormula extends Formula { // IN future - allow pass
315
315
  query.sync = true
316
316
 
317
317
  var bindingsFound: Bindings[] = []
318
+ query.pat.initBindings = [];
318
319
 
319
320
  targetKB.query(
320
321
  query,
package/src/tf-types.ts CHANGED
File without changes
package/src/types.ts CHANGED
File without changes
File without changes
File without changes
package/src/uri.ts CHANGED
File without changes
File without changes
File without changes
File without changes
package/src/utils-js.js CHANGED
File without changes
package/src/utils.ts CHANGED
File without changes
package/src/variable.ts CHANGED
File without changes
File without changes
package/src/xsd.js CHANGED
File without changes
package/esm/convert.js DELETED
@@ -1,60 +0,0 @@
1
- import asyncLib from 'async'; // @@ Goal: remove this dependency
2
- import jsonld from 'jsonld';
3
- import { Parser, Writer } from 'n3'; // @@ Goal: remove this dependency
4
-
5
- export function convertToJson(n3String, jsonCallback) {
6
- var jsonString;
7
- var n3Parser = new Parser();
8
- var n3Writer = new Writer({
9
- format: 'N-Quads'
10
- });
11
- asyncLib.waterfall([function (callback) {
12
- n3Parser.parse(n3String, function (error, quad, prefixes) {
13
- if (error) {
14
- callback(error);
15
- } else if (quad !== null) {
16
- n3Writer.addQuad(quad);
17
- } else {
18
- n3Writer.end(callback);
19
- }
20
- });
21
- }, function (result, callback) {
22
- try {
23
- jsonld.fromRDF(result, {
24
- format: 'application/nquads'
25
- }).then(function (result) {
26
- callback(null, result);
27
- });
28
- } catch (err) {
29
- callback(err);
30
- }
31
- }, function (json, callback) {
32
- jsonString = JSON.stringify(json);
33
- jsonCallback(null, jsonString);
34
- }], function (err, result) {
35
- jsonCallback(err, jsonString);
36
- });
37
- }
38
- export function convertToNQuads(n3String, nquadCallback) {
39
- var nquadString;
40
- var n3Parser = new Parser();
41
- var n3Writer = new Writer({
42
- format: 'N-Quads'
43
- });
44
- asyncLib.waterfall([function (callback) {
45
- n3Parser.parse(n3String, function (error, triple, prefixes) {
46
- if (error) {
47
- callback(error);
48
- } else if (quad !== null) {
49
- n3Writer.addQuad(quad);
50
- } else {
51
- n3Writer.end(callback);
52
- }
53
- });
54
- }, function (result, callback) {
55
- nquadString = result;
56
- nquadCallback(null, nquadString);
57
- }], function (err, result) {
58
- nquadCallback(err, nquadString);
59
- });
60
- }
package/lib/convert.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export function convertToJson(n3String: any, jsonCallback: any): void;
2
- export function convertToNQuads(n3String: any, nquadCallback: any): void;
package/lib/convert.js DELETED
@@ -1,71 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.convertToJson = convertToJson;
8
- exports.convertToNQuads = convertToNQuads;
9
- var _async = _interopRequireDefault(require("async"));
10
- var _jsonld = _interopRequireDefault(require("jsonld"));
11
- var _n = require("n3");
12
- // @@ Goal: remove this dependency
13
-
14
- // @@ Goal: remove this dependency
15
-
16
- function convertToJson(n3String, jsonCallback) {
17
- var jsonString;
18
- var n3Parser = new _n.Parser();
19
- var n3Writer = new _n.Writer({
20
- format: 'N-Quads'
21
- });
22
- _async.default.waterfall([function (callback) {
23
- n3Parser.parse(n3String, function (error, quad, prefixes) {
24
- if (error) {
25
- callback(error);
26
- } else if (quad !== null) {
27
- n3Writer.addQuad(quad);
28
- } else {
29
- n3Writer.end(callback);
30
- }
31
- });
32
- }, function (result, callback) {
33
- try {
34
- _jsonld.default.fromRDF(result, {
35
- format: 'application/nquads'
36
- }).then(function (result) {
37
- callback(null, result);
38
- });
39
- } catch (err) {
40
- callback(err);
41
- }
42
- }, function (json, callback) {
43
- jsonString = JSON.stringify(json);
44
- jsonCallback(null, jsonString);
45
- }], function (err, result) {
46
- jsonCallback(err, jsonString);
47
- });
48
- }
49
- function convertToNQuads(n3String, nquadCallback) {
50
- var nquadString;
51
- var n3Parser = new _n.Parser();
52
- var n3Writer = new _n.Writer({
53
- format: 'N-Quads'
54
- });
55
- _async.default.waterfall([function (callback) {
56
- n3Parser.parse(n3String, function (error, triple, prefixes) {
57
- if (error) {
58
- callback(error);
59
- } else if (quad !== null) {
60
- n3Writer.addQuad(quad);
61
- } else {
62
- n3Writer.end(callback);
63
- }
64
- });
65
- }, function (result, callback) {
66
- nquadString = result;
67
- nquadCallback(null, nquadString);
68
- }], function (err, result) {
69
- nquadCallback(err, nquadString);
70
- });
71
- }