npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jsonld-rapper

v0.2.5

Published

Convert between RDF and JSON-LD using rapper

Downloads

7

Readme

jsonld-rapper

Convert between RDF and JSON-LD using rapper

Build Status

Installation

This module requires the rapper utility, version >=2.0.14 to be in $PATH.

If it isn't in the $PATH, override rapperBinary.

Based on https://github.com/ruby-rdf/rdf-raptor:

% [sudo] port install raptor             # Mac OS X with MacPorts
% [sudo] fink install raptor-bin         # Mac OS X with Fink
% brew install raptor                    # Mac OS X with Homebrew
% [sudo] apt-get install raptor2-utils   # Ubuntu / Debian with apt-get
% [sudo] yum install raptor2             # Fedora / CentOS / RHEL
% [sudo] zypper install raptor           # openSUSE
% [sudo] emerge raptor                   # Gentoo Linux
% [sudo] pacman -S raptor                # Arch Linux
% [sudo] pkg_add -r raptor               # FreeBSD
% [sudo] pkg_add raptor                  # OpenBSD / NetBSD

Install dependencies: npm install

Test: npm test

Generate docs in apidocs: npm run docs

Example

var JsonLD2RDF = require('jsonld-rapper')

var j2r = new JsonLD2RDF();

var jsonld1 = {'@id': 'http://example.org/foo', 'http://example.org/prop1': 'bar'};
var turtle1 = {'@prefix ex: <http://example.org/> .\n ex:foo ex:prop1 "bar" .'

j2r.convert(turtle1, 'turtle', 'jsonld', function (err, asJsonLD) {
  // do something with asJsonLD, an object
});

j2r.convert(jsonld1, 'jsonld', 'rdfxml', function (err, asRdfxml) {
  // do something with asRdfxml, a string
});

API

Exports

  • JsonLD2RDF: Class with the convert method

Options

  • rapperBinary: Absolute path or $PATH-relative path to the rapper(1) binary
  • baseURI: TODO
  • expandContext: TODO
  • profile: JSON-LD profile to use when outputting JSON-LD
  • jsonldToRDF: Options passed to jsonld.toRDF. Defaults:
    • baseURI: Instance's baseURI
    • expandContext: Instance's expandContext
    • format: 'application/nquads'. Since the jsonld module supports only nquads, don't change this.
  • jsonldFromRDF: Options passed to jsonld.fromRDF. Defaults
    • format: 'application/nquads'. Since the jsonld module supports only nquads, don't change this.
    • useRdfType: false
    • useNativeTypes: false
  • jsonldCompact, jsonldExpand, jsonldFlatten: Options passed to jsonld's resp. function

Convert

var JsonLD2RDF = require('jsonld-rapper');
var j2r = new JsonLD2RDF();
j2r.convert(input, from, to, methodOpts, callback)
  • input: string of RDF/JSON-LD or JSON-LD object
  • from: One of the supported input media types or short names
  • to: One of the supported output media types or short names
  • methodOpts (OPTIONAL): Options to override the instance-wide options
  • callback: Callback, gets passed (err, converted) where err is an error object (including a cause field for errors from rapper) and converted is the converted RDF/JSON-LD string/object.

Constants

Properties of the JsonLD2RDF instance

  • SUPPORTED_INPUT_TYPE: Supported input types used as the from argument
  • SUPPORTED_OUTPUT_TYPE: Supported output types used as the from argument
  • JSONLD_PROFILE: Supported JSON-LD profiles
var JsonLD2RDF = require('jsonld-rapper');
var j2r = new JsonLD2RDF();
for (profile in j2r.JSONLD_PROFILE) {
  console.log profile
}
// COMPACTED =>    'http://www.w3.org/ns/json-ld#compacted'
// FLATTENED =>    'http://www.w3.org/ns/json-ld#flattened'
// FLATTENED_EXPANDED =>   'http://www.w3.org/ns/json-ld#flattened+expanded'
// EXPANDED =>     'http://www.w3.org/ns/json-ld#expanded'

Rights

This library is licensed under the terms of the MIT license.

Library | License -------- | -------- async | MIT colors | MIT merge | MIT jsonld | BSD 3-Clause n3 | MIT which | ISC which | MIT