@rdfjs/parser-jsonld
Advanced tools
Comparing version 1.3.0 to 1.3.1
@@ -26,11 +26,14 @@ const rdf = require('@rdfjs/data-model') | ||
return quad => { | ||
const parts = [ | ||
cleanup(quad.subject), | ||
cleanup(quad.predicate), | ||
cleanup(quad.object), | ||
cleanup(quad.graph) | ||
] | ||
const subject = cleanup(quad.subject) | ||
const predicate = cleanup(quad.predicate) | ||
const object = cleanup(quad.object) | ||
const graph = cleanup(quad.graph) | ||
if (parts[0] || parts[1] || parts[2] || parts[3]) { | ||
return factory.quad(...parts) | ||
if (subject || predicate || object || graph) { | ||
return factory.quad( | ||
subject || quad.subject, | ||
predicate || quad.predicate, | ||
object || quad.object, | ||
graph || quad.graph | ||
) | ||
} | ||
@@ -37,0 +40,0 @@ |
{ | ||
"name": "@rdfjs/parser-jsonld", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "JSON-LD parser that implements the RDFJS Sink interface using jsonld.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# @rdfjs/parser-jsonld | ||
[![Build Status](https://travis-ci.org/rdfjs/parser-jsonld.svg?branch=master)](https://travis-ci.org/rdfjs/parser-jsonld) | ||
[![build status](https://img.shields.io/github/workflow/status/rdfjs-base/parser-jsonld/Test)](https://github.com/rdfjs-base/parser-jsonld/actions/workflows/test.yaml) | ||
[![npm version](https://img.shields.io/npm/v/@rdfjs/parser-jsonld.svg)](https://www.npmjs.com/package/@rdfjs/parser-jsonld) | ||
JSON-LD parser that implements the [RDFJS Sink interface](http://rdf.js.org/) using [jsonld.js](https://github.com/digitalbazaar/jsonld.js). | ||
JSON-LD parser that implements the [RDF/JS Sink interface](http://rdf.js.org/) using [jsonld-streaming-parser](https://github.com/rubensworks/jsonld-streaming-parser.js). | ||
## Usage | ||
Use the following command to add the package as a dependency to your project: | ||
```bash | ||
npm install @rdfjs/data-model --save | ||
``` | ||
The package exports the parser as a class, so an instance must be created before it can be used. | ||
The `.import` method, as defined in the [RDFJS specification](http://rdf.js.org/#sink-interface), must be called to do the actual parsing. | ||
The `.import` method, as defined in the [RDF/JS specification](http://rdf.js.org/#sink-interface), must be called to do the actual parsing. | ||
It expects a JSON string stream or a stream which emits a single object. | ||
@@ -18,5 +22,5 @@ The method will return a stream which emits the parsed quads. | ||
- `baseIRI`: Allows passing the base IRI manually to the `jsonld.js` library. | ||
- `context`: Allows passing a JSON-LD context manually to the `jsonld.js` library. | ||
- `factory`: Use an alternative RDFJS data factory. | ||
- `baseIRI`: Allows passing the base IRI manually to the `jsonld-streaming-parser` library. | ||
- `context`: Allows passing a JSON-LD context manually to the `jsonld-streaming-parser` library. | ||
- `factory`: Use an alternative RDF/JS data factory. | ||
By default the [reference implementation](https://github.com/rdfjs-base/data-model/) us used. | ||
@@ -23,0 +27,0 @@ |
@@ -52,2 +52,6 @@ const { rejects, strictEqual } = require('assert') | ||
strictEqual(output[0].subject.value, '') | ||
strictEqual(output[0].predicate.termType, 'NamedNode') | ||
strictEqual(output[0].predicate.value, 'http://example.org/predicate') | ||
strictEqual(output[0].object.termType, 'Literal') | ||
strictEqual(output[0].object.value, 'object') | ||
}) | ||
@@ -54,0 +58,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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
17423
427
61
0