Socket
Socket
Sign inDemoInstall

@tpluscode/rdf-string

Package Overview
Dependencies
11
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @tpluscode/rdf-string

Simplifies creating of RDF strings using ECMAscript templates


Version published
Weekly downloads
2.5K
decreased by-12.9%
Maintainers
1
Install size
6.78 MB
Created
Weekly downloads
 

Changelog

Source

1.3.3

Patch Changes

  • ff439be: In cases when 1.x and 0.x versions were mixed in a project, building an RDF string would fail trying to access the RDF/JS Environment which is required by the latest versions

Readme

Source

@tpluscode/rdf-string Test codecov npm version

Simplifies the construction of RDF strings (turtle, n-triples, SPARQL, etc.) by taking care of correctly serializing values to their string representation and automatically prefixing URIs.

Usage

The heart of the library are EcmaScript template string tag functions. All interpolated values are serialized according to the syntactic rules of the given RDF format.

Formats which support prefixes will automatically abbreviate the URIs and return the prefix declarations according to the specific syntax.

SPARQL

import * as RDF from '@rdfjs/data-model' 
import { prefixes } from '@zazuko/rdf-vocabularies'
import namespace from '@rdfjs/namespace'

import { sparql } from '@zazuko/rdf-string'

const person = RDF.variable('person')
const PersonType = RDF.namedNode('http://example.com/Person')
const schema = namespace(prefixes.schema)
const name = "John"

const query = sparql`SELECT * WHERE {
  ${person} a ${PersonType} .
  ${person} ${schema.name} ${name} .
}`

query.toString()

The last line will return a complete query.

PREFIX schema: <http://schema.org/>

SELECT * WHERE {
  ?person a <http://example.com/Person> .
  ?person schema:name "John" .
}

turtle

TBD

n-triples

TBD

Keywords

FAQs

Last updated on 23 May 2024

Did you know?

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc