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

@rdfjs/term-map

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rdfjs/term-map - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

.github/workflows/ci.yaml

10

index.js

@@ -1,2 +0,2 @@

const { termToNTriples } = require('@rdfjs/to-ntriples')
const toNT = require('@rdfjs/to-ntriples')

@@ -23,3 +23,3 @@ class TermMap {

delete (term) {
return this.index.delete(termToNTriples(term))
return this.index.delete(toNT(term))
}

@@ -40,3 +40,3 @@

get (term) {
const item = this.index.get(termToNTriples(term))
const item = this.index.get(toNT(term))

@@ -47,3 +47,3 @@ return item && item.value

has (term) {
return this.index.has(termToNTriples(term))
return this.index.has(toNT(term))
}

@@ -58,3 +58,3 @@

set (term, value) {
const key = termToNTriples(term)
const key = toNT(term)

@@ -61,0 +61,0 @@ this.index.set(key, { term, value })

{
"name": "@rdfjs/term-map",
"version": "1.0.1",
"version": "1.1.0",
"description": "Map for RDF/JS Terms keys",

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

"coverage": "codecov",
"test": "standard && nyc --reporter=lcov 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.1.2",
"codecov": "^3.6.5",
"mocha": "^7.1.2",
"nyc": "^15.0.1",
"standard": "^14.3.3"
"@rdfjs/data-model": "^1.3.1",
"c8": "^7.7.3",
"codecov": "^3.8.2",
"mocha": "^9.0.1",
"stricter-standard": "^0.2.0"
}
}
const { strictEqual } = require('assert')
const rdf = require('@rdfjs/data-model')
const toNT = require('@rdfjs/to-ntriples')
const { describe, it } = require('mocha')
const rdf = require('@rdfjs/data-model')
const { termToNTriples } = require('@rdfjs/to-ntriples')
const TermMap = require('..')

@@ -62,2 +62,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 termmap = new TermMap([[term0, null], [term1, null]])
termmap.delete(term0)
strictEqual(termmap.index.size, 1)
strictEqual(term1.equals([...termmap.index.values()][0].term), true)
})
it('should return true if the given term was deleted', () => {

@@ -143,2 +157,15 @@ const term = rdf.namedNode('http://example.org/')

it('should return the value for 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 termmap = new TermMap([[term0, 0], [term1, 1]])
const result = termmap.get(term0)
strictEqual(result, 0)
})
it('should return undefined if there is no value for the given term', () => {

@@ -170,2 +197,13 @@ const term0 = rdf.namedNode('http://example.org/0')

it('should return true if it 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 termmap = new TermMap([[term0, 0], [term1, 1]])
strictEqual(termmap.has(term0), true)
})
it('should return false if it doesn\'t contain the given term', () => {

@@ -216,3 +254,3 @@ const term0 = rdf.namedNode('http://example.org/0')

strictEqual(entries.length, 1)
strictEqual(entries[0][0], termToNTriples(term))
strictEqual(entries[0][0], toNT(term))
strictEqual(term.equals(entries[0][1].term), true)

@@ -222,2 +260,19 @@ strictEqual(entries[0][1].value, 1)

it('should add the given Quad entry 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 termmap = new TermMap()
termmap.set(term, 1)
const entries = [...termmap.index]
strictEqual(entries.length, 1)
strictEqual(entries[0][0], toNT(term))
strictEqual(term.equals(entries[0][1].term), true)
strictEqual(entries[0][1].value, 1)
})
it('should update an entry if another one with the same N-Triple representation is added', () => {

@@ -234,3 +289,3 @@ const term0 = rdf.namedNode('http://example.org/')

strictEqual(entries.length, 1)
strictEqual(entries[0][0], termToNTriples(term0))
strictEqual(entries[0][0], toNT(term0))
strictEqual(term0.equals(entries[0][1].term), true)

@@ -237,0 +292,0 @@ strictEqual(entries[0][1].value, 1)

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