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

ldf-facade

v0.3.0

Published

Existing LDF servers are typically used to expose a datasource with less restrictive querying capabilities (e.g. a SPARQL endpoint) with more restrictive querying capabilities (triple pattern fragments).

Downloads

2

Readme

A minimal server for linked data fragments designed to create linked data views over things that aren't linked data.

Motivation

Existing LDF servers are typically used to expose a datasource with less restrictive querying capabilities (e.g. a SPARQL endpoint) with more restrictive querying capabilities (triple pattern fragments).

In contrast, ldf-facade is designed to expose a datasource with more restrictive querying capabilities - such as a HTTP API - as triple pattern fragments, which are often less restrictive than the API.

Usage

There are two user callbacks used by ldf-facade which you need to implement:

  • enumSubjects: enumerates all possible subjects in the dataset
  • pattern: evaluates a triple pattern and returns some triples

Crucially, everything is paginated. To accommodate this, the user callbacks are deterministic mappers from state -> { results, nextState|null }. If called multiple times with the same state, the callback should return the same results each time. The actual value of the state is entirely up to you: it could be an offset, an identifier, or anything else required to keep track of upstream position.

This allows the ldf-server to create prev and next links for each page, so that ldf clients can navigate a result set. The nextState returned by a user callback becomes the state parameter passed into the same callback to retrieve the next page.

Creating a server

var LDFServer, { BOUND, UNBOUND } = require('ldf-facade')

var server = new LDFServer({ /* opts */ }) 

Implementing enumSubjects

server.enumSubjects(async function(state) {
    
    if(!state) {
    	// create initial state
    }
    
    // get some subjects from somewhere        
    // get total number of subjects
    
    return { values: [ subjects... ], total, nextState }
    
    // return nextState: null when there are no more subjects to enumerate 
})

Implementing pattern

You can register as many user callbacks for pattern as required. Each pattern callback is associated with a pattern. For example, a user callback registered for { s: BOUND, p: UNBOUND, o: UNBOUND } would match triple patterns where the subject is specified but the predicate and object are not (i.e. tell me everything you know about this subject).

Where a pattern is requested of the server and no user callback is registered to match it, ldf-facade will attempt to generalise (for unbound -> bound) or specialize by filtering (for bound -> unbound). In theory, this means that registering any one pattern allows any other pattern to be answered, but as generalisation and specialisation is likely to be very expensive, any patterns that can be answered directly should be registered.

server.pattern({ 
	s: BOUND, p: UNBOUND, o: UNBOUND
}, async function(state, pattern) {

	// pattern.s contains the subject as it is bound
	// pattern.p and pattern.o will be undefined
	
	// generate triples that match { pattern.s, ?, ? }
	
	return { triples, total, nextState }

    // return nextState: null when there are no more triples to return 
})

Starting the server

server.listen(port)