パッケージの詳細

@rdf-esm/namespace

rdf-esm12.6kMIT0.5.5

Named Node builder

rdf, rdfjs, namednode, namespace

readme

@rdf-esm/namespace

Build Status

npm version

Named Node builder.

Fork alert :exclamation:

This package is an ES Modules fork of @rdfjs/namespace

The original, commonjs version is used node environment.

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 @rdf-esm/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.

import namespace from '@rdf-esm/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

更新履歴

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

0.5.5 (2022-02-04)

0.5.4 (2022-01-31)

Features

  • re-export v2 of @rdfjs/namespace (75187e7)

0.5.3 (2021-04-06)

Bug Fixes

  • missing types for @rdfjs/namespace (27fa798)

0.5.2 (2020-11-25)

Bug Fixes

  • re-export namespace builder to allow its generic form (d21c720)

0.5.1 (2020-07-13)

0.5.0 (2020-07-13)