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

rdf-ext

Package Overview
Dependencies
Maintainers
3
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rdf-ext - npm Package Compare versions

Comparing version 1.3.1 to 1.3.2

.github/workflows/ci.yaml

2

index.js

@@ -5,3 +5,3 @@ const streams = require('./lib/streams')

let DataFactory = require('./lib/DataFactory')
const DataFactory = require('./lib/DataFactory')

@@ -8,0 +8,0 @@ DataFactory.asEvent = streams.asEvent

@@ -1,3 +0,1 @@

'use strict'
const BlankNode = require('./BlankNode')

@@ -51,3 +49,3 @@ const DataFactory = require('@rdfjs/data-model')

static graph (quads) {
let dataset = new DataFactoryExt.defaults.Dataset()
const dataset = new DataFactoryExt.defaults.Dataset()

@@ -64,3 +62,3 @@ if (quads) {

static dataset (quads, graph) {
let dataset = new DataFactoryExt.defaults.Dataset()
const dataset = new DataFactoryExt.defaults.Dataset()

@@ -67,0 +65,0 @@ if (quads) {

@@ -0,6 +1,11 @@

const Dataset = require('@rdfjs/dataset/DatasetCore.js')
const { quadToNTriples } = require('@rdfjs/to-ntriples')
const normalize = require('rdf-normalize')
const quadToNTriples = require('@rdfjs/to-ntriples').quadToNTriples
const Dataset = require('rdf-dataset-indexed/dataset')
const { finished, Readable } = require('readable-stream')
const Quad = require('./Quad')
function createDataset (obj, quads) {
return new obj.constructor(quads)
}
class DatasetExt extends Dataset {

@@ -11,2 +16,101 @@ constructor (quads) {

get length () {
return this.size
}
addAll (quads) {
for (const quad of quads) {
this.add(quad)
}
return this
}
clone () {
return createDataset(this, this)
}
difference (other) {
return this.filter(quad => !other.has(quad))
}
every (callback) {
return Array.from(this).every(quad => callback(quad, this))
}
filter (callback) {
return createDataset(this, Array.from(this).filter(quad => callback(quad, this)))
}
forEach (callback) {
Array.from(this).forEach(quad => callback(quad, this))
}
import (stream) {
stream.on('data', quad => this.add(quad))
return new Promise((resolve, reject) => {
finished(stream, err => {
if (err) {
reject(err)
} else {
resolve(this)
}
})
})
}
includes (quad) {
return this.has(quad)
}
intersection (other) {
return this.filter(quad => other.includes(quad))
}
map (callback) {
return createDataset(this, Array.from(this).map(quad => callback(quad, this)))
}
merge (other) {
return (this.clone()).addAll(other)
}
remove (quad) {
return this.delete(quad)
}
removeMatches (subject, predicate, object, graph) {
const quads = this.match(subject, predicate, object, graph)
for (const quad of quads) {
this.delete(quad)
}
return this
}
some (callback) {
return Array.from(this).some(quad => callback(quad, this))
}
toArray () {
return Array.from(this)
}
toStream () {
const stream = new Readable({
objectMode: true,
read: () => {
for (const quad of this) {
stream.push(quad)
}
stream.push(null)
}
})
return stream
}
equals (other) {

@@ -13,0 +117,0 @@ return this.toCanonical() === other.toCanonical()

@@ -19,3 +19,3 @@ class Parsers {

list () {
let propertyBlackList = ['find', 'list', 'read']
const propertyBlackList = ['find', 'list', 'read']

@@ -28,3 +28,3 @@ return Object.keys(this).filter((property) => {

import (mediaType, input, options) {
let parser = this.find(mediaType)
const parser = this.find(mediaType)

@@ -31,0 +31,0 @@ if (!parser) {

@@ -18,3 +18,3 @@ const streams = require('./streams')

addAll (prefixes) {
for (let prefix in prefixes) {
for (const prefix in prefixes) {
const namespace = prefixes[prefix]

@@ -53,3 +53,3 @@

for (let prefix in this.map) {
for (const prefix in this.map) {
const namespace = this.map[prefix].value

@@ -56,0 +56,0 @@

@@ -19,3 +19,3 @@ class Serializers {

import (mediaType, input, options) {
let serializer = this.find(mediaType)
const serializer = this.find(mediaType)

@@ -30,3 +30,3 @@ if (!serializer) {

list () {
let propertyBlackList = ['find', 'import', 'list']
const propertyBlackList = ['find', 'import', 'list']

@@ -33,0 +33,0 @@ return Object.keys(this).filter((property) => {

const Event = require('events').EventEmitter
function asEvent (p) {
let event = new Event()
const event = new Event()

@@ -6,0 +6,0 @@ Promise.resolve().then(() => {

{
"name": "rdf-ext",
"version": "1.3.1",
"version": "1.3.2",
"description": "Extended Linked Data module",
"main": "index.js",
"scripts": {
"test": "standard && mocha"
"test": "standard && c8 --reporter=lcov --reporter=text mocha"
},

@@ -26,10 +26,13 @@ "repository": {

"@rdfjs/data-model": "^1.1.0",
"@rdfjs/dataset": "^1.1.1",
"@rdfjs/to-ntriples": "^1.0.1",
"rdf-dataset-indexed": "^0.4.0",
"rdf-normalize": "^1.0.0"
"rdf-normalize": "^1.0.0",
"readable-stream": "^3.6.0"
},
"devDependencies": {
"mocha": "^5.2.0",
"standard": "^12.0.1"
"c8": "^7.7.2",
"get-stream": "^6.0.1",
"mocha": "^8.4.0",
"standard": "^16.0.3"
}
}

@@ -1,7 +0,6 @@

/* global describe, it */
const assert = require('assert')
const standard = require('@rdfjs/data-model/test')
const { describe, it } = require('mocha')
const rdf = require('../lib/DataFactory')
const DatasetExt = require('../lib/Dataset')
const standard = require('@rdfjs/data-model/test')

@@ -193,8 +192,8 @@ describe('DataFactory', () => {

const expected = {
'value': string,
'termType': 'Literal',
'language': lang,
'datatype': {
'termType': 'NamedNode',
'value': 'http://www.w3.org/1999/02/22-rdf-syntax-ns#langString'
value: string,
termType: 'Literal',
language: lang,
datatype: {
termType: 'NamedNode',
value: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#langString'
}

@@ -302,7 +301,7 @@ }

it('should return a canonical representation', () => {
var subject = rdf.namedNode('http://example.org/subject')
var predicate = rdf.namedNode('http://example.org/predicate')
var object = rdf.namedNode('http://example.org/object')
var graph = rdf.namedNode('http://example.org/graph')
var quad = rdf.quad(subject, predicate, object, graph)
const subject = rdf.namedNode('http://example.org/subject')
const predicate = rdf.namedNode('http://example.org/predicate')
const object = rdf.namedNode('http://example.org/object')
const graph = rdf.namedNode('http://example.org/graph')
const quad = rdf.quad(subject, predicate, object, graph)

@@ -313,6 +312,6 @@ assert.strictEqual(quad.toCanonical(), '<http://example.org/subject> <http://example.org/predicate> <http://example.org/object> <http://example.org/graph> .')

it('should skip the graph if it\'s a DefaultGraph', () => {
var subject = rdf.namedNode('http://example.org/subject')
var predicate = rdf.namedNode('http://example.org/predicate')
var object = rdf.namedNode('http://example.org/object')
var quad = rdf.quad(subject, predicate, object)
const subject = rdf.namedNode('http://example.org/subject')
const predicate = rdf.namedNode('http://example.org/predicate')
const object = rdf.namedNode('http://example.org/object')
const quad = rdf.quad(subject, predicate, object)

@@ -325,7 +324,7 @@ assert.strictEqual(quad.toCanonical(), '<http://example.org/subject> <http://example.org/predicate> <http://example.org/object> .')

it('should return a canonical representation', () => {
var subject = rdf.namedNode('http://example.org/subject')
var predicate = rdf.namedNode('http://example.org/predicate')
var object = rdf.namedNode('http://example.org/object')
var graph = rdf.namedNode('http://example.org/graph')
var quad = rdf.quad(subject, predicate, object, graph)
const subject = rdf.namedNode('http://example.org/subject')
const predicate = rdf.namedNode('http://example.org/predicate')
const object = rdf.namedNode('http://example.org/object')
const graph = rdf.namedNode('http://example.org/graph')
const quad = rdf.quad(subject, predicate, object, graph)

@@ -336,6 +335,6 @@ assert.strictEqual(quad.toString(), '<http://example.org/subject> <http://example.org/predicate> <http://example.org/object> <http://example.org/graph> .')

it('should skip the graph if it\'s a DefaultGraph', () => {
var subject = rdf.namedNode('http://example.org/subject')
var predicate = rdf.namedNode('http://example.org/predicate')
var object = rdf.namedNode('http://example.org/object')
var quad = rdf.quad(subject, predicate, object)
const subject = rdf.namedNode('http://example.org/subject')
const predicate = rdf.namedNode('http://example.org/predicate')
const object = rdf.namedNode('http://example.org/object')
const quad = rdf.quad(subject, predicate, object)

@@ -348,7 +347,7 @@ assert.strictEqual(quad.toString(), '<http://example.org/subject> <http://example.org/predicate> <http://example.org/object> .')

it('should be a method', () => {
var subject = rdf.namedNode('http://example.org/subject')
var predicate = rdf.namedNode('http://example.org/predicate')
var object = rdf.namedNode('http://example.org/object')
var graph = rdf.namedNode('http://example.org/graph')
var quad = rdf.quad(subject, predicate, object, graph)
const subject = rdf.namedNode('http://example.org/subject')
const predicate = rdf.namedNode('http://example.org/predicate')
const object = rdf.namedNode('http://example.org/object')
const graph = rdf.namedNode('http://example.org/graph')
const quad = rdf.quad(subject, predicate, object, graph)

@@ -358,7 +357,7 @@ assert.strictEqual(typeof quad.toJSON, 'function')

it('should return the JSON', () => {
var subject = rdf.namedNode('http://example.org/subject')
var predicate = rdf.namedNode('http://example.org/predicate')
var object = rdf.namedNode('http://example.org/object')
var graph = rdf.namedNode('http://example.org/graph')
var quad = rdf.quad(subject, predicate, object, graph)
const subject = rdf.namedNode('http://example.org/subject')
const predicate = rdf.namedNode('http://example.org/predicate')
const object = rdf.namedNode('http://example.org/object')
const graph = rdf.namedNode('http://example.org/graph')
const quad = rdf.quad(subject, predicate, object, graph)

@@ -381,3 +380,3 @@ assert.deepStrictEqual(quad.toJSON(), {

it('should return an empty Dataset', () => {
let dataset = rdf.graph()
const dataset = rdf.graph()

@@ -388,3 +387,3 @@ assert.strictEqual(dataset.length, 0)

it('should initialize the Dataset with the given triples', () => {
let triple1 = rdf.quad(
const triple1 = rdf.quad(
rdf.namedNode('http://example.org/subject'),

@@ -394,3 +393,3 @@ rdf.namedNode('http://example.org/predicate'),

let triple2 = rdf.quad(
const triple2 = rdf.quad(
rdf.namedNode('http://example.org/subject'),

@@ -400,3 +399,3 @@ rdf.namedNode('http://example.org/predicate'),

let dataset = rdf.graph([triple1, triple2])
const dataset = rdf.graph([triple1, triple2])

@@ -424,21 +423,4 @@ assert.strictEqual(dataset.length, 2)

describe('implements the extended Dataset interface', () => {
it('should implement .equals', () => {
const dataset = rdf.dataset()
assert.strictEqual(typeof dataset.equals, 'function')
})
it('should implement .toCanonical', () => {
const dataset = rdf.dataset()
assert.strictEqual(typeof dataset.toCanonical, 'function')
})
it('should implement .toString', () => {
const dataset = rdf.dataset()
assert.strictEqual(typeof dataset.toString, 'function')
})
})
it('should initialize the Dataset with the given quads', () => {
let quad1 = rdf.quad(
const quad1 = rdf.quad(
rdf.namedNode('http://example.org/subject'),

@@ -449,3 +431,3 @@ rdf.namedNode('http://example.org/predicate'),

let quad2 = rdf.quad(
const quad2 = rdf.quad(
rdf.namedNode('http://example.org/subject'),

@@ -456,3 +438,3 @@ rdf.namedNode('http://example.org/predicate'),

let dataset = rdf.dataset([quad1, quad2])
const dataset = rdf.dataset([quad1, quad2])

@@ -466,3 +448,3 @@ assert.strictEqual(dataset.length, 2)

it('should replace the graph part of the quad if a second parameter is given', () => {
let quad = rdf.quad(
const quad = rdf.quad(
rdf.namedNode('http://example.org/subject'),

@@ -473,3 +455,3 @@ rdf.namedNode('http://example.org/predicate'),

let dataset = rdf.dataset([quad], rdf.namedNode('http://example.org/graph-replaced'))
const dataset = rdf.dataset([quad], rdf.namedNode('http://example.org/graph-replaced'))

@@ -479,76 +461,3 @@ assert.strictEqual(dataset.length, 1)

})
describe('.equals', () => {
it('should compare the other graph for equality', () => {
let quad1a = rdf.quad(rdf.namedNode('http://example.org/subject'), rdf.namedNode('http://example.org/predicate'),
rdf.blankNode())
let quad1b = rdf.quad(rdf.namedNode('http://example.org/subject'), rdf.namedNode('http://example.org/predicate'),
rdf.blankNode())
let quad2 = rdf.quad(rdf.namedNode('http://example.org/subject'), rdf.namedNode('http://example.org/predicate'),
rdf.literal('c'))
let dataset1a = rdf.dataset([quad1a])
let dataset1b = rdf.dataset([quad1b])
let dataset2 = rdf.dataset([quad2])
assert.strictEqual(dataset1a.equals(dataset1b), true)
assert.strictEqual(dataset1a.equals(dataset2), false)
})
})
describe('.toCanonical', () => {
it('should return the canonical representation', () => {
let quad = rdf.quad(rdf.namedNode('http://example.org/subject'), rdf.namedNode('http://example.org/predicate'),
rdf.blankNode())
let dataset = rdf.dataset([quad])
assert.strictEqual(dataset.toCanonical(), '<http://example.org/subject> <http://example.org/predicate> _:c14n0 .\n', true)
})
})
describe('.toString', () => {
it('should return N-Quads', () => {
let quad = rdf.quad(
rdf.namedNode('http://example.org/subject'),
rdf.namedNode('http://example.org/predicate'),
rdf.literal('object'),
rdf.namedNode('http://example.org/graph'))
let dataset = rdf.dataset([quad])
assert.strictEqual(dataset.toString(), '<http://example.org/subject> <http://example.org/predicate> "object" <http://example.org/graph> .\n')
})
})
describe('.toJSON', () => {
it('should return the JSON', () => {
let quad = rdf.quad(
rdf.namedNode('http://example.org/subject'),
rdf.namedNode('http://example.org/predicate'),
rdf.literal('object'),
rdf.namedNode('http://example.org/graph'))
let dataset = rdf.dataset([ quad ])
assert.deepStrictEqual(dataset.toJSON(), [
{
subject: { value: 'http://example.org/subject', termType: 'NamedNode' },
predicate: { value: 'http://example.org/predicate', termType: 'NamedNode' },
object: {
value: 'object',
termType: 'Literal',
language: '',
datatype: {
value: 'http://www.w3.org/2001/XMLSchema#string', termType: 'NamedNode'
}
},
graph: { value: 'http://example.org/graph', termType: 'NamedNode' }
}
])
})
})
})
})

@@ -1,6 +0,5 @@

/* global describe, it */
const assert = require('assert')
const EventEmitter = require('events').EventEmitter
const Parsers = require('..').Parsers
const { EventEmitter } = require('events')
const { describe, it } = require('mocha')
const { Parsers } = require('..')

@@ -16,3 +15,3 @@ describe('parsers', () => {

it('should return null if no parser was found', function () {
let parsers = new Parsers()
const parsers = new Parsers()

@@ -23,6 +22,6 @@ assert.strictEqual(parsers.find('image/jpeg'), null)

it('should return the parser class for the given media type', function () {
let jsonld = {}
let turtle = {}
const jsonld = {}
const turtle = {}
let parsers = new Parsers({
const parsers = new Parsers({
'application/ld+json': jsonld,

@@ -38,4 +37,4 @@ 'text/turtle': turtle

it('should return an array', function () {
let parsers = new Parsers()
let mediaTypes = parsers.list()
const parsers = new Parsers()
const mediaTypes = parsers.list()

@@ -46,3 +45,3 @@ assert(Array.isArray(mediaTypes))

it('should return all media types', function () {
let parsers = new Parsers({
const parsers = new Parsers({
'application/ld+json': {},

@@ -58,3 +57,3 @@ 'text/turtle': {}

it('should return null if no parser was found', function () {
let parsers = new Parsers()
const parsers = new Parsers()

@@ -66,4 +65,4 @@ assert.strictEqual(parsers.import('image/jpeg', ''), null)

let touched = false
let jsonld = {}
let turtle = new EventEmitter()
const jsonld = {}
const turtle = new EventEmitter()

@@ -74,3 +73,3 @@ turtle.import = () => {

let parsers = new Parsers({
const parsers = new Parsers({
'application/ld+json': jsonld,

@@ -82,3 +81,3 @@ 'text/turtle': turtle

let result = new Promise((resolve) => {
const result = new Promise((resolve) => {
turtle.on('end', () => {

@@ -85,0 +84,0 @@ assert(touched)

@@ -1,6 +0,5 @@

/* global describe, it */
const assert = require('assert')
const { EventEmitter } = require('events')
const { describe, it } = require('mocha')
const DataFactory = require('../lib/DataFactory')
const EventEmitter = require('events').EventEmitter
const PrefixMap = require('../lib/PrefixMap')

@@ -7,0 +6,0 @@

@@ -1,6 +0,5 @@

/* global describe, it */
const assert = require('assert')
const EventEmitter = require('events').EventEmitter
const Serializers = require('..').Serializers
const { EventEmitter } = require('events')
const { describe, it } = require('mocha')
const { Serializers } = require('..')

@@ -16,3 +15,3 @@ describe('serializers', () => {

it('should return null if no serializer was found', function () {
let serializers = new Serializers()
const serializers = new Serializers()

@@ -23,6 +22,6 @@ assert.strictEqual(serializers.find('image/jpeg'), null)

it('should return the serializer class for the given media type', function () {
let jsonld = {}
let turtle = {}
const jsonld = {}
const turtle = {}
let serializer = new Serializers({
const serializer = new Serializers({
'application/ld+json': jsonld,

@@ -38,4 +37,4 @@ 'text/turtle': turtle

it('should return an array', function () {
let serializers = new Serializers()
let mediaTypes = serializers.list()
const serializers = new Serializers()
const mediaTypes = serializers.list()

@@ -46,3 +45,3 @@ assert(Array.isArray(mediaTypes))

it('should return all media types', function () {
let serializers = new Serializers({
const serializers = new Serializers({
'application/ld+json': {},

@@ -58,3 +57,3 @@ 'text/turtle': {}

it('should return null if no serializer was found', function () {
let serializers = new Serializers()
const serializers = new Serializers()

@@ -66,4 +65,4 @@ assert.strictEqual(serializers.import('image/jpeg', ''), null)

let touched = false
let jsonld = {}
let turtle = new EventEmitter()
const jsonld = {}
const turtle = new EventEmitter()

@@ -74,3 +73,3 @@ turtle.import = () => {

let serializers = new Serializers({
const serializers = new Serializers({
'application/ld+json': jsonld,

@@ -82,3 +81,3 @@ 'text/turtle': turtle

let result = new Promise((resolve) => {
const result = new Promise((resolve) => {
turtle.on('end', () => {

@@ -85,0 +84,0 @@ assert(touched)

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