rdflib 2.2.10 → 2.2.12-5f141ca2

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 (190) hide show
  1. package/.babelrc +0 -0
  2. package/README.md +1 -0
  3. package/changes.txt +0 -0
  4. package/dist/rdflib.min.js +62 -0
  5. package/dist/rdflib.min.js.map +1 -0
  6. package/esm/blank-node.js +137 -0
  7. package/esm/class-order.js +12 -0
  8. package/esm/collection.js +173 -0
  9. package/esm/convert.js +61 -0
  10. package/esm/default-graph.js +57 -0
  11. package/esm/empty.js +46 -0
  12. package/esm/factories/canonical-data-factory.js +204 -0
  13. package/esm/factories/extended-term-factory.js +55 -0
  14. package/esm/factories/factory-types.js +18 -0
  15. package/esm/factories/rdflib-data-factory.js +55 -0
  16. package/esm/fetcher.js +2180 -0
  17. package/esm/formula.js +987 -0
  18. package/esm/index.js +64 -0
  19. package/esm/jsonldparser.js +122 -0
  20. package/esm/jsonparser.js +60 -0
  21. package/esm/literal.js +236 -0
  22. package/esm/log.js +13 -0
  23. package/esm/n3parser.js +1854 -0
  24. package/esm/named-node.js +154 -0
  25. package/esm/namespace.js +17 -0
  26. package/esm/node-internal.js +151 -0
  27. package/esm/node.js +46 -0
  28. package/esm/parse.js +138 -0
  29. package/esm/patch-parser.js +110 -0
  30. package/esm/query-to-sparql.js +83 -0
  31. package/esm/query.js +620 -0
  32. package/esm/rdfaparser.js +1197 -0
  33. package/esm/rdfxmlparser.js +588 -0
  34. package/esm/serialize.js +95 -0
  35. package/esm/serializer.js +1162 -0
  36. package/esm/sparql-to-query.js +566 -0
  37. package/esm/statement.js +128 -0
  38. package/esm/store.js +1306 -0
  39. package/esm/tf-types.js +1 -0
  40. package/esm/types.js +25 -0
  41. package/esm/update-manager.js +1252 -0
  42. package/esm/updates-via.js +197 -0
  43. package/esm/uri.js +245 -0
  44. package/esm/utils/default-graph-uri.js +4 -0
  45. package/esm/utils/termValue.js +8 -0
  46. package/esm/utils/terms.js +72 -0
  47. package/esm/utils-js.js +348 -0
  48. package/esm/utils.js +103 -0
  49. package/esm/variable.js +101 -0
  50. package/esm/xsd-internal.js +10 -0
  51. package/esm/xsd.js +15 -0
  52. package/lib/blank-node.d.ts +44 -0
  53. package/lib/blank-node.js +0 -0
  54. package/lib/class-order.d.ts +7 -0
  55. package/lib/class-order.js +0 -0
  56. package/lib/collection.d.ts +65 -0
  57. package/lib/collection.js +0 -0
  58. package/lib/convert.d.ts +2 -0
  59. package/lib/convert.js +0 -0
  60. package/lib/default-graph.d.ts +13 -0
  61. package/lib/default-graph.js +0 -0
  62. package/lib/empty.d.ts +11 -0
  63. package/lib/empty.js +0 -0
  64. package/lib/factories/canonical-data-factory.d.ts +6 -0
  65. package/lib/factories/canonical-data-factory.js +0 -0
  66. package/lib/factories/extended-term-factory.d.ts +13 -0
  67. package/lib/factories/extended-term-factory.js +0 -0
  68. package/lib/factories/factory-types.d.ts +67 -0
  69. package/lib/factories/factory-types.js +0 -0
  70. package/lib/factories/rdflib-data-factory.d.ts +4 -0
  71. package/lib/factories/rdflib-data-factory.js +0 -0
  72. package/lib/fetcher.d.ts +443 -0
  73. package/lib/fetcher.js +3 -2
  74. package/lib/formula.d.ts +327 -0
  75. package/lib/formula.js +0 -0
  76. package/lib/index.d.ts +40 -0
  77. package/lib/index.js +0 -0
  78. package/lib/jsonldparser.d.ts +13 -0
  79. package/lib/jsonldparser.js +0 -0
  80. package/lib/jsonparser.d.ts +4 -0
  81. package/lib/jsonparser.js +0 -0
  82. package/lib/literal.d.ts +67 -0
  83. package/lib/literal.js +0 -0
  84. package/lib/log.d.ts +15 -0
  85. package/lib/log.js +0 -0
  86. package/lib/n3parser.d.ts +62 -0
  87. package/lib/n3parser.js +1334 -1289
  88. package/lib/named-node.d.ts +44 -0
  89. package/lib/named-node.js +0 -0
  90. package/lib/namespace.d.ts +7 -0
  91. package/lib/namespace.js +0 -0
  92. package/lib/node-internal.d.ts +63 -0
  93. package/lib/node-internal.js +0 -0
  94. package/lib/node.d.ts +2 -0
  95. package/lib/node.js +0 -0
  96. package/lib/parse.d.ts +16 -0
  97. package/lib/parse.js +0 -0
  98. package/lib/patch-parser.d.ts +3 -0
  99. package/lib/patch-parser.js +0 -0
  100. package/lib/query-to-sparql.d.ts +1 -0
  101. package/lib/query-to-sparql.js +0 -0
  102. package/lib/query.d.ts +27 -0
  103. package/lib/query.js +0 -0
  104. package/lib/rdfaparser.d.ts +78 -0
  105. package/lib/rdfaparser.js +0 -0
  106. package/lib/rdfxmlparser.d.ts +60 -0
  107. package/lib/rdfxmlparser.js +430 -413
  108. package/lib/serialize.d.ts +23 -0
  109. package/lib/serialize.js +1 -1
  110. package/lib/serializer.d.ts +54 -0
  111. package/lib/serializer.js +851 -824
  112. package/lib/sparql-to-query.d.ts +6 -0
  113. package/lib/sparql-to-query.js +0 -0
  114. package/lib/statement.d.ts +55 -0
  115. package/lib/statement.js +0 -0
  116. package/lib/store.d.ts +302 -0
  117. package/lib/store.js +0 -0
  118. package/lib/tf-types.d.ts +151 -0
  119. package/lib/tf-types.js +0 -0
  120. package/lib/types.d.ts +68 -0
  121. package/lib/types.js +0 -0
  122. package/lib/update-manager.d.ts +198 -0
  123. package/lib/update-manager.js +0 -0
  124. package/lib/updates-via.d.ts +26 -0
  125. package/lib/updates-via.js +0 -0
  126. package/lib/uri.d.ts +33 -0
  127. package/lib/uri.js +0 -0
  128. package/lib/utils/default-graph-uri.d.ts +3 -0
  129. package/lib/utils/default-graph-uri.js +0 -0
  130. package/lib/utils/termValue.d.ts +3 -0
  131. package/lib/utils/termValue.js +0 -0
  132. package/lib/utils/terms.d.ts +33 -0
  133. package/lib/utils/terms.js +0 -0
  134. package/lib/utils-js.d.ts +50 -0
  135. package/lib/utils-js.js +0 -0
  136. package/lib/utils.d.ts +20 -0
  137. package/lib/utils.js +0 -0
  138. package/lib/variable.d.ts +29 -0
  139. package/lib/variable.js +0 -0
  140. package/lib/xsd-internal.d.ts +11 -0
  141. package/lib/xsd-internal.js +0 -0
  142. package/lib/xsd.d.ts +19 -0
  143. package/lib/xsd.js +8 -14
  144. package/package.json +3 -3
  145. package/src/blank-node.ts +0 -0
  146. package/src/class-order.ts +0 -0
  147. package/src/collection.ts +0 -0
  148. package/src/convert.js +0 -0
  149. package/src/default-graph.ts +0 -0
  150. package/src/empty.ts +0 -0
  151. package/src/factories/canonical-data-factory.ts +0 -0
  152. package/src/factories/extended-term-factory.ts +0 -0
  153. package/src/factories/factory-types.ts +0 -0
  154. package/src/factories/rdflib-data-factory.ts +0 -0
  155. package/src/fetcher.ts +6 -3
  156. package/src/formula.ts +0 -0
  157. package/src/index.ts +0 -0
  158. package/src/jsonldparser.js +0 -0
  159. package/src/jsonparser.js +0 -0
  160. package/src/literal.ts +0 -0
  161. package/src/log.js +0 -0
  162. package/src/n3parser.js +1114 -1110
  163. package/src/named-node.ts +0 -0
  164. package/src/namespace.ts +0 -0
  165. package/src/node-internal.ts +0 -0
  166. package/src/node.ts +0 -0
  167. package/src/parse.ts +0 -0
  168. package/src/patch-parser.js +0 -0
  169. package/src/query-to-sparql.js +0 -0
  170. package/src/query.js +0 -0
  171. package/src/rdfaparser.js +0 -0
  172. package/src/rdfxmlparser.js +22 -21
  173. package/src/serialize.ts +3 -3
  174. package/src/serializer.js +74 -62
  175. package/src/sparql-to-query.js +0 -0
  176. package/src/statement.ts +0 -0
  177. package/src/store.ts +0 -0
  178. package/src/tf-types.ts +0 -0
  179. package/src/types.ts +0 -0
  180. package/src/update-manager.ts +0 -0
  181. package/src/updates-via.js +0 -0
  182. package/src/uri.ts +0 -0
  183. package/src/utils/default-graph-uri.ts +0 -0
  184. package/src/utils/termValue.ts +0 -0
  185. package/src/utils/terms.ts +0 -0
  186. package/src/utils-js.js +0 -0
  187. package/src/utils.ts +0 -0
  188. package/src/variable.ts +0 -0
  189. package/src/xsd-internal.js +0 -0
  190. package/src/xsd.js +16 -14
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
@@ -57,23 +57,31 @@
57
57
  */
58
58
  import * as uriUtil from './uri'
59
59
 
60
- /*
61
- * @constructor
62
- * @param {RDFStore} store An RDFStore object
63
- */
64
60
 
65
- export default function RDFParser(store) {
66
- var RDFParser = {}
61
+ export default class RDFParser {
62
+
63
+ /*
64
+ * @constructor
65
+ * @param {RDFStore} store An RDFStore object
66
+ */
67
+ constructor(store) {
68
+ /** Our triple store reference @private */
69
+
70
+ this.store = store /** Our identified blank nodes @private */
71
+ this.bnodes = {} /** A context for context-aware stores @private */
72
+ this.why = null /** Reification flag */
73
+ this.reify = false
74
+ }
67
75
 
68
76
  /** Standard namespaces that we know how to handle @final
69
77
  * @member RDFParser
70
78
  */
71
- RDFParser.ns = {'RDF': 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'RDFS': 'http://www.w3.org/2000/01/rdf-schema#'}
79
+ static ns = {'RDF': 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'RDFS': 'http://www.w3.org/2000/01/rdf-schema#'}
72
80
 
73
81
  /** DOM Level 2 node type magic numbers @final
74
82
  * @member RDFParser
75
83
  */
76
- RDFParser.nodeType = {'ELEMENT': 1, 'ATTRIBUTE': 2, 'TEXT': 3,
84
+ static nodeType = {'ELEMENT': 1, 'ATTRIBUTE': 2, 'TEXT': 3,
77
85
  'CDATA_SECTION': 4, 'ENTITY_REFERENCE': 5,
78
86
  'ENTITY': 6, 'PROCESSING_INSTRUCTION': 7,
79
87
  'COMMENT': 8, 'DOCUMENT': 9, 'DOCUMENT_TYPE': 10,
@@ -87,7 +95,7 @@ export default function RDFParser(store) {
87
95
  * @private
88
96
  */
89
97
 
90
- this.frameFactory = function (parser, parent, element) {
98
+ frameFactory(parser, parent, element) {
91
99
  return {'NODE': 1, 'ARC': 2, 'parent': parent, 'parser': parser, 'store': parser.store, 'element': element,
92
100
  'lastChild': 0, 'base': null, 'lang': null, 'node': null, 'nodeType': null, 'listIndex': 1, 'rdfid': null, 'datatype': null, 'collection': false, /** Terminate the frame and notify the store that we're done */
93
101
  'terminateFrame': function () {
@@ -167,7 +175,7 @@ export default function RDFParser(store) {
167
175
  }
168
176
 
169
177
  // from the OpenLayers source .. needed to get around IE problems.
170
- this.getAttributeNodeNS = function (node, uri, name) {
178
+ getAttributeNodeNS(node, uri, name) {
171
179
  var attributeNode = null
172
180
  if (node.getAttributeNodeNS) {
173
181
  attributeNode = node.getAttributeNodeNS(uri, name)
@@ -188,13 +196,6 @@ export default function RDFParser(store) {
188
196
  return attributeNode
189
197
  }
190
198
 
191
- /** Our triple store reference @private */
192
-
193
- this.store = store /** Our identified blank nodes @private */
194
- this.bnodes = {} /** A context for context-aware stores @private */
195
- this.why = null /** Reification flag */
196
- this.reify = false
197
-
198
199
  /**
199
200
  * Build our initial scope frame and parse the DOM into triples
200
201
  * @param {DOMTree} document The DOM to parse
@@ -202,7 +203,7 @@ export default function RDFParser(store) {
202
203
  * @param {Object} why The context to which this resource belongs
203
204
  */
204
205
 
205
- this.parse = function (document, base, why) {
206
+ parse(document, base, why) {
206
207
  var children = document.childNodes // clean up for the next run
207
208
  this.cleanParser() // figure out the root element
208
209
  var root
@@ -228,7 +229,7 @@ export default function RDFParser(store) {
228
229
  return true
229
230
  }
230
231
 
231
- this.parseDOM = function (frame) {
232
+ parseDOM(frame) {
232
233
  // a DOM utility function used in parsing
233
234
  var rdfid
234
235
  var elementURI = function (el) {
@@ -408,7 +409,7 @@ export default function RDFParser(store) {
408
409
  * Cleans out state from a previous parse run
409
410
  * @private
410
411
  */
411
- this.cleanParser = function () {
412
+ cleanParser() {
412
413
  this.bnodes = {}
413
414
  this.why = null
414
415
  }
@@ -417,7 +418,7 @@ export default function RDFParser(store) {
417
418
  * Builds scope frame
418
419
  * @private
419
420
  */
420
- this.buildFrame = function (parent, element) {
421
+ buildFrame(parent, element) {
421
422
  var frame = this.frameFactory(this, parent, element)
422
423
  if (parent) {
423
424
  frame.base = parent.base
package/src/serialize.ts CHANGED
@@ -30,7 +30,7 @@ export default function serialize (
30
30
  * Defaults to Turtle.
31
31
  */
32
32
  contentType?: string | ContentType,
33
- callback?: (err: Error | undefined | null, result?: string | null) => any,
33
+ callback?: (err: Error | undefined | null, result?: string) => any,
34
34
  options?: {
35
35
  /**
36
36
  * A string of letters, each of which set an options
@@ -42,7 +42,7 @@ export default function serialize (
42
42
  base = base || target.value
43
43
  const opts = options || {}
44
44
  contentType = contentType || TurtleContentType // text/n3 if complex?
45
- var documentString: string | null = null
45
+ var documentString: string | undefined = undefined
46
46
  try {
47
47
  var sz = Serializer(kb)
48
48
  if ((opts as any).flags) sz.setFlags((opts as any).flags)
@@ -92,7 +92,7 @@ export default function serialize (
92
92
  throw err // Don't hide problems from caller in sync mode
93
93
  }
94
94
 
95
- function executeCallback (err: Error | null | undefined, result: string | null | undefined): string | undefined {
95
+ function executeCallback (err: Error | null | undefined, result: string | undefined): string | undefined {
96
96
  if (callback) {
97
97
  callback(err, result)
98
98
  return
package/src/serializer.js CHANGED
@@ -13,8 +13,13 @@ import CanonicalDataFactory from './factories/canonical-data-factory'
13
13
  import { createXSD } from './xsd'
14
14
  import solidNs from 'solid-namespace'
15
15
 
16
- export default (function () {
17
- var __Serializer = function (store) {
16
+
17
+ export default function createSerializer(store) {
18
+ return new Serializer(store);
19
+ };
20
+
21
+ export class Serializer {
22
+ constructor(store) {
18
23
  this.flags = ''
19
24
  this.base = null
20
25
 
@@ -41,11 +46,17 @@ export default (function () {
41
46
  this.xsd = createXSD(this.rdfFactory)
42
47
  }
43
48
 
44
- __Serializer.prototype.setBase = function (base) { this.base = base; return this }
49
+ setBase(base) {
50
+ this.base = base;
51
+ return this
52
+ }
45
53
 
46
- __Serializer.prototype.setFlags = function (flags) { this.flags = flags || ''; return this }
54
+ setFlags(flags) {
55
+ this.flags = flags || '';
56
+ return this
57
+ }
47
58
 
48
- __Serializer.prototype.toStr = function (x) {
59
+ toStr(x) {
49
60
  var s = x.toNT()
50
61
  if (x.termType === 'Graph') {
51
62
  this.formulas[s] = x // remember as reverse does not work
@@ -53,7 +64,7 @@ export default (function () {
53
64
  return s
54
65
  }
55
66
 
56
- __Serializer.prototype.fromStr = function (s) {
67
+ fromStr(s) {
57
68
  if (s[0] === '{') {
58
69
  var x = this.formulas[s]
59
70
  if (!x) console.log('No formula object for ' + s)
@@ -61,12 +72,13 @@ export default (function () {
61
72
  }
62
73
  return this.store.fromNT(s)
63
74
  }
75
+
64
76
  /* Accumulate Namespaces
65
77
  **
66
78
  ** These are only hints. If two overlap, only one gets used
67
79
  ** There is therefore no guarantee in general.
68
80
  */
69
- __Serializer.prototype.suggestPrefix = function (prefix, uri) {
81
+ suggestPrefix(prefix, uri) {
70
82
  if (prefix.slice(0, 7) === 'default') return // Try to weed these out
71
83
  if (prefix.slice(0, 2) === 'ns') return // From others inferior algos
72
84
  if (!prefix || !uri) return // empty strings not suitable
@@ -76,34 +88,34 @@ export default (function () {
76
88
  }
77
89
 
78
90
  // Takes a namespace -> prefix map
79
- __Serializer.prototype.suggestNamespaces = function (namespaces) {
91
+ suggestNamespaces(namespaces) {
80
92
  for (var px in namespaces) {
81
93
  this.suggestPrefix(px, namespaces[px])
82
94
  }
83
95
  return this
84
96
  }
85
97
 
86
- __Serializer.prototype.checkIntegrity = function () {
98
+ checkIntegrity() {
87
99
  var p, ns
88
100
  for (p in this.namespaces) {
89
101
  if (this.prefixes[this.namespaces[p]] !== p) {
90
102
  throw new Error('Serializer integity error 1: ' + p + ', ' +
91
- this.namespaces[p] + ', ' + this.prefixes[this.namespaces[p]] + '!')
103
+ this.namespaces[p] + ', ' + this.prefixes[this.namespaces[p]] + '!')
92
104
  }
93
105
  }
94
106
  for (ns in this.prefixes) {
95
107
  if (this.namespaces[this.prefixes[ns]] !== ns) {
96
108
  throw new Error('Serializer integity error 2: ' + ns + ', ' +
97
- this.prefixs[ns] + ', ' + this.namespaces[this.prefixes[ns]] + '!')
109
+ this.prefixs[ns] + ', ' + this.namespaces[this.prefixes[ns]] + '!')
98
110
  }
99
111
  }
100
112
  }
101
113
 
102
114
  // Make up an unused prefix for a random namespace
103
- __Serializer.prototype.makeUpPrefix = function (uri) {
115
+ makeUpPrefix(uri) {
104
116
  var p = uri
105
117
  function canUseMethod (pp) {
106
- if (!__Serializer.prototype.validPrefix.test(pp)) return false // bad format
118
+ if (!this.validPrefix.test(pp)) return false // bad format
107
119
  if (pp === 'ns') return false // boring
108
120
  if (pp in this.namespaces) return false // already used
109
121
  this.prefixes[uri] = pp
@@ -131,13 +143,13 @@ export default (function () {
131
143
  if (canUse(p.slice(0, 4))) return p.slice(0, 4)
132
144
  if (canUse(p.slice(0, 1))) return p.slice(0, 1)
133
145
  if (canUse(p.slice(0, 5))) return p.slice(0, 5)
134
- if (!__Serializer.prototype.validPrefix.test(p)) {
146
+ if (!this.validPrefix.test(p)) {
135
147
  p = 'n' // Otherwise the loop below may never termimnate
136
148
  }
137
149
  for (var j = 0; ; j++) if (canUse(p.slice(0, 3) + j)) return p.slice(0, 3) + j
138
150
  }
139
151
 
140
- __Serializer.prototype.rootSubjects = function (sts) {
152
+ rootSubjects(sts) {
141
153
  var incoming = {}
142
154
  var subjects = {}
143
155
  var allBnodes = {}
@@ -194,15 +206,15 @@ export default (function () {
194
206
 
195
207
  // //////////////////////////////////////////////////////
196
208
 
197
- __Serializer.prototype.toN3 = function (f) {
209
+ toN3(f) {
198
210
  return this.statementsToN3(f.statements)
199
211
  }
200
212
 
201
- __Serializer.prototype._notQNameChars = '\t\r\n !"#$%&\'()*.,+/;<=>?@[\\]^`{|}~'
202
- __Serializer.prototype._notNameChars =
203
- (__Serializer.prototype._notQNameChars + ':')
213
+ _notQNameChars = '\t\r\n !"#$%&\'()*.,+/;<=>?@[\\]^`{|}~'
214
+ _notNameChars =
215
+ (this._notQNameChars + ':')
204
216
 
205
- __Serializer.prototype.explicitURI = function (uri) {
217
+ explicitURI(uri) {
206
218
  if (this.flags.indexOf('r') < 0 && this.base) {
207
219
  uri = Uri.refTo(this.base, uri)
208
220
  } else if (this.flags.indexOf('u') >= 0) { // Unicode encoding NTriples style
@@ -213,7 +225,7 @@ export default (function () {
213
225
  return '<' + uri + '>'
214
226
  }
215
227
 
216
- __Serializer.prototype.statementsToNTriples = function (sts) {
228
+ statementsToNTriples(sts) {
217
229
  var sorted = sts.slice()
218
230
  sorted.sort()
219
231
  var str = ''
@@ -250,7 +262,7 @@ export default (function () {
250
262
  return str
251
263
  }
252
264
 
253
- __Serializer.prototype.statementsToN3 = function (sts) {
265
+ statementsToN3(sts) {
254
266
  var indent = 4
255
267
  var width = 80
256
268
  var kb = this.store
@@ -400,9 +412,10 @@ export default (function () {
400
412
  results = results.concat([objects])
401
413
  return results
402
414
  }
415
+
403
416
  var propertyTree = propertyTreeMethod.bind(this)
404
417
 
405
- function objectTreeMethod (obj, stats, force) {
418
+ function objectTreeMethod(obj, stats, force) {
406
419
  if (obj.termType === 'BlankNode' &&
407
420
  (force || stats.rootsHash[obj.toNT()] === undefined)) {// if not a root
408
421
  if (stats.subjects[this.toStr(obj)]) {
@@ -413,9 +426,10 @@ export default (function () {
413
426
  }
414
427
  return termToN3(obj, stats)
415
428
  }
429
+
416
430
  var objectTree = objectTreeMethod.bind(this)
417
431
 
418
- function termToN3Method (expr, stats) { //
432
+ function termToN3Method(expr, stats) { //
419
433
  var i, res
420
434
  switch (expr.termType) {
421
435
  case 'Graph':
@@ -435,7 +449,7 @@ export default (function () {
435
449
  return this.atomicTermToN3(expr)
436
450
  }
437
451
  }
438
- __Serializer.prototype.termToN3 = termToN3
452
+ Serializer.prototype.termToN3 = termToN3
439
453
  var termToN3 = termToN3Method.bind(this)
440
454
 
441
455
  function prefixDirectivesMethod () {
@@ -459,7 +473,7 @@ export default (function () {
459
473
  // //////////////////////////////////////////// Atomic Terms
460
474
 
461
475
  // Deal with term level things and nesting with no bnode structure
462
- __Serializer.prototype.atomicTermToN3 = function atomicTermToN3 (expr, stats) {
476
+ atomicTermToN3 (expr, stats) {
463
477
  switch (expr.termType) {
464
478
  case 'BlankNode':
465
479
  case 'Variable':
@@ -508,11 +522,11 @@ export default (function () {
508
522
 
509
523
  // stringToN3: String escaping for N3
510
524
 
511
- __Serializer.prototype.validPrefix = new RegExp(/^[a-zA-Z][a-zA-Z0-9]*$/)
525
+ validPrefix = new RegExp(/^[a-zA-Z][a-zA-Z0-9]*$/)
512
526
 
513
- __Serializer.prototype.forbidden1 = new RegExp(/[\\"\b\f\r\v\t\n\u0080-\uffff]/gm)
514
- __Serializer.prototype.forbidden3 = new RegExp(/[\\"\b\f\r\v\u0080-\uffff]/gm)
515
- __Serializer.prototype.stringToN3 = function stringToN3 (str, flags) {
527
+ forbidden1 = new RegExp(/[\\"\b\f\r\v\t\n\u0080-\uffff]/gm)
528
+ forbidden3 = new RegExp(/[\\"\b\f\r\v\u0080-\uffff]/gm)
529
+ stringToN3(str, flags) {
516
530
  if (!flags) flags = 'e'
517
531
  var res = ''
518
532
  var i, j, k
@@ -523,10 +537,10 @@ export default (function () {
523
537
  flags.indexOf('n') < 0 && // Force single line
524
538
  (str.indexOf('\n') > 0 || str.indexOf('"') > 0)) {
525
539
  delim = '"""'
526
- forbidden = __Serializer.prototype.forbidden3
540
+ forbidden = this.forbidden3
527
541
  } else {
528
542
  delim = '"'
529
- forbidden = __Serializer.prototype.forbidden1
543
+ forbidden = this.forbidden1
530
544
  }
531
545
  for (i = 0; i < str.length;) {
532
546
  forbidden.lastIndex = 0
@@ -556,7 +570,7 @@ export default (function () {
556
570
  }
557
571
  // A single symbol, either in <> or namespace notation
558
572
 
559
- __Serializer.prototype.symbolToN3 = function symbolToN3 (x) { // c.f. symbolString() in notation3.py
573
+ symbolToN3 (x) { // c.f. symbolString() in notation3.py
560
574
  var uri = x.uri
561
575
  var j = uri.indexOf('#')
562
576
  if (j < 0 && this.flags.indexOf('/') < 0) {
@@ -567,7 +581,7 @@ export default (function () {
567
581
  (uri.indexOf('http') === 0 || uri.indexOf('ws') === 0 || uri.indexOf('file') === 0)) {
568
582
  var canSplit = true
569
583
  for (var k = j + 1; k < uri.length; k++) {
570
- if (__Serializer.prototype._notNameChars.indexOf(uri[k]) >= 0) {
584
+ if (this._notNameChars.indexOf(uri[k]) >= 0) {
571
585
  canSplit = false
572
586
  break
573
587
  }
@@ -604,33 +618,12 @@ export default (function () {
604
618
  }
605
619
  return this.explicitURI(uri)
606
620
  }
607
- // String escaping utilities
608
-
609
- function hexify (str) { // also used in parser
610
- return encodeURI(str)
611
- }
612
-
613
- function backslashUify (str) {
614
- var res = ''
615
- var k
616
- for (var i = 0; i < str.length; i++) {
617
- k = str.charCodeAt(i)
618
- if (k > 65535) {
619
- res += '\\U' + ('00000000' + k.toString(16)).slice(-8) // convert to upper?
620
- } else if (k > 126) {
621
- res += '\\u' + ('0000' + k.toString(16)).slice(-4)
622
- } else {
623
- res += str[i]
624
- }
625
- }
626
- return res
627
- }
628
621
 
629
622
  // /////////////////////////// Quad store serialization
630
623
 
631
624
  // @para. write - a function taking a single string to be output
632
625
  //
633
- __Serializer.prototype.writeStore = function (write) {
626
+ writeStore(write) {
634
627
  var kb = this.store
635
628
  var fetcher = kb.fetcher
636
629
  var session = fetcher && fetcher.appNode
@@ -671,7 +664,7 @@ export default (function () {
671
664
 
672
665
  // ////////////////////////////////////////////// XML serialization
673
666
 
674
- __Serializer.prototype.statementsToXML = function (sts) {
667
+ statementsToXML(sts) {
675
668
  var indent = 4
676
669
  var width = 80
677
670
 
@@ -935,7 +928,7 @@ export default (function () {
935
928
  if (j < 0) throw new Error('Cannot make qname out of <' + uri + '>')
936
929
 
937
930
  for (var k = j + 1; k < uri.length; k++) {
938
- if (__Serializer.prototype._notNameChars.indexOf(uri[k]) >= 0) {
931
+ if (this._notNameChars.indexOf(uri[k]) >= 0) {
939
932
  throw new Error('Invalid character "' + uri[k] + '" cannot be in XML qname for URI: ' + uri)
940
933
  }
941
934
  }
@@ -970,7 +963,26 @@ export default (function () {
970
963
  var tree2 = [str, tree, '</rdf:RDF>'] // @@ namespace declrations
971
964
  return XMLtreeToString(tree2, -1)
972
965
  } // End @@ body
973
-
974
- var Serializer = function (store) { return new __Serializer(store) }
975
- return Serializer
976
- }())
966
+ }
967
+
968
+ // String escaping utilities
969
+
970
+ function hexify (str) { // also used in parser
971
+ return encodeURI(str)
972
+ }
973
+
974
+ function backslashUify (str) {
975
+ var res = ''
976
+ var k
977
+ for (var i = 0; i < str.length; i++) {
978
+ k = str.charCodeAt(i)
979
+ if (k > 65535) {
980
+ res += '\\U' + ('00000000' + k.toString(16)).slice(-8) // convert to upper?
981
+ } else if (k > 126) {
982
+ res += '\\u' + ('0000' + k.toString(16)).slice(-4)
983
+ } else {
984
+ res += str[i]
985
+ }
986
+ }
987
+ return res
988
+ }
File without changes
package/src/statement.ts CHANGED
File without changes
package/src/store.ts CHANGED
File without changes
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
@@ -1,19 +1,21 @@
1
- import CanonicalDataFactory from './factories/canonical-data-factory'
1
+ import CanonicalDataFactory from "./factories/canonical-data-factory";
2
2
 
3
3
  export function createXSD(localFactory = CanonicalDataFactory) {
4
- class XSD {}
5
-
6
- XSD.boolean = localFactory.namedNode('http://www.w3.org/2001/XMLSchema#boolean')
7
- XSD.dateTime = localFactory.namedNode('http://www.w3.org/2001/XMLSchema#dateTime')
8
- XSD.decimal = localFactory.namedNode('http://www.w3.org/2001/XMLSchema#decimal')
9
- XSD.double = localFactory.namedNode('http://www.w3.org/2001/XMLSchema#double')
10
- XSD.integer = localFactory.namedNode('http://www.w3.org/2001/XMLSchema#integer')
11
- XSD.langString = localFactory.namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#langString')
12
- XSD.string = localFactory.namedNode('http://www.w3.org/2001/XMLSchema#string')
13
-
14
- return XSD
4
+ return {
5
+ boolean: localFactory.namedNode("http://www.w3.org/2001/XMLSchema#boolean"),
6
+ dateTime: localFactory.namedNode(
7
+ "http://www.w3.org/2001/XMLSchema#dateTime"
8
+ ),
9
+ decimal: localFactory.namedNode("http://www.w3.org/2001/XMLSchema#decimal"),
10
+ double: localFactory.namedNode("http://www.w3.org/2001/XMLSchema#double"),
11
+ integer: localFactory.namedNode("http://www.w3.org/2001/XMLSchema#integer"),
12
+ langString: localFactory.namedNode(
13
+ "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"
14
+ ),
15
+ string: localFactory.namedNode("http://www.w3.org/2001/XMLSchema#string"),
16
+ };
15
17
  }
16
18
 
17
- const defaultXSD = createXSD(CanonicalDataFactory)
19
+ const defaultXSD = createXSD(CanonicalDataFactory);
18
20
 
19
- export default defaultXSD
21
+ export default defaultXSD;