rdf-object
Advanced tools
Comparing version 1.7.1 to 1.8.0
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
<a name="v1.8.0"></a> | ||
## [v1.8.0](https://github.com/rubensworks/rdf-object.js/compare/v1.7.1...v1.8.0) - 2020-12-03 | ||
### Added | ||
* [Also handle RDF lists in Resource#toQuads](https://github.com/rubensworks/rdf-object.js/commit/70dd1bdce52e6a7a653f0b4c4d3b55c5b1008a7f) | ||
<a name="v1.7.1"></a> | ||
@@ -5,0 +11,0 @@ ## [v1.7.1](https://github.com/rubensworks/rdf-object.js/compare/v1.7.0...v1.7.1) - 2020-11-25 |
@@ -7,2 +7,3 @@ "use strict"; | ||
const rdf_string_1 = require("rdf-string"); | ||
const RdfListMaterializer_1 = require("./RdfListMaterializer"); | ||
const ShortcutPropertyHandler_1 = require("./ShortcutPropertyHandler"); | ||
@@ -103,2 +104,3 @@ const SingularPropertyHandler_1 = require("./SingularPropertyHandler"); | ||
toQuads(quads = [], dataFactory = new rdf_data_factory_1.DataFactory()) { | ||
// Handle predicates | ||
for (const [property, resources] of Object.entries(this.propertiesUri)) { | ||
@@ -108,3 +110,3 @@ const subject = this.term; | ||
for (const resource of resources) { | ||
const object = resource.term; | ||
const object = resource.list && resource.list.length === 0 ? RdfListMaterializer_1.RdfListMaterializer.RDF_NIL : resource.term; | ||
quads.push(dataFactory.quad(subject, predicate, object)); | ||
@@ -114,2 +116,19 @@ resource.toQuads(quads, dataFactory); | ||
} | ||
// Handle RDF lists | ||
if (this.list) { | ||
let chain = this.term; | ||
let chainPrev; | ||
for (const element of this.list) { | ||
if (chainPrev) { | ||
quads.push(dataFactory.quad(chainPrev, RdfListMaterializer_1.RdfListMaterializer.RDF_REST, chain)); | ||
} | ||
quads.push(dataFactory.quad(chain, RdfListMaterializer_1.RdfListMaterializer.RDF_FIRST, element.term)); | ||
element.toQuads(quads, dataFactory); | ||
chainPrev = chain; | ||
chain = dataFactory.blankNode(); | ||
} | ||
if (chainPrev) { | ||
quads.push(dataFactory.quad(chainPrev, RdfListMaterializer_1.RdfListMaterializer.RDF_REST, RdfListMaterializer_1.RdfListMaterializer.RDF_NIL)); | ||
} | ||
} | ||
return quads; | ||
@@ -116,0 +135,0 @@ } |
{ | ||
"name": "rdf-object", | ||
"version": "1.7.1", | ||
"version": "1.8.0", | ||
"description": "Loads RDF as JSON objects", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -46,3 +46,3 @@ # RDF Object | ||
```javascript | ||
import {namedNode, literal, triple} as DataFactory from "@rdfjs/data-model"; // External library | ||
import {namedNode, literal, triple} from "@rdfjs/data-model"; // External library | ||
import {RdfObjectLoader} from "rdf-object"; | ||
@@ -49,0 +49,0 @@ ``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44020
651