rdfprefix
RDF Prefix helper to expand and compact iri (compatible with json-ld context)
Features
- Expand prefixed iri to iri
- Compact iri to prefixed iri
- Support JSON-LD context as prefix definition
Installation
npm install --save rdfprefix
Usage
var rdfprefix = // Basic initializationvar prefixes = // Initialize with prefixesvar prefixes = // Initialize with an array of prefixesvar prefixes = // Supports Json-ld @contextvar prefixes = // Add prefixes... // Use prefixesvar schema = // -> 'http://schema.org/name' // Expand prefixed iriprefixes // -> 'http://schema.org/name'prefixes // -> 'http://purl.org/dc/terms/abstract' (see '@vocab')prefixes // -> 'http://www.exemple.org/play'prefixes // -> throw Error()prefixes // -> 'undefinedprefix:foo' (tolerant = true) // Compact iriprefixcompact'http://schema.org/name' // -> 'schema:name'prefixcompact'http://purl.org/dc/terms/abstract' // -> 'abstract' (see '@vocab')prefixcompact'http://www.exemple.org/play' // -> 'http://www.exemple.org/play' // Get a serializable copy of prefixesprefix // -> { schema: 'http://schema.org/', ... } (without '@vocab') // Like toJSON but with the '@vocab' prefix if anyprefix // -> { '@vocab': 'http://purl.org/dc/terms/abstract', schema: ... }
Test coverage
Statements | 100% ( 76/76 ) |
Branches | 100% ( 52/52 ) |
Functions | 100% ( 14/14 ) |
Lines | 100% ( 76/76 ) |