@rdfjs/term-set
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -35,2 +35,6 @@ const { termToNTriples } = require('@rdfjs/to-ntriples') | ||
delete (term) { | ||
if (!term) { | ||
return false | ||
} | ||
return this.index.delete(termToNTriples(term)) | ||
@@ -48,2 +52,6 @@ } | ||
has (term) { | ||
if (!term) { | ||
return false | ||
} | ||
return this.index.has(termToNTriples(term)) | ||
@@ -50,0 +58,0 @@ } |
{ | ||
"name": "@rdfjs/term-set", | ||
"version": "1.0.1", | ||
"description": "Set for RDFJS Terms", | ||
"version": "1.0.2", | ||
"description": "Set for RDF/JS Terms", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "standard && jest" | ||
"coverage": "codecov", | ||
"test": "standard && c8 --reporter=lcov --reporter=text mocha" | ||
}, | ||
@@ -29,9 +30,8 @@ "repository": { | ||
"devDependencies": { | ||
"@rdfjs/data-model": "^1.1.2", | ||
"jest": "^24.9.0", | ||
"standard": "^14.0.0" | ||
}, | ||
"engines": { | ||
"node": ">=8" | ||
"@rdfjs/data-model": "^1.2.0", | ||
"c8": "^7.7.1", | ||
"codecov": "^3.8.1", | ||
"mocha": "^8.3.2", | ||
"standard": "^16.0.3" | ||
} | ||
} |
114
test/test.js
@@ -1,5 +0,5 @@ | ||
/* global describe, expect, it */ | ||
const { strictEqual } = require('assert') | ||
const rdf = require('@rdfjs/data-model') | ||
const { termToNTriples } = require('@rdfjs/to-ntriples') | ||
const { describe, it } = require('mocha') | ||
const TermSet = require('..') | ||
@@ -9,3 +9,3 @@ | ||
it('should be a constructor', () => { | ||
expect(typeof TermSet).toBe('function') | ||
strictEqual(typeof TermSet, 'function') | ||
}) | ||
@@ -17,3 +17,3 @@ | ||
expect(typeof termset.size).toBe('number') | ||
strictEqual(typeof termset.size, 'number') | ||
}) | ||
@@ -25,3 +25,3 @@ | ||
expect(termset.size).toBe(1) | ||
strictEqual(termset.size, 1) | ||
}) | ||
@@ -34,3 +34,3 @@ }) | ||
expect(typeof termset.add).toBe('function') | ||
strictEqual(typeof termset.add, 'function') | ||
}) | ||
@@ -44,4 +44,4 @@ | ||
expect([...termset.index.values()][0]).toBe(term) | ||
expect([...termset.index.keys()][0]).toBe(termToNTriples(term)) | ||
strictEqual([...termset.index.values()][0], term) | ||
strictEqual([...termset.index.keys()][0], termToNTriples(term)) | ||
}) | ||
@@ -57,4 +57,4 @@ | ||
expect(termset.index.size).toBe(1) | ||
expect(term0.equals([...termset.index.values()][0])).toBe(true) | ||
strictEqual(termset.index.size, 1) | ||
strictEqual(term0.equals([...termset.index.values()][0]), true) | ||
}) | ||
@@ -68,3 +68,3 @@ | ||
expect(termset.add(term)).toBe(termset) | ||
strictEqual(termset.add(term), termset) | ||
}) | ||
@@ -77,3 +77,3 @@ }) | ||
expect(typeof termset.clear).toBe('function') | ||
strictEqual(typeof termset.clear, 'function') | ||
}) | ||
@@ -87,3 +87,3 @@ | ||
expect(termset.index.size).toBe(0) | ||
strictEqual(termset.index.size, 0) | ||
}) | ||
@@ -96,3 +96,3 @@ }) | ||
expect(typeof termset.delete).toBe('function') | ||
strictEqual(typeof termset.delete, 'function') | ||
}) | ||
@@ -107,4 +107,4 @@ | ||
expect(termset.index.size).toBe(1) | ||
expect(term0.equals([...termset.index.values()][0])).toBe(true) | ||
strictEqual(termset.index.size, 1) | ||
strictEqual(term0.equals([...termset.index.values()][0]), true) | ||
}) | ||
@@ -116,3 +116,3 @@ | ||
expect(termset.delete(term)).toBe(true) | ||
strictEqual(termset.delete(term), true) | ||
}) | ||
@@ -124,4 +124,16 @@ | ||
expect(termset.delete(term)).toBe(false) | ||
strictEqual(termset.delete(term), false) | ||
}) | ||
it('should return false if null is given', () => { | ||
const termset = new TermSet() | ||
strictEqual(termset.delete(null), false) | ||
}) | ||
it('should return false if a non-Term object is given', () => { | ||
const termset = new TermSet() | ||
strictEqual(termset.delete({}), false) | ||
}) | ||
}) | ||
@@ -133,3 +145,3 @@ | ||
expect(typeof termset.entries).toBe('function') | ||
strictEqual(typeof termset.entries, 'function') | ||
}) | ||
@@ -144,7 +156,7 @@ | ||
expect(entries.length).toBe(2) | ||
expect(term0.equals(entries[0][0])).toBe(true) | ||
expect(term0.equals(entries[0][1])).toBe(true) | ||
expect(term1.equals(entries[1][0])).toBe(true) | ||
expect(term1.equals(entries[1][1])).toBe(true) | ||
strictEqual(entries.length, 2) | ||
strictEqual(term0.equals(entries[0][0]), true) | ||
strictEqual(term0.equals(entries[0][1]), true) | ||
strictEqual(term1.equals(entries[1][0]), true) | ||
strictEqual(term1.equals(entries[1][1]), true) | ||
}) | ||
@@ -157,3 +169,3 @@ }) | ||
expect(typeof termset.forEach).toBe('function') | ||
strictEqual(typeof termset.forEach, 'function') | ||
}) | ||
@@ -171,5 +183,5 @@ | ||
expect(terms.length).toBe(2) | ||
expect(term0.equals(terms[0])).toBe(true) | ||
expect(term1.equals(terms[1])).toBe(true) | ||
strictEqual(terms.length, 2) | ||
strictEqual(term0.equals(terms[0]), true) | ||
strictEqual(term1.equals(terms[1]), true) | ||
}) | ||
@@ -182,3 +194,3 @@ }) | ||
expect(typeof termset.has).toBe('function') | ||
strictEqual(typeof termset.has, 'function') | ||
}) | ||
@@ -191,3 +203,3 @@ | ||
expect(termset.has(term1)).toBe(true) | ||
strictEqual(termset.has(term1), true) | ||
}) | ||
@@ -200,4 +212,20 @@ | ||
expect(termset.has(term1)).toBe(false) | ||
strictEqual(termset.has(term1), false) | ||
}) | ||
it('should return false if null is given', () => { | ||
const term0 = rdf.namedNode('http://example.org/0') | ||
const term1 = rdf.namedNode('http://example.org/1') | ||
const termset = new TermSet([term0, term1]) | ||
strictEqual(termset.has(null), false) | ||
}) | ||
it('should return false if a non-Term object is given', () => { | ||
const term0 = rdf.namedNode('http://example.org/0') | ||
const term1 = rdf.namedNode('http://example.org/1') | ||
const termset = new TermSet([term0, term1]) | ||
strictEqual(termset.has({}), false) | ||
}) | ||
}) | ||
@@ -209,3 +237,3 @@ | ||
expect(typeof termset.values).toBe('function') | ||
strictEqual(typeof termset.values, 'function') | ||
}) | ||
@@ -220,5 +248,5 @@ | ||
expect(values.length).toBe(2) | ||
expect(term0.equals(values[0])).toBe(true) | ||
expect(term1.equals(values[1])).toBe(true) | ||
strictEqual(values.length, 2) | ||
strictEqual(term0.equals(values[0]), true) | ||
strictEqual(term1.equals(values[1]), true) | ||
}) | ||
@@ -231,3 +259,3 @@ }) | ||
expect(typeof termset.keys).toBe('function') | ||
strictEqual(typeof termset.keys, 'function') | ||
}) | ||
@@ -242,5 +270,5 @@ | ||
expect(values.length).toBe(2) | ||
expect(term0.equals(values[0])).toBe(true) | ||
expect(term1.equals(values[1])).toBe(true) | ||
strictEqual(values.length, 2) | ||
strictEqual(term0.equals(values[0]), true) | ||
strictEqual(term1.equals(values[1]), true) | ||
}) | ||
@@ -253,3 +281,3 @@ }) | ||
expect(typeof termset[Symbol.iterator]).toBe('function') | ||
strictEqual(typeof termset[Symbol.iterator], 'function') | ||
}) | ||
@@ -264,7 +292,7 @@ | ||
expect(terms.length).toBe(2) | ||
expect(term0.equals(terms[0])).toBe(true) | ||
expect(term1.equals(terms[1])).toBe(true) | ||
strictEqual(terms.length, 2) | ||
strictEqual(term0.equals(terms[0]), true) | ||
strictEqual(term1.equals(terms[1]), true) | ||
}) | ||
}) | ||
}) |
11324
266
5