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

@bruju/wasm-tree

v0.3.0

Published

RDF Dataset and Store using Web Assembly

Readme

Wasm Tree

This package is an implementation of RDF.JS Dataset and RDF.JS Store that resorts to Web Assembly to store the quads in the form of several BTrees of numbers (unsigned int on 32 bits).

Correspondance between numbers and actual terms is done in Javascript.

Quick example in Node.js

// Import wasmtree
const wasmtree = require('@bruju/wasm-tree');

// Import other rdf libraries as wasm tree doesn't provide any RDF.JS data model
const rdf = require('@graphy/core.data.factory');
const namespace = require('@rdfjs/namespace');
const ex = namespace('http://example.org/', rdf);

// Populate a dataset
let dataset = new wasmtree.Dataset();
dataset.add(rdf.quad(ex.subject, ex.predicate, ex.object));
dataset.add(rdf.quad(ex.subject, ex.predicate, ex.otherobject));
dataset.add(rdf.quad(ex.other  , ex.predicate, ex.object));

// Count number of quads with the object ex.object
const occObjectInObject = dataset.match(null, null, ex.object).size;
console.log(occObjectInObject + " quads have " + ex.object.value + " in object position");

// Free the Web Assembly linear memory
dataset.free();

You can run this example by writing the code in a file named example.js and then run :

$ npm install @bruju/wasm-tree @graphy/core.data.factory @rdfjs/namespace
$ node example.js
2 quads have http://example.org/object in object position

How to instanciate a dataset or a store

const wasmtree = require('@bruju/wasm-tree');

let dataset = new wasmtree.Dataset();
let store = new wasmtree.Store();

Dataset

The DatasetCore and most Dataset features from RDF.JS are implemented

https://rdf.js.org/dataset-spec/

We currently do not implement import, toStream, toString and toCanonical.

Also note that the equals function does not normalize the black node as specified.

Store

The Store interface from RDF.JS is fully implemented

http://rdf.js.org/stream-spec/

add(quad: RDF.Quad): void and addQuad(quad: RDF.Quad): void are also provided to help synchronously populate the store.

You can also use the storeStream function const myStore = wasmtree.storeStream(aStreamOfQuads); which has a similar behaviour as the npm package RDF Store Stream.

About memory

As Web Assembly doesn't provide a garbage collector, the dataset and the store will keep memory until it is explicitely freed.

const wasmtree = require('@bruju/wasm-tree');

let dataset = new wasmtree.Dataset();
let store = new wasmtree.Store();

// Do some interesting work

dataset.free();
store.free();

The free function will deallocate the memory, and empty the structures. If a freed variable is reused, it will allocate again some web assembly memory.

Note that some dataset built from other dataset calls do not necessarily have to be freed (but still can). For example, dataset.match() will not allocate memory from web assembly until a complex operation like adding a quad is required (looping on the dataset does not trigger the allocation process).

License

Licensied under the MIT License

This has been funded by the REPID Project.