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

@rdfjs/term-set

Package Overview
Dependencies
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rdfjs/term-set - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

16

index.js

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

const { termToNTriples } = require('@rdfjs/to-ntriples')
const toNT = require('@rdfjs/to-ntriples')
function quietToNT (term) {
try {
return toNT(term)
} catch (err) {
return null
}
}
class TermSet {

@@ -19,3 +27,3 @@ constructor (terms) {

add (term) {
const key = termToNTriples(term)
const key = toNT(term)

@@ -40,3 +48,3 @@ if (this.index.has(key)) {

return this.index.delete(termToNTriples(term))
return this.index.delete(quietToNT(term))
}

@@ -57,3 +65,3 @@

return this.index.has(termToNTriples(term))
return this.index.has(quietToNT(term))
}

@@ -60,0 +68,0 @@

{
"name": "@rdfjs/term-set",
"version": "1.0.2",
"version": "1.1.0",
"description": "Set for RDF/JS Terms",

@@ -8,3 +8,3 @@ "main": "index.js",

"coverage": "codecov",
"test": "standard && c8 --reporter=lcov --reporter=text mocha"
"test": "stricter-standard && c8 --reporter=lcov --reporter=text mocha"
},

@@ -28,11 +28,11 @@ "repository": {

"dependencies": {
"@rdfjs/to-ntriples": "^1.0.2"
"@rdfjs/to-ntriples": "^2.0.0"
},
"devDependencies": {
"@rdfjs/data-model": "^1.2.0",
"c8": "^7.7.1",
"codecov": "^3.8.1",
"mocha": "^8.3.2",
"standard": "^16.0.3"
"@rdfjs/data-model": "^1.3.1",
"c8": "^7.7.3",
"codecov": "^3.8.2",
"mocha": "^9.0.1",
"stricter-standard": "^0.2.0"
}
}

@@ -1,4 +0,4 @@

const { strictEqual } = require('assert')
const { strictEqual, throws } = require('assert')
const rdf = require('@rdfjs/data-model')
const { termToNTriples } = require('@rdfjs/to-ntriples')
const toNT = require('@rdfjs/to-ntriples')
const { describe, it } = require('mocha')

@@ -41,5 +41,18 @@ const TermSet = require('..')

strictEqual([...termset.index.values()][0], term)
strictEqual([...termset.index.keys()][0], termToNTriples(term))
strictEqual([...termset.index.keys()][0], toNT(term))
})
it('should add the given Quad term to the index', () => {
const subject = rdf.blankNode()
const predicate = rdf.namedNode('http://example.org/predicate')
const object = rdf.literal('example')
const term = rdf.quad(subject, predicate, object)
const termset = new TermSet()
termset.add(term)
strictEqual([...termset.index.values()][0], term)
strictEqual([...termset.index.keys()][0], toNT(term))
})
it('should keep the term if another one with the same N-Triple representation is added', () => {

@@ -65,2 +78,10 @@ const term0 = rdf.namedNode('http://example.org/')

})
it('should throw an error if a non-Term object is given', () => {
const termset = new TermSet()
throws(() => {
termset.add({})
})
})
})

@@ -103,2 +124,16 @@

it('should delete the given Quad term', () => {
const subject = rdf.blankNode()
const predicate = rdf.namedNode('http://example.org/predicate')
const object = rdf.literal('example')
const term0 = rdf.quad(subject, predicate, object)
const term1 = rdf.namedNode('http://example.org/1')
const termset = new TermSet([term0, term1])
termset.delete(term0)
strictEqual(termset.index.size, 1)
strictEqual(term1.equals([...termset.index.values()][0]), true)
})
it('should return true if the given term was deleted', () => {

@@ -191,2 +226,13 @@ const term = rdf.namedNode('http://example.org/')

it('should return true if the Termset contains the given Quad term', () => {
const subject = rdf.blankNode()
const predicate = rdf.namedNode('http://example.org/predicate')
const object = rdf.literal('example')
const term0 = rdf.quad(subject, predicate, object)
const term1 = rdf.namedNode('http://example.org/1')
const termset = new TermSet([term0, term1])
strictEqual(termset.has(term0), true)
})
it('should return false if the Termset does not contain the given term', () => {

@@ -193,0 +239,0 @@ const term0 = rdf.namedNode('http://example.org/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