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

beltline

v0.0.3

Published

A framework using Dristributed Data Protocol for the Semantic Web

Readme

beltline.js

A JavaScript framework using Dristriubted Data Protocol for the Semantic Web

Demo

Explore an example of beltline's usage at .

Installation

npm install beltline --save

Usage

To illustrait the usuage of beltline.js we'll be walking through how to build an application that keeps track of a list of people. An example can be seen here.

1) Define Publish Methods

Publish methods only are executed on the server and use SPARQL CONSTRUCT queries to define a subgraph. Later we will use "subscribe" methods on the client to subscribe to these publish methods.

The following example receives an "id" parameter from the client

personApi.js

export default function personApi(beltline) {
  if (beltline.isServer) {
    beltline.publish('person', ({ id }) => {
      return `
        PREFIX f: <http://example.com/owl/families#>
        PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
        CONSTRUCT { ?s ?p ?o } WHERE {
          f:${id} ?p ?o .
          ?s rdf:type f:Person .
          ?s ?p ?o 
        }
      `;
    });
  }
}

2) Define Shared Methods

Shared methods modify the database in some way. They are shared between both the client and the server. Calling a shared method on the client will update the data on the client, server, and all other clients that are subscribed to a subgraph that contains the modified data.

In this example, we define a method to change a person's name.

personApi.js

export default function personApi(beltline) {
  // ...
  beltline.method('changeName', async ({ id, newName }, db) => {
    await db.execute(`
      PREFIX f: <http://example.com/owl/families#>
      PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
      PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
      DELETE { f:${id} rdf:name ?o }
      INSERT { f:${id} rdf:name "${newName}"^^xsd:string }
      WHERE  { f:${id} rdf:name ?o }
    `);
  });
}

3) Initialize Beltline on the Server

Attach your Node.js Server to Beltline by creating a database connection, providing beltline with than database connection, and adding your custom APIs to beltline.

server.js

import express from 'express'
import BeltlineServer from 'beltline';
import initDatabase from 'beltline-local-storage-database';
import personApi from './beltlineMethods/personApi';

const app = express();
const server = require('http').createServer(app);

initDatabase(async (db) => {
  await db.load('text/turtle', turtleString);
  const beltline = new BeltlineServer(server, db);
  personApi(beltline);
});

server.listen(8080);

4) Initialize Beltline on the Client

Point the beltline client to your server and initialize it with your custom api.

client.js

import BeltlineClient from 'beltline-client';
import personApi from '../../beltlineMethods/personApi';

const beltlineClient = new BeltlineClient('http://localhost:8080');
personApi(beltlineClient);

5) Call Subscriptions and Methods from the Client

Subscribe to your publish methods by using the subscribe methods. Once you subscribe, the callback will be called with the current subgraph. It will also be called with any subsequent updates to this subgraph.

peopleActions.js

await beltline.subscribe(
  'person',
  { id },
  (newGraph) => {
    // Do what you will with your new sub-graph
  }
);

Modify your database with calls to your predefined methods.

peopleActions.js

beltline.call('changeName', { id, newName });