rdflib 2.2.37-c049d599 → 2.2.37-dbccd446

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.
@@ -56,7 +56,9 @@ function listToCollection(kb, obj) {
56
56
  export default function jsonldParser(str, kb, base, callback) {
57
57
  const baseString = base && Object.prototype.hasOwnProperty.call(base, 'termType') ? base.value : base;
58
58
  return import('jsonld').then(jsonld => {
59
- return jsonld.flatten(JSON.parse(str), null, {
59
+ // ⚠ Unit tests also work without accessing `jsonld.default` explicitly, but real browser usage will fail with
60
+ // just calling `jsonld.flatten`, so please do not remove `default`
61
+ return jsonld.default.flatten(JSON.parse(str), null, {
60
62
  base: baseString
61
63
  });
62
64
  }).then(flattened => flattened.reduce((store, flatResource) => {
@@ -63,7 +63,9 @@ function listToCollection(kb, obj) {
63
63
  function jsonldParser(str, kb, base, callback) {
64
64
  const baseString = base && Object.prototype.hasOwnProperty.call(base, 'termType') ? base.value : base;
65
65
  return Promise.resolve().then(() => _interopRequireWildcard(require('jsonld'))).then(jsonld => {
66
- return jsonld.flatten(JSON.parse(str), null, {
66
+ // ⚠ Unit tests also work without accessing `jsonld.default` explicitly, but real browser usage will fail with
67
+ // just calling `jsonld.flatten`, so please do not remove `default`
68
+ return jsonld.default.flatten(JSON.parse(str), null, {
67
69
  base: baseString
68
70
  });
69
71
  }).then(flattened => flattened.reduce((store, flatResource) => {
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.37-c049d599",
4
+ "version": "2.2.37-dbccd446",
5
5
  "private": false,
6
6
  "browserslist": [
7
7
  "> 0.5%"
@@ -1,4 +1,4 @@
1
- import { arrayToStatements } from './utils'
1
+ import {arrayToStatements} from './utils'
2
2
 
3
3
  /**
4
4
  * Parses json-ld formatted JS objects to a rdf Term.
@@ -6,7 +6,7 @@ import { arrayToStatements } from './utils'
6
6
  * @param obj - The json-ld object to process.
7
7
  * @return {Literal|NamedNode|BlankNode|Collection}
8
8
  */
9
- export function jsonldObjectToTerm (kb, obj) {
9
+ export function jsonldObjectToTerm(kb, obj) {
10
10
  if (typeof obj === 'string') {
11
11
  return kb.rdfFactory.literal(obj)
12
12
  }
@@ -41,7 +41,7 @@ export function jsonldObjectToTerm (kb, obj) {
41
41
  /**
42
42
  * Adds the statements in a json-ld list object to {kb}.
43
43
  */
44
- function listToStatements (kb, obj) {
44
+ function listToStatements(kb, obj) {
45
45
  const listId = obj['@id'] ? nodeType(kb, obj) : kb.rdfFactory.blankNode()
46
46
 
47
47
  const items = obj['@list'].map((listItem => jsonldObjectToTerm(kb, listItem)))
@@ -51,7 +51,7 @@ function listToStatements (kb, obj) {
51
51
  return listId
52
52
  }
53
53
 
54
- function listToCollection (kb, obj) {
54
+ function listToCollection(kb, obj) {
55
55
  if (!Array.isArray(obj)) {
56
56
  throw new TypeError("Object must be an array")
57
57
  }
@@ -63,13 +63,15 @@ function listToCollection (kb, obj) {
63
63
  *
64
64
  * Ensure that {kb.rdfFactory} is a DataFactory.
65
65
  */
66
- export default function jsonldParser (str, kb, base, callback) {
67
- const baseString = base && Object.prototype.hasOwnProperty.call(base, 'termType')
68
- ? base.value
69
- : base
66
+ export default function jsonldParser(str, kb, base, callback) {
67
+ const baseString = base && Object.prototype.hasOwnProperty.call(base, 'termType') ? base.value : base
70
68
 
71
69
  return import('jsonld')
72
- .then(jsonld => { return jsonld.flatten(JSON.parse(str), null, { base: baseString }) })
70
+ .then(jsonld => {
71
+ // ⚠ Unit tests also work without accessing `jsonld.default` explicitly, but real browser usage will fail with
72
+ // just calling `jsonld.flatten`, so please do not remove `default`
73
+ return jsonld.default.flatten(JSON.parse(str), null, {base: baseString})
74
+ })
73
75
  .then((flattened) => flattened.reduce((store, flatResource) => {
74
76
 
75
77
  kb = processResource(kb, base, flatResource)
@@ -80,7 +82,7 @@ export default function jsonldParser (str, kb, base, callback) {
80
82
  .catch(callback)
81
83
  }
82
84
 
83
- function nodeType (kb, obj) {
85
+ function nodeType(kb, obj) {
84
86
  if (obj['@id'].startsWith('_:')) {
85
87
  // This object is a Blank Node. Pass the id without the `_:` prefix
86
88
  return kb.rdfFactory.blankNode(obj['@id'].substring(2));
@@ -106,7 +108,7 @@ function processResource(kb, base, flatResource) {
106
108
  const nestedFlatResources = flatResource[property]
107
109
 
108
110
  // recursively process all flat resources in the array, but with the graphId as base.
109
- for (let i = 0; i < nestedFlatResources.length; i++ ) {
111
+ for (let i = 0; i < nestedFlatResources.length; i++) {
110
112
  kb = processResource(kb, graphId, nestedFlatResources[i])
111
113
  }
112
114
  }