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

@rdfjs/namespace

Package Overview
Dependencies
Maintainers
4
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rdfjs/namespace

Named Node builder

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
4
Created
Source

@rdfjs/namespace

Build Status

npm version

Named Node builder.

Usage

The package exports a factory to create builders for Named Nodes. The baseIRI given to the factory will be used together with the parameter given to the builder to create Named Nodes.

Factory

The factory must be called with the baseIRI as a string:

const builder = namespace('http://example.org/base-iri#')

An optional factory can be defined:

const builder = namespace('http://example.org/base-iri#', { factory: customFactory })

By default @rdfjs/data-model is used.

Builder

The builder can be called in three different ways:

  • function call: (builder('property'))
  • tagged template string: (builder`property` )
  • property: (builder.property)

Calling the builder using the propery requires Proxy support. At the moment IE11 is the only major platform which doesn't support Proxy.

Example

This example shows how to create a builder and create Named Nodes using the three different ways. The properties of the Named Nodes are written to the console.

const namespace = require('@rdfjs/namespace')

const schema = namespace('http://schema.org/')

const hasPart = schema('hasPart')
console.log(hasPart.termType) // NamedNode
console.log(hasPart.value) // http://schema.org/hasPart

const person = schema`Person`
console.log(person.termType) // NamedNode
console.log(person.value) // http://schema.org/Person

const comment = schema.Comment
console.log(comment.termType) // NamedNode
console.log(comment.value) // http://schema.org/Comment

Keywords

FAQs

Package last updated on 16 Oct 2018

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