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 🙏

© 2026 – Pkg Stats / Ryan Hefner

pg-rdf-to-json

v0.1.0

Published

Transforms RDF files from rdf-files.tar.bz2 provided by Project Gutenberg into JS/JSON objects.

Downloads

30

Readme

pg-rdf-to-json

Tests Badge

Transforms RDF files from rdf-files.tar.bz2 provided by Project Gutenberg into JS/JSON objects.

Usage

There are two main ways to use this library: As a CLI or as a library.

CLI

The CLI accepts three arguments:

--input

  • Short: -i
  • Type: string
  • Default: -

This option defines the location of rdf-files.tar.bz2 file to be read. If it is not provided, or if it is set to -, then the XML files will be read from stdin.

--output

  • Short: -o
  • Type: string

If passed, this value should be a path with defines where the output JSON files should be written to. If not passed, the files will be written to stdout as Record separator-delimited JSON.

--validate

  • Short: -v
  • Type: boolean
  • Default: false

If passed and set to true, this option will ensure that every JSON object outputted conforms to the JSON Type Definition defined in types.ts.

Example CLI Usage

Here's an example of reading from rdf-files.tar.bz2, converting the contained files to JSON, and using jq to output the title of each book as it is converted:

tar -lxOf input-files/rdf-files.tar.bz2 | npx pg-rdf-to-json | jq --seq -r .title

Library

The library exposes two generator functions for converting RDF files to JSON.

booksFromStream

Accepts a Readable stream as its only parameter.

This function expects the passed stream to yield the text of at least one XML file.

This function is an async generator which means it conforms to the async iterator protocol. This means you can read its results using a for-await...of loop like so:

const tar = spawn('tar', ['-lxOf', 'rdf-files.tar.bz2']);

for await (const book of booksFromStream(tar.stdout)) {
  console.log(book.title);
}

booksFromArchive

Accepts a path to a .tar.bz2 file as a string as its only parameter.

[!IMPORTANT] This function spawns an internal instance of tar and has only been tested on Linux.

Like booksFromStream, this function is an async generator which means it conforms to the async iterator protocol. This means you can read its results using a for-await...of loop like so:

for await (const book of booksFromArchive('rdf-files.tar.bz2')) {
  console.log(book.title);
}