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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@muze-nl/oldm

v0.3.6

Published

Object - Linked Data Mapper

Readme

OLDM: Object Linked Data Mapper

OLDM has the same role as an ORM for SQL data, but for Linked Data instead. It turns triples into an object graph that you can just use in your javascript code.

The parse() method returns either the full graph or the specific subject requested:

import oldm from '@muze-nl/oldm'

const context = oldm.context({
    prefixes: {
        'ldp':    'http://www.w3.org/ns/ldp#',
        'rdf':    'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
        'dct':    'http://purl.org/dc/terms/',
        'stat':   'http://www.w3.org/ns/posix/stat#',
        'turtle': 'http://www.w3.org/ns/iana/media-types/text/turtle#',
        'schem':  'https://schema.org/',
        'solid':  'http://www.w3.org/ns/solid/terms#',
        'acl':    'http://www.w3.org/ns/auth/acl#',
        'pims':   'http://www.w3.org/ns/pim/space#',
        'vcard':  'http://www.w3.org/2006/vcard/ns#',
        'foaf':   'http://xmlns.com/foaf/0.1/'
    },
    parser: oldm.n3Parser,
    writer: oldm.n3Writer
})

const url = 'https://auke.solidcommunity.net/profile/card#me'
const response = await fetch(url)
if (!response.ok) {
    throw new Error(response.status+':'+response.statusText)
}
const text = await response.text()
const source = context.parse(text, url, 'text/turtle')
const myProfile = source.primary

The source.primary is filled with the subject that matches the url exactly. source.subjects is an object with all subjects in the linked data source, as id : subject. source.data is a get function that returns an array with all subjects.

myProfile now looks like this (JSON stringified):

{
    "vcard$bday":"1972-09-20",
    "vcard$fn":"Auke van Slooten",
    "vcard$hasEmail":[
        {
            "vcard$value":"mailto:[email protected]"
        },
// etc...

Each subject has these non-enumerable properties as well:

  • id: the full URI that identifies this subject
  • a: one or more rdf:type values
  • graph: refers back to the source which contains this subject

JSON-LD uses @context to translate json property names (keys) to linked data predicate URI's. OLDM instead doesn't translate predicate URI's at all, it just shortens them using the prefixes you define. So http://www.w3.org/2006/vcard/ns#bday becomes vcard$bday.

Subject and Object id's are never shortened. The source.subjects is an object with the full subject and object id's as key.

Predicate URI's are shortened by using the prefixes you defined in the options for the OLDM parser. They appear as prefix$part properties in the objects. You can switch this to appear as prefix:part, by setting the separator option to ":" in the options for the parser. The reason the default is $ is so that you can access predicates (properties) without using the ["..."] syntax. So you can type object.vcard$bday instead of object["vcard:bday"].

Literal string and number values are converted into String and Number objects. If an xsd type is set on the literal, this is set as a type property on those objects. If a language is set on a string literal, this is set as a language property on the String object.

const type = profile.vcard$bday.type
// returns 'xsd$date'

Lists (Collections)

The turtle format support a short notation for ordered lists. OLDM translates that to a Collection class, that extends Array. You can create an ordered list like this:

import oldm, {Collection} from '@muze-nl/oldm'

let coll = new Collection()
coll.push("A string")