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

@rdfjs-elements/lit-helpers

v0.3.13

Published

Useful utilities for using `lit-html` and `LitElement` together with RDF/JS objects.

Readme

@rdfjs-elements/lit-helpers

Useful utilities for using lit-html and LitElement together with RDF/JS objects.

localizedLabel directive

Use it to render resource's label of tagged literals by selecting the object matching user's preferred locale.

taggedLiteral directive

Similar to localizedLabel but its argument is a pointer to a literal and not resource pointer.

All usages in a page will use the same language setting, which be default is to select the best matching literals prioritised according to the navigator.languages property.

Usage

All examples use assume these resources

prefix sh: <http://www.w3.org/ns/shacl#>
prefix ex: <http://example.org/>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>

<apple>
  a ex:Apple ;
  rdfs:label "Apple"@en, "Apfel"@de, "Jabłko"@pl ;
.

<Fruit>
  a sh:NodeShape ;
  sh:property [ sh:name "name"@en, "Name"@de, "Nazwa"@pl ] ;
.

Basic usage of localizedLabel

To render the rdfs:label using the browser's default setting

import { html } from 'lit'
import { localizedLabel } from '@rdfjs-elements/lit-helpers/localizedLabel.js'
import type { GraphPointer } from 'clownface'

let apple: GraphPointer

function render() {
  // renders apple's rdfs:label property
  return html`<span>${localizedLabel(apple, { fallback: 'a fruit' })}</span>`
}

The second parameter is optional. fallback will be rendered if no label was found

Basic usage of taggedLiteral

Similar to the above but useful when only a direct literal pointer is available

import { html } from 'lit'
import { taggedLiteral } from '@rdfjs-elements/lit-helpers/taggedLiteral.js'
import type { GraphPointer } from 'clownface'

let apple: GraphPointer
let label = apple.out(rdfs.label)

function render() {
  // renders apple's rdfs:label property
  return html`<span>${taggedLiteral(label, { fallback: 'a fruit' })}</span>`
}

The second parameter is optional. fallback will be rendered if no label was found

Using localizedLabel different predicate

Pass second argument to use a different predicate

import { html } from 'lit'
import { localizedLabel } from '@rdfjs-elements/lit-helpers/localizedLabel.js'
import type { GraphPointer } from 'clownface'
import { sh } from '@tpluscode/rdf-ns-builders'

let fruit: GraphPointer

function render() {
  // renders PropertyShape's sh:name property
  return html`<span>${localizedLabel(fruit.out(sh.property), { property: sh.name })}</span>`
}

Switching language

At any point during page's lifecycle the language can be changed by calling the setLanguages function. It will automatically update all occurrences of taggedLiteral and localizedLabel directives on a page to reflect the new priority of languages.

import { html } from 'lit'
import { localizedLabel } from '@rdfjs-elements/lit-helpers/localizedLabel.js'
import { setLanguages } from '@rdfjs-elements/lit-helpers'
import type { GraphPointer } from 'clownface'

let apple: GraphPointer

function render() {
  // renders apple's rdfs:label property using current langauges
  return html`<span>${localizedLabel(apple)}</span>`
}

// switch to Swiss German or German
setLanguages('de-CH', 'de')

Using localizedLabel with rdfine objects

import { html } from 'lit'
import { localizedLabel } from '@rdfjs-elements/lit-helpers/localizedLabel.js'
import type { GraphPointer } from 'clownface'
import Environment from '@zazuko/env/Environment.js'
import RdfineEnv from '@rdfine/env'
import Shacl from '@rdfine/shacl/Factory'

const env = new Environment([Shacl], { parent: RdfineEnv })

let fruitPointer: GraphPointer
const fruit = env.rdfine.sh.NodeShape(fruitPointer)

function render() {
  // renders PropertyShape's sh:name property
  return html`<span>${localizedLabel(fruit.property[0], { property: sh.name })}</span>`
}