Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rdfjs/parser-jsonld

Package Overview
Dependencies
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rdfjs/parser-jsonld - npm Package Compare versions

Comparing version 1.3.0 to 1.3.1

.github/workflows/test.yaml

19

lib/ParserStream.js

@@ -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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc