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

@rdfjs/prefix-map

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rdfjs/prefix-map

A Map for RDF/JS prefixes

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

@rdfjs/prefix-map

build status npm version

A Map for RDF/JS prefixes.

This package implements the JavaScript Map interface for RDF prefixes. Key-Value pairs are stored with the prefix as the key as a string and the namespaces as the value in an RDF/JS NamedNode object. There are some additional convenience methods to handle CURIEs and prefix events of RDF/JS Quad streams.

Usage

The package exports the constructor of the PrefixMap. New instances with initial pairs can be created just like JavaScript Maps but require an additional factory argument:

import rdf from '@rdfjs/data-model'
import PrefixMap from '@rdfjs/prefix-map'

// create a PrefixMap, fill it with some initial values, and hand over the data model factory
const prefixes = new PrefixMap([
  ['rdf', rdf.namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#')],
  ['schema', rdf.namedNode('http://schema.org')]
], { factory: rdf })

// create two NamedNodes, one with a CURIE and one with a full IRI
const personShort = rdf.namedNode('schema:Person')
const typeLong = rdf.namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type') 

// convert the CURIE to a full IRI and vice versa
const personLong = prefixes.resolve(personShort)
const typeShort = prefixes.shrink(typeLong)

// write the result to the console
console.log(personLong.value) // -> http://schema.org/Person
console.log(typeShort.value) // -> rdf:type

Keywords

FAQs

Package last updated on 02 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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