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

clownface

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clownface - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

28

docs/api.md

@@ -54,4 +54,4 @@ ## Classes

* [.namedNode(values)](#Clownface+namedNode) ⇒ [<code>Clownface</code>](#Clownface)
* [.in(predicates)](#Clownface+in) ⇒ [<code>Clownface</code>](#Clownface)
* [.out(predicates, [options])](#Clownface+out) ⇒ [<code>Clownface</code>](#Clownface)
* [.in([predicates])](#Clownface+in) ⇒ [<code>Clownface</code>](#Clownface)
* [.out([predicates], [options])](#Clownface+out) ⇒ [<code>Clownface</code>](#Clownface)
* [.has(predicates, [objects])](#Clownface+has) ⇒ [<code>Clownface</code>](#Clownface)

@@ -61,4 +61,4 @@ * [.addIn(predicates, subjects, [callback])](#Clownface+addIn) ⇒ [<code>Clownface</code>](#Clownface)

* [.addList(predicates, items)](#Clownface+addList) ⇒ [<code>Clownface</code>](#Clownface)
* [.deleteIn(predicates)](#Clownface+deleteIn) ⇒ [<code>Clownface</code>](#Clownface)
* [.deleteOut(predicates)](#Clownface+deleteOut) ⇒ [<code>Clownface</code>](#Clownface)
* [.deleteIn([predicates], [subjects])](#Clownface+deleteIn) ⇒ [<code>Clownface</code>](#Clownface)
* [.deleteOut([predicates], [objects])](#Clownface+deleteOut) ⇒ [<code>Clownface</code>](#Clownface)
* [.deleteList(predicates)](#Clownface+deleteList) ⇒ [<code>Clownface</code>](#Clownface)

@@ -273,3 +273,3 @@

### clownface.in(predicates) ⇒ [<code>Clownface</code>](#Clownface)
### clownface.in([predicates]) ⇒ [<code>Clownface</code>](#Clownface)
Creates a graph pointer to nodes which are linked to the current pointer by `predicates`

@@ -286,3 +286,3 @@

<tr>
<td>predicates</td><td><code>Term</code> | <code>Array.&lt;Term&gt;</code> | <code><a href="#Clownface">Clownface</a></code> | <code><a href="#Clownface">Array.&lt;Clownface&gt;</a></code></td><td><p>one or more RDF/JS term identifying a property</p>
<td>[predicates]</td><td><code>Term</code> | <code>Array.&lt;Term&gt;</code> | <code><a href="#Clownface">Clownface</a></code> | <code><a href="#Clownface">Array.&lt;Clownface&gt;</a></code></td><td><p>one or more RDF/JS term identifying a property</p>
</td>

@@ -294,3 +294,3 @@ </tr> </tbody>

### clownface.out(predicates, [options]) ⇒ [<code>Clownface</code>](#Clownface)
### clownface.out([predicates], [options]) ⇒ [<code>Clownface</code>](#Clownface)
Creates a graph pointer to nodes which link the current pointer by `predicates`

@@ -307,3 +307,3 @@

<tr>
<td>predicates</td><td><code>Term</code> | <code>Array.&lt;Term&gt;</code> | <code><a href="#Clownface">Clownface</a></code> | <code><a href="#Clownface">Array.&lt;Clownface&gt;</a></code></td><td><p>one or more RDF/JS term identifying a property</p>
<td>[predicates]</td><td><code>Term</code> | <code>Array.&lt;Term&gt;</code> | <code><a href="#Clownface">Clownface</a></code> | <code><a href="#Clownface">Array.&lt;Clownface&gt;</a></code></td><td><p>one or more RDF/JS term identifying a property</p>
</td>

@@ -415,3 +415,3 @@ </tr><tr>

### clownface.deleteIn(predicates) ⇒ [<code>Clownface</code>](#Clownface)
### clownface.deleteIn([predicates], [subjects]) ⇒ [<code>Clownface</code>](#Clownface)
Deletes all quads where the current graph pointer contexts are the objects

@@ -429,3 +429,5 @@

<tr>
<td>predicates</td><td><code>Term</code> | <code>Array.&lt;Term&gt;</code> | <code><a href="#Clownface">Clownface</a></code> | <code><a href="#Clownface">Array.&lt;Clownface&gt;</a></code></td>
<td>[predicates]</td><td><code>Term</code> | <code>Array.&lt;Term&gt;</code> | <code><a href="#Clownface">Clownface</a></code> | <code><a href="#Clownface">Array.&lt;Clownface&gt;</a></code></td>
</tr><tr>
<td>[subjects]</td><td><code>Term</code> | <code>Array.&lt;Term&gt;</code> | <code><a href="#Clownface">Clownface</a></code> | <code><a href="#Clownface">Array.&lt;Clownface&gt;</a></code></td>
</tr> </tbody>

@@ -436,3 +438,3 @@ </table>

### clownface.deleteOut(predicates) ⇒ [<code>Clownface</code>](#Clownface)
### clownface.deleteOut([predicates], [objects]) ⇒ [<code>Clownface</code>](#Clownface)
Deletes all quads where the current graph pointer contexts are the subjects

@@ -450,3 +452,5 @@

<tr>
<td>predicates</td><td><code>Term</code> | <code>Array.&lt;Term&gt;</code> | <code><a href="#Clownface">Clownface</a></code> | <code><a href="#Clownface">Array.&lt;Clownface&gt;</a></code></td>
<td>[predicates]</td><td><code>Term</code> | <code>Array.&lt;Term&gt;</code> | <code><a href="#Clownface">Clownface</a></code> | <code><a href="#Clownface">Array.&lt;Clownface&gt;</a></code></td>
</tr><tr>
<td>[objects]</td><td><code>Term</code> | <code>Array.&lt;Term&gt;</code> | <code><a href="#Clownface">Clownface</a></code> | <code><a href="#Clownface">Array.&lt;Clownface&gt;</a></code></td>
</tr> </tbody>

@@ -453,0 +457,0 @@ </table>

@@ -264,3 +264,3 @@ const rdf = require('@rdfjs/data-model')

* Creates a graph pointer to nodes which are linked to the current pointer by `predicates`
* @param {Term|Term[]|Clownface|Clownface[]} predicates one or more RDF/JS term identifying a property
* @param {Term|Term[]|Clownface|Clownface[]} [predicates] one or more RDF/JS term identifying a property
* @returns {Clownface}

@@ -278,3 +278,3 @@ */

* Creates a graph pointer to nodes which link the current pointer by `predicates`
* @param {Term|Term[]|Clownface|Clownface[]} predicates one or more RDF/JS term identifying a property
* @param {Term|Term[]|Clownface|Clownface[]} [predicates] one or more RDF/JS term identifying a property
* @param {object} [options]

@@ -393,9 +393,11 @@ * @param {string | string[] | undefined} [options.language]

*
* @param {Term|Term[]|Clownface|Clownface[]} predicates
* @param {Term|Term[]|Clownface|Clownface[]} [predicates]
* @param {Term|Term[]|Clownface|Clownface[]} [subjects]
* @returns {Clownface} current graph pointer
*/
deleteIn (predicates) {
deleteIn (predicates, subjects) {
predicates = this._toTermArray(predicates)
subjects = this._toTermArray(subjects)
this._context.forEach(context => context.deleteIn(predicates))
this._context.forEach(context => context.deleteIn(predicates, subjects))

@@ -408,9 +410,11 @@ return this

*
* @param {Term|Term[]|Clownface|Clownface[]} predicates
* @param {Term|Term[]|Clownface|Clownface[]} [predicates]
* @param {Term|Term[]|Clownface|Clownface[]} [objects]
* @returns {Clownface} current graph pointer
*/
deleteOut (predicates) {
deleteOut (predicates, objects) {
predicates = this._toTermArray(predicates)
objects = this._toTermArray(objects)
this._context.forEach(context => context.deleteOut(predicates))
this._context.forEach(context => context.deleteOut(predicates, objects))

@@ -417,0 +421,0 @@ return this

@@ -94,8 +94,8 @@ const term = require('./term')

deleteIn (predicate) {
this.deleteMatch(null, predicate, toArray(this.term), toArray(this.graph))
deleteIn (predicate, subject) {
this.deleteMatch(subject, predicate, toArray(this.term), toArray(this.graph))
}
deleteOut (predicate) {
this.deleteMatch(toArray(this.term), predicate, null, toArray(this.graph))
deleteOut (predicate, objects) {
this.deleteMatch(toArray(this.term), predicate, objects, toArray(this.graph))
}

@@ -102,0 +102,0 @@

@@ -6,9 +6,13 @@ function toArray (value, defaultValue) {

if (!Array.isArray(value)) {
return [value]
if (Array.isArray(value)) {
return value
}
return value
if (typeof value !== 'string' && value[Symbol.iterator]) {
return [...value]
}
return [value]
}
module.exports = toArray
{
"name": "clownface",
"version": "1.1.1",
"version": "1.2.0",
"description": "Simple but powerful graph traversing library",

@@ -33,2 +33,3 @@ "main": "index.js",

"@rdfjs/parser-n3": "^1.1.2",
"@rdfjs/term-set": "^1.0.1",
"docsify-cli": "^4.4.0",

@@ -35,0 +36,0 @@ "husky": "^4.2.5",

# clownface
[![Build Status](https://travis-ci.org/clownface/clownface.svg?branch=master)](https://travis-ci.org/clownface/clownface)
[![Build Status](https://travis-ci.org/zazuko/clownface.svg?branch=master)](https://travis-ci.org/github/zazuko/clownface)
[![NPM Version](https://img.shields.io/npm/v/clownface.svg?style=flat)](https://npm.im/clownface)
Simple but powerful graph traversing library
Clownface is a graph traversal library inspired by [Gremlin](https://tinkerpop.apache.org/gremlin.html) which allows to query any [RDF dataset](https://rdf.js.org/dataset-spec/) in a concise and readable way.
Clownface greatly simplifies interacting with RDF data in JavaScript.
# Learn more
For documentation and examples see http://zazuko.github.io/clownface/.
If you are new to RDF and JavaScript, consider our [Getting Started](https://zazuko.com/get-started/developers/#traverse-an-rdf-graph) guide that also covers Clownface basics.
For API documentation and examples, see http://zazuko.github.io/clownface/.

@@ -66,2 +66,16 @@ /* global describe, it */

})
it('should support multiple values in an iterable', () => {
const labelA = 'b321a'
const labelB = 'b321b'
const cf = clownface({ dataset: rdf.dataset() })
const result = cf.blankNode(new Set([labelA, labelB]))
assert.strictEqual(result._context.length, 2)
assert.strictEqual(result._context[0].term.termType, 'BlankNode')
assert.strictEqual(result._context[0].term.value, labelA)
assert.strictEqual(result._context[1].term.termType, 'BlankNode')
assert.strictEqual(result._context[1].term.value, labelB)
})
})

@@ -6,2 +6,3 @@ /* global describe, it */

const loadExample = require('../support/example')
const ns = require('../support/namespace')
const rdf = require('../support/factory')

@@ -62,2 +63,26 @@ const { addAll } = require('rdf-dataset-ext')

})
it('should remove quads based on the object value, predicate and subject', async () => {
const dataset = addAll(rdf.dataset(), await loadExample())
const cf = clownface({
dataset,
term: ns.tbbtp('bernadette-rostenkowski')
})
cf.deleteIn(ns.schema.knows, ns.tbbtp('amy-farrah-fowler'))
assert.strictEqual(dataset.size, 125)
})
it('should remove quads based on the object value, multiple predicates and multiple subjects', async () => {
const dataset = addAll(rdf.dataset(), await loadExample())
const cf = clownface({
dataset,
term: ns.tbbtp('bernadette-rostenkowski')
})
cf.deleteIn([ns.schema.knows, ns.schema.spouse], [ns.tbbtp('amy-farrah-fowler'), ns.tbbtp('howard-wolowitz')])
assert.strictEqual(dataset.size, 123)
})
})

@@ -6,2 +6,3 @@ /* global describe, it */

const loadExample = require('../support/example')
const ns = require('../support/namespace')
const rdf = require('../support/factory')

@@ -24,3 +25,3 @@ const { addAll } = require('rdf-dataset-ext')

it('should remove quad based on the object value', async () => {
it('should remove quads based on the object value', async () => {
const dataset = addAll(rdf.dataset(), await loadExample())

@@ -37,3 +38,3 @@ const cf = clownface({

it('should remove quad based on the object value and predicate', async () => {
it('should remove quads based on the object value and predicate', async () => {
const dataset = addAll(rdf.dataset(), await loadExample())

@@ -50,3 +51,3 @@ const cf = clownface({

it('should remove quad based on the object value and multiple predicates', async () => {
it('should remove quads based on the object value and multiple predicates', async () => {
const dataset = addAll(rdf.dataset(), await loadExample())

@@ -65,2 +66,38 @@ const cf = clownface({

})
it('should remove quads based on the object value and predicate', async () => {
const dataset = addAll(rdf.dataset(), await loadExample())
const cf = clownface({
dataset,
term: rdf.namedNode('http://localhost:8080/data/person/bernadette-rostenkowski')
})
cf.deleteOut(rdf.namedNode('http://schema.org/knows'))
assert.strictEqual(dataset.size, 119)
})
it('should remove quads based on the object value, predicate and object', async () => {
const dataset = addAll(rdf.dataset(), await loadExample())
const cf = clownface({
dataset,
term: ns.tbbtp('bernadette-rostenkowski')
})
cf.deleteOut(ns.schema.knows, ns.tbbtp('amy-farrah-fowler'))
assert.strictEqual(dataset.size, 125)
})
it('should remove quads based on the object value, multiple predicates and multiple objects', async () => {
const dataset = addAll(rdf.dataset(), await loadExample())
const cf = clownface({
dataset,
term: ns.tbbtp('bernadette-rostenkowski')
})
cf.deleteOut([ns.schema.knows, ns.schema.spouse], [ns.tbbtp('amy-farrah-fowler'), ns.tbbtp('howard-wolowitz')])
assert.strictEqual(dataset.size, 123)
})
})

@@ -7,2 +7,3 @@ /* global describe, it */

const rdf = require('../support/factory')
const ns = require('../support/namespace')
const Clownface = require('../../lib/Clownface')

@@ -17,3 +18,3 @@

it('should return a new Dataset instance', async () => {
it('should return a new Clownface instance', async () => {
const cf = clownface({

@@ -30,5 +31,16 @@ dataset: await loadExample(),

it('should search object -> subject', async () => {
it('should search object -> subject without predicate', async () => {
const cf = clownface({
dataset: await loadExample(),
term: ns.tbbtp('bernadette-rostenkowski')
})
const result = cf.in()
assert.strictEqual(result._context.length, 8)
})
it('should search object -> subject with predicate', async () => {
const cf = clownface({
dataset: await loadExample(),
value: '2311 North Los Robles Avenue, Aparment 4A'

@@ -35,0 +47,0 @@ })

@@ -138,2 +138,14 @@ /* global describe, it */

it('should support multiple values in an iterable', () => {
const cf = clownface({ dataset: rdf.dataset() })
const result = cf.literal(new Set(['1', '2']))
assert.strictEqual(result._context.length, 2)
assert.strictEqual(result._context[0].term.termType, 'Literal')
assert.strictEqual(result._context[0].term.value, '1')
assert.strictEqual(result._context[1].term.termType, 'Literal')
assert.strictEqual(result._context[1].term.value, '2')
})
it('should use the given datatype', () => {

@@ -140,0 +152,0 @@ const datatypeIri = 'http://example.org/datatype'

/* global describe, it */
const assert = require('assert')
const TermSet = require('@rdfjs/term-set')
const clownface = require('../..')

@@ -57,2 +58,28 @@ const rdf = require('../support/factory')

})
it('should support multiple values from NamedNode iterator', () => {
const iriA = rdf.namedNode('http://example.org/a')
const iriB = rdf.namedNode('http://example.org/b')
const cf = clownface({ dataset: rdf.dataset() })
const result = cf.namedNode(new TermSet([iriA, iriB]))
assert.strictEqual(result._context.length, 2)
assert.deepStrictEqual(result._context[0].term, iriA)
assert.deepStrictEqual(result._context[1].term, iriB)
})
it('should support multiple values from string iterator', () => {
const iriA = 'http://example.org/a'
const iriB = 'http://example.org/b'
const cf = clownface({ dataset: rdf.dataset() })
const result = cf.namedNode(new Set([iriA, iriB]))
assert.strictEqual(result._context.length, 2)
assert.strictEqual(result._context[0].term.termType, 'NamedNode')
assert.strictEqual(result._context[0].term.value, iriA)
assert.strictEqual(result._context[1].term.termType, 'NamedNode')
assert.strictEqual(result._context[1].term.value, iriB)
})
})
/* global describe, it */
const assert = require('assert')
const TermSet = require('@rdfjs/term-set')
const { xsd } = require('../support/namespace')
const clownface = require('../..')

@@ -113,2 +115,18 @@ const loadExample = require('../support/example')

it('should create nodes from term iterator', () => {
const cf = clownface({ dataset: rdf.dataset() })
const nodes = new TermSet([
rdf.namedNode('http://example.com/'),
rdf.literal('10', xsd.int),
rdf.blankNode()
])
const result = cf.node(nodes)
assert.strictEqual(result._context.length, 3)
assert.deepStrictEqual(result._context[0].term, rdf.namedNode('http://example.com/'))
assert.deepStrictEqual(result._context[1].term, rdf.literal('10', xsd.int))
assert.strictEqual(result._context[2].term.termType, 'BlankNode')
})
it('should use the given datatype', () => {

@@ -115,0 +133,0 @@ const datatype = rdf.namedNode('http://example.org/datatype')

@@ -7,3 +7,3 @@ const { describe, it } = require('mocha')

const Clownface = require('../../lib/Clownface')
const { ex, rdfs } = require('../support/namespace')
const ns = require('../support/namespace')
const parse = require('../support/parse')

@@ -18,3 +18,3 @@

it('should return a new Dataset instance', async () => {
it('should return a new Clownface instance', async () => {
const cf = clownface({

@@ -31,5 +31,16 @@ dataset: await loadExample(),

it('should search subject -> object', async () => {
it('should search subject -> object without predicate', async () => {
const cf = clownface({
dataset: await loadExample(),
term: ns.tbbtp('amy-farrah-fowler')
})
const result = cf.out()
assert.strictEqual(result._context.length, 12)
})
it('should search subject -> object with predicate', async () => {
const cf = clownface({
dataset: await loadExample(),
term: rdf.namedNode('http://localhost:8080/data/person/amy-farrah-fowler')

@@ -74,30 +85,30 @@ })

describe('with language option', () => {
const testData = `<${ex.ananas.value}>
<${rdfs.label.value}> "Pineapple" ;
<${rdfs.label.value}> "Ananas"@pl ;
<${rdfs.label.value}> "Ananas"@de ;
<${rdfs.label.value}> "Ananász"@hu ;
<${rdfs.label.value}> "Ananas"@sr-Latn ;
<${rdfs.label.value}> "Ананас"@sr-Cyrl ;
const testData = `<${ns.ex.ananas.value}>
<${ns.rdfs.label.value}> "Pineapple" ;
<${ns.rdfs.label.value}> "Ananas"@pl ;
<${ns.rdfs.label.value}> "Ananas"@de ;
<${ns.rdfs.label.value}> "Ananász"@hu ;
<${ns.rdfs.label.value}> "Ananas"@sr-Latn ;
<${ns.rdfs.label.value}> "Ананас"@sr-Cyrl ;
.
<${ex.noLabels.value}> <${rdfs.label.value}> _:foo , <${ex.bar.value.value}>, 41 .
<${ns.ex.noLabels.value}> <${ns.rdfs.label.value}> _:foo , <${ns.ex.bar.value.value}>, 41 .
<${ex.apple.value}>
<${rdfs.label.value}> "Apple"@en ;
<${rdfs.label.value}> "Apfel"@de ;
<${rdfs.label.value}> "Јабука"@sr-Cyrl .
<${ns.ex.apple.value}>
<${ns.rdfs.label.value}> "Apple"@en ;
<${ns.rdfs.label.value}> "Apfel"@de ;
<${ns.rdfs.label.value}> "Јабука"@sr-Cyrl .
<${ex.carrot.value}>
<${rdfs.label.value}> "Karotte"@de ;
<${rdfs.label.value}> "Karotte"@de-AT ;
<${rdfs.label.value}> "Rüebli"@de-CH ;
<${ns.ex.carrot.value}>
<${ns.rdfs.label.value}> "Karotte"@de ;
<${ns.rdfs.label.value}> "Karotte"@de-AT ;
<${ns.rdfs.label.value}> "Rüebli"@de-CH ;
.
<${ex.eggplant.value}>
<${rdfs.label.value}> "Psianka podłużna"@pl, "Bakłażan"@pl, "Oberżyna"@pl .
<${ns.ex.eggplant.value}>
<${ns.rdfs.label.value}> "Psianka podłużna"@pl, "Bakłażan"@pl, "Oberżyna"@pl .
<${ex.kongressstrasse.value}>
<${rdfs.label.value}> "Kongressstraße"@de ;
<${rdfs.label.value}> "Kongreßstraße"@de-DE-1901 ;
<${ns.ex.kongressstrasse.value}>
<${ns.rdfs.label.value}> "Kongressstraße"@de ;
<${ns.rdfs.label.value}> "Kongreßstraße"@de-DE-1901 ;
.`.toString()

@@ -107,5 +118,5 @@

it('should not return non-literals and non-string literals when language parameter is defined', async () => {
const apple = (await parse(testData)).node(ex.noLabels)
const apple = (await parse(testData)).node(ns.ex.noLabels)
const label = apple.out(rdfs.label, { language: '' })
const label = apple.out(ns.rdfs.label, { language: '' })

@@ -116,5 +127,5 @@ assert.strictEqual(label.terms.length, 0)

it('should return exact match for given language', async () => {
const apple = (await parse(testData)).node(ex.apple)
const apple = (await parse(testData)).node(ns.ex.apple)
const label = apple.out(rdfs.label, { language: 'de' })
const label = apple.out(ns.rdfs.label, { language: 'de' })

@@ -125,5 +136,5 @@ assert(label.term.equals(rdf.literal('Apfel', 'de')))

it('should return plain string when language is empty string', async () => {
const apple = (await parse(testData)).node(ex.ananas)
const apple = (await parse(testData)).node(ns.ex.ananas)
const label = apple.out(rdfs.label, { language: '' })
const label = apple.out(ns.rdfs.label, { language: '' })

@@ -134,5 +145,5 @@ assert(label.term.equals(rdf.literal('Pineapple')))

it('should skip pointers which do not have matching language', async () => {
const apple = (await parse(testData)).node(ex.ananas)
const apple = (await parse(testData)).node(ns.ex.ananas)
const label = apple.out(rdfs.label, { language: 'en' })
const label = apple.out(ns.rdfs.label, { language: 'en' })

@@ -143,5 +154,5 @@ assert.strictEqual(label.values.length, 0)

it('should return any result for wildcard language', async () => {
const apple = (await parse(testData)).node(ex.ananas)
const apple = (await parse(testData)).node(ns.ex.ananas)
const label = apple.out(rdfs.label, { language: '*' })
const label = apple.out(ns.rdfs.label, { language: '*' })

@@ -152,5 +163,5 @@ assert.ok(label.term)

it('should return all matching literals for a language', async () => {
const apple = (await parse(testData)).node(ex.eggplant)
const apple = (await parse(testData)).node(ns.ex.eggplant)
const label = apple.out(rdfs.label, { language: 'pl' })
const label = apple.out(ns.rdfs.label, { language: 'pl' })

@@ -161,5 +172,5 @@ assert.strictEqual(label.terms.length, 3)

it('should return all matching literals for a wildcard language', async () => {
const apple = (await parse(testData)).node(ex.eggplant)
const apple = (await parse(testData)).node(ns.ex.eggplant)
const label = apple.out(rdfs.label, { language: '*' })
const label = apple.out(ns.rdfs.label, { language: '*' })

@@ -170,5 +181,5 @@ assert.strictEqual(label.terms.length, 3)

it('should be case-insensitive', async () => {
const apple = (await parse(testData)).node(ex.apple)
const apple = (await parse(testData)).node(ns.ex.apple)
const label = apple.out(rdfs.label, { language: 'SR-cyrl' })
const label = apple.out(ns.rdfs.label, { language: 'SR-cyrl' })

@@ -179,5 +190,5 @@ assert(label.term.equals(rdf.literal('Јабука', 'sr-Cyrl')))

it('should match secondary language tag by primary', async () => {
const apple = (await parse(testData)).node(ex.apple)
const apple = (await parse(testData)).node(ns.ex.apple)
const label = apple.out(rdfs.label, { language: 'sr' })
const label = apple.out(ns.rdfs.label, { language: 'sr' })

@@ -188,5 +199,5 @@ assert(label.term.equals(rdf.literal('Јабука', 'sr-Cyrl')))

it('should match secondary language tag by primary regardless of case', async () => {
const apple = (await parse(testData)).node(ex.apple)
const apple = (await parse(testData)).node(ns.ex.apple)
const label = apple.out(rdfs.label, { language: 'SR' })
const label = apple.out(ns.rdfs.label, { language: 'SR' })

@@ -197,5 +208,5 @@ assert(label.term.equals(rdf.literal('Јабука', 'sr-Cyrl')))

it('should match tertiary tag by secondary language', async () => {
const apple = (await parse(testData)).node(ex.kongressstrasse)
const apple = (await parse(testData)).node(ns.ex.kongressstrasse)
const label = apple.out(rdfs.label, { language: 'de-DE' })
const label = apple.out(ns.rdfs.label, { language: 'de-DE' })

@@ -208,5 +219,5 @@ assert(label.term.equals(rdf.literal('Kongreßstraße', 'de-DE-1901')))

it('should choose first match', async () => {
const apple = (await parse(testData)).node(ex.apple)
const apple = (await parse(testData)).node(ns.ex.apple)
const label = apple.out(rdfs.label, { language: ['fr', 'no', 'be', 'en', 'de'] })
const label = apple.out(ns.rdfs.label, { language: ['fr', 'no', 'be', 'en', 'de'] })

@@ -217,5 +228,5 @@ assert(label.term.equals(rdf.literal('Apple', 'en')))

it('should choose exact match over secondary language', async () => {
const apple = (await parse(testData)).node(ex.carrot)
const apple = (await parse(testData)).node(ns.ex.carrot)
const label = apple.out(rdfs.label, { language: ['de-1901', 'de'] })
const label = apple.out(ns.rdfs.label, { language: ['de-1901', 'de'] })

@@ -222,0 +233,0 @@ assert(label.term.equals(rdf.literal('Karotte', 'de')))

@@ -11,5 +11,7 @@ const rdf = require('rdf-ext')

rdfs: namespace('http://www.w3.org/2000/01/rdf-schema#'),
schema: namespace('http://schema.org/')
schema: namespace('http://schema.org/'),
xsd: namespace('http://www.w3.org/2001/XMLSchema#'),
tbbtp: namespace('http://localhost:8080/data/person/')
}
module.exports = ns

Sorry, the diff of this file is not supported yet

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